From 2d548236c38dcec3ae657405ddc72cc849f4b042 Mon Sep 17 00:00:00 2001 From: Katrina Uychaco Date: Wed, 4 Jan 2017 21:44:58 -0800 Subject: [PATCH 1/4] Add `Stage All` and `Unstage All` buttons in git panel --- lib/views/staging-view.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/views/staging-view.js b/lib/views/staging-view.js index 4371b8d22d..535929d90e 100644 --- a/lib/views/staging-view.js +++ b/lib/views/staging-view.js @@ -111,6 +111,18 @@ export default class StagingView { return true; } + @autobind + stageAll() { + const filePaths = this.props.unstagedChanges.map(filePatch => filePatch.filePath); + return this.props.attemptFileStageOperation(filePaths, 'unstaged'); + } + + @autobind + unstageAll() { + const filePaths = this.props.stagedChanges.map(filePatch => filePatch.filePath); + return this.props.attemptFileStageOperation(filePaths, 'staged'); + } + confirmSelectedItems() { const itemPaths = Array.from(this.selection.getSelectedItems()).map(item => item.filePath); return this.props.attemptFileStageOperation(itemPaths, this.selection.getActiveListKey()); @@ -266,6 +278,7 @@ export default class StagingView {
Unstaged Changes + { this.props.unstagedChanges.length ? this.renderStageAllButton() : null }
@@ -295,6 +308,7 @@ export default class StagingView { : '' } + { this.props.stagedChanges.length ? this.renderUnstageAllButton() : null }
{ @@ -347,6 +361,14 @@ export default class StagingView { } } + renderStageAllButton() { + return ; + } + + renderUnstageAllButton() { + return ; + } + getFocusClass(listKey) { return this.selection.getActiveListKey() === listKey ? 'is-focused' : ''; } From b22e23ff8ff8bc37a92aeec3ae3bb50798657645 Mon Sep 17 00:00:00 2001 From: simurai Date: Thu, 5 Jan 2017 21:55:18 +0900 Subject: [PATCH 2/4] Make stage-all button less heavy --- lib/views/staging-view.js | 4 ++-- styles/staging-view.less | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/lib/views/staging-view.js b/lib/views/staging-view.js index 535929d90e..e4bc383571 100644 --- a/lib/views/staging-view.js +++ b/lib/views/staging-view.js @@ -362,11 +362,11 @@ export default class StagingView { } renderStageAllButton() { - return ; + return ; } renderUnstageAllButton() { - return ; + return ; } getFocusClass(listKey) { diff --git a/styles/staging-view.less b/styles/staging-view.less index 753d864d65..5ced62f069 100644 --- a/styles/staging-view.less +++ b/styles/staging-view.less @@ -13,30 +13,57 @@ &-header { display: flex; - padding: @component-padding; - padding-bottom: 0; + align-items: center; + padding: 0 0 0 @component-padding; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + border-top: 1px solid @panel-heading-border-color; + border-bottom: 1px solid @panel-heading-border-color; + + .github-StagingView-group:first-child & { + border-top: none; + } .icon { text-align: center; &:before { color: @text-color-subtle; margin-right: @component-padding / 1.2; + vertical-align: middle; } } } + &-headerButton { + height: 2.5em; + border: none; + padding: 0 @component-padding; + font-weight: normal; + border-left: 1px solid @panel-heading-border-color; + background: none; + cursor: default; + + &:active { + background-color: @button-background-color-hover; + } + + &.icon:before { + margin-right: 0; + font-size: 1em; + text-align: left; + } + } + + &-title { flex: 1; - padding-bottom: .5em; - border-bottom: 1px solid @panel-heading-border-color; + margin-right: @component-padding; + line-height: 2.5em; } &-list { - padding: .3em 0; flex: 1 1 0; overflow-x: auto; } From cc62c4e5a6fe6a3301a1133a6c7a7d2dfff8d1ab Mon Sep 17 00:00:00 2001 From: simurai Date: Thu, 5 Jan 2017 22:16:37 +0900 Subject: [PATCH 3/4] Fix lint warning --- lib/views/staging-view.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/views/staging-view.js b/lib/views/staging-view.js index e4bc383571..fcb046410b 100644 --- a/lib/views/staging-view.js +++ b/lib/views/staging-view.js @@ -362,11 +362,17 @@ export default class StagingView { } renderStageAllButton() { - return ; + return ( + + ); } renderUnstageAllButton() { - return ; + return ( + + ); } getFocusClass(listKey) { From 049a96301a17037918b58d651b55df7bbc1d53d4 Mon Sep 17 00:00:00 2001 From: Katrina Uychaco Date: Thu, 5 Jan 2017 14:36:03 -0800 Subject: [PATCH 4/4] Add commands `github:stage-all` and `github:unstage-all` --- lib/views/staging-view.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/views/staging-view.js b/lib/views/staging-view.js index fcb046410b..7875269a49 100644 --- a/lib/views/staging-view.js +++ b/lib/views/staging-view.js @@ -62,6 +62,10 @@ export default class StagingView { 'github:activate-next-list': () => this.activateNextList(), 'github:activate-previous-list': () => this.activatePreviousList(), })); + this.subscriptions.add(this.props.commandRegistry.add('atom-workspace', { + 'github:stage-all': () => this.stageAll(), + 'github:unstage-all': () => this.unstageAll(), + })); window.addEventListener('mouseup', this.mouseup); this.subscriptions.add(new Disposable(() => window.removeEventListener('mouseup', this.mouseup))); } @@ -113,12 +117,14 @@ export default class StagingView { @autobind stageAll() { + if (this.props.unstagedChanges.length === 0) { return null; } const filePaths = this.props.unstagedChanges.map(filePatch => filePatch.filePath); return this.props.attemptFileStageOperation(filePaths, 'unstaged'); } @autobind unstageAll() { + if (this.props.stagedChanges.length === 0) { return null; } const filePaths = this.props.stagedChanges.map(filePatch => filePatch.filePath); return this.props.attemptFileStageOperation(filePaths, 'staged'); }