From 31e7b77fe7614a3fef3f3453b3e226d916405158 Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Fri, 27 Jan 2023 18:04:00 -0800 Subject: [PATCH 1/2] Improved docs and fixed switch fallthrough in example --- .../apis/slack/actions/post-message.mdx | 17 ++++++++++++++++- examples/send-to-slack/src/index.tsx | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/docs/integrations/apis/slack/actions/post-message.mdx b/apps/docs/integrations/apis/slack/actions/post-message.mdx index e2689e35f05..3310f1fbb4b 100644 --- a/apps/docs/integrations/apis/slack/actions/post-message.mdx +++ b/apps/docs/integrations/apis/slack/actions/post-message.mdx @@ -127,9 +127,12 @@ In this examples there are two workflows: 1. Messages your team every minute (!) and asks them how they're doing. 2. Receives the interaction from users. It adds reactions when the buttons are pressed and posts a message when a user selects from the dropdown menu. +Please note, that to use `jsx-slack` you will need to add the `jsxImportSource` pragma to the top of your file. This is because `jsx-slack` is not a React library, but it uses the same syntax as React. Also, you might need to add `"jsx": "react-jsx"` to your `compilerOption` in `tsconfig.json`. The workflow file needs to be a `.jsx` or `.tsx` file (like when you use React). + -```typescript Blocks with interactivity +```typescript workflow.tsx +/** @jsxImportSource jsx-slack */ import { slack } from "@trigger.dev/integrations"; import JSXSlack, { Actions, @@ -207,6 +210,7 @@ new Trigger({ channelId: event.channel.id, }); } + break; } case "status-help": { //the user needs help so add an 🆘 emoji as a reaction @@ -217,6 +221,7 @@ new Trigger({ channelId: event.channel.id, }); } + break; } case "rating": { if (action.type != "static_select") { @@ -244,4 +249,14 @@ new Trigger({ }).listen(); ``` +```json tsconfig.json +{ + //other options + "compilerOptions": { + "jsx": "react-jsx" + //other options + } +} +``` + diff --git a/examples/send-to-slack/src/index.tsx b/examples/send-to-slack/src/index.tsx index 08dbcb62b7d..7953c4031dc 100644 --- a/examples/send-to-slack/src/index.tsx +++ b/examples/send-to-slack/src/index.tsx @@ -221,6 +221,7 @@ new Trigger({ channelId: event.channel.id, }); } + break; } case "status-help": { //the user needs help so add an 🆘 emoji as a reaction @@ -231,6 +232,7 @@ new Trigger({ channelId: event.channel.id, }); } + break; } case "rating": { if (action.type != "static_select") { From d8ef6becec4729cdc050aee065aa830b2a4352ca Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Fri, 27 Jan 2023 18:04:08 -0800 Subject: [PATCH 2/2] Guard against null and undefined of lastRun --- .../routes/__app/orgs/$organizationSlug/__org/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/webapp/app/routes/__app/orgs/$organizationSlug/__org/index.tsx b/apps/webapp/app/routes/__app/orgs/$organizationSlug/__org/index.tsx index c051854f187..f73804499a9 100644 --- a/apps/webapp/app/routes/__app/orgs/$organizationSlug/__org/index.tsx +++ b/apps/webapp/app/routes/__app/orgs/$organizationSlug/__org/index.tsx @@ -184,15 +184,18 @@ function WorkflowList({ } function lastRunDescription(lastRun: WorkflowListItem["lastRun"]) { - if (lastRun === undefined) { + if (lastRun === null || lastRun === undefined) { return "Never"; } + if (lastRun.status === "SUCCESS") { if (lastRun.finishedAt) { return formatDateTime(lastRun.finishedAt); + } else { + return "Unknown"; } - throw new Error("lastRun.finishedAt is undefined"); } + return runStatusLabel(lastRun.status); }