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