Commit defca52a authored by Himanshu Kapoor's avatar Himanshu Kapoor Committed by Paul Slaughter

Remove redundant getter `hasChanges`

There is already a getter `someUncommitedChanges` that does the same
job, so replace it with that.

Also turns out that `repo_tabs.vue` doesn't really use the properties
`hasChanges` and `mergeRequestId` it takes in, so that resulted in a lot
of dead code removal.
parent bf0f8409
...@@ -13,7 +13,7 @@ export default { ...@@ -13,7 +13,7 @@ export default {
tooltip, tooltip,
}, },
computed: { computed: {
...mapGetters(['hasChanges']), ...mapGetters(['someUncommittedChanges']),
...mapState(['currentActivityView']), ...mapState(['currentActivityView']),
}, },
methods: { methods: {
...@@ -69,7 +69,7 @@ export default { ...@@ -69,7 +69,7 @@ export default {
<icon name="file-modified" /> <icon name="file-modified" />
</button> </button>
</li> </li>
<li v-show="hasChanges"> <li v-show="someUncommittedChanges">
<button <button
v-tooltip v-tooltip
:class="{ :class="{
......
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
computed: { computed: {
...mapState(['changedFiles', 'stagedFiles', 'currentActivityView', 'lastCommitMsg']), ...mapState(['changedFiles', 'stagedFiles', 'currentActivityView', 'lastCommitMsg']),
...mapState('commit', ['commitMessage', 'submitCommitLoading']), ...mapState('commit', ['commitMessage', 'submitCommitLoading']),
...mapGetters(['hasChanges']), ...mapGetters(['someUncommittedChanges']),
...mapGetters('commit', ['discardDraftButtonDisabled', 'preBuiltCommitMessage']), ...mapGetters('commit', ['discardDraftButtonDisabled', 'preBuiltCommitMessage']),
overviewText() { overviewText() {
return n__('%d changed file', '%d changed files', this.stagedFiles.length); return n__('%d changed file', '%d changed files', this.stagedFiles.length);
...@@ -126,7 +126,7 @@ export default { ...@@ -126,7 +126,7 @@ export default {
> >
<div v-if="isCompact" ref="compactEl" class="commit-form-compact"> <div v-if="isCompact" ref="compactEl" class="commit-form-compact">
<button <button
:disabled="!hasChanges" :disabled="!someUncommittedChanges"
type="button" type="button"
class="btn btn-primary btn-sm btn-block qa-begin-commit-button" class="btn btn-primary btn-sm btn-block qa-begin-commit-button"
@click="toggleIsCompact" @click="toggleIsCompact"
......
...@@ -40,7 +40,6 @@ export default { ...@@ -40,7 +40,6 @@ export default {
...mapState([ ...mapState([
'openFiles', 'openFiles',
'viewer', 'viewer',
'currentMergeRequestId',
'fileFindVisible', 'fileFindVisible',
'emptyStateSvgPath', 'emptyStateSvgPath',
'currentProjectId', 'currentProjectId',
...@@ -49,7 +48,6 @@ export default { ...@@ -49,7 +48,6 @@ export default {
]), ]),
...mapGetters([ ...mapGetters([
'activeFile', 'activeFile',
'hasChanges',
'someUncommittedChanges', 'someUncommittedChanges',
'isCommitModeActive', 'isCommitModeActive',
'allBlobs', 'allBlobs',
...@@ -108,14 +106,7 @@ export default { ...@@ -108,14 +106,7 @@ export default {
<div class="multi-file-edit-pane"> <div class="multi-file-edit-pane">
<template v-if="activeFile"> <template v-if="activeFile">
<commit-editor-header v-if="isCommitModeActive" :active-file="activeFile" /> <commit-editor-header v-if="isCommitModeActive" :active-file="activeFile" />
<repo-tabs <repo-tabs v-else :active-file="activeFile" :files="openFiles" :viewer="viewer" />
v-else
:active-file="activeFile"
:files="openFiles"
:viewer="viewer"
:has-changes="hasChanges"
:merge-request-id="currentMergeRequestId"
/>
<repo-editor :file="activeFile" class="multi-file-edit-pane-content" /> <repo-editor :file="activeFile" class="multi-file-edit-pane-content" />
</template> </template>
<template v-else> <template v-else>
......
...@@ -16,7 +16,7 @@ export default { ...@@ -16,7 +16,7 @@ export default {
computed: { computed: {
...mapState(['changedFiles', 'stagedFiles', 'lastCommitMsg']), ...mapState(['changedFiles', 'stagedFiles', 'lastCommitMsg']),
...mapState('commit', ['commitMessage', 'submitCommitLoading']), ...mapState('commit', ['commitMessage', 'submitCommitLoading']),
...mapGetters(['lastOpenedFile', 'hasChanges', 'someUncommittedChanges', 'activeFile']), ...mapGetters(['lastOpenedFile', 'someUncommittedChanges', 'activeFile']),
...mapGetters('commit', ['discardDraftButtonDisabled']), ...mapGetters('commit', ['discardDraftButtonDisabled']),
showStageUnstageArea() { showStageUnstageArea() {
return Boolean(this.someUncommittedChanges || this.lastCommitMsg); return Boolean(this.someUncommittedChanges || this.lastCommitMsg);
...@@ -26,8 +26,8 @@ export default { ...@@ -26,8 +26,8 @@ export default {
}, },
}, },
watch: { watch: {
hasChanges() { someUncommittedChanges() {
if (!this.hasChanges) { if (!this.someUncommittedChanges) {
this.updateActivityBarView(leftSidebarViews.edit.name); this.updateActivityBarView(leftSidebarViews.edit.name);
} }
}, },
......
...@@ -20,15 +20,6 @@ export default { ...@@ -20,15 +20,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
hasChanges: {
type: Boolean,
required: true,
},
mergeRequestId: {
type: String,
required: false,
default: '',
},
}, },
methods: { methods: {
...mapActions(['updateViewer', 'removePendingTab']), ...mapActions(['updateViewer', 'removePendingTab']),
......
...@@ -50,9 +50,6 @@ export const emptyRepo = state => ...@@ -50,9 +50,6 @@ export const emptyRepo = state =>
export const currentTree = state => export const currentTree = state =>
state.trees[`${state.currentProjectId}/${state.currentBranchId}`]; state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
export const hasChanges = state =>
Boolean(state.changedFiles.length) || Boolean(state.stagedFiles.length);
export const hasMergeRequest = state => Boolean(state.currentMergeRequestId); export const hasMergeRequest = state => Boolean(state.currentMergeRequestId);
export const allBlobs = state => export const allBlobs = state =>
......
...@@ -16,9 +16,7 @@ describe('RepoTabs', () => { ...@@ -16,9 +16,7 @@ describe('RepoTabs', () => {
vm = createComponent(RepoTabs, { vm = createComponent(RepoTabs, {
files: openedFiles, files: openedFiles,
viewer: 'editor', viewer: 'editor',
hasChanges: false,
activeFile: file('activeFile'), activeFile: file('activeFile'),
hasMergeRequest: false,
}); });
openedFiles[0].active = true; openedFiles[0].active = true;
......
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