From c6d7d2d576d5323d3595bdeabd5443cfbbab3343 Mon Sep 17 00:00:00 2001 From: Scott Cazan Date: Fri, 24 Nov 2023 17:26:03 +0100 Subject: [PATCH 1/4] update the layout of the notification list --- integrations/slack/src/index.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/integrations/slack/src/index.ts b/integrations/slack/src/index.ts index 0260a30f4..d74aa2d26 100644 --- a/integrations/slack/src/index.ts +++ b/integrations/slack/src/index.ts @@ -4,6 +4,7 @@ import { createIntegration, EventCallback } from '@gitbook/runtime'; import { SlackRuntimeContext } from './configuration'; import { handleFetchEvent } from './router'; import { slackAPI } from './slack'; +import { Spacer } from './ui'; /* * Handle content being updated: send a notification on Slack. @@ -100,6 +101,10 @@ const handleSpaceContentUpdated: EventCallback< space.title || 'Space' }>* has been updated.`; + const renderList = (list: string[]) => { + return list.map((item) => `• ${item}\n`); + }; + if ( createdPages.length > 0 || editedPages.length > 0 || @@ -109,32 +114,32 @@ const handleSpaceContentUpdated: EventCallback< editedFiles.length > 0 || deletedFiles.length > 0 ) { - notificationText += '\n\nSummary of changes:'; + // notificationText += '\n\n*Summary of changes:*'; if (createdPages.length > 0) { - notificationText += `\n• New pages: ${createdPages.join(', ')}`; + notificationText += `\n*New pages:*\n${renderList(createdPages)}\n\n`; } if (editedPages.length > 0) { - notificationText += `\n• Modified pages: ${editedPages.join(', ')}`; + notificationText += `\n*Modified pages:*\n${renderList(editedPages)}\n\n`; } if (deletedPages.length > 0) { - notificationText += `\n• Deleted pages: ${deletedPages.join(', ')}`; + notificationText += `\n*Deleted pages:*\n${renderList(deletedPages)}\n\n`; } if (movedPages.length > 0) { - notificationText += `\n• Moved pages: ${movedPages.join(', ')}`; + notificationText += `\n*Moved pages:*\n${renderList(movedPages)}\n\n`; } if (createdFiles.length > 0) { - notificationText += `\n• New files: ${createdFiles.join(', ')}`; + notificationText += `\n*New files:*\n${renderList(createdFiles)}\n\n`; } if (editedFiles.length > 0) { - notificationText += `\n• Modified files: ${editedFiles.join(', ')}`; + notificationText += `\n*Modified files:*\n${renderList(editedFiles)}\n\n`; } if (deletedFiles.length > 0) { - notificationText += `\n• Deleted files: ${deletedFiles.join(', ')}`; + notificationText += `\n*Deleted files:*\n${renderList(deletedFiles)}\n\n`; } if (semanticChanges.more > 0) { - notificationText += `\n\nAnd another ${semanticChanges.more} changes not listed here.`; + notificationText += `\n\nAnd another ${semanticChanges.more} changes not listed here.\n`; } } @@ -144,6 +149,7 @@ const handleSpaceContentUpdated: EventCallback< payload: { channel, blocks: [ + Spacer, { type: 'section', text: { @@ -151,6 +157,7 @@ const handleSpaceContentUpdated: EventCallback< text: notificationText, }, }, + Spacer, ], }, }); From 7a0b68efd9426ca4b5a448a6d1d1adaa7fe2705a Mon Sep 17 00:00:00 2001 From: Scott Cazan Date: Fri, 24 Nov 2023 17:27:07 +0100 Subject: [PATCH 2/4] typo --- integrations/slack/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/slack/README.md b/integrations/slack/README.md index 8b0161cc3..35ec148e7 100644 --- a/integrations/slack/README.md +++ b/integrations/slack/README.md @@ -1,6 +1,6 @@ # Slack integration -To configure it for your environment, create an application on Slack and use the `slack-manifest.yaml` file to configure it. Don't forget to update the URLs to natch your environment. +To configure it for your environment, create an application on Slack and use the `slack-manifest.yaml` file to configure it. Don't forget to update the URLs to match your environment. To publish it, run the command with the `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET`, and `SLACK_SIGNING_SECRET ` environment variables defined: From 172cdd36fdc418d8b85043746fb1b3f548da8972 Mon Sep 17 00:00:00 2001 From: Scott Cazan Date: Fri, 24 Nov 2023 17:38:28 +0100 Subject: [PATCH 3/4] changeset --- .changeset/lucky-beds-return.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lucky-beds-return.md diff --git a/.changeset/lucky-beds-return.md b/.changeset/lucky-beds-return.md new file mode 100644 index 000000000..cffe53820 --- /dev/null +++ b/.changeset/lucky-beds-return.md @@ -0,0 +1,5 @@ +--- +'@gitbook/integration-slack': minor +--- + +Reformats the notifications into a list From 336aea988577c181ffeb42c786c880999b46ff2f Mon Sep 17 00:00:00 2001 From: Scott Cazan Date: Fri, 24 Nov 2023 17:39:13 +0100 Subject: [PATCH 4/4] remove commented code --- integrations/slack/src/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/integrations/slack/src/index.ts b/integrations/slack/src/index.ts index d74aa2d26..b4a2b8e25 100644 --- a/integrations/slack/src/index.ts +++ b/integrations/slack/src/index.ts @@ -114,8 +114,6 @@ const handleSpaceContentUpdated: EventCallback< editedFiles.length > 0 || deletedFiles.length > 0 ) { - // notificationText += '\n\n*Summary of changes:*'; - if (createdPages.length > 0) { notificationText += `\n*New pages:*\n${renderList(createdPages)}\n\n`; }