ref: Refactoring
parent
1f569bdb61
commit
3714bbc06f
@ -1,22 +0,0 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export const handleActionCreate = (action) => ({
|
||||
type: ActionTypes.ACTION_CREATE_HANDLE,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleActionUpdate = (action) => ({
|
||||
type: ActionTypes.ACTION_UPDATE_HANDLE,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleActionDelete = (action) => ({
|
||||
type: ActionTypes.ACTION_DELETE_HANDLE,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
@ -1,50 +0,0 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export const fetchActions = (cardId) => ({
|
||||
type: ActionTypes.ACTIONS_FETCH,
|
||||
payload: {
|
||||
cardId,
|
||||
},
|
||||
});
|
||||
|
||||
fetchActions.success = (cardId, actions, users) => ({
|
||||
type: ActionTypes.ACTIONS_FETCH__SUCCESS,
|
||||
payload: {
|
||||
cardId,
|
||||
actions,
|
||||
users,
|
||||
},
|
||||
});
|
||||
|
||||
fetchActions.failure = (cardId, error) => ({
|
||||
type: ActionTypes.ACTIONS_FETCH__FAILURE,
|
||||
payload: {
|
||||
cardId,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
export const toggleActionsDetails = (cardId, isVisible) => ({
|
||||
type: ActionTypes.ACTIONS_DETAILS_TOGGLE,
|
||||
payload: {
|
||||
cardId,
|
||||
isVisible,
|
||||
},
|
||||
});
|
||||
|
||||
toggleActionsDetails.success = (cardId, actions, users) => ({
|
||||
type: ActionTypes.ACTIONS_DETAILS_TOGGLE__SUCCESS,
|
||||
payload: {
|
||||
cardId,
|
||||
actions,
|
||||
users,
|
||||
},
|
||||
});
|
||||
|
||||
toggleActionsDetails.failure = (cardId, error) => ({
|
||||
type: ActionTypes.ACTIONS_DETAILS_TOGGLE__FAILURE,
|
||||
payload: {
|
||||
cardId,
|
||||
error,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,79 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
const fetchActivities = (cardId) => ({
|
||||
type: ActionTypes.ACTIVITIES_FETCH,
|
||||
payload: {
|
||||
cardId,
|
||||
},
|
||||
});
|
||||
|
||||
fetchActivities.success = (cardId, activities, users) => ({
|
||||
type: ActionTypes.ACTIVITIES_FETCH__SUCCESS,
|
||||
payload: {
|
||||
cardId,
|
||||
activities,
|
||||
users,
|
||||
},
|
||||
});
|
||||
|
||||
fetchActivities.failure = (cardId, error) => ({
|
||||
type: ActionTypes.ACTIVITIES_FETCH__FAILURE,
|
||||
payload: {
|
||||
cardId,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
const toggleActivitiesDetails = (cardId, isVisible) => ({
|
||||
type: ActionTypes.ACTIVITIES_DETAILS_TOGGLE,
|
||||
payload: {
|
||||
cardId,
|
||||
isVisible,
|
||||
},
|
||||
});
|
||||
|
||||
toggleActivitiesDetails.success = (cardId, activities, users) => ({
|
||||
type: ActionTypes.ACTIVITIES_DETAILS_TOGGLE__SUCCESS,
|
||||
payload: {
|
||||
cardId,
|
||||
activities,
|
||||
users,
|
||||
},
|
||||
});
|
||||
|
||||
toggleActivitiesDetails.failure = (cardId, error) => ({
|
||||
type: ActionTypes.ACTIVITIES_DETAILS_TOGGLE__FAILURE,
|
||||
payload: {
|
||||
cardId,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
const handleActivityCreate = (activity) => ({
|
||||
type: ActionTypes.ACTIVITY_CREATE_HANDLE,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
const handleActivityUpdate = (activity) => ({
|
||||
type: ActionTypes.ACTIVITY_UPDATE_HANDLE,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
const handleActivityDelete = (activity) => ({
|
||||
type: ActionTypes.ACTIVITY_DELETE_HANDLE,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
fetchActivities,
|
||||
toggleActivitiesDetails,
|
||||
handleActivityCreate,
|
||||
handleActivityUpdate,
|
||||
handleActivityDelete,
|
||||
};
|
||||
@ -1,69 +0,0 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export const createCommentAction = (action) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_CREATE,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
createCommentAction.success = (localId, action) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_CREATE__SUCCESS,
|
||||
payload: {
|
||||
localId,
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
createCommentAction.failure = (localId, error) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_CREATE__FAILURE,
|
||||
payload: {
|
||||
localId,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
export const updateCommentAction = (id, data) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_UPDATE,
|
||||
payload: {
|
||||
id,
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
updateCommentAction.success = (action) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_UPDATE__SUCCESS,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
updateCommentAction.failure = (id, error) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_UPDATE__FAILURE,
|
||||
payload: {
|
||||
id,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteCommentAction = (id) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
deleteCommentAction.success = (action) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_DELETE__SUCCESS,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
deleteCommentAction.failure = (id, error) => ({
|
||||
type: ActionTypes.COMMENT_ACTION_DELETE__FAILURE,
|
||||
payload: {
|
||||
id,
|
||||
error,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,75 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
const createCommentActivity = (activity) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_CREATE,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
createCommentActivity.success = (localId, activity) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_CREATE__SUCCESS,
|
||||
payload: {
|
||||
localId,
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
createCommentActivity.failure = (localId, error) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_CREATE__FAILURE,
|
||||
payload: {
|
||||
localId,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
const updateCommentActivity = (id, data) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_UPDATE,
|
||||
payload: {
|
||||
id,
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
updateCommentActivity.success = (activity) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_UPDATE__SUCCESS,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
updateCommentActivity.failure = (id, error) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_UPDATE__FAILURE,
|
||||
payload: {
|
||||
id,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
const deleteCommentActivity = (id) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
deleteCommentActivity.success = (activity) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_DELETE__SUCCESS,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
deleteCommentActivity.failure = (id, error) => ({
|
||||
type: ActionTypes.COMMENT_ACTIVITY_DELETE__FAILURE,
|
||||
payload: {
|
||||
id,
|
||||
error,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
createCommentActivity,
|
||||
updateCommentActivity,
|
||||
deleteCommentActivity,
|
||||
};
|
||||
@ -1,22 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const handleActionCreate = (action) => ({
|
||||
type: EntryActionTypes.ACTION_CREATE_HANDLE,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleActionUpdate = (action) => ({
|
||||
type: EntryActionTypes.ACTION_UPDATE_HANDLE,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleActionDelete = (action) => ({
|
||||
type: EntryActionTypes.ACTION_DELETE_HANDLE,
|
||||
payload: {
|
||||
action,
|
||||
},
|
||||
});
|
||||
@ -1,13 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const fetchActionsInCurrentCard = () => ({
|
||||
type: EntryActionTypes.ACTIONS_IN_CURRENT_CARD_FETCH,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export const toggleActionsDetailsInCurrentCard = (isVisible) => ({
|
||||
type: EntryActionTypes.ACTIONS_DETAILS_IN_CURRENT_CARD_TOGGLE,
|
||||
payload: {
|
||||
isVisible,
|
||||
},
|
||||
});
|
||||
@ -1,29 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const createMembershipInCurrentBoard = (data) => ({
|
||||
type: EntryActionTypes.MEMBERSHIP_IN_CURRENT_BOARD_CREATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleBoardMembershipCreate = (boardMembership) => ({
|
||||
type: EntryActionTypes.BOARD_MEMBERSHIP_CREATE_HANDLE,
|
||||
payload: {
|
||||
boardMembership,
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteBoardMembership = (id) => ({
|
||||
type: EntryActionTypes.BOARD_MEMBERSHIP_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleBoardMembershipDelete = (boardMembership) => ({
|
||||
type: EntryActionTypes.BOARD_MEMBERSHIP_DELETE_HANDLE,
|
||||
payload: {
|
||||
boardMembership,
|
||||
},
|
||||
});
|
||||
@ -1,23 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const createCommentActionInCurrentCard = (data) => ({
|
||||
type: EntryActionTypes.COMMENT_ACTION_IN_CURRENT_CARD_CREATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const updateCommentAction = (id, data) => ({
|
||||
type: EntryActionTypes.COMMENT_ACTION_UPDATE,
|
||||
payload: {
|
||||
id,
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteCommentAction = (id) => ({
|
||||
type: EntryActionTypes.COMMENT_ACTION_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const initializeCore = () => ({
|
||||
type: EntryActionTypes.CORE_INITIALIZE,
|
||||
payload: {},
|
||||
});
|
||||
@ -1,18 +0,0 @@
|
||||
export * from './socket';
|
||||
export * from './login';
|
||||
export * from './core';
|
||||
export * from './modal';
|
||||
export * from './user';
|
||||
export * from './project';
|
||||
export * from './project-manager';
|
||||
export * from './board';
|
||||
export * from './board-membership';
|
||||
export * from './label';
|
||||
export * from './list';
|
||||
export * from './card';
|
||||
export * from './task';
|
||||
export * from './attachment';
|
||||
export * from './actions';
|
||||
export * from './action';
|
||||
export * from './comment-action';
|
||||
export * from './notification';
|
||||
@ -1,18 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const authenticate = (data) => ({
|
||||
type: EntryActionTypes.AUTHENTICATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const clearAuthenticateError = () => ({
|
||||
type: EntryActionTypes.AUTHENTICATE_ERROR_CLEAR,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export const logout = () => ({
|
||||
type: EntryActionTypes.LOGOUT,
|
||||
payload: {},
|
||||
});
|
||||
@ -1,22 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const handleNotificationCreate = (notification) => ({
|
||||
type: EntryActionTypes.NOTIFICATION_CREATE_HANDLE,
|
||||
payload: {
|
||||
notification,
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteNotification = (id) => ({
|
||||
type: EntryActionTypes.NOTIFICATION_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleNotificationDelete = (notification) => ({
|
||||
type: EntryActionTypes.NOTIFICATION_DELETE_HANDLE,
|
||||
payload: {
|
||||
notification,
|
||||
},
|
||||
});
|
||||
@ -1,29 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const createManagerInCurrentProject = (data) => ({
|
||||
type: EntryActionTypes.MANAGER_IN_CURRENT_PROJECT_CREATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleProjectManagerCreate = (projectManager) => ({
|
||||
type: EntryActionTypes.PROJECT_MANAGER_CREATE_HANDLE,
|
||||
payload: {
|
||||
projectManager,
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteProjectManager = (id) => ({
|
||||
type: EntryActionTypes.PROJECT_MANAGER_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleProjectManagerDelete = (projectManager) => ({
|
||||
type: EntryActionTypes.PROJECT_MANAGER_DELETE_HANDLE,
|
||||
payload: {
|
||||
projectManager,
|
||||
},
|
||||
});
|
||||
@ -1,11 +0,0 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
|
||||
export const handleSocketDisconnect = () => ({
|
||||
type: EntryActionTypes.SOCKET_DISCONNECT_HANDLE,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export const handleSocketReconnect = () => ({
|
||||
type: EntryActionTypes.SOCKET_RECONNECT_HANDLE,
|
||||
payload: {},
|
||||
});
|
||||
@ -1,19 +1,39 @@
|
||||
export * from './router';
|
||||
export * from './socket';
|
||||
export * from './login';
|
||||
export * from './core';
|
||||
export * from './modal';
|
||||
export * from './user';
|
||||
export * from './project';
|
||||
export * from './project-manager';
|
||||
export * from './board';
|
||||
export * from './board-membership';
|
||||
export * from './label';
|
||||
export * from './list';
|
||||
export * from './card';
|
||||
export * from './task';
|
||||
export * from './attachment';
|
||||
export * from './actions';
|
||||
export * from './action';
|
||||
export * from './comment-action';
|
||||
export * from './notification';
|
||||
import router from './router';
|
||||
import socket from './socket';
|
||||
import login from './login';
|
||||
import core from './core';
|
||||
import modals from './modals';
|
||||
import users from './users';
|
||||
import projects from './projects';
|
||||
import projectManagers from './project-managers';
|
||||
import boards from './boards';
|
||||
import boardMemberships from './board-memberships';
|
||||
import labels from './labels';
|
||||
import lists from './lists';
|
||||
import cards from './cards';
|
||||
import tasks from './tasks';
|
||||
import attachments from './attachments';
|
||||
import activities from './activities';
|
||||
import commentActivities from './comment-activities';
|
||||
import notifications from './notifications';
|
||||
|
||||
export default {
|
||||
...router,
|
||||
...socket,
|
||||
...login,
|
||||
...core,
|
||||
...modals,
|
||||
...users,
|
||||
...projects,
|
||||
...projectManagers,
|
||||
...boards,
|
||||
...boardMemberships,
|
||||
...labels,
|
||||
...lists,
|
||||
...cards,
|
||||
...tasks,
|
||||
...attachments,
|
||||
...activities,
|
||||
...commentActivities,
|
||||
...notifications,
|
||||
};
|
||||
|
||||
@ -1,13 +1,18 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export const openModal = (type) => ({
|
||||
const openModal = (type) => ({
|
||||
type: ActionTypes.MODAL_OPEN,
|
||||
payload: {
|
||||
type,
|
||||
},
|
||||
});
|
||||
|
||||
export const closeModal = () => ({
|
||||
const closeModal = () => ({
|
||||
type: ActionTypes.MODAL_CLOSE,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export default {
|
||||
openModal,
|
||||
closeModal,
|
||||
};
|
||||
@ -1,36 +0,0 @@
|
||||
import socket from './socket';
|
||||
|
||||
/* Transformers */
|
||||
|
||||
export const transformAction = (action) => ({
|
||||
...action,
|
||||
createdAt: new Date(action.createdAt),
|
||||
});
|
||||
|
||||
/* Actions */
|
||||
|
||||
const getActions = (cardId, data) =>
|
||||
socket.get(`/cards/${cardId}/actions`, data).then((body) => ({
|
||||
...body,
|
||||
items: body.items.map(transformAction),
|
||||
}));
|
||||
|
||||
/* Event handlers */
|
||||
|
||||
const makeHandleActionCreate = (next) => (body) => {
|
||||
next({
|
||||
...body,
|
||||
item: transformAction(body.item),
|
||||
});
|
||||
};
|
||||
|
||||
const makeHandleActionUpdate = makeHandleActionCreate;
|
||||
|
||||
const makeHandleActionDelete = makeHandleActionCreate;
|
||||
|
||||
export default {
|
||||
getActions,
|
||||
makeHandleActionCreate,
|
||||
makeHandleActionUpdate,
|
||||
makeHandleActionDelete,
|
||||
};
|
||||
@ -0,0 +1,36 @@
|
||||
import socket from './socket';
|
||||
|
||||
/* Transformers */
|
||||
|
||||
export const transformActivity = (activity) => ({
|
||||
...activity,
|
||||
createdAt: new Date(activity.createdAt),
|
||||
});
|
||||
|
||||
/* Actions */
|
||||
|
||||
const getActivities = (cardId, data) =>
|
||||
socket.get(`/cards/${cardId}/actions`, data).then((body) => ({
|
||||
...body,
|
||||
items: body.items.map(transformActivity),
|
||||
}));
|
||||
|
||||
/* Event handlers */
|
||||
|
||||
const makeHandleActivityCreate = (next) => (body) => {
|
||||
next({
|
||||
...body,
|
||||
item: transformActivity(body.item),
|
||||
});
|
||||
};
|
||||
|
||||
const makeHandleActivityUpdate = makeHandleActivityCreate;
|
||||
|
||||
const makeHandleActivityDelete = makeHandleActivityCreate;
|
||||
|
||||
export default {
|
||||
getActivities,
|
||||
makeHandleActivityCreate,
|
||||
makeHandleActivityUpdate,
|
||||
makeHandleActivityDelete,
|
||||
};
|
||||
@ -1,28 +0,0 @@
|
||||
import socket from './socket';
|
||||
import { transformAction } from './actions';
|
||||
|
||||
/* Actions */
|
||||
|
||||
const createCommentAction = (cardId, data) =>
|
||||
socket.post(`/cards/${cardId}/comment-actions`, data).then((body) => ({
|
||||
...body,
|
||||
item: transformAction(body.item),
|
||||
}));
|
||||
|
||||
const updateCommentAction = (id, data) =>
|
||||
socket.patch(`/comment-actions/${id}`, data).then((body) => ({
|
||||
...body,
|
||||
item: transformAction(body.item),
|
||||
}));
|
||||
|
||||
const deleteCommentAction = (id) =>
|
||||
socket.delete(`/comment-actions/${id}`).then((body) => ({
|
||||
...body,
|
||||
item: transformAction(body.item),
|
||||
}));
|
||||
|
||||
export default {
|
||||
createCommentAction,
|
||||
updateCommentAction,
|
||||
deleteCommentAction,
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
import socket from './socket';
|
||||
import { transformActivity } from './activities';
|
||||
|
||||
/* Actions */
|
||||
|
||||
const createCommentActivity = (cardId, data) =>
|
||||
socket.post(`/cards/${cardId}/comment-actions`, data).then((body) => ({
|
||||
...body,
|
||||
item: transformActivity(body.item),
|
||||
}));
|
||||
|
||||
const updateCommentActivity = (id, data) =>
|
||||
socket.patch(`/comment-actions/${id}`, data).then((body) => ({
|
||||
...body,
|
||||
item: transformActivity(body.item),
|
||||
}));
|
||||
|
||||
const deleteCommentActivity = (id) =>
|
||||
socket.delete(`/comment-actions/${id}`).then((body) => ({
|
||||
...body,
|
||||
item: transformActivity(body.item),
|
||||
}));
|
||||
|
||||
export default {
|
||||
createCommentActivity,
|
||||
updateCommentActivity,
|
||||
deleteCommentActivity,
|
||||
};
|
||||
@ -1,33 +1,61 @@
|
||||
import omit from 'lodash/omit';
|
||||
|
||||
import socket from './socket';
|
||||
import { transformCard } from './cards';
|
||||
import { transformAction } from './actions';
|
||||
import { transformActivity } from './activities';
|
||||
|
||||
/* Transformers */
|
||||
|
||||
export const transformNotification = (notification) => ({
|
||||
...omit(notification, 'actionId'),
|
||||
activityId: notification.actionId,
|
||||
});
|
||||
|
||||
/* Actions */
|
||||
|
||||
const getNotifications = () =>
|
||||
socket.get('/notifications').then((body) => ({
|
||||
...body,
|
||||
items: body.items.map(transformNotification),
|
||||
included: {
|
||||
...body.included,
|
||||
...omit(body.included, 'actions'),
|
||||
cards: body.included.cards.map(transformCard),
|
||||
actions: body.included.actions.map(transformAction),
|
||||
activities: body.included.actions.map(transformActivity),
|
||||
},
|
||||
}));
|
||||
|
||||
const getNotification = (id) =>
|
||||
socket.get(`/notifications/${id}`).then((body) => ({
|
||||
...body,
|
||||
item: transformNotification(body.item),
|
||||
included: {
|
||||
...body.included,
|
||||
...omit(body.included, 'actions'),
|
||||
cards: body.included.cards.map(transformCard),
|
||||
actions: body.included.actions.map(transformAction),
|
||||
activities: body.included.actions.map(transformActivity),
|
||||
},
|
||||
}));
|
||||
|
||||
const updateNotifications = (ids, data) => socket.patch(`/notifications/${ids.join(',')}`, data);
|
||||
const updateNotifications = (ids, data) =>
|
||||
socket.patch(`/notifications/${ids.join(',')}`, data).then((body) => ({
|
||||
...body,
|
||||
items: body.items.map(transformNotification),
|
||||
}));
|
||||
|
||||
/* Event handlers */
|
||||
|
||||
const makeHandleNotificationCreate = (next) => (body) => {
|
||||
next({
|
||||
...body,
|
||||
item: transformNotification(body.item),
|
||||
});
|
||||
};
|
||||
|
||||
const makeHandleNotificationUpdate = makeHandleNotificationCreate;
|
||||
|
||||
export default {
|
||||
getNotifications,
|
||||
getNotification,
|
||||
updateNotifications,
|
||||
makeHandleNotificationCreate,
|
||||
makeHandleNotificationUpdate,
|
||||
};
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
import Actions from './Actions';
|
||||
|
||||
export default Actions;
|
||||
@ -0,0 +1,3 @@
|
||||
import Activities from './Activities';
|
||||
|
||||
export default Activities;
|
||||
@ -0,0 +1,42 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const fetchActivitiesInCurrentCard = () => ({
|
||||
type: EntryActionTypes.ACTIVITIES_IN_CURRENT_CARD_FETCH,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
const toggleActivitiesDetailsInCurrentCard = (isVisible) => ({
|
||||
type: EntryActionTypes.ACTIVITIES_DETAILS_IN_CURRENT_CARD_TOGGLE,
|
||||
payload: {
|
||||
isVisible,
|
||||
},
|
||||
});
|
||||
|
||||
const handleActivityCreate = (activity) => ({
|
||||
type: EntryActionTypes.ACTIVITY_CREATE_HANDLE,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
const handleActivityUpdate = (activity) => ({
|
||||
type: EntryActionTypes.ACTIVITY_UPDATE_HANDLE,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
const handleActivityDelete = (activity) => ({
|
||||
type: EntryActionTypes.ACTIVITY_DELETE_HANDLE,
|
||||
payload: {
|
||||
activity,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
fetchActivitiesInCurrentCard,
|
||||
toggleActivitiesDetailsInCurrentCard,
|
||||
handleActivityCreate,
|
||||
handleActivityUpdate,
|
||||
handleActivityDelete,
|
||||
};
|
||||
@ -0,0 +1,36 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const createMembershipInCurrentBoard = (data) => ({
|
||||
type: EntryActionTypes.MEMBERSHIP_IN_CURRENT_BOARD_CREATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
const handleBoardMembershipCreate = (boardMembership) => ({
|
||||
type: EntryActionTypes.BOARD_MEMBERSHIP_CREATE_HANDLE,
|
||||
payload: {
|
||||
boardMembership,
|
||||
},
|
||||
});
|
||||
|
||||
const deleteBoardMembership = (id) => ({
|
||||
type: EntryActionTypes.BOARD_MEMBERSHIP_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
const handleBoardMembershipDelete = (boardMembership) => ({
|
||||
type: EntryActionTypes.BOARD_MEMBERSHIP_DELETE_HANDLE,
|
||||
payload: {
|
||||
boardMembership,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
createMembershipInCurrentBoard,
|
||||
handleBoardMembershipCreate,
|
||||
deleteBoardMembership,
|
||||
handleBoardMembershipDelete,
|
||||
};
|
||||
@ -0,0 +1,29 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const createCommentActivityInCurrentCard = (data) => ({
|
||||
type: EntryActionTypes.COMMENT_ACTIVITY_IN_CURRENT_CARD_CREATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
const updateCommentActivity = (id, data) => ({
|
||||
type: EntryActionTypes.COMMENT_ACTIVITY_UPDATE,
|
||||
payload: {
|
||||
id,
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
const deleteCommentActivity = (id) => ({
|
||||
type: EntryActionTypes.COMMENT_ACTIVITY_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
createCommentActivityInCurrentCard,
|
||||
updateCommentActivity,
|
||||
deleteCommentActivity,
|
||||
};
|
||||
@ -0,0 +1,16 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const initializeCore = () => ({
|
||||
type: EntryActionTypes.CORE_INITIALIZE,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
const logout = () => ({
|
||||
type: EntryActionTypes.LOGOUT,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export default {
|
||||
initializeCore,
|
||||
logout,
|
||||
};
|
||||
@ -0,0 +1,37 @@
|
||||
import socket from './socket';
|
||||
import login from './login';
|
||||
import core from './core';
|
||||
import modals from './modals';
|
||||
import users from './users';
|
||||
import projects from './projects';
|
||||
import projectManagers from './project-managers';
|
||||
import boards from './boards';
|
||||
import boardMemberships from './board-memberships';
|
||||
import labels from './labels';
|
||||
import lists from './lists';
|
||||
import cards from './cards';
|
||||
import tasks from './tasks';
|
||||
import attachments from './attachments';
|
||||
import activities from './activities';
|
||||
import commentActivities from './comment-activities';
|
||||
import notifications from './notifications';
|
||||
|
||||
export default {
|
||||
...socket,
|
||||
...login,
|
||||
...core,
|
||||
...modals,
|
||||
...users,
|
||||
...projects,
|
||||
...projectManagers,
|
||||
...boards,
|
||||
...boardMemberships,
|
||||
...labels,
|
||||
...lists,
|
||||
...cards,
|
||||
...tasks,
|
||||
...attachments,
|
||||
...activities,
|
||||
...commentActivities,
|
||||
...notifications,
|
||||
};
|
||||
@ -0,0 +1,18 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const authenticate = (data) => ({
|
||||
type: EntryActionTypes.AUTHENTICATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
const clearAuthenticateError = () => ({
|
||||
type: EntryActionTypes.AUTHENTICATE_ERROR_CLEAR,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export default {
|
||||
authenticate,
|
||||
clearAuthenticateError,
|
||||
};
|
||||
@ -1,35 +1,43 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
import ModalTypes from '../../constants/ModalTypes';
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
import ModalTypes from '../constants/ModalTypes';
|
||||
|
||||
export const openUsersModal = () => ({
|
||||
const openUsersModal = () => ({
|
||||
type: EntryActionTypes.MODAL_OPEN,
|
||||
payload: {
|
||||
type: ModalTypes.USERS,
|
||||
},
|
||||
});
|
||||
|
||||
export const openUserSettingsModal = () => ({
|
||||
const openUserSettingsModal = () => ({
|
||||
type: EntryActionTypes.MODAL_OPEN,
|
||||
payload: {
|
||||
type: ModalTypes.USER_SETTINGS,
|
||||
},
|
||||
});
|
||||
|
||||
export const openProjectAddModal = () => ({
|
||||
const openProjectAddModal = () => ({
|
||||
type: EntryActionTypes.MODAL_OPEN,
|
||||
payload: {
|
||||
type: ModalTypes.PROJECT_ADD,
|
||||
},
|
||||
});
|
||||
|
||||
export const openProjectSettingsModal = () => ({
|
||||
const openProjectSettingsModal = () => ({
|
||||
type: EntryActionTypes.MODAL_OPEN,
|
||||
payload: {
|
||||
type: ModalTypes.PROJECT_SETTINGS,
|
||||
},
|
||||
});
|
||||
|
||||
export const closeModal = () => ({
|
||||
const closeModal = () => ({
|
||||
type: EntryActionTypes.MODAL_CLOSE,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export default {
|
||||
openUsersModal,
|
||||
openUserSettingsModal,
|
||||
openProjectAddModal,
|
||||
openProjectSettingsModal,
|
||||
closeModal,
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const handleNotificationCreate = (notification) => ({
|
||||
type: EntryActionTypes.NOTIFICATION_CREATE_HANDLE,
|
||||
payload: {
|
||||
notification,
|
||||
},
|
||||
});
|
||||
|
||||
const deleteNotification = (id) => ({
|
||||
type: EntryActionTypes.NOTIFICATION_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
const handleNotificationDelete = (notification) => ({
|
||||
type: EntryActionTypes.NOTIFICATION_DELETE_HANDLE,
|
||||
payload: {
|
||||
notification,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
handleNotificationCreate,
|
||||
deleteNotification,
|
||||
handleNotificationDelete,
|
||||
};
|
||||
@ -0,0 +1,36 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const createManagerInCurrentProject = (data) => ({
|
||||
type: EntryActionTypes.MANAGER_IN_CURRENT_PROJECT_CREATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
const handleProjectManagerCreate = (projectManager) => ({
|
||||
type: EntryActionTypes.PROJECT_MANAGER_CREATE_HANDLE,
|
||||
payload: {
|
||||
projectManager,
|
||||
},
|
||||
});
|
||||
|
||||
const deleteProjectManager = (id) => ({
|
||||
type: EntryActionTypes.PROJECT_MANAGER_DELETE,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
const handleProjectManagerDelete = (projectManager) => ({
|
||||
type: EntryActionTypes.PROJECT_MANAGER_DELETE_HANDLE,
|
||||
payload: {
|
||||
projectManager,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
createManagerInCurrentProject,
|
||||
handleProjectManagerCreate,
|
||||
deleteProjectManager,
|
||||
handleProjectManagerDelete,
|
||||
};
|
||||
@ -1,48 +1,58 @@
|
||||
import EntryActionTypes from '../../constants/EntryActionTypes';
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
export const createProject = (data) => ({
|
||||
const createProject = (data) => ({
|
||||
type: EntryActionTypes.PROJECT_CREATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleProjectCreate = (project) => ({
|
||||
const handleProjectCreate = (project) => ({
|
||||
type: EntryActionTypes.PROJECT_CREATE_HANDLE,
|
||||
payload: {
|
||||
project,
|
||||
},
|
||||
});
|
||||
|
||||
export const updateCurrentProject = (data) => ({
|
||||
const updateCurrentProject = (data) => ({
|
||||
type: EntryActionTypes.CURRENT_PROJECT_UPDATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const handleProjectUpdate = (project) => ({
|
||||
const handleProjectUpdate = (project) => ({
|
||||
type: EntryActionTypes.PROJECT_UPDATE_HANDLE,
|
||||
payload: {
|
||||
project,
|
||||
},
|
||||
});
|
||||
|
||||
export const updateCurrentProjectBackgroundImage = (data) => ({
|
||||
const updateCurrentProjectBackgroundImage = (data) => ({
|
||||
type: EntryActionTypes.CURRENT_PROJECT_BACKGROUND_IMAGE_UPDATE,
|
||||
payload: {
|
||||
data,
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteCurrentProject = () => ({
|
||||
const deleteCurrentProject = () => ({
|
||||
type: EntryActionTypes.CURRENT_PROJECT_DELETE,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export const handleProjectDelete = (project) => ({
|
||||
const handleProjectDelete = (project) => ({
|
||||
type: EntryActionTypes.PROJECT_DELETE_HANDLE,
|
||||
payload: {
|
||||
project,
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
createProject,
|
||||
handleProjectCreate,
|
||||
updateCurrentProject,
|
||||
handleProjectUpdate,
|
||||
updateCurrentProjectBackgroundImage,
|
||||
deleteCurrentProject,
|
||||
handleProjectDelete,
|
||||
};
|
||||
@ -0,0 +1,16 @@
|
||||
import EntryActionTypes from '../constants/EntryActionTypes';
|
||||
|
||||
const handleSocketDisconnect = () => ({
|
||||
type: EntryActionTypes.SOCKET_DISCONNECT_HANDLE,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
const handleSocketReconnect = () => ({
|
||||
type: EntryActionTypes.SOCKET_RECONNECT_HANDLE,
|
||||
payload: {},
|
||||
});
|
||||
|
||||
export default {
|
||||
handleSocketDisconnect,
|
||||
handleSocketReconnect,
|
||||
};
|
||||
@ -1,95 +0,0 @@
|
||||
import { Model, attr, fk } from 'redux-orm';
|
||||
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
static modelName = 'Action';
|
||||
|
||||
static fields = {
|
||||
id: attr(),
|
||||
type: attr(),
|
||||
data: attr(),
|
||||
createdAt: attr({
|
||||
getDefault: () => new Date(),
|
||||
}),
|
||||
isInCard: attr({
|
||||
getDefault: () => true,
|
||||
}),
|
||||
cardId: fk({
|
||||
to: 'Card',
|
||||
as: 'card',
|
||||
relatedName: 'actions',
|
||||
}),
|
||||
userId: fk({
|
||||
to: 'User',
|
||||
as: 'user',
|
||||
relatedName: 'actions',
|
||||
}),
|
||||
};
|
||||
|
||||
static reducer({ type, payload }, Action) {
|
||||
switch (type) {
|
||||
case ActionTypes.SOCKET_RECONNECT_HANDLE:
|
||||
Action.all().delete();
|
||||
|
||||
payload.actions.forEach((action) => {
|
||||
Action.upsert({
|
||||
...action,
|
||||
isInCard: false,
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.CORE_INITIALIZE:
|
||||
payload.actions.forEach((action) => {
|
||||
Action.upsert({
|
||||
...action,
|
||||
isInCard: false,
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.ACTIONS_FETCH__SUCCESS:
|
||||
case ActionTypes.ACTIONS_DETAILS_TOGGLE__SUCCESS:
|
||||
case ActionTypes.NOTIFICATION_CREATE_HANDLE:
|
||||
payload.actions.forEach((action) => {
|
||||
Action.upsert(action);
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.ACTION_CREATE_HANDLE:
|
||||
case ActionTypes.ACTION_UPDATE_HANDLE:
|
||||
case ActionTypes.COMMENT_ACTION_CREATE:
|
||||
case ActionTypes.COMMENT_ACTION_UPDATE__SUCCESS:
|
||||
Action.upsert(payload.action);
|
||||
|
||||
break;
|
||||
case ActionTypes.ACTION_DELETE_HANDLE:
|
||||
case ActionTypes.COMMENT_ACTION_DELETE__SUCCESS: {
|
||||
const actionModel = Action.withId(payload.action.id);
|
||||
|
||||
if (actionModel) {
|
||||
actionModel.delete();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ActionTypes.COMMENT_ACTION_CREATE__SUCCESS:
|
||||
Action.withId(payload.localId).delete();
|
||||
Action.upsert(payload.action);
|
||||
|
||||
break;
|
||||
case ActionTypes.COMMENT_ACTION_UPDATE:
|
||||
Action.withId(payload.id).update({
|
||||
data: payload.data,
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.COMMENT_ACTION_DELETE:
|
||||
Action.withId(payload.id).delete();
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
import { Model, attr, fk } from 'redux-orm';
|
||||
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
static modelName = 'Activity';
|
||||
|
||||
static fields = {
|
||||
id: attr(),
|
||||
type: attr(),
|
||||
data: attr(),
|
||||
createdAt: attr({
|
||||
getDefault: () => new Date(),
|
||||
}),
|
||||
isInCard: attr({
|
||||
getDefault: () => true,
|
||||
}),
|
||||
cardId: fk({
|
||||
to: 'Card',
|
||||
as: 'card',
|
||||
relatedName: 'activities',
|
||||
}),
|
||||
userId: fk({
|
||||
to: 'User',
|
||||
as: 'user',
|
||||
relatedName: 'activities',
|
||||
}),
|
||||
};
|
||||
|
||||
static reducer({ type, payload }, Activity) {
|
||||
switch (type) {
|
||||
case ActionTypes.SOCKET_RECONNECT_HANDLE:
|
||||
Activity.all().delete();
|
||||
|
||||
payload.activities.forEach((activity) => {
|
||||
Activity.upsert({
|
||||
...activity,
|
||||
isInCard: false,
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.CORE_INITIALIZE:
|
||||
payload.activities.forEach((activity) => {
|
||||
Activity.upsert({
|
||||
...activity,
|
||||
isInCard: false,
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.ACTIVITIES_FETCH__SUCCESS:
|
||||
case ActionTypes.ACTIVITIES_DETAILS_TOGGLE__SUCCESS:
|
||||
case ActionTypes.NOTIFICATION_CREATE_HANDLE:
|
||||
payload.activities.forEach((activity) => {
|
||||
Activity.upsert(activity);
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.ACTIVITY_CREATE_HANDLE:
|
||||
case ActionTypes.ACTIVITY_UPDATE_HANDLE:
|
||||
case ActionTypes.COMMENT_ACTIVITY_CREATE:
|
||||
case ActionTypes.COMMENT_ACTIVITY_UPDATE__SUCCESS:
|
||||
Activity.upsert(payload.activity);
|
||||
|
||||
break;
|
||||
case ActionTypes.ACTIVITY_DELETE_HANDLE:
|
||||
case ActionTypes.COMMENT_ACTIVITY_DELETE__SUCCESS: {
|
||||
const activityModel = Activity.withId(payload.activity.id);
|
||||
|
||||
if (activityModel) {
|
||||
activityModel.delete();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ActionTypes.COMMENT_ACTIVITY_CREATE__SUCCESS:
|
||||
Activity.withId(payload.localId).delete();
|
||||
Activity.upsert(payload.activity);
|
||||
|
||||
break;
|
||||
case ActionTypes.COMMENT_ACTIVITY_UPDATE:
|
||||
Activity.withId(payload.id).update({
|
||||
data: payload.data,
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.COMMENT_ACTIVITY_DELETE:
|
||||
Activity.withId(payload.id).delete();
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue