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

8992-enabling-view-when-clause #9156

Merged

Conversation

danarad05
Copy link
Contributor

Enabling setting view when clauses with these values: undefined, true, false or expressions.

Signed-off-by: Dan Arad [email protected]

What it does

Fixes: #8992

How to test

follow #8992 explanation - set different test views

  • without when clause
  • with when = "true"
  • with when = "false"
  • with when = "{expression}"

i.e.:

"views": {
            "explorer": [
                {
                    "id": "testView",
                    "name": "Test View true",
                    "when": "true"
                },
                {
                    "id": "testView2",
                    "name": "Test View2 false",
                    "when": "false"
                },
                {
                    "id": "testView3",
                    "name": "Test View3 undefined"
                },
                {
                    "id": "testView4",
                    "name": "Test View4 expression",
                    "when": "debugConfigurationType == 'pwa-extensionHost'"
                }
            ]
        },

Review checklist

Reminder for reviewers

@danarad05 danarad05 force-pushed the 8992-enabling-view-when-clause branch from c556c5c to 2e4764f Compare March 8, 2021 09:54
@vince-fugnitto vince-fugnitto added tree issues related to the tree (ex: tree widget) vscode issues related to VSCode compatibility labels Mar 8, 2021
@colin-grant-work colin-grant-work self-requested a review March 9, 2021 23:20
@danarad05 danarad05 force-pushed the 8992-enabling-view-when-clause branch 2 times, most recently from cd52b47 to cf66ee6 Compare March 10, 2021 09:57
@danarad05
Copy link
Contributor Author

@colin-grant-work Please review latest changes. Thanks

@colin-grant-work
Copy link
Contributor

I believe the current code is working as expected 🎉. There are some hiccoughs, though. For example, it looks like the data coming in for the .when clause isn't being sanitized, so e.g. " true " is not treated as "true". It may be advisable either to sanitize the when when we first see the view in the registerView method, or to add .trim() anywhere we're checking for strict identity.

@alvsan09
Copy link
Contributor

I tried the fix and it works fine,
I have a question though, it seems like changing the views via the package.json don't take effect unless I used a different view id,
I know the question is unrelated to the change, but I am just wondering if you know about the issue or a workaround for it.

Enabling setting view when clauses with these values: undefined, true, false or expressions.

Signed-off-by: Dan Arad <[email protected]>
@danarad05 danarad05 force-pushed the 8992-enabling-view-when-clause branch from 6c44488 to 408b74b Compare March 11, 2021 09:37
@danarad05
Copy link
Contributor Author

I believe the current code is working as expected 🎉. There are some hiccoughs, though. For example, it looks like the data coming in for the .when clause isn't being sanitized, so e.g. " true " is not treated as "true". It may be advisable either to sanitize the when when we first see the view in the registerView method, or to add .trim() anywhere we're checking for strict identity.

Thanks for catching this. Fixed.

@danarad05
Copy link
Contributor Author

I tried the fix and it works fine,
I have a question though, it seems like changing the views via the package.json don't take effect unless I used a different view id,
I know the question is unrelated to the change, but I am just wondering if you know about the issue or a workaround for it.

I also had this issue. The cause of it is that layout is stored in localStorage and retrieved onload. So, to workaround it - you need to clear localStorage.

image

@colin-grant-work
Copy link
Contributor

I tried the fix and it works fine,
I have a question though, it seems like changing the views via the package.json don't take effect unless I used a different view id,
I know the question is unrelated to the change, but I am just wondering if you know about the issue or a workaround for it.

@alvsan09, the easiest way to get around this is to run the Reset Workbench Layout command from the command palette. Then you'll see what would have happened if you hadn't had a layout stored.

@alvsan09
Copy link
Contributor

the easiest way to get around this is to run the Reset Workbench Layout command from the command palette.

Thanks @colin-grant-work, the reset works great !

@danarad05
Copy link
Contributor Author

@vince-fugnitto who can also review this ?

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

Ideally the context-key-service should be responsible for properly handling all when clauses including determining enablement through true and false strings.

We should definitely think of improving the service (by re-using implementation from vscode) rather than adding such workarounds for all clients (commands, keybindings, menus, views).

@danarad05
Copy link
Contributor Author

We should definitely think of improving the service (by re-using implementation f

As I mentioned here #9156 (comment), in monaco 0.23.x there will be additional contextkey types that would streamline the solution but till then - why not accept this change?

@vince-fugnitto
Copy link
Member

We should definitely think of improving the service (by re-using implementation f

As I mentioned here #9156 (comment), in monaco 0.23.x there will be additional contextkey types that would streamline the solution but till then - why not accept this change?

@danarad05 if we do merge for now, please open follow-up issues to clean up the technical debt.

@colin-grant-work
Copy link
Contributor

colin-grant-work commented Mar 18, 2021

Sorry, I thought I'd already approved this! (But I guess the approval got stale?)

@danarad05
Copy link
Contributor Author

Sorry, I thought I'd already approved this! (But I guess the approval got stale?)

Thank you @colin-grant-work

@amiramw amiramw merged commit 5dc9612 into eclipse-theia:master Mar 21, 2021
@vince-fugnitto vince-fugnitto added this to the 1.12.0 milestone Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tree issues related to the tree (ex: tree widget) vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'when' clause doesn't work for views
5 participants