Skip to content
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

Screen store TS conversion #15313

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

deanhannigan
Copy link
Contributor

Description

Store and JSDoc updates required to convert the Screen builder store to TypeScript.

Launchcontrol

Convert the Screen builder store into TypeScript.

Copy link

qa-wolf bot commented Jan 6, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@github-actions github-actions bot added the size/l label Jan 6, 2025
Copy link
Member

@aptkingston aptkingston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few initial comments but looks good overall!

export interface ComponentState {
components: Record<string, ComponentDefinition>
customComponents: string[]
selectedComponentId?: string | null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use either an optional property or type it as string | null shouldn't we? Rather than both. I've been opting to go for optional properties - the only change being we'll need to ensure we always clear these by setting them to undefined rather than null.

@@ -440,6 +442,11 @@ export class ComponentStore extends BudiStore<ComponentState> {
* @returns
*/
createInstance(componentName: string, presetProps: any, parent: any) {
const screen = get(selectedScreen)
if (!screen || !selectedScreen) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: the !selectedScreen part is redundant here.

interface ScreenState {
screens: Screen[]
selectedScreenId?: string
selected?: Screen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see any external usages of this selected property other than in the afterAction of the history store constructor, so it'll always be null... I'm assuming this is maybe a leftover and we can refactor it out? I think in after action we should be reading the selectedScreen derived store and using that to select a component instead of this selected property, which we can remove.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants