From 10864527c48e5d51a1f4d435e41dc1702f560989 Mon Sep 17 00:00:00 2001 From: Shun Miyazawa Date: Fri, 24 May 2024 09:24:55 +0000 Subject: [PATCH 1/8] Allow undefined --- apps/app/src/server/util/slack.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/app/src/server/util/slack.js b/apps/app/src/server/util/slack.js index 474acf0eacc..d1828574d9a 100644 --- a/apps/app/src/server/util/slack.js +++ b/apps/app/src/server/util/slack.js @@ -25,6 +25,10 @@ const prepareAttachmentTextForCreate = function(page, siteUrl) { }; const prepareAttachmentTextForUpdate = function(page, siteUrl, previousRevision) { + if (previousRevision == null) { + return; + } + const diff = require('diff'); let diffText = ''; From 1e03b8f5856295ae25025ff5c54355069e86b2da Mon Sep 17 00:00:00 2001 From: Shun Miyazawa Date: Mon, 27 May 2024 03:57:18 +0000 Subject: [PATCH 2/8] { isSlackEnabled: boolean } passed to the server side --- .../src/components/PageEditor/PageEditor.tsx | 1 + apps/app/src/components/SavePageControls.tsx | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/app/src/components/PageEditor/PageEditor.tsx b/apps/app/src/components/PageEditor/PageEditor.tsx index 8e703271687..d46fc8fabb8 100644 --- a/apps/app/src/components/PageEditor/PageEditor.tsx +++ b/apps/app/src/components/PageEditor/PageEditor.tsx @@ -68,6 +68,7 @@ declare global { export type SaveOptions = { wip: boolean, slackChannels: string, + isSlackEnabled: boolean, overwriteScopesOfDescendants?: boolean } export type Save = ( diff --git a/apps/app/src/components/SavePageControls.tsx b/apps/app/src/components/SavePageControls.tsx index 6382baf28ef..ffa74bc07b1 100644 --- a/apps/app/src/components/SavePageControls.tsx +++ b/apps/app/src/components/SavePageControls.tsx @@ -35,30 +35,32 @@ declare global { const logger = loggerFactory('growi:SavePageControls'); -const SavePageButton = (props: {slackChannels: string, isDeviceLargerThanMd?: boolean}) => { +const SavePageButton = (props: {slackChannels: string, isSlackEnabled?: boolean, isDeviceLargerThanMd?: boolean}) => { const { t } = useTranslation(); const { data: _isWaitingSaveProcessing } = useWaitingSaveProcessing(); const [isSavePageModalShown, setIsSavePageModalShown] = useState(false); - const { slackChannels, isDeviceLargerThanMd } = props; + const { slackChannels, isSlackEnabled, isDeviceLargerThanMd } = props; const isWaitingSaveProcessing = _isWaitingSaveProcessing === true; // ignore undefined const save = useCallback(async(): Promise => { // save - globalEmitter.emit('saveAndReturnToView', { wip: false, slackChannels }); - }, [slackChannels]); + globalEmitter.emit('saveAndReturnToView', { wip: false, slackChannels, isSlackEnabled }); + }, [isSlackEnabled, slackChannels]); const saveAndOverwriteScopesOfDescendants = useCallback(() => { // save - globalEmitter.emit('saveAndReturnToView', { wip: false, overwriteScopesOfDescendants: true, slackChannels }); - }, [slackChannels]); + globalEmitter.emit('saveAndReturnToView', { + wip: false, overwriteScopesOfDescendants: true, slackChannels, isSlackEnabled, + }); + }, [isSlackEnabled, slackChannels]); const saveAndMakeWip = useCallback(() => { // save - globalEmitter.emit('saveAndReturnToView', { wip: true, slackChannels }); - }, [slackChannels]); + globalEmitter.emit('saveAndReturnToView', { wip: true, slackChannels, isSlackEnabled }); + }, [isSlackEnabled, slackChannels]); const labelSubmitButton = t('Update'); const labelOverwriteScopes = t('page_edit.overwrite_scopes', { operation: labelSubmitButton }); @@ -197,11 +199,11 @@ export const SavePageControls = (): JSX.Element | null => { ) } - + ) : ( <> - +