From bcc92dfa76794365361b04f6f26b41ad76f307a1 Mon Sep 17 00:00:00 2001
From: Mikhail Khromov <44099594+VeryBigSad@users.noreply.github.com>
Date: Wed, 26 Feb 2025 21:56:32 +0300
Subject: [PATCH] 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.
---
client/src/components/CardModal/CardModal.jsx | 40 +++++-
.../components/CardModal/CardModal.test.js | 120 ++++++++++++++++++
client/src/models/Task.js | 1 +
client/src/utils/validator.js | 10 ++
server/api/controllers/cards/show.js | 8 +-
server/api/controllers/cards/update.js | 16 +++
6 files changed, 193 insertions(+), 2 deletions(-)
mode change 100755 => 100644 client/src/components/CardModal/CardModal.jsx
create mode 100644 client/src/components/CardModal/CardModal.test.js
mode change 100755 => 100644 client/src/models/Task.js
mode change 100755 => 100644 server/api/controllers/cards/show.js
mode change 100755 => 100644 server/api/controllers/cards/update.js
diff --git a/client/src/components/CardModal/CardModal.jsx b/client/src/components/CardModal/CardModal.jsx
old mode 100755
new mode 100644
index b31a1f05..7fb02b92
--- a/client/src/components/CardModal/CardModal.jsx
+++ b/client/src/components/CardModal/CardModal.jsx
@@ -2,7 +2,7 @@ import React, { useCallback, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
-import { Button, Checkbox, Grid, Icon, Modal } from 'semantic-ui-react';
+import { Button, Checkbox, Grid, Icon, Modal, Input } from 'semantic-ui-react';
import { usePopup } from '../../lib/popup';
import { Markdown } from '../../lib/custom-ui';
@@ -83,6 +83,8 @@ const CardModal = React.memo(
}) => {
const [t] = useTranslation();
const [isLinkCopied, setIsLinkCopied] = useState(false);
+ const [isGithubLinkInputVisible, setIsGithubLinkInputVisible] = useState(false);
+ const [githubLink, setGithubLink] = useState('');
const isGalleryOpened = useRef(false);
@@ -178,6 +180,17 @@ const CardModal = React.memo(
onClose();
}, [onClose]);
+ const handleGithubLinkChange = useCallback((e) => {
+ setGithubLink(e.target.value);
+ }, []);
+
+ const handleGithubLinkSave = useCallback(() => {
+ onUpdate({
+ githubLink,
+ });
+ setIsGithubLinkInputVisible(false);
+ }, [githubLink, onUpdate]);
+
const AttachmentAddPopup = usePopup(AttachmentAddStep);
const BoardMembershipsPopup = usePopup(BoardMembershipsStep);
const LabelsPopup = usePopup(LabelsStep);
@@ -433,6 +446,31 @@ const CardModal = React.memo(
)}
+