-
Notifications
You must be signed in to change notification settings - Fork 9
new arg to filter by subclass ref #2105
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
Changes from 8 commits
1f202c3
ce4ed57
9f0fe1c
b402924
f69662b
258dca8
f0c74bb
9a66cd6
bfb4749
499f680
02e8408
9c8e743
9b39afa
4e01ccc
00ecb24
0ce4775
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ import { | |
identifyCard, | ||
CardContextName, | ||
RealmURLContextName, | ||
type ResolvedCodeRef, | ||
getNarrowestType, | ||
Loader, | ||
} from '@cardstack/runtime-common'; | ||
import { AddButton, IconButton } from '@cardstack/boxel-ui/components'; | ||
import { IconMinusCircle } from '@cardstack/boxel-ui/icons'; | ||
|
@@ -33,6 +36,7 @@ interface Signature { | |
Args: { | ||
model: Box<CardDef | null>; | ||
field: Field<typeof CardDef>; | ||
subclassType?: ResolvedCodeRef; | ||
}; | ||
} | ||
|
||
|
@@ -143,6 +147,7 @@ export class LinksToEditor extends GlimmerComponent<Signature> { | |
|
||
private chooseCard = restartableTask(async () => { | ||
let type = identifyCard(this.args.field.card) ?? baseCardRef; | ||
type = await getNarrowestType(this.args.subclassType, type, myLoader()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, you can only call this function if a subclassType arg was provided There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually do you even need to check if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we do. We need to check if type is base CardDef as a terminating condition to "stop checking". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @burieberry maybe we can talk thru this after standup. Probably some small misunderstanding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @burieberry I have made the change that you have suggested |
||
let chosenCard: CardDef | undefined = await chooseCard( | ||
{ filter: { type } }, | ||
{ | ||
|
@@ -160,3 +165,14 @@ export class LinksToEditor extends GlimmerComponent<Signature> { | |
} | ||
}); | ||
} | ||
|
||
function myLoader(): Loader { | ||
// we know this code is always loaded by an instance of our Loader, which sets | ||
// import.meta.loader. | ||
|
||
// When type-checking realm-server, tsc sees this file and thinks | ||
// it will be transpiled to CommonJS and so it complains about this line. But | ||
// this file is always loaded through our loader and always has access to import.meta. | ||
// @ts-ignore | ||
return (import.meta as any).loader; | ||
} |
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.
Perhaps
typeConstraint
orallowedClass
would be a better name?