Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenwerk committed Jan 20, 2025
1 parent be60654 commit 62ba7b9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Empty file.
27 changes: 17 additions & 10 deletions packages/host/app/components/operator-mode/interact-submode.gts
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,25 @@ export default class InteractSubmode extends Component<Signature> {
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,
};
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/host/app/components/operator-mode/stack-item.gts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export default class OperatorModeStackItem extends Component<Signature> {
return cardTypeDisplayName(this.card);
}

private get moreOptionsMenuItemsForCardInError() {
private get moreOptionsMenuItemsForErrorCard() {
if (this.isBuried) {
return undefined;
}
Expand Down Expand Up @@ -630,7 +630,7 @@ export default class OperatorModeStackItem extends Component<Signature> {
@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
Expand Down

0 comments on commit 62ba7b9

Please sign in to comment.