From 62ba7b9214b02eee865515189ed90f49a6a85dd3 Mon Sep 17 00:00:00 2001 From: Matic Jurglic Date: Mon, 20 Jan 2025 09:31:35 +0100 Subject: [PATCH] Cleanup --- .../SprintTask/cocojambo.txt | 0 .../operator-mode/interact-submode.gts | 27 ++++++++++++------- .../components/operator-mode/stack-item.gts | 4 +-- 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 packages/experiments-realm/SprintTask/cocojambo.txt diff --git a/packages/experiments-realm/SprintTask/cocojambo.txt b/packages/experiments-realm/SprintTask/cocojambo.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/host/app/components/operator-mode/interact-submode.gts b/packages/host/app/components/operator-mode/interact-submode.gts index 237a15f6ba..4f7b605bcf 100644 --- a/packages/host/app/components/operator-mode/interact-submode.gts +++ b/packages/host/app/components/operator-mode/interact-submode.gts @@ -304,18 +304,25 @@ export default class InteractSubmode extends Component { title: loadedCard.title, }; } catch (error: any) { - // Case when card is in error state - let cardTitle = JSON.parse(error.responseText)?.errors?.[0]?.meta - ?.cardTitle; + // If we get a 500 Internal Server Error, it is probable that the card is in error state. + // In this case a cardTitle should be present - we use this to display the card title in the delete modal. + if (error.status === 500) { + let cardTitle = JSON.parse(error.responseText)?.errors?.[0]?.meta + ?.cardTitle; + + if (!cardTitle) { + throw new Error( + `Could not get card title for ${card} - the server returned a 500 but perhaps for other reason than the card being in error state`, + ); + } - if (!cardTitle) { - throw new Error(`Could not get card title for ${card}`); + cardToDelete = { + id: cardUrl.href, + title: cardTitle, + }; + } else { + throw error; } - - cardToDelete = { - id: cardUrl.href, - title: cardTitle, - }; } } diff --git a/packages/host/app/components/operator-mode/stack-item.gts b/packages/host/app/components/operator-mode/stack-item.gts index 277f8282f3..d52ef4caed 100644 --- a/packages/host/app/components/operator-mode/stack-item.gts +++ b/packages/host/app/components/operator-mode/stack-item.gts @@ -282,7 +282,7 @@ export default class OperatorModeStackItem extends Component { return cardTypeDisplayName(this.card); } - private get moreOptionsMenuItemsForCardInError() { + private get moreOptionsMenuItemsForErrorCard() { if (this.isBuried) { return undefined; } @@ -630,7 +630,7 @@ export default class OperatorModeStackItem extends Component { @cardTypeDisplayName={{this.cardErrorTitle}} @cardTypeIcon={{ExclamationCircle}} @isTopCard={{this.isTopCard}} - @moreOptionsMenuItems={{this.moreOptionsMenuItemsForCardInError}} + @moreOptionsMenuItems={{this.moreOptionsMenuItemsForErrorCard}} @onClose={{unless this.isBuried (perform this.closeItem)}} class='stack-item-header stack-item-header-error' style={{cssVar