mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 06:39:44 +02:00
Add GitHub link field to tasks
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.
This commit is contained in:
parent
b88a2894b6
commit
bcc92dfa76
6 changed files with 193 additions and 2 deletions
16
server/api/controllers/cards/update.js
Executable file → Normal file
16
server/api/controllers/cards/update.js
Executable file → Normal file
|
@ -43,6 +43,16 @@ const stopwatchValidator = (value) => {
|
|||
return true;
|
||||
};
|
||||
|
||||
const githubLinkValidator = (value) => {
|
||||
const urlPattern = new RegExp('^(https?:\\/\\/)?'+ // validate the protocol
|
||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+ // validate the domain name
|
||||
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR validate the IP (v4) address
|
||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // validate the port and path
|
||||
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // validate the query string
|
||||
'(\\#[-a-z\\d_]*)?$','i'); // validate the fragment locator
|
||||
return !!urlPattern.test(value) && value.startsWith('https://github.com/');
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
id: {
|
||||
|
@ -91,6 +101,11 @@ module.exports = {
|
|||
isSubscribed: {
|
||||
type: 'boolean',
|
||||
},
|
||||
githubLink: {
|
||||
type: 'string',
|
||||
custom: githubLinkValidator,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
|
@ -180,6 +195,7 @@ module.exports = {
|
|||
'isDueDateCompleted',
|
||||
'stopwatch',
|
||||
'isSubscribed',
|
||||
'githubLink',
|
||||
]);
|
||||
|
||||
card = await sails.helpers.cards.updateOne
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue