-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1834 from cardstack/cs-7526-update-the-isolated-c…
…ard-rendering-for-stack-items-in-an Add last known good rendering of card in error state to stack item
- Loading branch information
Showing
16 changed files
with
576 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
packages/host/app/components/operator-mode/card-error-detail.gts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { fn } from '@ember/helper'; | ||
import { on } from '@ember/modifier'; | ||
import { service } from '@ember/service'; | ||
|
||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
import TriangleAlert from '@cardstack/boxel-icons/triangle-alert'; | ||
|
||
import { dropTask } from 'ember-concurrency'; | ||
import perform from 'ember-concurrency/helpers/perform'; | ||
|
||
import { Accordion, Button } from '@cardstack/boxel-ui/components'; | ||
|
||
import SwitchSubmodeCommand from '../../commands/switch-submode'; | ||
import { type CardError } from '../../resources/card-resource'; | ||
|
||
import type CommandService from '../../services/command-service'; | ||
|
||
interface Signature { | ||
Args: { | ||
error: CardError['errors'][0]; | ||
title?: string; | ||
}; | ||
} | ||
|
||
export default class CardErrorDetail extends Component<Signature> { | ||
@tracked private showErrorDetail = false; | ||
@service private declare commandService: CommandService; | ||
|
||
private toggleDetail = () => (this.showErrorDetail = !this.showErrorDetail); | ||
|
||
private viewInCodeMode = dropTask(async () => { | ||
let switchSubmodeCommand = new SwitchSubmodeCommand( | ||
this.commandService.commandContext, | ||
); | ||
const InputType = await switchSubmodeCommand.getInputType(); | ||
let input = new InputType({ | ||
submode: 'code', | ||
codePath: `${this.args.error.id}.json`, | ||
}); | ||
await switchSubmodeCommand.execute(input); | ||
}); | ||
|
||
<template> | ||
<Accordion as |A|> | ||
<A.Item | ||
data-test-error-detail-toggle | ||
@onClick={{fn this.toggleDetail 'schema'}} | ||
@isOpen={{this.showErrorDetail}} | ||
> | ||
<:title> | ||
<TriangleAlert /> | ||
An error was encountered on this card: | ||
<span class='error-detail' data-test-error-title>{{@title}}</span> | ||
</:title> | ||
<:content> | ||
<div class='actions'> | ||
<Button | ||
data-test-view-in-code-mode-button | ||
@kind='primary' | ||
{{on 'click' (perform this.viewInCodeMode)}} | ||
>View in Code Mode</Button> | ||
</div> | ||
<div class='detail'> | ||
<div class='detail-item'> | ||
<div class='detail-title'>Details:</div> | ||
<div | ||
class='detail-contents' | ||
data-test-error-detail | ||
>{{@error.message}}</div> | ||
</div> | ||
{{#if @error.meta.stack}} | ||
<div class='detail-item'> | ||
<div class='detail-title'>Stack trace:</div> | ||
<pre | ||
data-test-error-stack | ||
> | ||
{{@error.meta.stack}} | ||
</pre> | ||
</div> | ||
{{/if}} | ||
</div> | ||
</:content> | ||
</A.Item> | ||
</Accordion> | ||
|
||
<style scoped> | ||
.actions { | ||
display: flex; | ||
justify-content: center; | ||
margin-top: var(--boxel-sp-lg); | ||
} | ||
.detail { | ||
padding: var(--boxel-sp); | ||
} | ||
.detail-item { | ||
margin-top: var(--boxel-sp); | ||
} | ||
.detail-title { | ||
font: 600 var(--boxel-font); | ||
} | ||
.detail-contents { | ||
font: var(--boxel-font); | ||
} | ||
pre { | ||
margin-top: 0; | ||
white-space: pre-wrap; | ||
word-break: break-all; | ||
} | ||
</style> | ||
</template> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { TemplateOnlyComponent } from '@ember/component/template-only'; | ||
|
||
import FileAlert from '@cardstack/boxel-icons/file-alert'; | ||
|
||
const CardErrorComponent: TemplateOnlyComponent = <template> | ||
<div class='card-error'> | ||
<FileAlert class='icon' /> | ||
<div class='message'>This card contains an error.</div> | ||
</div> | ||
|
||
<style scoped> | ||
.icon { | ||
height: 100px; | ||
width: 100px; | ||
} | ||
.card-error { | ||
display: flex; | ||
height: 100%; | ||
align-content: center; | ||
justify-content: center; | ||
flex-wrap: wrap; | ||
} | ||
.message { | ||
width: 100%; | ||
text-align: center; | ||
font: 600 var(--boxel-font); | ||
} | ||
</style> | ||
</template>; | ||
|
||
export default CardErrorComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.