From 8dc85cf5f6c45d4bb5de150bc513bbdf610e87fa Mon Sep 17 00:00:00 2001 From: Sophia Mersmann Date: Fri, 7 Mar 2025 09:29:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9D=20(admin)=20disable=20slack=20mess?= =?UTF-8?q?age=20on=20DI=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminSiteClient/CreateDataInsightModal.tsx | 122 +-------------------- adminSiteClient/admin.scss | 4 - 2 files changed, 2 insertions(+), 124 deletions(-) diff --git a/adminSiteClient/CreateDataInsightModal.tsx b/adminSiteClient/CreateDataInsightModal.tsx index 6a2b9eac69..58fa3c38bc 100644 --- a/adminSiteClient/CreateDataInsightModal.tsx +++ b/adminSiteClient/CreateDataInsightModal.tsx @@ -30,14 +30,10 @@ import cx from "classnames" import { fetchFigmaProvidedImageUrl, ImageUploadResponse, - makeImageSrc, uploadImageFromSourceUrl, } from "./imagesHelpers" import { AdminAppContext } from "./AdminAppContext" -import { - GRAPHER_DYNAMIC_THUMBNAIL_URL, - SLACK_DI_PITCHES_CHANNEL_ID, -} from "../settings/clientSettings" +import { GRAPHER_DYNAMIC_THUMBNAIL_URL } from "../settings/clientSettings" import { LoadingImage } from "./ReuploadImageForDataInsightModal" import { ApiChartViewOverview } from "../adminShared/AdminTypes" import { @@ -48,7 +44,6 @@ import { RequiredBy, } from "@ourworldindata/utils" import { match } from "ts-pattern" -import { Checkbox } from "antd/lib" const DEFAULT_RUNNING_MESSAGE: Record = { createDI: "Creating data insight...", @@ -56,7 +51,6 @@ const DEFAULT_RUNNING_MESSAGE: Record = { loadFigmaImage: "Loading Figma image...", suggestAltText: "Suggesting alt text...", setTopicTags: "Setting topic tags...", - sendSlackMessage: "Sending Slack message...", } as const const DEFAULT_SUCCESS_MESSAGE: Record = { @@ -65,7 +59,6 @@ const DEFAULT_SUCCESS_MESSAGE: Record = { loadFigmaImage: "Figma image loaded successfully", suggestAltText: "Alt text suggested successfully", setTopicTags: "Topic tags assigned", - sendSlackMessage: "Slack message sent", } as const const DEFAULT_ERROR_MESSAGE: Record = { @@ -74,7 +67,6 @@ const DEFAULT_ERROR_MESSAGE: Record = { loadFigmaImage: "Loading Figma image failed", suggestAltText: "Suggesting alt text failed", setTopicTags: "Setting topic tags failed", - sendSlackMessage: "Sending Slack message failed", } as const type Task = @@ -83,7 +75,6 @@ type Task = | "loadFigmaImage" | "suggestAltText" | "setTopicTags" - | "sendSlackMessage" type Progress = | { status: "idle" } @@ -99,7 +90,6 @@ type FormFieldName = | "figmaUrl" | "imageFilename" | "imageAltText" - | "slackNote" type ImageFormFieldName = "imageFilename" | "imageAltText" type FormData = Partial< @@ -162,13 +152,9 @@ export function CreateDataInsightModal(props: { "uploadImage", "loadFigmaImage", "suggestAltText", - "setTopicTags", - "sendSlackMessage" + "setTopicTags" ) - const [shouldSendMessageToSlack, setShouldSendMessageToSlack] = - useState(true) - // loaded from Figma if a Figma URL is provided const [figmaImageUrl, setFigmaImageUrl] = useState() @@ -277,7 +263,6 @@ export function CreateDataInsightModal(props: { setProgress("createDI", "running") - let cloudflareImageId: string | undefined if (imageUrl && isValidForImageUpload(formData)) { setProgress("uploadImage", "running") @@ -291,8 +276,6 @@ export function CreateDataInsightModal(props: { "Not attempted since image upload failed" ) return - } else { - cloudflareImageId = response.image.cloudflareId ?? undefined } } catch (error) { const errorMessage = @@ -326,22 +309,6 @@ export function CreateDataInsightModal(props: { } } - // Send a message to Slack if requested - if (shouldSendMessageToSlack && cloudflareImageId) { - setProgress("sendSlackMessage", "running") - try { - await sendDataInsightToSlack({ - formData, - imageUrl: makeImageSrc(cloudflareImageId, 1250), - }) - setProgress("sendSlackMessage", "success") - } catch (error) { - const errorMessage = - error instanceof Error ? error.message : String(error) - setProgress("sendSlackMessage", "failure", errorMessage) - } - } - props.onFinish?.(createResponse) } @@ -406,40 +373,6 @@ export function CreateDataInsightModal(props: { ) } - const sendDataInsightToSlack = async ({ - formData, - imageUrl, - }: { - formData: FormDataWithTitle - imageUrl: string - }) => { - const { title, slackNote, authors } = formData - - let text = `*${title}*` - if (slackNote) text += `\n\n${slackNote}` - if (authors) text += `\n\nby ${authors}` - - const blocks = [ - { - type: "section", - text: { type: "mrkdwn", text }, - }, - { - type: "image", - image_url: imageUrl, - alt_text: formData.imageAltText, - }, - ] - - const payload = { - blocks, - channel: SLACK_DI_PITCHES_CHANNEL_ID, - username: "Data insight bot", - } - - void admin.requestJSON(`/api/slack/sendMessage`, payload, "POST") - } - const fetchFigmaImage = async (figmaUrl: string) => { setProgress("loadFigmaImage", "running") try { @@ -729,31 +662,6 @@ export function CreateDataInsightModal(props: { )} - {imageUrl && ( -

- { - setShouldSendMessageToSlack( - e.target.checked - ) - }} - > - Share data insight in the #data-insight-pitches - channel - - {shouldSendMessageToSlack && ( - - - - )} -

- )} - {showFeedbackBox({ formData, progress, imageUrl }) && (

This data insight will be created by:

@@ -774,13 +682,6 @@ export function CreateDataInsightModal(props: { progress={progress.setTopicTags} /> - -
)} @@ -1025,25 +926,6 @@ function TopicTagsFeedback({ ) } -function SendMessageToSlackFeedback({ - shouldSend, - progress, -}: { - shouldSend: boolean - progress: Progress -}) { - if (!shouldSend) return null - return ( -

- - The newly created data insight will be shared in the - #data-insight-pitches channel for review. - - -

- ) -} - function FeedbackTag({ progress }: { progress: Progress }) { if (progress.status === "idle") return null diff --git a/adminSiteClient/admin.scss b/adminSiteClient/admin.scss index b022b06612..779bc438f1 100644 --- a/adminSiteClient/admin.scss +++ b/adminSiteClient/admin.scss @@ -1379,10 +1379,6 @@ main:not(.ChartEditorPage):not(.GdocsEditPage) { } } - .slackNote { - margin-top: 12px; - } - .image-preview { margin: 24px 0;