Skip to content

Add Reveal in Explorer option to changed file's context menu - #1677

Merged
niik merged 1 commit into
desktop:masterfrom
zhuowei:master
Jun 7, 2017
Merged

Add Reveal in Explorer option to changed file's context menu#1677
niik merged 1 commit into
desktop:masterfrom
zhuowei:master

Conversation

@zhuowei

@zhuowei zhuowei commented May 21, 2017

Copy link
Copy Markdown
Contributor

Fixes #1566.

I tested this on Windows 10; I don't have a Mac, but I think this would still work there since it just uses electron's shell api.

ghdesktop_openinfinder

Questions:

  • should I refactor the path normalization code into a helper function? I just copied and pasted it from the repo clone code from the same file.

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label May 22, 2017

@shiftkey shiftkey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A great start @zhuowei! Some feedback to get things moving...

Comment thread app/src/ui/changes/changed-file.tsx Outdated

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/lib/dispatcher/dispatcher.ts Outdated

This comment was marked as spam.

@zhuowei

zhuowei commented May 22, 2017

Copy link
Copy Markdown
Contributor Author

Pull request updated:

  • per @rlabrecque's suggestion, the open in editor command is now just named "Open"
  • moved the path join and normalization code to a helper function

Comment thread app/src/ui/changes/changed-file.tsx Outdated

This comment was marked as spam.

@niik

niik commented May 22, 2017

Copy link
Copy Markdown
Member

In the classic app on Windows we would always open a file with the 'Edit' verb to prevent the user from accidentally executing arbitrary code (like .exe, .js, .com etc). IIRC the default 'Open' action on Windows for .js is the windows script host which will happily run whatever you throw at it.

If we couldn't find a registered Edit verb we still wouldn't launch with the 'Open' verb but rather fall back to opening the file in Explorer.

I think we need to implement similar safeguards here although I'm not quite sure how to specify a verb in this environment.

@zhuowei

zhuowei commented May 22, 2017

Copy link
Copy Markdown
Contributor Author

@niik Updated text per comment.

For opening with a separate verb, I can't find any npm modules that can do this, so we may either need to write a module that wraps ShellExecute, or use node-ffi to wrap the function through ffi.

@rlabrecque

rlabrecque commented May 23, 2017

Copy link
Copy Markdown

So, my problem with the Edit verb is, how do you even change it? I wouldn't want to open my .js files with notepad which is the default 'Edit' action. In this case I'd expect that I would be opening the file in VSCode which is my default after going through, open with -> set as default.

Opening explorer if there was no default association feels weird too, why not just let the OS deal with this?
image

@niik

niik commented May 23, 2017

Copy link
Copy Markdown
Member

For opening with a separate verb, I can't find any npm modules that can do this, so we may either need to write a module that wraps ShellExecute, or use node-ffi to wrap the function through ffi.

Yeah, I think we should land this PR with just the 'Reveal in Finder/Show in Explorer' menu item and push the open option further down the line. It's tricky to get right and on macOS it seems like although there's an equivalent of the edit verb it can't be trusted to not execute code. I think as we start to get into 'Open in Atom/Open in [insert favorite IDE here]' the need for a generic open item will diminish somewhat.

shiftkey
shiftkey previously approved these changes May 25, 2017
@shiftkey

Copy link
Copy Markdown
Member

@zhuowei this looks like it's close, however there's a merge conflict that needs to be 🔥'd first.

@niik

niik commented May 25, 2017

Copy link
Copy Markdown
Member

@shiftkey also #1677 (comment)

@shiftkey

Copy link
Copy Markdown
Member

@niik 👍 gonna drop myself off this review, but feel free to pull me in if you want an extra set of 👀

@shiftkey shiftkey removed their assignment May 25, 2017
@zhuowei zhuowei changed the title Add Open in external editor, Reveal in Explorer options to context menu Add Reveal in Explorer option to changed file's context menu May 26, 2017
@zhuowei

zhuowei commented May 26, 2017

Copy link
Copy Markdown
Contributor Author

@niik Open button removed; only the Reveal in Finder/Open in Explorer menu item is left. Also, conflict resolved.

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking good @zhuowei, I had a few questions 👇

Comment thread app/src/lib/dispatcher/dispatcher.ts Outdated

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/ui/changes/changed-file.tsx Outdated

This comment was marked as spam.

Comment thread app/src/ui/changes/sidebar.tsx Outdated

This comment was marked as spam.

Comment thread app/src/ui/changes/changes-list.tsx Outdated

This comment was marked as spam.

Comment thread app/src/ui/changes/changed-file.tsx Outdated

This comment was marked as spam.

Comment thread app/src/lib/dispatcher/dispatcher.ts Outdated

This comment was marked as spam.

@zhuowei

zhuowei commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

Addressed @niik's comments.

@zhuowei

zhuowei commented Jun 7, 2017

Copy link
Copy Markdown
Contributor Author

Rebased to fix build.

@niik

niik commented Jun 7, 2017

Copy link
Copy Markdown
Member

Nicely done @zhuowei, thank you!

@niik
niik merged commit ab3be5f into desktop:master Jun 7, 2017
@ofek ofek mentioned this pull request Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants