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