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

Input/controls constraints for viewers #4713

Merged
merged 9 commits into from
Jan 10, 2024
Merged

Conversation

ruggi
Copy link
Contributor

@ruggi ruggi commented Jan 9, 2024

Fixes #4712

Problem:

  • inspector inputs appear editable for viewers - even if they are really not doing anything
  • drag/resize/etc. controls are visible for viewers on selected elements, which should not be

Fix:

  • Hide element controls on the canvas for selected elements for viewers
  • Disable the various inputs (and tangential actionable components and interactions) for viewers
    • number inputs
    • string inputs
    • draggable scrubbers
    • color pickers
    • popup lists
    • increment buttons
    • color swatches
  • added the useIsMyProject hook which returns whether the user is an owner of the current project, regardless of the baton

Copy link
Contributor

github-actions bot commented Jan 9, 2024

Try me

Copy link

relativeci bot commented Jan 9, 2024

Job #9811: Bundle Size — 62.2MiB (~+0.01%).

ac5685d(current) vs df0030c master#9798(baseline)

Warning

Bundle contains 66 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
Job #9811
     Baseline
Job #9798
Regression  Initial JS 45.41MiB(~+0.01%) 45.4MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 21.52% 19.86%
No change  Chunks 26 26
No change  Assets 30 30
No change  Modules 4362 4362
No change  Duplicate Modules 471 471
No change  Duplicate Code 30.75% 30.75%
No change  Packages 462 462
No change  Duplicate Packages 65 65
Bundle size by type  Change 1 change Regression 1 regression
                 Current
Job #9811
     Baseline
Job #9798
Regression  JS 62.19MiB (~+0.01%) 62.19MiB
Not changed  HTML 11.54KiB 11.54KiB

View job #9811 reportView feat/disable-inspector-viewer branch activity

Copy link
Contributor

github-actions bot commented Jan 9, 2024

Performance test results:
(Chart1)
(Chart2)

ruggi added 8 commits January 9, 2024 21:29
# Conflicts:
#	editor/src/components/canvas/controls/new-canvas-controls.tsx
#	editor/src/core/performance/performance-regression-tests.spec.tsx
@@ -686,6 +686,9 @@ export function handleKeyDown(
)
},
[INSERT_DIV_SHORTCUT]: () => {
if (!allowedToEdit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have some other INSERT_ shortcuts that might need this check then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed (not just insert_ but a lot more), but since changes cannot propagate, I added this here like we did for the text mode so the cursor does not change to a misleading crosshair, it's not meant to safeguard from the insertion per-se, as it's implicitly prevented by the collaboration

@@ -717,3 +717,11 @@ export function useAllowedToEditProject(): boolean {
'useAllowedToEditProject',
)
}

export function useIsMyProject(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this clash with the baton passing work? I'm thinking that a lot of the places using this check should be instead using useAllowedToEditProject?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it clashes, but it definitely makes it more granular. My take would be to wait that there are no baton-opened PRs to revisit and update

Copy link
Contributor

@Rheeseyb Rheeseyb left a comment

Choose a reason for hiding this comment

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

I'm approving because the code and feature looks good, but please check the question around whether useIsMyProject is suitable for all the cases here before merging

@ruggi ruggi merged commit 4dc398d into master Jan 10, 2024
20 checks passed
@ruggi ruggi deleted the feat/disable-inspector-viewer branch January 10, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable inspector inputs for non-editors
3 participants