From 58d7e2eb3ddeb3895f150dc4eb9910308a9013cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20L=C3=BCdeke?= Date: Mon, 24 Mar 2025 10:54:28 +0100 Subject: [PATCH] Add support for handling failing checks without error patterns in account summary --- .../blocks/accountSummaryBlock.script.ts | 13 +++++ src/slackbot/blocks/accountSummaryBlock.ts | 50 +++++++++++-------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/slackbot/blocks/accountSummaryBlock.script.ts b/src/slackbot/blocks/accountSummaryBlock.script.ts index aecb263..1a785c5 100755 --- a/src/slackbot/blocks/accountSummaryBlock.script.ts +++ b/src/slackbot/blocks/accountSummaryBlock.script.ts @@ -45,6 +45,19 @@ async function main() { }, ], }), + // Failing checks without error patterns + createAccountSummaryBlock({ + accountName: "FailingNoErrors", + passingChecks: 42, + degradedChecks: 3, + failingChecks: 5, + hasIssues: true, + issuesSummary: + "New degrading or failing checks detected in the last 24h.", + failingChecksGoals: "Some checks have failed in the last 24h.", + failingCheckIds: ["126", "127", "128", "129", "130"], + errorPatterns: [], + }), // Some failing createAccountSummaryBlock({ accountName: "Failing", diff --git a/src/slackbot/blocks/accountSummaryBlock.ts b/src/slackbot/blocks/accountSummaryBlock.ts index b91feb2..1410016 100644 --- a/src/slackbot/blocks/accountSummaryBlock.ts +++ b/src/slackbot/blocks/accountSummaryBlock.ts @@ -123,31 +123,39 @@ export function createAccountSummaryBlock({ text: `:white_check_mark: *PASSING*: ${passingChecks} :warning: *DEGRADED*: ${degradedChecks} :x: *FAILING*: ${failingChecks}`, }, }, - ...(failingCheckIds.length > 0 + ...(failingCheckIds.length > 0 || errorPatterns.length > 0 ? [ { type: "actions", elements: [ - { - type: "button", - text: { - type: "plain_text", - emoji: true, - text: "List Failing Checks", - }, - action_id: LIST_FAILING_CHECKS_ACTION_ID, - value: failingCheckIds.join(","), - }, - { - type: "button", - text: { - type: "plain_text", - emoji: true, - text: "List Error Patterns", - }, - action_id: LIST_ERROR_PATTERNS_ACTION_ID, - value: errorPatterns.map((ep) => ep.id).join(","), - }, + ...(failingCheckIds.length > 0 + ? [ + { + type: "button", + text: { + type: "plain_text", + emoji: true, + text: "List Failing Checks", + }, + action_id: LIST_FAILING_CHECKS_ACTION_ID, + value: failingCheckIds.join(","), + }, + ] + : []), + ...(errorPatterns.length > 0 + ? [ + { + type: "button", + text: { + type: "plain_text", + emoji: true, + text: "List Error Patterns", + }, + action_id: LIST_ERROR_PATTERNS_ACTION_ID, + value: errorPatterns.map((ep) => ep.id).join(","), + }, + ] + : []), ], }, ]