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

"Create screen" component context option #14255

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deanhannigan
Copy link
Contributor

@deanhannigan deanhannigan commented Jul 26, 2024

Description

A Create screen option has been added to the component context menu in the builder. Selecting the option will:

  • Generate a brand new screen with the Basic role
  • Clone the selected component and place it in the the screen.
  • The default screen path will be /new-screen. If you create multiple screens in a row a suffix will be appended to avoid collision e.g. /new-screen-2

Addresses

  • Fix - component context options were being cached between screens. When pasting or cloning into new screens, it wasn't immediately clear what elements had become broken due to broken context references until full page refresh. The component options will now clear when the active screen is changed.
  • Minor refactoring of the screen store to centralise some screen autogeneration functionality.

Screenshots

Screenshot 2024-07-26 at 14 58 07

Launchcontrol

Create a new screen from a selected component

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.

Nice one Dean! Happy to get this in if we remove the context stuff for now. Also one wee change suggested which should remove a bunch of code as we already have a utility for generating sequential names 👌

candidateUrl = makeCandidateUrl(screen, ++suffix)
let candidateUrl = screenStore.makeCandidateUrl(screen, suffix)
while (screenStore.hasExistingUrl(candidateUrl, screenAccessRole)) {
candidateUrl = screenStore.makeCandidateUrl(screen, ++suffix)
Copy link
Member

Choose a reason for hiding this comment

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

Rather than all this logic (some of which I know was pre-existing), we should use our getSequentialName utility which is designed to do exactly this!

globalContext.actions.clearComponentContext()
}

$: purgeGlobalComponentContext($screenStore?.activeScreen?._id)
Copy link
Member

Choose a reason for hiding this comment

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

I understand the purpose of this, but I think we should come up with a cleaner way of handling it than trying to whitelist all properties that we want to persist between screen changes. I have a few ideas in mind... For now I think it would be better to take this out of this PR as it's a separate issue, and we can tackle it elsewhere.

@github-actions github-actions bot removed the stale label Sep 19, 2024
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