Commit cc530bcd authored by Himanshu Kapoor's avatar Himanshu Kapoor

Remove unusedSeal and related actions

The property unusedSeal, and related actions and mutations were
redundant. We can easily identify if there are no changes by checking
`someUncommitedChanges` property on state.
parent 7994efee
......@@ -9,10 +9,7 @@ export default {
</script>
<template>
<div
v-if="!lastCommitMsg"
class="multi-file-commit-panel-section ide-commit-empty-state js-empty-state"
>
<div v-if="!lastCommitMsg" class="multi-file-commit-panel-section ide-commit-empty-state">
<div class="ide-commit-empty-state-container">
<div class="svg-content svg-80"><img :src="noChangesStateSvgPath" /></div>
<div class="append-right-default prepend-left-default">
......
......@@ -14,12 +14,12 @@ export default {
tooltip,
},
computed: {
...mapState(['changedFiles', 'stagedFiles', 'lastCommitMsg', 'unusedSeal']),
...mapState(['changedFiles', 'stagedFiles', 'lastCommitMsg']),
...mapState('commit', ['commitMessage', 'submitCommitLoading']),
...mapGetters(['lastOpenedFile', 'hasChanges', 'someUncommittedChanges', 'activeFile']),
...mapGetters('commit', ['discardDraftButtonDisabled']),
showStageUnstageArea() {
return Boolean(this.someUncommittedChanges || this.lastCommitMsg || !this.unusedSeal);
return Boolean(this.someUncommittedChanges || this.lastCommitMsg);
},
activeFileKey() {
return this.activeFile ? this.activeFile.key : null;
......@@ -67,6 +67,6 @@ export default {
icon-name="unstaged"
/>
</template>
<empty-state v-if="unusedSeal" />
<empty-state v-else />
</div>
</template>
......@@ -207,8 +207,6 @@ export default {
state.changedFiles = state.changedFiles.concat(entry);
}
}
state.unusedSeal = false;
},
[types.RENAME_ENTRY](state, { path, name, parentPath }) {
const oldEntry = state.entries[path];
......
......@@ -153,13 +153,11 @@ export default {
[types.ADD_FILE_TO_CHANGED](state, path) {
Object.assign(state, {
changedFiles: state.changedFiles.concat(state.entries[path]),
unusedSeal: false,
});
},
[types.REMOVE_FILE_FROM_CHANGED](state, path) {
Object.assign(state, {
changedFiles: state.changedFiles.filter(f => f.path !== path),
unusedSeal: false,
});
},
[types.STAGE_CHANGE](state, { path, diffInfo }) {
......@@ -175,7 +173,6 @@ export default {
deleted: diffInfo.deleted,
}),
}),
unusedSeal: false,
});
if (stagedFile) {
......
......@@ -20,7 +20,6 @@ export default () => ({
viewer: viewerTypes.edit,
delayViewerUpdated: false,
currentActivityView: leftSidebarViews.edit.name,
unusedSeal: true,
fileFindVisible: false,
links: {},
errorMessage: null,
......
......@@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils';
import { createStore } from '~/ide/stores';
import router from '~/ide/ide_router';
import RepoCommitSection from '~/ide/components/repo_commit_section.vue';
import EmptyState from '~/ide/components/commit_sidebar/empty_state.vue';
import { stageKeys } from '~/ide/constants';
import { file } from '../helpers';
......@@ -63,7 +64,7 @@ describe('RepoCommitSection', () => {
wrapper.destroy();
});
describe('empty Stage', () => {
describe('empty state', () => {
beforeEach(() => {
store.state.noChangesStateSvgPath = TEST_NO_CHANGES_SVG;
store.state.committedStateSvgPath = 'svg';
......@@ -74,11 +75,16 @@ describe('RepoCommitSection', () => {
it('renders no changes text', () => {
expect(
wrapper
.find('.js-empty-state')
.find(EmptyState)
.text()
.trim(),
).toContain('No changes');
expect(wrapper.find('.js-empty-state img').attributes('src')).toBe(TEST_NO_CHANGES_SVG);
expect(
wrapper
.find(EmptyState)
.find('img')
.attributes('src'),
).toBe(TEST_NO_CHANGES_SVG);
});
});
......@@ -109,6 +115,10 @@ describe('RepoCommitSection', () => {
expect(changedFileNames).toEqual(allFiles.map(x => x.path));
});
it('does not show empty state', () => {
expect(wrapper.find(EmptyState).exists()).toBe(false);
});
});
describe('with unstaged file', () => {
......@@ -129,5 +139,9 @@ describe('RepoCommitSection', () => {
keyPrefix: stageKeys.unstaged,
});
});
it('does not show empty state', () => {
expect(wrapper.find(EmptyState).exists()).toBe(false);
});
});
});
......@@ -587,20 +587,6 @@ describe('IDE store file actions', () => {
})
.catch(done.fail);
});
it('bursts unused seal', done => {
store
.dispatch('changeFileContent', {
path: tmpFile.path,
content: 'content',
})
.then(() => {
expect(store.state.unusedSeal).toBe(false);
done();
})
.catch(done.fail);
});
});
describe('with changed file', () => {
......
......@@ -292,21 +292,6 @@ describe('Multi-file store actions', () => {
})
.catch(done.fail);
});
it('bursts unused seal', done => {
store
.dispatch('createTempEntry', {
name: 'test',
branchId: 'mybranch',
type: 'blob',
})
.then(() => {
expect(store.state.unusedSeal).toBe(false);
done();
})
.catch(done.fail);
});
});
});
......@@ -682,19 +667,6 @@ describe('Multi-file store actions', () => {
});
});
});
it('bursts unused seal', done => {
store.state.entries.test = file('test');
store
.dispatch('deleteEntry', 'test')
.then(() => {
expect(store.state.unusedSeal).toBe(false);
done();
})
.catch(done.fail);
});
});
describe('renameEntry', () => {
......@@ -839,20 +811,6 @@ describe('Multi-file store actions', () => {
.then(done)
.catch(done.fail);
});
it('bursts unused seal', done => {
store
.dispatch('renameEntry', {
path: 'orig',
name: 'renamed',
})
.then(() => {
expect(store.state.unusedSeal).toBe(false);
done();
})
.catch(done.fail);
});
});
describe('folder', () => {
......
......@@ -356,14 +356,6 @@ describe('IDE store file mutations', () => {
expect(localState.changedFiles.length).toBe(1);
});
it('bursts unused seal', () => {
expect(localState.unusedSeal).toBe(true);
mutations.ADD_FILE_TO_CHANGED(localState, localFile.path);
expect(localState.unusedSeal).toBe(false);
});
});
describe('REMOVE_FILE_FROM_CHANGED', () => {
......@@ -374,14 +366,6 @@ describe('IDE store file mutations', () => {
expect(localState.changedFiles.length).toBe(0);
});
it('bursts unused seal', () => {
expect(localState.unusedSeal).toBe(true);
mutations.REMOVE_FILE_FROM_CHANGED(localState, localFile.path);
expect(localState.unusedSeal).toBe(false);
});
});
describe.each`
......@@ -533,19 +517,6 @@ describe('IDE store file mutations', () => {
},
);
describe('STAGE_CHANGE', () => {
it('bursts unused seal', () => {
expect(localState.unusedSeal).toBe(true);
mutations.STAGE_CHANGE(localState, {
path: localFile.path,
diffInfo: localStore.getters.getDiffInfo(localFile.path),
});
expect(localState.unusedSeal).toBe(false);
});
});
describe('TOGGLE_FILE_CHANGED', () => {
it('updates file changed status', () => {
mutations.TOGGLE_FILE_CHANGED(localState, {
......
......@@ -265,16 +265,6 @@ describe('Multi-file store mutations', () => {
expect(localState.changedFiles).toEqual([]);
expect(localState.stagedFiles).toEqual([]);
});
it('bursts unused seal', () => {
localState.entries.test = file('test');
expect(localState.unusedSeal).toBe(true);
mutations.DELETE_ENTRY(localState, 'test');
expect(localState.unusedSeal).toBe(false);
});
});
describe('UPDATE_FILE_AFTER_COMMIT', () => {
......
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