Add file attachments

This commit is contained in:
Maksim Eltyshev
2020-04-21 05:04:34 +05:00
parent 87a3cf751a
commit f743f4ea8b
103 changed files with 1847 additions and 305 deletions

View File

@@ -0,0 +1,117 @@
import ActionTypes from '../constants/ActionTypes';
/* Actions */
export const createAttachment = (attachment) => ({
type: ActionTypes.ATTACHMENT_CREATE,
payload: {
attachment,
},
});
export const updateAttachment = (id, data) => ({
type: ActionTypes.ATTACHMENT_UPDATE,
payload: {
id,
data,
},
});
export const deleteAttachment = (id) => ({
type: ActionTypes.ATTACHMENT_DELETE,
payload: {
id,
},
});
/* Events */
export const createAttachmentRequested = (localId, data) => ({
type: ActionTypes.ATTACHMENT_CREATE_REQUESTED,
payload: {
localId,
data,
},
});
export const createAttachmentSucceeded = (localId, attachment) => ({
type: ActionTypes.ATTACHMENT_CREATE_SUCCEEDED,
payload: {
localId,
attachment,
},
});
export const createAttachmentFailed = (localId, error) => ({
type: ActionTypes.ATTACHMENT_CREATE_FAILED,
payload: {
localId,
error,
},
});
export const createAttachmentReceived = (attachment) => ({
type: ActionTypes.ATTACHMENT_CREATE_RECEIVED,
payload: {
attachment,
},
});
export const updateAttachmentRequested = (id, data) => ({
type: ActionTypes.ATTACHMENT_UPDATE_REQUESTED,
payload: {
id,
data,
},
});
export const updateAttachmentSucceeded = (attachment) => ({
type: ActionTypes.ATTACHMENT_UPDATE_SUCCEEDED,
payload: {
attachment,
},
});
export const updateAttachmentFailed = (id, error) => ({
type: ActionTypes.ATTACHMENT_UPDATE_FAILED,
payload: {
id,
error,
},
});
export const updateAttachmentReceived = (attachment) => ({
type: ActionTypes.ATTACHMENT_UPDATE_RECEIVED,
payload: {
attachment,
},
});
export const deleteAttachmentRequested = (id) => ({
type: ActionTypes.ATTACHMENT_DELETE_REQUESTED,
payload: {
id,
},
});
export const deleteAttachmentSucceeded = (attachment) => ({
type: ActionTypes.ATTACHMENT_DELETE_SUCCEEDED,
payload: {
attachment,
},
});
export const deleteAttachmentFailed = (id, error) => ({
type: ActionTypes.ATTACHMENT_DELETE_FAILED,
payload: {
id,
error,
},
});
export const deleteAttachmentReceived = (attachment) => ({
type: ActionTypes.ATTACHMENT_DELETE_RECEIVED,
payload: {
attachment,
},
});

View File

@@ -76,6 +76,7 @@ export const fetchBoardSucceeded = (
cardMemberships,
cardLabels,
tasks,
attachments,
) => ({
type: ActionTypes.BOARD_FETCH_SUCCEEDED,
payload: {
@@ -86,6 +87,7 @@ export const fetchBoardSucceeded = (
cardMemberships,
cardLabels,
tasks,
attachments,
},
});

View File

@@ -0,0 +1,23 @@
import EntryActionTypes from '../../constants/EntryActionTypes';
export const createAttachmentInCurrentCard = (data) => ({
type: EntryActionTypes.ATTACHMENT_IN_CURRENT_CARD_CREATE,
payload: {
data,
},
});
export const updateAttachment = (id, data) => ({
type: EntryActionTypes.ATTACHMENT_UPDATE,
payload: {
id,
data,
},
});
export const deleteAttachment = (id) => ({
type: EntryActionTypes.ATTACHMENT_DELETE,
payload: {
id,
},
});

View File

@@ -8,6 +8,7 @@ export * from './list';
export * from './label';
export * from './card';
export * from './task';
export * from './attachment';
export * from './actions';
export * from './comment-action';
export * from './notification';

View File

@@ -63,10 +63,10 @@ export const clearCurrentUserUsernameUpdateError = () => ({
payload: {},
});
export const uploadCurrentUserAvatar = (file) => ({
type: EntryActionTypes.CURRENT_USER_AVATAR_UPLOAD,
export const updateCurrentUserAvatar = (data) => ({
type: EntryActionTypes.CURRENT_USER_AVATAR_UPDATE,
payload: {
file,
data,
},
});

View File

@@ -14,6 +14,7 @@ export * from './card';
export * from './card-membership';
export * from './card-label';
export * from './task';
export * from './attachment';
export * from './actions';
export * from './action';
export * from './comment-action';

View File

@@ -233,23 +233,23 @@ export const updateUserUsernameFailed = (id, error) => ({
},
});
export const uploadUserAvatarRequested = (id) => ({
type: ActionTypes.USER_AVATAR_UPLOAD_REQUESTED,
export const updateUserAvatarRequested = (id) => ({
type: ActionTypes.USER_AVATAR_UPDATE_REQUESTED,
payload: {
id,
},
});
export const uploadUserAvatarSucceeded = (id, avatar) => ({
type: ActionTypes.USER_AVATAR_UPLOAD_SUCCEEDED,
export const updateUserAvatarSucceeded = (id, avatarUrl) => ({
type: ActionTypes.USER_AVATAR_UPDATE_SUCCEEDED,
payload: {
id,
avatar,
avatarUrl,
},
});
export const uploadUserAvatarFailed = (id, error) => ({
type: ActionTypes.USER_AVATAR_UPLOAD_FAILED,
export const updateUserAvatarFailed = (id, error) => ({
type: ActionTypes.USER_AVATAR_UPDATE_FAILED,
payload: {
id,
error,