@@ -31,6 +31,7 @@ import {
31
31
identifyCard ,
32
32
isFieldDef ,
33
33
isCardDocumentString ,
34
+ isPrimitive ,
34
35
hasExecutableExtension ,
35
36
RealmPaths ,
36
37
isResolvedCodeRef ,
@@ -82,7 +83,7 @@ import CardURLBar from './card-url-bar';
82
83
import CodeEditor from ' ./code-editor' ;
83
84
import InnerContainer from ' ./code-submode/inner-container' ;
84
85
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' ;
86
87
import SchemaEditor , { SchemaEditorTitle } from ' ./code-submode/schema-editor' ;
87
88
import SpecPreview from ' ./code-submode/spec-preview' ;
88
89
import CreateFileModal , { type FileType } from ' ./create-file-modal' ;
@@ -480,12 +481,8 @@ export default class CodeSubmode extends Component<Signature> {
480
481
}
481
482
482
483
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 ;
489
486
}
490
487
491
488
get showSpecPreview() {
@@ -993,32 +990,54 @@ export default class CodeSubmode extends Component<Signature> {
993
990
</: content >
994
991
</A.Item >
995
992
</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 }}
1007
1014
<PlaygroundPanel
1008
1015
@ codeRef ={{this .selectedCodeRef }}
1009
1016
@ isUpdating ={{this .moduleContentsResource.isLoading }}
1010
- @ isLoadingNewModule ={{this .moduleContentsResource.isLoadingNewModule }}
1011
1017
@ isFieldDef ={{isFieldDef
1012
1018
this . selectedCardOrField.cardOrField
1013
1019
}}
1014
1020
/>
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 >
1015
1030
{{/if }}
1016
- </ : content >
1017
- </A.Item >
1018
- {{/ if }}
1031
+ {{/ if }}
1032
+ </: content >
1033
+ </ A.Item >
1019
1034
{{#if this . showSpecPreview }}
1020
1035
<SpecPreview
1021
1036
@ selectedDeclaration ={{this .selectedDeclaration }}
1037
+ @ onPlaygroundAccordionToggle ={{fn
1038
+ this . selectAccordionItem
1039
+ ' playground'
1040
+ }}
1022
1041
as | SpecPreviewTitle SpecPreviewContent |
1023
1042
>
1024
1043
<A.Item
@@ -1207,6 +1226,10 @@ export default class CodeSubmode extends Component<Signature> {
1207
1226
color : var (--boxel-450 );
1208
1227
font-weight : 500 ;
1209
1228
padding : var (--boxel-sp-xl );
1229
+ margin-block : 0 ;
1230
+ }
1231
+ .file-incompatible-message > span {
1232
+ max-width : 400px ;
1210
1233
}
1211
1234
.empty-container {
1212
1235
background-color : var (--boxel-light-100 );
0 commit comments