-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can autogenerate spec or containedExamples from playground #2322
base: main
Are you sure you want to change the base?
Conversation
Host Test Results 1 files ±0 1 suites ±0 27m 9s ⏱️ +55s Results for commit 655392e. ± Comparison against base commit 73e7266. This pull request removes 2 and adds 2 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
}); | ||
|
||
private createNewField = task(async (specCard: Spec) => { | ||
private createNewField = restartableTask(async (specCard: Spec) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is now a restartableTask
because fieldInstances
getter is called twice and this task starts running if there are no instances
{{else if this.canGenerateFieldSpec}} | ||
<div {{runFn this.createNew}} /> | ||
{{/if}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a little awkward. using a modifier to kickstart createNew
if conditions have been met
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be conditionally initiated in the constructor instead?
private get specQuery(): Query { | ||
return { | ||
filter: { | ||
on: specRef, | ||
eq: { ref: this.args.codeRef }, | ||
}, | ||
}; | ||
} | ||
|
||
private searchFieldSpec = getSearch( | ||
this, | ||
() => this.specQuery, | ||
() => this.realmServer.availableRealmURLs, | ||
{ isLive: true, isAutoSaved: true }, | ||
); | ||
|
||
private get canGenerateFieldSpec() { | ||
if ( | ||
!this.args.isFieldDef || | ||
!this.canWriteRealm || | ||
this.createNewCard.isRunning | ||
) { | ||
return false; | ||
} | ||
return ( | ||
!this.searchFieldSpec.isLoading && | ||
this.searchFieldSpec.instances?.length === 0 | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this checks if there's a preexisting spec as well as other conditions for running createNew to autogenerate a new spec
This is for fields only:
containedExamples
, then on opening playground panel, autogenerate a field instance and add tocontainedExamples
.containedExamples
.Review needed: See my comments below in using a search resource and a modifier to check if spec exists and to auto-generate it if it doesn't.