-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Upload command always visible on browser #11756
Upload command always visible on browser #11756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@federicobozzini I'm not sure this change works as you intended, a selection of a directory is needed in order for the command to be added in the first place and is not always visible (I think this behavior is odd):
initially (perform a reset workbench layout
)
after a directory selection:
2805f53
to
35b0066
Compare
@vince-fugnitto My mistake, it should now be fixed. This weird behavior comes from the fact that the command handler is transformed by the
|
@@ -33,7 +33,7 @@ export class SelectionCommandHandler<S> implements CommandHandler { | |||
|
|||
isVisible(...args: any[]): boolean { | |||
const selection = this.getSelection(...args); | |||
return !!selection && (!this.options.isVisible || (this.options.isVisible as any)(selection as any, ...args)); | |||
return !this.options.isVisible || (this.options.isVisible as any)(selection as any, ...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change that is problematic. We should not update isVisible
for all selection command handlers to fix the minor bug. The isVisible
would break downstream applications if used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a different solution, with no breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to think about this one a bit more, I'm not sure the proper or cleanest solution would be to force the selection-command-handler
to suit our needs but maybe rather create a new handler
, or even omit using the selection-command-handler
and instead handle things ourselves with the selectionService
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this issue can be fixed in different ways. My basic understanding is that there is no reason why SelectionCommandHandler
should force the visibility of item to always consider a selection though. I don't think it's completely unreasonable to let this be decided for every specific command handler getting registered.
In any case I'm happy to change this PR if you have a better suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By definition and name the SelectionCommandHandler
is based on selection so that makes sense. If we do not care about the selection like in this case then the handler shouldn't be used and we can instead handle it ourselves rather than try to fit it to our needs for this specific use-case.
35b0066
to
3ecfa82
Compare
I would recommend simply rewriting the handler for this item not to be a |
c6366a9
to
0af9263
Compare
@vince-fugnitto @colin-grant-work I've change this PR to only change the behavior of the upload button. There is some code repetition but I think that's unfortunately inevitable. |
packages/filesystem/src/browser/filesystem-frontend-contribution.ts
Outdated
Show resolved
Hide resolved
packages/filesystem/src/browser/filesystem-frontend-contribution.ts
Outdated
Show resolved
Hide resolved
@colin-grant-work @vince-fugnitto Can this PR be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me 👍
-
upload files...
is always visible -
upload files...
is enabled if a folder is selected -
upload files...
is disabled if a file is selected - uploading files works as expected
@federicobozzini, it looks like this is failing the Eclipse Contributor Agreement check because of the shared commits - would you mind pushing a squashed version? |
@federicobozzini Do you mind squashing your commits to fix the ECA check? |
Signed-off-by: Federico Bozzini <[email protected]>
f155a6d
to
a8791a9
Compare
I've pushed a squashed version, thanks. |
What it does
This PR makes the
Upload Files...
menu entry always visible on a browser environment. At the moment the menu entry disappears if no folder is selected on the explorer and I think this might quite counter-intuitive for a lot of users as menu entries don't generally disappear if they are unusable but they just get disabled.How to test
Just start Theia and check the menu entry for uploading files and the
File
menu. It should now always be visible.Review checklist
Reminder for reviewers