mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
Add a custom field named "Github Link" to tasks and display it in the frontend. * Add `githubLink` attribute to the `Task` model in `client/src/models/Task.js`. * Update `createTask` and `updateTask` actions in `client/src/actions/tasks.js` to handle the `githubLink` attribute. * Add input field for `githubLink` in `CardModal` component in `client/src/components/CardModal/CardModal.jsx`. * Display `githubLink` as a clickable link when filled in. * Display a button that expands into an input field when `githubLink` is not filled in. * Include `githubLink` attribute in card data retrieval logic in `server/api/controllers/cards/show.js`. * Include `githubLink` attribute in card data updating logic in `server/api/controllers/cards/update.js`. * Add validation function for `githubLink` in `client/src/utils/validator.js`. * Add unit tests for `githubLink` field in `client/src/components/CardModal/CardModal.test.js`. * Test display of `githubLink` as a clickable link when filled in. * Test display of button to add `githubLink` when not filled in. * Test input field display when add `githubLink` button is clicked. * Test `onUpdate` call with `githubLink` when save button is clicked. * Test validation of `githubLink` format.
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
const Errors = {
|
|
CARD_NOT_FOUND: {
|
|
cardNotFound: 'Card not found',
|
|
},
|
|
};
|
|
|
|
module.exports = {
|
|
inputs: {
|
|
id: {
|
|
type: 'string',
|
|
regex: /^[0-9]+$/,
|
|
required: true,
|
|
},
|
|
},
|
|
|
|
exits: {
|
|
cardNotFound: {
|
|
responseType: 'notFound',
|
|
},
|
|
},
|
|
|
|
async fn(inputs) {
|
|
const { currentUser } = this.req;
|
|
|
|
const { card, project } = await sails.helpers.cards
|
|
.getProjectPath(inputs.id)
|
|
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
|
|
|
const isBoardMember = await sails.helpers.users.isBoardMember(currentUser.id, card.boardId);
|
|
|
|
if (!isBoardMember) {
|
|
const isProjectManager = await sails.helpers.users.isProjectManager(
|
|
currentUser.id,
|
|
project.id,
|
|
);
|
|
|
|
if (!isProjectManager) {
|
|
throw Errors.CARD_NOT_FOUND; // Forbidden
|
|
}
|
|
}
|
|
|
|
card.isSubscribed = await sails.helpers.users.isCardSubscriber(currentUser.id, card.id);
|
|
|
|
const cardMemberships = await sails.helpers.cards.getCardMemberships(card.id);
|
|
const cardLabels = await sails.helpers.cards.getCardLabels(card.id);
|
|
const tasks = await sails.helpers.cards.getTasks(card.id);
|
|
const attachments = await sails.helpers.cards.getAttachments(card.id);
|
|
|
|
// Include the githubLink attribute in the tasks
|
|
const tasksWithGithubLink = tasks.map((task) => ({
|
|
...task,
|
|
githubLink: task.githubLink || null,
|
|
}));
|
|
|
|
return {
|
|
item: card,
|
|
included: {
|
|
cardMemberships,
|
|
cardLabels,
|
|
tasks: tasksWithGithubLink,
|
|
attachments,
|
|
},
|
|
};
|
|
},
|
|
};
|