From 2aa47e10d4efd1c2e70cbdd1ebc6ef3b0dbc1fbd Mon Sep 17 00:00:00 2001
From: Phil Hughes
Date: Mon, 3 Sep 2018 11:57:41 +0100
Subject: Improved IDE commit flow
Closes #48182
---
.../components/commit_sidebar/editor_header.vue | 78 ++++++++++++++++++++++
.../ide/components/commit_sidebar/list.vue | 34 +++++-----
.../ide/components/commit_sidebar/stage_button.vue | 53 +++++++++------
.../components/commit_sidebar/unstage_button.vue | 4 +-
app/assets/javascripts/ide/components/ide.vue | 9 ++-
.../ide/components/repo_commit_section.vue | 2 +
app/assets/stylesheets/framework/buttons.scss | 4 ++
app/assets/stylesheets/page_bundles/ide.scss | 12 ++--
locale/gitlab.pot | 18 ++++-
9 files changed, 165 insertions(+), 49 deletions(-)
create mode 100644 app/assets/javascripts/ide/components/commit_sidebar/editor_header.vue
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/editor_header.vue b/app/assets/javascripts/ide/components/commit_sidebar/editor_header.vue
new file mode 100644
index 00000000000..c3ca147e850
--- /dev/null
+++ b/app/assets/javascripts/ide/components/commit_sidebar/editor_header.vue
@@ -0,0 +1,78 @@
+
+
+
+
+
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/list.vue b/app/assets/javascripts/ide/components/commit_sidebar/list.vue
index d0fb0e3d99e..9b4cea35538 100644
--- a/app/assets/javascripts/ide/components/commit_sidebar/list.vue
+++ b/app/assets/javascripts/ide/components/commit_sidebar/list.vue
@@ -56,6 +56,11 @@ export default {
type: String,
required: true,
},
+ emptyStateText: {
+ type: String,
+ required: false,
+ default: __('No changes'),
+ },
},
computed: {
titleText() {
@@ -91,17 +96,20 @@ export default {
:name="iconName"
:size="18"
/>
- {{ titleText }}
+
+ {{ titleText }}
+
-
- {{ filesLength }}
-
@@ -143,9 +143,9 @@ export default {
- {{ __('No changes') }}
+ {{ emptyStateText }}
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/stage_button.vue b/app/assets/javascripts/ide/components/commit_sidebar/stage_button.vue
index e6044401c9f..13e66e4bcf5 100644
--- a/app/assets/javascripts/ide/components/commit_sidebar/stage_button.vue
+++ b/app/assets/javascripts/ide/components/commit_sidebar/stage_button.vue
@@ -1,11 +1,14 @@
@@ -25,51 +39,48 @@ export default {
-
+
+ {{ __("You will loose all changes you've made to this file. This action cannot be undone.") }}
+
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/unstage_button.vue b/app/assets/javascripts/ide/components/commit_sidebar/unstage_button.vue
index 9cec73ec00e..4a24cf65e5a 100644
--- a/app/assets/javascripts/ide/components/commit_sidebar/unstage_button.vue
+++ b/app/assets/javascripts/ide/components/commit_sidebar/unstage_button.vue
@@ -39,8 +39,8 @@ export default {
@click="unstageChange(path)"
>
diff --git a/app/assets/javascripts/ide/components/ide.vue b/app/assets/javascripts/ide/components/ide.vue
index 6a5ab35a16a..a3add3b778f 100644
--- a/app/assets/javascripts/ide/components/ide.vue
+++ b/app/assets/javascripts/ide/components/ide.vue
@@ -10,6 +10,7 @@ import RepoEditor from './repo_editor.vue';
import FindFile from './file_finder/index.vue';
import RightPane from './panes/right.vue';
import ErrorMessage from './error_message.vue';
+import CommitEditorHeader from './commit_sidebar/editor_header.vue';
const originalStopCallback = Mousetrap.stopCallback;
@@ -23,6 +24,7 @@ export default {
FindFile,
RightPane,
ErrorMessage,
+ CommitEditorHeader,
},
computed: {
...mapState([
@@ -34,7 +36,7 @@ export default {
'currentProjectId',
'errorMessage',
]),
- ...mapGetters(['activeFile', 'hasChanges', 'someUncommitedChanges']),
+ ...mapGetters(['activeFile', 'hasChanges', 'someUncommitedChanges', 'isCommitModeActive']),
},
mounted() {
window.onbeforeunload = e => this.onBeforeUnload(e);
@@ -96,7 +98,12 @@ export default {
+
svg {
top: 0;
}
@@ -1456,3 +1452,9 @@ $ide-tree-text-start: $ide-activity-bar-width + $ide-tree-padding;
max-height: 222px;
}
}
+
+.ide-commit-editor-header {
+ padding: 8px 16px;
+ background-color: $white-normal;
+ box-shadow: inset 0 -1px $white-dark;
+}
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index e72f9a759dc..a9b0d8a4662 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -2301,6 +2301,9 @@ msgstr ""
msgid "Disable group Runners"
msgstr ""
+msgid "Discard"
+msgstr ""
+
msgid "Discard changes"
msgstr ""
@@ -3777,9 +3780,6 @@ msgstr ""
msgid "More"
msgstr ""
-msgid "More actions"
-msgstr ""
-
msgid "More information"
msgstr ""
@@ -5769,6 +5769,12 @@ msgstr ""
msgid "There are no projects shared with this group yet"
msgstr ""
+msgid "There are no staged changes"
+msgstr ""
+
+msgid "There are no unstaged changes"
+msgstr ""
+
msgid "There are problems accessing Git storage: "
msgstr ""
@@ -6226,6 +6232,9 @@ msgstr ""
msgid "Unresolve discussion"
msgstr ""
+msgid "Unstage"
+msgstr ""
+
msgid "Unstage all changes"
msgstr ""
@@ -6643,6 +6652,9 @@ msgstr ""
msgid "You need permission."
msgstr ""
+msgid "You will loose all changes you've made to this file. This action cannot be undone."
+msgstr ""
+
msgid "You will not get any notifications via email"
msgstr ""
--
cgit v1.2.1
From 1f808ffe9e567bcafce3372c488f20ca293b14a7 Mon Sep 17 00:00:00 2001
From: Phil Hughes
Date: Mon, 3 Sep 2018 16:38:27 +0100
Subject: update components to match designs in commit section
---
.../ide/components/commit_sidebar/list.vue | 49 +++++++++++++++++++++-
.../ide/components/repo_commit_section.vue | 4 +-
app/assets/javascripts/ide/stores/actions/file.js | 31 +++++++++++---
app/assets/stylesheets/page_bundles/ide.scss | 11 -----
package.json | 2 +-
.../components/commit_sidebar/stage_button_spec.js | 4 +-
.../ide/components/repo_commit_section_spec.js | 4 +-
yarn.lock | 6 +--
8 files changed, 82 insertions(+), 29 deletions(-)
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/list.vue b/app/assets/javascripts/ide/components/commit_sidebar/list.vue
index 9b4cea35538..92cd46e9385 100644
--- a/app/assets/javascripts/ide/components/commit_sidebar/list.vue
+++ b/app/assets/javascripts/ide/components/commit_sidebar/list.vue
@@ -1,7 +1,9 @@
@@ -89,12 +100,13 @@ export default {
class="multi-file-commit-panel-header"
>
@@ -147,5 +182,15 @@ export default {
>
{{ emptyStateText }}
+
+ {{ $options.discardModalText }}
+
diff --git a/app/assets/javascripts/ide/components/repo_commit_section.vue b/app/assets/javascripts/ide/components/repo_commit_section.vue
index e24469f17ed..d3b24c5b793 100644
--- a/app/assets/javascripts/ide/components/repo_commit_section.vue
+++ b/app/assets/javascripts/ide/components/repo_commit_section.vue
@@ -97,7 +97,7 @@ export default {
:active-file-key="activeFileKey"
:empty-state-text="__('There are no unstaged changes')"
action="stageAllChanges"
- action-btn-icon="mobile-issue-close"
+ action-btn-icon="stage-all"
item-action-component="stage-button"
class="is-first"
icon-name="unstaged"
@@ -111,7 +111,7 @@ export default {
:active-file-key="activeFileKey"
:empty-state-text="__('There are no staged changes')"
action="unstageAllChanges"
- action-btn-icon="history"
+ action-btn-icon="unstage-all"
item-action-component="unstage-button"
icon-name="staged"
/>
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js
index 28b9d0df201..30dcf7ef4df 100644
--- a/app/assets/javascripts/ide/stores/actions/file.js
+++ b/app/assets/javascripts/ide/stores/actions/file.js
@@ -5,7 +5,7 @@ import service from '../../services';
import * as types from '../mutation_types';
import router from '../../ide_router';
import { setPageTitle } from '../utils';
-import { viewerTypes } from '../../constants';
+import { viewerTypes, stageKeys } from '../../constants';
export const closeFile = ({ commit, state, dispatch }, file) => {
const { path } = file;
@@ -208,8 +208,9 @@ export const discardFileChanges = ({ dispatch, state, commit, getters }, path) =
eventHub.$emit(`editor.update.model.dispose.unstaged-${file.key}`, file.content);
};
-export const stageChange = ({ commit, state }, path) => {
+export const stageChange = ({ commit, state, dispatch }, path) => {
const stagedFile = state.stagedFiles.find(f => f.path === path);
+ const openFile = state.openFiles.find(f => f.path === path);
commit(types.STAGE_CHANGE, path);
commit(types.SET_LAST_COMMIT_MSG, '');
@@ -217,21 +218,39 @@ export const stageChange = ({ commit, state }, path) => {
if (stagedFile) {
eventHub.$emit(`editor.update.model.new.content.staged-${stagedFile.key}`, stagedFile.content);
}
+
+ if (openFile && openFile.active) {
+ const file = state.stagedFiles.find(f => f.path === path);
+
+ dispatch('openPendingTab', {
+ file,
+ keyPrefix: stageKeys.staged,
+ });
+ }
};
-export const unstageChange = ({ commit }, path) => {
+export const unstageChange = ({ commit, dispatch, state }, path) => {
+ const openFile = state.openFiles.find(f => f.path === path);
+
commit(types.UNSTAGE_CHANGE, path);
+
+ if (openFile && openFile.active) {
+ const file = state.changedFiles.find(f => f.path === path);
+
+ dispatch('openPendingTab', {
+ file,
+ keyPrefix: stageKeys.unstaged,
+ });
+ }
};
-export const openPendingTab = ({ commit, getters, dispatch, state }, { file, keyPrefix }) => {
+export const openPendingTab = ({ commit, getters, state }, { file, keyPrefix }) => {
if (getters.activeFile && getters.activeFile.key === `${keyPrefix}-${file.key}`) return false;
state.openFiles.forEach(f => eventHub.$emit(`editor.update.model.dispose.${f.key}`));
commit(types.ADD_PENDING_TAB, { file, keyPrefix });
- dispatch('scrollToTab');
-
router.push(`/project/${file.projectId}/tree/${state.currentBranchId}/`);
return true;
diff --git a/app/assets/stylesheets/page_bundles/ide.scss b/app/assets/stylesheets/page_bundles/ide.scss
index 0f0890f9fb6..f4c99016696 100644
--- a/app/assets/stylesheets/page_bundles/ide.scss
+++ b/app/assets/stylesheets/page_bundles/ide.scss
@@ -574,17 +574,6 @@ $ide-tree-text-start: $ide-activity-bar-width + $ide-tree-padding;
padding: 12px 0;
}
-.multi-file-commit-panel-header-title {
- display: flex;
- flex: 1;
- align-items: center;
-
- svg {
- margin-right: $gl-btn-padding;
- color: $theme-gray-700;
- }
-}
-
.multi-file-commit-panel-collapse-btn {
border-left: 1px solid $white-dark;
margin-left: auto;
diff --git a/package.json b/package.json
index 7e6ddf0fca7..d5b747b4131 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"webpack-prod": "NODE_ENV=production webpack --config config/webpack.config.js"
},
"dependencies": {
- "@gitlab-org/gitlab-svgs": "^1.28.0",
+ "@gitlab-org/gitlab-svgs": "^1.29.0",
"@gitlab-org/gitlab-ui": "1.0.5",
"autosize": "^4.0.0",
"axios": "^0.17.1",
diff --git a/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js b/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
index a5b906da8a1..e09ccbe2a63 100644
--- a/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
+++ b/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
@@ -29,7 +29,7 @@ describe('IDE stage file button', () => {
});
it('renders button to discard & stage', () => {
- expect(vm.$el.querySelectorAll('.btn').length).toBe(2);
+ expect(vm.$el.querySelectorAll('.btn-blank').length).toBe(2);
});
it('calls store with stage button', () => {
@@ -39,7 +39,7 @@ describe('IDE stage file button', () => {
});
it('calls store with discard button', () => {
- vm.$el.querySelector('.dropdown-menu button').click();
+ vm.$el.querySelector('.btn-danger').click();
expect(vm.discardFileChanges).toHaveBeenCalledWith(f.path);
});
diff --git a/spec/javascripts/ide/components/repo_commit_section_spec.js b/spec/javascripts/ide/components/repo_commit_section_spec.js
index 30cd92b2ca4..d09ccd7ac34 100644
--- a/spec/javascripts/ide/components/repo_commit_section_spec.js
+++ b/spec/javascripts/ide/components/repo_commit_section_spec.js
@@ -111,7 +111,7 @@ describe('RepoCommitSection', () => {
.then(vm.$nextTick)
.then(() => {
expect(vm.$el.querySelector('.ide-commit-list-container').textContent).toContain(
- 'No changes',
+ 'There are no unstaged changes',
);
})
.then(done)
@@ -133,7 +133,7 @@ describe('RepoCommitSection', () => {
});
it('discards a single file', done => {
- vm.$el.querySelector('.multi-file-discard-btn .dropdown-menu button').click();
+ vm.$el.querySelector('.multi-file-commit-list li:first-child .js-modal-primary-action').click();
Vue.nextTick(() => {
expect(vm.$el.querySelector('.ide-commit-list-container').textContent).not.toContain('file1');
diff --git a/yarn.lock b/yarn.lock
index 6f96e5ff228..aa3ed1aa7eb 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -82,9 +82,9 @@
version "1.27.0"
resolved "https://registry.yarnpkg.com/@gitlab-org/gitlab-svgs/-/gitlab-svgs-1.27.0.tgz#638e70399ebd59e503732177316bb9a18bf7a13f"
-"@gitlab-org/gitlab-svgs@^1.28.0":
- version "1.28.0"
- resolved "https://registry.yarnpkg.com/@gitlab-org/gitlab-svgs/-/gitlab-svgs-1.28.0.tgz#f689dfd46504df0a75027d6dd4ea01a71cd46f88"
+"@gitlab-org/gitlab-svgs@^1.29.0":
+ version "1.29.0"
+ resolved "https://registry.yarnpkg.com/@gitlab-org/gitlab-svgs/-/gitlab-svgs-1.29.0.tgz#03b65b513f9099bbda6ecf94d673a2952f8c6c70"
"@gitlab-org/gitlab-ui@1.0.5":
version "1.0.5"
--
cgit v1.2.1
From ebc15f4318ed23ccdfe7dc543721968ae92daae0 Mon Sep 17 00:00:00 2001
From: Phil Hughes
Date: Tue, 4 Sep 2018 09:00:25 +0100
Subject: design improvements
---
.../ide/components/commit_sidebar/list.vue | 8 +++---
.../ide/components/commit_sidebar/list_item.vue | 29 ++++++++++++-------
.../ide/components/commit_sidebar/stage_button.vue | 8 ++++--
.../components/commit_sidebar/unstage_button.vue | 3 +-
app/assets/stylesheets/page_bundles/ide.scss | 33 ++++++++++++++++------
5 files changed, 54 insertions(+), 27 deletions(-)
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/list.vue b/app/assets/javascripts/ide/components/commit_sidebar/list.vue
index 92cd46e9385..a69df0956bc 100644
--- a/app/assets/javascripts/ide/components/commit_sidebar/list.vue
+++ b/app/assets/javascripts/ide/components/commit_sidebar/list.vue
@@ -97,7 +97,7 @@ export default {
class="ide-commit-list-container"
>