Move "Undo Discard" button behind context menu #1702
Conversation
The more verbose
The
An alternative could be the kebab icon But I think the ellipsis is still better because the icon on the left also has three bars (with bullets). Something that might be a bit confusing is that:
Should all 3 options be in both menus so that users don't have to think where to find what? The right-click menu would be:
The ellipsis icon menu would be:
|
This also sounds like a good idea. "Don't worry about discarding, you can still undo it". |
Makes it look more consistent with the Stage All button
Co-Authored-By: David Wilson <daviwil@users.noreply.github.com>
Co-Authored-By: David Wilson <daviwil@users.noreply.github.com>
@simurai agreed 👍 I ended up removing the "Stage All" and "Discard All" from the header context menu. Now that we have a dedicated UI element for exposing these actions, it seems unnecessary to have a right-click context menu for the same actions on the header. |
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.
Yesss ✨
addEvent('undo-last-discard', { | ||
package: 'github', | ||
component: 'FilePatchController', | ||
}); |
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.
Yess metrics
@@ -377,20 +381,30 @@ export default class StagingView extends React.Component { | |||
this.subs.dispose(); | |||
} | |||
|
|||
getSelectedItemFilePaths() { |
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.
👍 for refactoring this out.
lib/views/staging-view.js
Outdated
|
||
const menu = new Menu(); | ||
|
||
const selectedItemCount = this.getSelectedItemFilePaths().length; |
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 could also be this.state.selection.getSelectedItems().size
to save an Array construction, yeah?
(Micro-optimization, not important 😆 )
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.
Indeed. I'm all for optimization 👍
it('records an event', function() { | ||
const wrapper = mount(component); | ||
sinon.stub(reporterProxy, 'addEvent'); | ||
wrapper.instance().discardLines(['once upon a time', 'there was an octocat named mona lisa']); |
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.
Co-Authored-By: Ash Wilson <smashwilson@gmail.com>
const menu = new Menu(); | ||
|
||
const selectedItemCount = this.state.selection.getSelectedItems().size; | ||
const pluralization = selectedItemCount > 1 ? 's' : ''; |
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.
if we ever i18n our package, all our hard coded pluralization is going to be fun to convert....
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.
Yuuuup 😕
@@ -797,6 +846,11 @@ export default class StagingView extends React.Component { | |||
return; | |||
} | |||
|
|||
addEvent('undo-last-discard', { |
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.
same comment as above - would recommend refactoring this so that you're logging menu views as a ui interaction.
Co-Authored-By: Tilde Ann Thurium <annthurium@github.com>
@annthurium what do you think of my addition of metadata for event collection in 32b0ada. I still have to do something similar for discarding 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.
ah, I like eventSource
! That does solve the problem elegantly. Thanks for addressing my review feedback!
We should figure out a way of instrumenting context menu actions. I'll file an issue for that.
@annthurium Totally! Thanks for pushing me to think past my initial block on this :) |
Description of the Change
This PR removes the
Undo Discard
button and hides this functionality behind a context menu that is accessed from the Unstaged Changes list header.Note: A similar context menu currently exists in the Merge Conflicts list header for bulk resolve actions.
When multiple files are selected, the context menu item is pluralized to
Discard Changes in Selected Files
. I chose this more verbose description (rather than simplyDiscard Changes
) to make it clear that this would discard changes for the Unstaged Changes file list, and not for the file diff view which has separate discard state.The Stage/Unstage all buttons no longer disappear when there are no changes. Now they simply become disabled. This gives something for the new kebab menu to sit up against.
Alternate Designs
Initially, I moved the
Undo Discard
button into the header and hid the text when the width was too narrow (see b82e732):This solution still leaves room for the user to accidentally click the
Undo Discard
button. It's right next to theStage All
button and, depending on styling and theme, the boundary between the two buttons may not be super visible, making it easier for users to mistakenly hit theUndo discard
button when trying to hit theStage All
button.Hiding the undo-discard functionality behind a context menu on the header makes it harder to accidentally trigger this action. See images in section above.
Benefits
This UX makes it harder to accidentally undo the last discard.
Possible Drawbacks
The undo discard functionality might be less discoverable since it is hidden behind a menu. Users may be confused by the disappearance of a button from the UI.
Applicable Issues
Issue -- #1242
Supersedes PR #1252
Fixes #1260
Metrics
undoLastDiscard
methodTests
Manual testing steps:
No context menu unit tests added as there is currently no way to write UI tests for context menus in electron --
electron-userland/spectron#21
Added metrics tests for recording the following:
Documentation
User Experience Research (Optional)
Some light UXR before shipping would be helpful. Especially to assess discoverability.
After shipping, we can monitor usage of the discard/undo discard functionality. It would be interesting to tweet about it and see if that affects feature usage.
Questions:
Stage All
button disappears and the ellipses icon moves to the right. This might look jarring. Maybe we should keep it fixed in the middle of the header, or place it to the right of theStage All
button. If we place it to the right then theStage All
button won't line up with theUnstage All
button in the section below.../cc @simurai for 💭s on ☝️
TODO:
Undo Last Discard
only if there is undo historyFuture steps: