Commit 9d9d952c authored by Phil Hughes's avatar Phil Hughes

moved strings into constants file

parent b2cb0c6c
...@@ -48,6 +48,10 @@ export default { ...@@ -48,6 +48,10 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
keyPrefix: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -118,7 +122,7 @@ export default { ...@@ -118,7 +122,7 @@ export default {
<list-item <list-item
:file="file" :file="file"
:action-component="itemActionComponent" :action-component="itemActionComponent"
:key-prefix="title" :key-prefix="keyPrefix"
:staged-list="stagedList" :staged-list="stagedList"
:active-file-key="activeFileKey" :active-file-key="activeFileKey"
/> />
......
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
return `multi-file-${this.file.tempFile ? 'addition' : 'modified'} append-right-8`; return `multi-file-${this.file.tempFile ? 'addition' : 'modified'} append-right-8`;
}, },
fullKey() { fullKey() {
return `${this.keyPrefix.toLowerCase()}-${this.file.key}`; return `${this.keyPrefix}-${this.file.key}`;
}, },
isActive() { isActive() {
return this.activeFileKey === this.fullKey; return this.activeFileKey === this.fullKey;
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
openFileInEditor() { openFileInEditor() {
return this.openPendingTab({ return this.openPendingTab({
file: this.file, file: this.file,
keyPrefix: this.keyPrefix.toLowerCase(), keyPrefix: this.keyPrefix,
}).then(changeViewer => { }).then(changeViewer => {
if (changeViewer) { if (changeViewer) {
this.updateViewer(viewerTypes.diff); this.updateViewer(viewerTypes.diff);
......
...@@ -6,7 +6,7 @@ import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue'; ...@@ -6,7 +6,7 @@ import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
import CommitFilesList from './commit_sidebar/list.vue'; import CommitFilesList from './commit_sidebar/list.vue';
import EmptyState from './commit_sidebar/empty_state.vue'; import EmptyState from './commit_sidebar/empty_state.vue';
import * as consts from '../stores/modules/commit/constants'; import * as consts from '../stores/modules/commit/constants';
import { activityBarViews } from '../constants'; import { activityBarViews, stageKeys } from '../constants';
export default { export default {
components: { components: {
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
if (this.lastOpenedFile) { if (this.lastOpenedFile) {
this.openPendingTab({ this.openPendingTab({
file: this.lastOpenedFile, file: this.lastOpenedFile,
keyPrefix: this.lastOpenedFile.changed ? 'unstaged' : 'staged', keyPrefix: this.lastOpenedFile.changed ? stageKeys.unstaged : stageKeys.staged,
}) })
.then(changeViewer => { .then(changeViewer => {
if (changeViewer) { if (changeViewer) {
...@@ -66,6 +66,7 @@ export default { ...@@ -66,6 +66,7 @@ export default {
return this.updateCommitAction(consts.COMMIT_TO_NEW_BRANCH).then(() => this.commitChanges()); return this.updateCommitAction(consts.COMMIT_TO_NEW_BRANCH).then(() => this.commitChanges());
}, },
}, },
stageKeys,
}; };
</script> </script>
...@@ -92,6 +93,7 @@ export default { ...@@ -92,6 +93,7 @@ export default {
class="is-first" class="is-first"
icon-name="unstaged" icon-name="unstaged"
:title="__('Unstaged')" :title="__('Unstaged')"
:key-prefix="$options.stageKeys.unstaged"
:file-list="changedFiles" :file-list="changedFiles"
action="stageAllChanges" action="stageAllChanges"
:action-btn-text="__('Stage all')" :action-btn-text="__('Stage all')"
...@@ -101,6 +103,7 @@ export default { ...@@ -101,6 +103,7 @@ export default {
<commit-files-list <commit-files-list
icon-name="staged" icon-name="staged"
:title="__('Staged')" :title="__('Staged')"
:key-prefix="$options.stageKeys.staged"
:file-list="stagedFiles" :file-list="stagedFiles"
action="unstageAllChanges" action="unstageAllChanges"
:action-btn-text="__('Unstage all')" :action-btn-text="__('Unstage all')"
......
...@@ -25,3 +25,8 @@ export const rightSidebarViews = { ...@@ -25,3 +25,8 @@ export const rightSidebarViews = {
pipelines: 'pipelines-list', pipelines: 'pipelines-list',
jobsDetail: 'jobs-detail', jobsDetail: 'jobs-detail',
}; };
export const stageKeys = {
unstaged: 'unstaged',
staged: 'staged',
};
...@@ -18,6 +18,7 @@ describe('Multi-file editor commit sidebar list', () => { ...@@ -18,6 +18,7 @@ describe('Multi-file editor commit sidebar list', () => {
actionBtnText: 'stage all', actionBtnText: 'stage all',
itemActionComponent: 'stage-button', itemActionComponent: 'stage-button',
activeFileKey: 'staged-testing', activeFileKey: 'staged-testing',
keyPrefix: 'staged',
}); });
vm.$store.state.rightPanelCollapsed = false; vm.$store.state.rightPanelCollapsed = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment