Get file extension and realm info#656
Conversation
|
After pairing yesterday, I was thinking deeper about this adoption chain resource and I have a few thoughts.
|
Screen.Recording.2023-09-20.at.3.15.08.PM.movHere is an updated screeen recording. Its a mock out of the new design. It makes a lot of better sense now. The resource I created is motivated by this design. As you can see there is a selection highlight for the export that is selected. I will incorporate a fuller design in another pr |
|
Ok suggested new names
|
|
belurgh fixing test |
| {{else}} | ||
| {{! Module case when visting, eg author.gts }} | ||
| <h3>In This File</h3> | ||
| {{#each this.elementsInFile as |el|}} |
There was a problem hiding this comment.
What is the difference between: elements, exports, definitions?
* register a redirect handler that returns redirected response * revert original change * fix * fix * fix * fix lint * fix * reposition * clean up & organise useage * fix file response.url not returning * fix url parts using pathname * arg to pass in realm * make realm url explicit to guard from the wrong use of handle
| get adoptionChainTypes() { | ||
| return this.args.adoptionChain?.types; | ||
| get isCardInstance() { | ||
| return this.args.readyFile.url.endsWith('.json'); |
There was a problem hiding this comment.
https://linear.app/cardstack/issue/CS-6053/stop-using-endswithjson-use-iscarddocument figured this is in a few places
jurgenwerk
left a comment
There was a problem hiding this comment.
Overall it looks good to me, comments for minor data passing simplifications.
| <Label class='realm-name' data-test-definition-realm-name>in | ||
| {{this.realmName}}</Label> | ||
| </div> | ||
| {{#if @realmInfo}} |
There was a problem hiding this comment.
Consider using the RealmInfoProvider component (it was merged recently) so you don't have to pass the realm info into this component and you can get rid of the realmIcon getter
| return this.load.isRunning; | ||
| } | ||
|
|
||
| get selectedElement() { |
There was a problem hiding this comment.
Would be great to paste this comment into a code comment here so it's clear what elements are https://github.com/cardstack/boxel/pull/656/files#r1332754268
|
This has a big renaming of |
| } | ||
|
|
||
| // forwards the card type resource (doesn't care about the card type resource) | ||
| export class AdoptionChainManager extends Resource<AdoptionChainManagerArgs> { |
There was a problem hiding this comment.
I'm just trying to understand what this resource is actually doing--Manager is such a overloaded term. it's doesn't really help me to know what this thing does. Reading thru this i think what this resource is doing is trying to load all the cards specifically from a module? Maybe CardsFromModuleResource would be a better name for this? the isSelected is super confusing--that feels like it should be state of a component, not this resource. It's not clear how isSelected contributes to this resource other then adding unrelated state
There was a problem hiding this comment.
Hmmmm i will say that this resource is in charge of managing the selection of elements (elements being exported cards, unexported cards, exported function, exported class). What I intended for this resource is to be consumed by both the detailPanel & the schemeEditor. Perhaps, at one point it will be consumed by monaco to get the location of the selection.
Would it be better to kill the resource and put things in code mode? Or Rename it?
There was a problem hiding this comment.
that's super confusing to me--why do you need a resource to manage selection? that seems to be something that fits more naturally in a component not a resource. The component should use the resource to understand what all cards exist, and the selection state should live in the component since that is the class that contains the template that consumes the action for selection
There was a problem hiding this comment.
the fact that you have an action on your resource is a tell that something is not right. the only way to change the state from the outside of the resource should be to pass it in as a thunk that triggers the resource to recompute when state in the thunk changes--not as an action
There was a problem hiding this comment.
Actually the existence of cards wud be handled by the module resource. And i think it will continue that way. Ok in that case, i will remove this resource and put all logic in the root code mode component
There was a problem hiding this comment.
Ive moved the select logic in code. And I also moved the array of cardTypes into code mode but still in a resource pattern. I think this is what we want tho. If it wasn't a resource, we would be recreating cardType everytime. So like you said we still need to load the cards. But I do agree that having it as adoption-chain-manager was confusing because it was not clear what it was doing
| @service declare cardService: CardService; | ||
| declare loader: Loader; | ||
| typeCache: Map<string, Type> = new Map(); | ||
| moduleMetaCache: Map<string, { extension: string; realmInfo: RealmInfo }> = |
There was a problem hiding this comment.
perhaps the cache would actually do more if it lived in module scope--then all resources could share it. I would think this kind of information would change very rarely if ever. so probably a cache that could be shared by all resource instances would be more beneficial
There was a problem hiding this comment.
Actually I think the realmInfoService can be used for this
This PR handles getting of file extension AND getting of realm url to display at an arbitrary depth of the file types
Screen.Recording.2023-09-19.at.7.48.51.PM.mov
Now u can see that
draftsandbaserealm exist side by side because its loaded from the typeI actually wanted to move stuff into the adoption chain RESOURCE. But there is a reactivity thing that when I call .type it becomes an infinite loop.