Skip to content

Commit

Permalink
lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
Moe-Shoman committed Jul 12, 2018
1 parent b840fc5 commit 5526636
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 12,171 deletions.
12,098 changes: 0 additions & 12,098 deletions package-lock.json

This file was deleted.

19 changes: 6 additions & 13 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,21 @@ import './App.css';

class App extends Component {
render() {
const {
authenticated,
contributionPoints,
removeNotification,
increaseContributionAmount,
username
} = this.props;
return (
<Router>
<div className="App">
<NavBar
authenticated={authenticated}
contributionPoints={contributionPoints}
username={username}
onRemoveNotification={removeNotification}
onIncreaseContributionAmount={increaseContributionAmount}
authenticated={this.props.authenticated}
contributionPoints={this.props.contributionPoints}
username={this.props.username}
onRemoveNotification={this.props.removeNotification}
onIncreaseContributionAmount={this.props.increaseContributionAmount}
/>
<Switch>
{/* Temporary redirect from /; will use HomePage component */ }
<Route exact path="/" render={() => <Redirect to="/dashboard" />} />
<Route exact path="/dashboard" render={() => {
return authenticated
return this.props.authenticated
? <Dashboard />
: <Redirect to="/pursuance/all" />
}} />
Expand Down
12 changes: 6 additions & 6 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {
postMembershipReq,
getMembershipsReq,
delMembershipReq
deleteMembershipReq
} from '../api/memberships';

export const updateFormField = (formId, fieldId, value) => ({
Expand Down Expand Up @@ -246,17 +246,17 @@ export const getInvites = ({ pursuanceId }) => ({
pursuanceId
});

export const postMembership = (membership) => ({
export const postMembership = membership => ({
type: 'POST_MEMBERSHIP',
payload: postMembershipReq(membership)
});

export const getMemberships = (filterOption) => ({
export const getMemberships = filterOption => ({
type: 'GET_MEMBERSHIPS',
payload: getMembershipsReq(filterOption)
});

export const delMembership = (membership) => ({
export const deleteMembership = membership => ({
type: 'DELETE_MEMBERSHIP',
payload: delMembershipReq(membership)
})
payload: deleteMembershipReq(membership)
});
34 changes: 18 additions & 16 deletions src/api/memberships.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,31 @@ export const postMembershipReq = membership => {
.catch(err => console.log('Error posting membership:', err));
};


export const getMembershipsReq = (filterOption) => {
export const getMembershipsReq = filterOption => {
const filterKey = Object.keys(filterOption)[0];
const filterVal = Object.values(filterOption)[0];
const filterVal = filterOption[filterKey];
return postgrest
.getJSON('/memberships')
.then(memberships => memberships.filter((membership) => {
return membership[filterKey] === filterVal;
}))
.then((memberships) => memberships.map((membership) => {
return {
[membership.pursuance_id] : membership
};
}))
.getJSON(`/memberships?${filterKey}=eq.${filterVal}`)
.then(memberships =>
memberships.map(membership => {
return {
[membership.pursuance_id]: membership
};
})
)
.catch(err => console.log('Error fetching memberships', err));
};

export const delMembershipReq = ({ pursuance_id, user_username}) => {
export const deleteMembershipReq = ({ pursuance_id, user_username }) => {
return postgrest
.deleteJSON(`/memberships?user_username=eq.${user_username}&pursuance_id=eq.${pursuance_id}`,
.deleteJSON(
`/memberships?user_username=eq.${user_username}&pursuance_id=eq.${
pursuance_id
}`,
{
Prefer: 'return=representation'
})
}
)
.then(membershipJSON => membershipJSON[0])
.catch(err => console.log('Error deleting membership:', err));
}
};
22 changes: 14 additions & 8 deletions src/api/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ export const patchTaskReq = task => {

export const deleteTaskReq = task => {
return postgrest
.deleteJSON(`/tasks?gid=eq.${task.gid}`, { Prefer: 'return=representation' })
.deleteJSON(`/tasks?gid=eq.${task.gid}`, {
Prefer: 'return=representation'
})
.then(taskJSON => taskJSON[0])
.catch(err => console.log('Error deleting task:', err));
}
};

export const getTasksReq = (pursuanceId, { includeArchived = false } = {}) => {
return postgrest
.getJSON(
`/tasks?or=(pursuance_id.eq.${pursuanceId},assigned_to_pursuance_id.eq.${pursuanceId})&order=created.asc,id.asc` +
`/tasks?or=(pursuance_id.eq.${pursuanceId},assigned_to_pursuance_id.eq.${
pursuanceId
})&order=created.asc,id.asc` +
(includeArchived ? '' : '&is_archived=is.false')
)
.then(tasks => {
Expand All @@ -53,8 +57,10 @@ const buildTaskHierarchy = (tasks, pursuanceId) => {
if (taskMap[t.parent_task_gid]) {
taskMap[t.parent_task_gid].subtask_gids.push(t.gid);
} else {
console.log(`Task ${t.gid} ("${t.title}")'s parent ${t.parent_task_gid}` +
` not found in taskMap`);
console.log(
`Task ${t.gid} ("${t.title}")'s parent ${t.parent_task_gid}` +
` not found in taskMap`
);
}
}
}
Expand All @@ -70,11 +76,11 @@ const buildTaskHierarchy = (tasks, pursuanceId) => {
};
};

const sortGidsBy = (pursuanceIdStr) => {
const sortGidsBy = pursuanceIdStr => {
return (g1, g2) => {
if (g1.startsWith(pursuanceIdStr)) {
return -1000;
}
return g2.localeCompare(g1);
}
}
};
};
6 changes: 3 additions & 3 deletions src/components/Content/PursuanceList/PursuanceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class PursuanceList extends Component {
return null;
}
return (
<div key={pursuance.id} className="pursuance-list-ctn">
<div className="pursuance-description">
<Link to={`/pursuance/${pursuance.id}`}>
<div key={pursuance.id} className="pursuance-list-ctn">
<div className="pursuance-description">
<Link to={`/pursuance/${pursuance.id}`}>
<h3><strong>{pursuance.name}</strong></h3>
</Link>
<p><strong>Mission:</strong> {pursuance.mission}</p>
Expand Down
8 changes: 4 additions & 4 deletions src/components/PublicPursuances/PublicPursuanceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import * as postgrest from '../../api/postgrest';
import { postMembership, getMemberships, delMembership } from '../../actions';
import { postMembership, getMemberships, deleteMembership } from '../../actions';


class PublicPursuanceList extends Component {
Expand All @@ -13,7 +13,7 @@ class PublicPursuanceList extends Component {
}

getPublicPursuanceList = () => {
const { user, publicPursuances, postMembership, memberships, delMembership } = this.props;
const { user, publicPursuances, postMembership, memberships, deleteMembership } = this.props;
const pursuanceArr = Object.values(publicPursuances);
return pursuanceArr.map((pursuance) => (
<div key={pursuance.id} className="pursuance-list-ctn">
Expand Down Expand Up @@ -46,7 +46,7 @@ class PublicPursuanceList extends Component {
&&
<button
className="leave-btn pursuance-btn"
onClick={() => delMembership({
onClick={() => deleteMembership({
"pursuance_id": pursuance.id,
"user_username": user.username
})}
Expand Down Expand Up @@ -74,5 +74,5 @@ export default connect(({ publicPursuances, user, memberships }) =>
({ publicPursuances, user, memberships }),{
postMembership,
getMemberships,
delMembership
deleteMembership
})(PublicPursuanceList);
11 changes: 7 additions & 4 deletions src/reducers/invitesReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ export default function(state = initialState, action) {
pursuance_id: 33,
permissions_level: 'Admin',
purpose: 'Emailing to co-workers',
invite_url: 'https://app.pursuanceproject.org/invite/3e99889a-850e-11e8-80a7-00163e5e6c13#MammalKimonoJazzEquipmentJellyKryptonGamekeeperFossilGiddinessRearrangeArrowhead'
invite_url:
'https://app.pursuanceproject.org/invite/3e99889a-850e-11e8-80a7-00163e5e6c13#MammalKimonoJazzEquipmentJellyKryptonGamekeeperFossilGiddinessRearrangeArrowhead'
},
'4e99889a-850e-11e8-80a7-00163e5e6c13': {
id: '4e99889a-850e-11e8-80a7-00163e5e6c13',
pursuance_id: 33,
permissions_level: 'NormalUser',
purpose: 'Sending to in-house volunteers via Slack',
invite_url: 'https://app.pursuanceproject.org/invite/4e99889a-850e-11e8-80a7-00163e5e6c13#MammalKimonoJazzEquipmentJellyKryptonGamekeeperFossilGiddinessRearrangeArrowhead'
invite_url:
'https://app.pursuanceproject.org/invite/4e99889a-850e-11e8-80a7-00163e5e6c13#MammalKimonoJazzEquipmentJellyKryptonGamekeeperFossilGiddinessRearrangeArrowhead'
},
'5e99889a-850e-11e8-80a7-00163e5e6c13': {
id: '5e99889a-850e-11e8-80a7-00163e5e6c13',
pursuance_id: 33,
permissions_level: 'Viewer',
purpose: 'Posting to mailing list and website',
invite_url: 'https://app.pursuanceproject.org/invite/5e99889a-850e-11e8-80a7-00163e5e6c13#MammalKimonoJazzEquipmentJellyKryptonGamekeeperFossilGiddinessRearrangeArrowhead'
},
invite_url:
'https://app.pursuanceproject.org/invite/5e99889a-850e-11e8-80a7-00163e5e6c13#MammalKimonoJazzEquipmentJellyKryptonGamekeeperFossilGiddinessRearrangeArrowhead'
}
});

default:
Expand Down
6 changes: 4 additions & 2 deletions src/reducers/membershipsReducer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default function(state = {}, action) {
switch (action.type) {

case 'POST_MEMBERSHIP_PENDING':
return state;

Expand All @@ -25,7 +24,10 @@ export default function(state = {}, action) {
return state;

case 'DELETE_MEMBERSHIP_FULFILLED':
const { [String(action.payload.pursuance_id)]: _, ...updatedState } = state;
const {
[String(action.payload.pursuance_id)]: _,
...updatedState
} = state;
return updatedState;

case 'DELETE_MEMBERSHIP_REJECTED':
Expand Down
5 changes: 3 additions & 2 deletions src/reducers/rightPanelReducer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const _now = new Date();
const _2monthsAgo = new Date(_now.getFullYear(), _now.getMonth()-2, 1);
const _2monthsAgo = new Date(_now.getFullYear(), _now.getMonth() - 2, 1);

const initialState = {
show: false,
tab: 'TaskList',
taskGid: '',
taskListFilter: '@me status:!done due:>' + _2monthsAgo.toISOString().slice(0, 10)
taskListFilter:
'@me status:!done due:>' + _2monthsAgo.toISOString().slice(0, 10)
};

export default function(state = initialState, action) {
Expand Down
7 changes: 4 additions & 3 deletions src/reducers/tasksReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ export default function(state = initialState, action) {
if (!parentTaskId) {
return Object.assign({}, state, {
taskMap: newTaskMap
})
});
}
const parent = state.taskMap[parentTaskId];
// Update parentTask.subtask_gids in redux so that it excludes
// deletedTask.gid
const newParentSubtaskGids =
parent.subtask_gids.filter((gid) => gid !== deletedTask.gid)
const newParentSubtaskGids = parent.subtask_gids.filter(
gid => gid !== deletedTask.gid
);
return Object.assign({}, state, {
taskMap: Object.assign(newTaskMap, {
[parentTaskId]: {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/object_values_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ if (Object && !Object.values) {
arr.push(obj[key]);
}
return arr;
}
};
}
2 changes: 1 addition & 1 deletion src/utils/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ const sortBySuggest = (suggest1, suggest2) => {

export const scrollIntoViewOptions = { behavior: 'smooth', block: 'nearest' };
if (window.browser === 'Firefox') {
scrollIntoViewOptions.block = 'end';
delete scrollIntoViewOptions.block;
}
25 changes: 15 additions & 10 deletions src/utils/tasks.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
export const showTaskInPursuance = (task, pursuanceId) => {
return task.pursuance_id === pursuanceId ||
task.assigned_to_pursuance_id === pursuanceId;
}
return (
task.pursuance_id === pursuanceId ||
task.assigned_to_pursuance_id === pursuanceId
);
};

export const showAssignee = (task, currentPursuanceId, pursuances) => {
const assignedPursuanceId = task.assigned_to_pursuance_id;
const assignedByThisPursuance = assignedPursuanceId === currentPursuanceId;
let placeholder = "";
let placeholder = '';
let assignedTo;
if (assignedPursuanceId && !assignedByThisPursuance && pursuances[assignedPursuanceId]) {
if (
assignedPursuanceId &&
!assignedByThisPursuance &&
pursuances[assignedPursuanceId]
) {
placeholder = pursuances[assignedPursuanceId].suggestionName;
assignedTo = pursuances[assignedPursuanceId].id;
}
else if (task.assigned_to) {
} else if (task.assigned_to) {
placeholder = '@' + task.assigned_to;
assignedTo = task.assigned_to;
}

return {
placeholder,
assignedTo
}
}
};
};

export const isRootTaskInPursuance = (task, pursuanceId) => {
return !task.parent_task_gid || task.assigned_to_pursuance_id === pursuanceId;
}
};

0 comments on commit 5526636

Please sign in to comment.