Skip to content

Commit 55dee17

Browse files
committed
Merge branch 'main' into code-block-refactor
2 parents 1715ed4 + 9839bc2 commit 55dee17

25 files changed

+1454
-1072
lines changed

Diff for: packages/host/app/components/card-catalog/modal.gts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343

4444
import type { CardDef } from 'https://cardstack.com/base/card-api';
4545

46-
import { getSearch, type SearchQuery } from '../../resources/search';
46+
import { getSearch, type SearchResource } from '../../resources/search';
4747

4848
import {
4949
suggestCardChooserTitle,
@@ -71,7 +71,7 @@ interface Signature {
7171
}
7272

7373
type Request = {
74-
search: SearchQuery;
74+
search: SearchResource;
7575
deferred: Deferred<CardDef | undefined>;
7676
opts?: {
7777
offerToCreate?: {

Diff for: packages/host/app/components/operator-mode/code-submode.gts

+45-22
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
identifyCard,
3232
isFieldDef,
3333
isCardDocumentString,
34+
isPrimitive,
3435
hasExecutableExtension,
3536
RealmPaths,
3637
isResolvedCodeRef,
@@ -82,7 +83,7 @@ import CardURLBar from './card-url-bar';
8283
import CodeEditor from './code-editor';
8384
import InnerContainer from './code-submode/inner-container';
8485
import CodeSubmodeLeftPanelToggle from './code-submode/left-panel-toggle';
85-
import PlaygroundPanel from './code-submode/playground-panel';
86+
import PlaygroundPanel from './code-submode/playground/playground-panel';
8687
import SchemaEditor, { SchemaEditorTitle } from './code-submode/schema-editor';
8788
import SpecPreview from './code-submode/spec-preview';
8889
import CreateFileModal, { type FileType } from './create-file-modal';
@@ -480,12 +481,8 @@ export default class CodeSubmode extends Component<Signature> {
480481
}
481482

482483
private get selectedCodeRef(): ResolvedCodeRef | undefined {
483-
let baseDefType = this.selectedCardOrField?.cardOrField;
484-
let codeRef = identifyCard(baseDefType);
485-
if (!isResolvedCodeRef(codeRef)) {
486-
return undefined;
487-
}
488-
return codeRef;
484+
let codeRef = identifyCard(this.selectedCardOrField?.cardOrField);
485+
return isResolvedCodeRef(codeRef) ? codeRef : undefined;
489486
}
490487

491488
get showSpecPreview() {
@@ -993,32 +990,54 @@ export default class CodeSubmode extends Component<Signature> {
993990
</:content>
994991
</A.Item>
995992
</SchemaEditor>
996-
{{#if this.selectedCodeRef}}
997-
<A.Item
998-
class='accordion-item'
999-
@contentClass='accordion-item-content'
1000-
@onClick={{fn this.selectAccordionItem 'playground'}}
1001-
@isOpen={{eq this.selectedAccordionItem 'playground'}}
1002-
data-test-accordion-item='playground'
1003-
>
1004-
<:title>Playground</:title>
1005-
<:content>
1006-
{{#if (eq this.selectedAccordionItem 'playground')}}
993+
<A.Item
994+
class='accordion-item'
995+
@contentClass='accordion-item-content'
996+
@onClick={{fn this.selectAccordionItem 'playground'}}
997+
@isOpen={{eq this.selectedAccordionItem 'playground'}}
998+
data-test-accordion-item='playground'
999+
>
1000+
<:title>Playground</:title>
1001+
<:content>
1002+
{{#if (eq this.selectedAccordionItem 'playground')}}
1003+
{{#if
1004+
(isPrimitive this.selectedCardOrField.cardOrField)
1005+
}}
1006+
<p
1007+
class='file-incompatible-message'
1008+
data-test-incompatible-primitives
1009+
>
1010+
<span>Playground is not currently supported for
1011+
primitive fields.</span>
1012+
</p>
1013+
{{else if this.selectedCodeRef}}
10071014
<PlaygroundPanel
10081015
@codeRef={{this.selectedCodeRef}}
10091016
@isUpdating={{this.moduleContentsResource.isLoading}}
1010-
@isLoadingNewModule={{this.moduleContentsResource.isLoadingNewModule}}
10111017
@isFieldDef={{isFieldDef
10121018
this.selectedCardOrField.cardOrField
10131019
}}
10141020
/>
1021+
{{else}}
1022+
<p
1023+
class='file-incompatible-message'
1024+
data-test-incompatible-nonexports
1025+
>
1026+
<span>Playground is not currently supported for
1027+
card or field definitions that are not
1028+
exported.</span>
1029+
</p>
10151030
{{/if}}
1016-
</:content>
1017-
</A.Item>
1018-
{{/if}}
1031+
{{/if}}
1032+
</:content>
1033+
</A.Item>
10191034
{{#if this.showSpecPreview}}
10201035
<SpecPreview
10211036
@selectedDeclaration={{this.selectedDeclaration}}
1037+
@onPlaygroundAccordionToggle={{fn
1038+
this.selectAccordionItem
1039+
'playground'
1040+
}}
10221041
as |SpecPreviewTitle SpecPreviewContent|
10231042
>
10241043
<A.Item
@@ -1207,6 +1226,10 @@ export default class CodeSubmode extends Component<Signature> {
12071226
color: var(--boxel-450);
12081227
font-weight: 500;
12091228
padding: var(--boxel-sp-xl);
1229+
margin-block: 0;
1230+
}
1231+
.file-incompatible-message > span {
1232+
max-width: 400px;
12101233
}
12111234
.empty-container {
12121235
background-color: var(--boxel-light-100);

0 commit comments

Comments
 (0)