feat: Version 2

Closes #627, closes #1047
This commit is contained in:
Maksim Eltyshev
2025-05-10 02:09:06 +02:00
parent ad7fb51cfa
commit 2ee1166747
1557 changed files with 76832 additions and 47042 deletions
+21 -2
View File
@@ -1,3 +1,10 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
import omit from 'lodash/omit';
import truncate from 'lodash/truncate';
import { call, put, select } from 'redux-saga/effects';
import request from '../request';
@@ -5,21 +12,33 @@ import selectors from '../../../selectors';
import actions from '../../../actions';
import api from '../../../api';
import { createLocalId } from '../../../utils/local-id';
import { AttachmentTypes } from '../../../constants/Enums';
export function* createAttachment(cardId, data) {
const localId = yield call(createLocalId);
const currentUserId = yield select(selectors.selectCurrentUserId);
const nextData = {
...data,
name: truncate(data.name, {
length: 128,
}),
};
yield put(
actions.createAttachment({
...omit(nextData, ['file', 'url']),
cardId,
id: localId,
name: data.file.name,
creatorUserId: currentUserId,
}),
);
let attachment;
try {
({ item: attachment } = yield call(request, api.createAttachment, cardId, data, localId));
({ item: attachment } = yield nextData.type === AttachmentTypes.FILE
? call(request, api.createAttachmentWithFile, cardId, nextData, localId)
: call(request, api.createAttachment, cardId, nextData));
} catch (error) {
yield put(actions.createAttachment.failure(localId, error));
return;