From cc32daa009c6bbd33db8c238cbf1f0f7e4a735cc Mon Sep 17 00:00:00 2001 From: HannesOberreiter Date: Wed, 10 Apr 2024 15:53:05 +0200 Subject: [PATCH 1/4] feat: Display clickable links in tasks (#694) Closes #330 --- client/package-lock.json | 16 +++++ client/package.json | 2 + client/src/components/Card/Tasks.jsx | 4 +- client/src/components/Card/Tasks.module.scss | 2 + .../src/components/CardModal/Tasks/Item.jsx | 3 +- client/src/components/Linkify.jsx | 68 +++++++++++++++++++ 6 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 client/src/components/Linkify.jsx diff --git a/client/package-lock.json b/client/package-lock.json index 62cebb9..b1e6907 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -17,6 +17,8 @@ "initials": "^3.1.2", "js-cookie": "^3.0.5", "jwt-decode": "^4.0.0", + "linkify-react": "^4.1.3", + "linkifyjs": "^4.1.3", "lodash": "^4.17.21", "nanoid": "^5.0.3", "node-sass": "^9.0.0", @@ -11911,6 +11913,20 @@ "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" }, + "node_modules/linkify-react": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/linkify-react/-/linkify-react-4.1.3.tgz", + "integrity": "sha512-rhI3zM/fxn5BfRPHfi4r9N7zgac4vOIxub1wHIWXLA5ENTMs+BGaIaFO1D1PhmxgwhIKmJz3H7uCP0Dg5JwSlA==", + "peerDependencies": { + "linkifyjs": "^4.0.0", + "react": ">= 15.0.0" + } + }, + "node_modules/linkifyjs": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.1.3.tgz", + "integrity": "sha512-auMesunaJ8yfkHvK4gfg1K0SaKX/6Wn9g2Aac/NwX+l5VdmFZzo/hdPGxEOETj+ryRa4/fiOPjeeKURSAJx1sg==" + }, "node_modules/loader-runner": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", diff --git a/client/package.json b/client/package.json index 25cdce0..3f3c4e1 100755 --- a/client/package.json +++ b/client/package.json @@ -70,6 +70,8 @@ "initials": "^3.1.2", "js-cookie": "^3.0.5", "jwt-decode": "^4.0.0", + "linkify-react": "^4.1.3", + "linkifyjs": "^4.1.3", "lodash": "^4.17.21", "nanoid": "^5.0.3", "node-sass": "^9.0.0", diff --git a/client/src/components/Card/Tasks.jsx b/client/src/components/Card/Tasks.jsx index d76340f..c530474 100644 --- a/client/src/components/Card/Tasks.jsx +++ b/client/src/components/Card/Tasks.jsx @@ -4,6 +4,8 @@ import classNames from 'classnames'; import { Progress } from 'semantic-ui-react'; import { useToggle } from '../../lib/hooks'; +import Linkify from '../Linkify'; + import styles from './Tasks.module.scss'; const Tasks = React.memo(({ items }) => { @@ -48,7 +50,7 @@ const Tasks = React.memo(({ items }) => { key={item.id} className={classNames(styles.task, item.isCompleted && styles.taskCompleted)} > - {item.name} + {item.name} ))} diff --git a/client/src/components/Card/Tasks.module.scss b/client/src/components/Card/Tasks.module.scss index 508ac89..8f8a7ec 100644 --- a/client/src/components/Card/Tasks.module.scss +++ b/client/src/components/Card/Tasks.module.scss @@ -55,8 +55,10 @@ display: block; font-size: 12px; line-height: 14px; + overflow: hidden; padding-bottom: 6px; padding-left: 14px; + text-overflow: ellipsis; &:before { content: "–"; diff --git a/client/src/components/CardModal/Tasks/Item.jsx b/client/src/components/CardModal/Tasks/Item.jsx index a34beb0..8bb3046 100755 --- a/client/src/components/CardModal/Tasks/Item.jsx +++ b/client/src/components/CardModal/Tasks/Item.jsx @@ -8,6 +8,7 @@ import { usePopup } from '../../../lib/popup'; import NameEdit from './NameEdit'; import ActionsStep from './ActionsStep'; +import Linkify from '../../Linkify'; import styles from './Item.module.scss'; @@ -65,7 +66,7 @@ const Item = React.memo( onClick={handleClick} > - {name} + {name} {isPersisted && canEdit && ( diff --git a/client/src/components/Linkify.jsx b/client/src/components/Linkify.jsx new file mode 100644 index 0000000..71b01fd --- /dev/null +++ b/client/src/components/Linkify.jsx @@ -0,0 +1,68 @@ +import React, { useCallback } from 'react'; +import PropTypes from 'prop-types'; +import LinkifyReact from 'linkify-react'; + +import history from '../history'; + +const Linkify = React.memo(({ children, linkStopPropagation, ...props }) => { + const handleLinkClick = useCallback( + (event) => { + if (linkStopPropagation) { + event.stopPropagation(); + } + + if (!event.target.getAttribute('target')) { + event.preventDefault(); + history.push(event.target.href); + } + }, + [linkStopPropagation], + ); + + const linkRenderer = useCallback( + ({ attributes: { href, ...linkProps }, content }) => { + let url; + try { + url = new URL(href, window.location); + } catch (error) {} // eslint-disable-line no-empty + + const isSameSite = !!url && url.origin === window.location.origin; + + return ( + + {isSameSite ? url.pathname : content} + + ); + }, + [handleLinkClick], + ); + + return ( + + {children} + + ); +}); + +Linkify.propTypes = { + children: PropTypes.string.isRequired, + linkStopPropagation: PropTypes.bool, +}; + +Linkify.defaultProps = { + linkStopPropagation: false, +}; + +export default Linkify; From 16499052f74b2aa4b79a68ad9504f00ff5991498 Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Wed, 10 Apr 2024 15:57:15 +0200 Subject: [PATCH 2/4] chore: Update version --- charts/planka/Chart.yaml | 4 ++-- client/.env | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/charts/planka/Chart.yaml b/charts/planka/Chart.yaml index 470f805..4a43c8f 100644 --- a/charts/planka/Chart.yaml +++ b/charts/planka/Chart.yaml @@ -15,13 +15,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.24 +version: 0.1.25 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.16.2" +appVersion: "1.16.3" dependencies: - alias: postgresql diff --git a/client/.env b/client/.env index e17aeb7..31c7289 100644 --- a/client/.env +++ b/client/.env @@ -1 +1 @@ -REACT_APP_VERSION=1.16.2 +REACT_APP_VERSION=1.16.3 diff --git a/package-lock.json b/package-lock.json index eee91c9..3f255b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "planka", - "version": "1.16.2", + "version": "1.16.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "planka", - "version": "1.16.2", + "version": "1.16.3", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { diff --git a/package.json b/package.json index 7e06e77..2b71a75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "planka", - "version": "1.16.2", + "version": "1.16.3", "private": true, "homepage": "https://plankanban.github.io/planka", "repository": { From 8a8c1fee0c650cfe410f2abc4756da1b4bc6cc3d Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Fri, 12 Apr 2024 12:07:19 +0200 Subject: [PATCH 3/4] fix: Fix error output when sending email or message to Slack --- client/src/containers/LoginContainer.js | 2 +- server/api/helpers/utils/send-email.js | 4 ++-- server/api/helpers/utils/send-slack-message.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/containers/LoginContainer.js b/client/src/containers/LoginContainer.js index 881b65b..1a16788 100755 --- a/client/src/containers/LoginContainer.js +++ b/client/src/containers/LoginContainer.js @@ -20,7 +20,7 @@ const mapStateToProps = (state) => { isSubmittingUsingOidc, error, withOidc: !!oidcConfig, - isOidcEnforced: oidcConfig && oidcConfig.isEnforced, + isOidcEnforced: !!oidcConfig && oidcConfig.isEnforced, }; }; diff --git a/server/api/helpers/utils/send-email.js b/server/api/helpers/utils/send-email.js index 7b8d08b..02593f8 100644 --- a/server/api/helpers/utils/send-email.js +++ b/server/api/helpers/utils/send-email.js @@ -23,9 +23,9 @@ module.exports = { from: sails.config.custom.smtpFrom, }); - sails.log.info('Email sent: %s', info.messageId); + sails.log.info(`Email sent: ${info.messageId}`); } catch (error) { - sails.log.error(error); // TODO: provide description text? + sails.log.error(`Error sending email: ${error}`); } }, }; diff --git a/server/api/helpers/utils/send-slack-message.js b/server/api/helpers/utils/send-slack-message.js index 573fcf8..510ae1b 100644 --- a/server/api/helpers/utils/send-slack-message.js +++ b/server/api/helpers/utils/send-slack-message.js @@ -35,19 +35,19 @@ module.exports = { body: JSON.stringify(body), }); } catch (error) { - sails.log.error(error); // TODO: provide description text? + sails.log.error(`Error sending to Slack: ${error}`); return; } if (!response.ok) { - sails.log.error('Error sending to Slack: %s', response.error); + sails.log.error(`Error sending to Slack: ${response.error}`); return; } const responseJson = await response.json(); if (!responseJson.ok) { - sails.log.error('Error sending to Slack: %s', responseJson.error); + sails.log.error(`Error sending to Slack: ${responseJson.error}`); } }, }; From 92f75789fa3c3d58655501373c3d990cde7c8d15 Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Fri, 12 Apr 2024 12:09:22 +0200 Subject: [PATCH 4/4] chore: Update version --- charts/planka/Chart.yaml | 4 ++-- client/.env | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/charts/planka/Chart.yaml b/charts/planka/Chart.yaml index 4a43c8f..02158c7 100644 --- a/charts/planka/Chart.yaml +++ b/charts/planka/Chart.yaml @@ -15,13 +15,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.25 +version: 0.1.26 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.16.3" +appVersion: "1.16.4" dependencies: - alias: postgresql diff --git a/client/.env b/client/.env index 31c7289..1b48387 100644 --- a/client/.env +++ b/client/.env @@ -1 +1 @@ -REACT_APP_VERSION=1.16.3 +REACT_APP_VERSION=1.16.4 diff --git a/package-lock.json b/package-lock.json index 3f255b0..9c2bff2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "planka", - "version": "1.16.3", + "version": "1.16.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "planka", - "version": "1.16.3", + "version": "1.16.4", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { diff --git a/package.json b/package.json index 2b71a75..dab2865 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "planka", - "version": "1.16.3", + "version": "1.16.4", "private": true, "homepage": "https://plankanban.github.io/planka", "repository": {