Commit 5037f32f authored by Himanshu Kapoor's avatar Himanshu Kapoor

Migrate deprecated modals in Web IDE to GlModal

Migrate deprecated modals (new file modal and discard all changes modal)
in the Web IDE to GlModal from @gitlab/ui
parent cb140072
<script> <script>
import $ from 'jquery';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { GlModal } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import ListItem from './list_item.vue'; import ListItem from './list_item.vue';
...@@ -11,7 +10,7 @@ export default { ...@@ -11,7 +10,7 @@ export default {
components: { components: {
Icon, Icon,
ListItem, ListItem,
GlModal: DeprecatedModal2, GlModal,
}, },
directives: { directives: {
tooltip, tooltip,
...@@ -58,7 +57,7 @@ export default { ...@@ -58,7 +57,7 @@ export default {
methods: { methods: {
...mapActions(['stageAllChanges', 'unstageAllChanges', 'discardAllChanges']), ...mapActions(['stageAllChanges', 'unstageAllChanges', 'discardAllChanges']),
openDiscardModal() { openDiscardModal() {
$('#discard-all-changes').modal('show'); this.$refs.discardAllModal.show();
}, },
unstageAndDiscardAllChanges() { unstageAndDiscardAllChanges() {
this.unstageAllChanges(); this.unstageAllChanges();
...@@ -114,11 +113,12 @@ export default { ...@@ -114,11 +113,12 @@ export default {
</p> </p>
<gl-modal <gl-modal
v-if="!stagedList" v-if="!stagedList"
id="discard-all-changes" ref="discardAllModal"
:footer-primary-button-text="__('Discard all changes')" ok-variant="danger"
:header-title-text="__('Discard all changes?')" modal-id="discard-all-changes"
footer-primary-button-variant="danger" :ok-title="__('Discard all changes')"
@submit="unstageAndDiscardAllChanges" :title="__('Discard all changes?')"
@ok="unstageAndDiscardAllChanges"
> >
{{ $options.discardModalText }} {{ $options.discardModalText }}
</gl-modal> </gl-modal>
......
...@@ -3,6 +3,7 @@ import Vue from 'vue'; ...@@ -3,6 +3,7 @@ import Vue from 'vue';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import { GlDeprecatedButton, GlLoadingIcon } from '@gitlab/ui'; import { GlDeprecatedButton, GlLoadingIcon } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { modalTypes } from '../constants';
import FindFile from '~/vue_shared/components/file_finder/index.vue'; import FindFile from '~/vue_shared/components/file_finder/index.vue';
import NewModal from './new_dropdown/modal.vue'; import NewModal from './new_dropdown/modal.vue';
import IdeSidebar from './ide_side_bar.vue'; import IdeSidebar from './ide_side_bar.vue';
...@@ -67,7 +68,7 @@ export default { ...@@ -67,7 +68,7 @@ export default {
document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`); document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`);
}, },
methods: { methods: {
...mapActions(['toggleFileFinder', 'openNewEntryModal']), ...mapActions(['toggleFileFinder']),
onBeforeUnload(e = {}) { onBeforeUnload(e = {}) {
const returnValue = __('Are you sure you want to lose unsaved changes?'); const returnValue = __('Are you sure you want to lose unsaved changes?');
...@@ -81,6 +82,9 @@ export default { ...@@ -81,6 +82,9 @@ export default {
openFile(file) { openFile(file) {
this.$router.push(`/project${file.url}`); this.$router.push(`/project${file.url}`);
}, },
createNewFile() {
this.$refs.newModal.open(modalTypes.blob);
},
}, },
}; };
</script> </script>
...@@ -137,7 +141,7 @@ export default { ...@@ -137,7 +141,7 @@ export default {
variant="success" variant="success"
:title="__('New file')" :title="__('New file')"
:aria-label="__('New file')" :aria-label="__('New file')"
@click="openNewEntryModal({ type: 'blob' })" @click="createNewFile()"
> >
{{ __('New file') }} {{ __('New file') }}
</gl-deprecated-button> </gl-deprecated-button>
...@@ -159,6 +163,6 @@ export default { ...@@ -159,6 +163,6 @@ export default {
<component :is="rightPaneComponent" v-if="currentProjectId" /> <component :is="rightPaneComponent" v-if="currentProjectId" />
</div> </div>
<ide-status-bar /> <ide-status-bar />
<new-modal /> <new-modal ref="newModal" />
</article> </article>
</template> </template>
<script> <script>
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import { modalTypes } from '../constants';
import IdeTreeList from './ide_tree_list.vue'; import IdeTreeList from './ide_tree_list.vue';
import Upload from './new_dropdown/upload.vue'; import Upload from './new_dropdown/upload.vue';
import NewEntryButton from './new_dropdown/button.vue'; import NewEntryButton from './new_dropdown/button.vue';
import NewModal from './new_dropdown/modal.vue';
export default { export default {
components: { components: {
Upload, Upload,
IdeTreeList, IdeTreeList,
NewEntryButton, NewEntryButton,
NewModal,
}, },
computed: { computed: {
...mapState(['currentBranchId']), ...mapState(['currentBranchId']),
...@@ -26,7 +29,13 @@ export default { ...@@ -26,7 +29,13 @@ export default {
} }
}, },
methods: { methods: {
...mapActions(['updateViewer', 'openNewEntryModal', 'createTempEntry', 'resetOpenFiles']), ...mapActions(['updateViewer', 'createTempEntry', 'resetOpenFiles']),
createNewFile() {
this.$refs.newModal.open(modalTypes.blob);
},
createNewFolder() {
this.$refs.newModal.open(modalTypes.tree);
},
}, },
}; };
</script> </script>
...@@ -41,7 +50,7 @@ export default { ...@@ -41,7 +50,7 @@ export default {
:show-label="false" :show-label="false"
class="d-flex border-0 p-0 mr-3 qa-new-file" class="d-flex border-0 p-0 mr-3 qa-new-file"
icon="doc-new" icon="doc-new"
@click="openNewEntryModal({ type: 'blob' })" @click="createNewFile()"
/> />
<upload <upload
:show-label="false" :show-label="false"
...@@ -54,9 +63,10 @@ export default { ...@@ -54,9 +63,10 @@ export default {
:show-label="false" :show-label="false"
class="d-flex border-0 p-0" class="d-flex border-0 p-0"
icon="folder-new" icon="folder-new"
@click="openNewEntryModal({ type: 'tree' })" @click="createNewFolder()"
/> />
</div> </div>
<new-modal ref="newModal" />
</template> </template>
</ide-tree-list> </ide-tree-list>
</template> </template>
...@@ -4,12 +4,14 @@ import icon from '~/vue_shared/components/icon.vue'; ...@@ -4,12 +4,14 @@ import icon from '~/vue_shared/components/icon.vue';
import upload from './upload.vue'; import upload from './upload.vue';
import ItemButton from './button.vue'; import ItemButton from './button.vue';
import { modalTypes } from '../../constants'; import { modalTypes } from '../../constants';
import NewModal from '../new_dropdown/modal.vue';
export default { export default {
components: { components: {
icon, icon,
upload, upload,
ItemButton, ItemButton,
NewModal,
}, },
props: { props: {
type: { type: {
...@@ -37,9 +39,9 @@ export default { ...@@ -37,9 +39,9 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['createTempEntry', 'openNewEntryModal', 'deleteEntry']), ...mapActions(['createTempEntry', 'deleteEntry']),
createNewItem(type) { createNewItem(type) {
this.openNewEntryModal({ type, path: this.path }); this.$refs.newModal.open(type, this.path);
this.$emit('toggle', false); this.$emit('toggle', false);
}, },
openDropdown() { openDropdown() {
...@@ -109,5 +111,6 @@ export default { ...@@ -109,5 +111,6 @@ export default {
</li> </li>
</ul> </ul>
</div> </div>
<new-modal ref="newModal" />
</div> </div>
</template> </template>
<script> <script>
import $ from 'jquery';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import flash from '~/flash'; import flash from '~/flash';
import { __, sprintf, s__ } from '~/locale'; import { __, sprintf, s__ } from '~/locale';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue'; import { GlModal } from '@gitlab/ui';
import { modalTypes } from '../../constants'; import { modalTypes } from '../../constants';
export default { export default {
components: { components: {
GlModal: DeprecatedModal2, GlModal,
}, },
data() { data() {
return { return {
name: '', name: '',
type: modalTypes.blob,
path: '',
}; };
}, },
computed: { computed: {
...mapState(['entries', 'entryModal']), ...mapState(['entries']),
...mapGetters('fileTemplates', ['templateTypes']), ...mapGetters('fileTemplates', ['templateTypes']),
entryName: { entryName: {
get() { get() {
const entryPath = this.entryModal.entry.path; if (this.type === modalTypes.rename) {
return this.name || this.path;
if (this.entryModal.type === modalTypes.rename) {
return this.name || entryPath;
} }
return this.name || (entryPath ? `${entryPath}/` : ''); return this.name || (this.path ? `${this.path}/` : '');
}, },
set(val) { set(val) {
this.name = val.trim(); this.name = val.trim();
}, },
}, },
modalTitle() { modalTitle() {
if (this.entryModal.type === modalTypes.tree) { const entry = this.entries[this.path];
if (this.type === modalTypes.tree) {
return __('Create new directory'); return __('Create new directory');
} else if (this.entryModal.type === modalTypes.rename) { } else if (this.type === modalTypes.rename) {
return this.entryModal.entry.type === modalTypes.tree return entry.type === modalTypes.tree ? __('Rename folder') : __('Rename file');
? __('Rename folder')
: __('Rename file');
} }
return __('Create new file'); return __('Create new file');
}, },
buttonLabel() { buttonLabel() {
if (this.entryModal.type === modalTypes.tree) { const entry = this.entries[this.path];
if (this.type === modalTypes.tree) {
return __('Create directory'); return __('Create directory');
} else if (this.entryModal.type === modalTypes.rename) { } else if (this.type === modalTypes.rename) {
return this.entryModal.entry.type === modalTypes.tree return entry.type === modalTypes.tree ? __('Rename folder') : __('Rename file');
? __('Rename folder')
: __('Rename file');
} }
return __('Create file'); return __('Create file');
}, },
isCreatingNewFile() { isCreatingNewFile() {
return this.entryModal.type === 'blob'; return this.type === modalTypes.blob;
}, },
placeholder() { placeholder() {
return this.isCreatingNewFile ? 'dir/file_name' : 'dir/'; return this.isCreatingNewFile ? 'dir/file_name' : 'dir/';
...@@ -64,7 +63,7 @@ export default { ...@@ -64,7 +63,7 @@ export default {
methods: { methods: {
...mapActions(['createTempEntry', 'renameEntry']), ...mapActions(['createTempEntry', 'renameEntry']),
submitForm() { submitForm() {
if (this.entryModal.type === modalTypes.rename) { if (this.type === modalTypes.rename) {
if (this.entries[this.entryName] && !this.entries[this.entryName].deleted) { if (this.entries[this.entryName] && !this.entries[this.entryName].deleted) {
flash( flash(
sprintf(s__('The name "%{name}" is already taken in this directory.'), { sprintf(s__('The name "%{name}" is already taken in this directory.'), {
...@@ -82,7 +81,7 @@ export default { ...@@ -82,7 +81,7 @@ export default {
parentPath = parentPath.join('/'); parentPath = parentPath.join('/');
this.renameEntry({ this.renameEntry({
path: this.entryModal.entry.path, path: this.path,
name: entryName, name: entryName,
parentPath, parentPath,
}); });
...@@ -90,17 +89,17 @@ export default { ...@@ -90,17 +89,17 @@ export default {
} else { } else {
this.createTempEntry({ this.createTempEntry({
name: this.name, name: this.name,
type: this.entryModal.type, type: this.type,
}); });
} }
}, },
createFromTemplate(template) { createFromTemplate(template) {
this.createTempEntry({ this.createTempEntry({
name: template.name, name: template.name,
type: this.entryModal.type, type: this.type,
}); });
$('#ide-new-entry').modal('toggle'); this.$refs.modal.toggle();
}, },
focusInput() { focusInput() {
const name = this.entries[this.entryName] ? this.entries[this.entryName].name : null; const name = this.entries[this.entryName] ? this.entries[this.entryName].name : null;
...@@ -112,8 +111,23 @@ export default { ...@@ -112,8 +111,23 @@ export default {
this.$refs.fieldName.setSelectionRange(inputValue.indexOf(name), inputValue.length); this.$refs.fieldName.setSelectionRange(inputValue.indexOf(name), inputValue.length);
} }
}, },
closedModal() { resetData() {
this.name = ''; this.name = '';
this.path = '';
this.type = modalTypes.blob;
},
open(type = modalTypes.blob, path = '') {
this.type = type;
this.path = path;
this.$refs.modal.show();
// wait for modal to show first
this.$nextTick(() => {
this.focusInput();
});
},
close() {
this.$refs.modal.hide();
}, },
}, },
}; };
...@@ -121,15 +135,15 @@ export default { ...@@ -121,15 +135,15 @@ export default {
<template> <template>
<gl-modal <gl-modal
id="ide-new-entry" ref="modal"
class="qa-new-file-modal" modal-id="ide-new-entry"
:header-title-text="modalTitle" modal-class="qa-new-file-modal"
:footer-primary-button-text="buttonLabel" :title="modalTitle"
footer-primary-button-variant="success" :ok-title="buttonLabel"
modal-size="lg" ok-variant="success"
@submit="submitForm" size="lg"
@open="focusInput" @ok="submitForm"
@closed="closedModal" @hide="resetData"
> >
<div class="form-group row"> <div class="form-group row">
<label class="label-bold col-form-label col-sm-2"> {{ __('Name') }} </label> <label class="label-bold col-form-label col-sm-2"> {{ __('Name') }} </label>
......
...@@ -78,6 +78,7 @@ export const commitItemIconMap = { ...@@ -78,6 +78,7 @@ export const commitItemIconMap = {
export const modalTypes = { export const modalTypes = {
rename: 'rename', rename: 'rename',
tree: 'tree', tree: 'tree',
blob: 'blob',
}; };
export const commitActionTypes = { export const commitActionTypes = {
......
import $ from 'jquery';
import Vue from 'vue'; import Vue from 'vue';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
...@@ -176,13 +175,6 @@ export const setLinks = ({ commit }, links) => commit(types.SET_LINKS, links); ...@@ -176,13 +175,6 @@ export const setLinks = ({ commit }, links) => commit(types.SET_LINKS, links);
export const setErrorMessage = ({ commit }, errorMessage) => export const setErrorMessage = ({ commit }, errorMessage) =>
commit(types.SET_ERROR_MESSAGE, errorMessage); commit(types.SET_ERROR_MESSAGE, errorMessage);
export const openNewEntryModal = ({ commit }, { type, path = '' }) => {
commit(types.OPEN_NEW_ENTRY_MODAL, { type, path });
// open the modal manually so we don't mess around with dropdown/rows
$('#ide-new-entry').modal('show');
};
export const deleteEntry = ({ commit, dispatch, state }, path) => { export const deleteEntry = ({ commit, dispatch, state }, path) => {
const entry = state.entries[path]; const entry = state.entries[path];
const { prevPath, prevName, prevParentPath } = entry; const { prevPath, prevName, prevParentPath } = entry;
......
...@@ -73,7 +73,6 @@ export const RESET_OPEN_FILES = 'RESET_OPEN_FILES'; ...@@ -73,7 +73,6 @@ export const RESET_OPEN_FILES = 'RESET_OPEN_FILES';
export const SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE'; export const SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE';
export const OPEN_NEW_ENTRY_MODAL = 'OPEN_NEW_ENTRY_MODAL';
export const DELETE_ENTRY = 'DELETE_ENTRY'; export const DELETE_ENTRY = 'DELETE_ENTRY';
export const RENAME_ENTRY = 'RENAME_ENTRY'; export const RENAME_ENTRY = 'RENAME_ENTRY';
export const REVERT_RENAME_ENTRY = 'REVERT_RENAME_ENTRY'; export const REVERT_RENAME_ENTRY = 'REVERT_RENAME_ENTRY';
......
...@@ -192,15 +192,6 @@ export default { ...@@ -192,15 +192,6 @@ export default {
[types.SET_ERROR_MESSAGE](state, errorMessage) { [types.SET_ERROR_MESSAGE](state, errorMessage) {
Object.assign(state, { errorMessage }); Object.assign(state, { errorMessage });
}, },
[types.OPEN_NEW_ENTRY_MODAL](state, { type, path }) {
Object.assign(state, {
entryModal: {
type,
path,
entry: { ...state.entries[path] },
},
});
},
[types.DELETE_ENTRY](state, path) { [types.DELETE_ENTRY](state, path) {
const entry = state.entries[path]; const entry = state.entries[path];
const { tempFile = false } = entry; const { tempFile = false } = entry;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
h1, h1,
h2, h2,
h3, h3,
h4:not(.modal-title), h4,
h5, h5,
h6, h6,
code, code,
...@@ -80,10 +80,6 @@ ...@@ -80,10 +80,6 @@
background-color: $dropdown-hover-background; background-color: $dropdown-hover-background;
} }
.modal-body {
color: $gl-text-color;
}
.dropdown-menu-toggle svg, .dropdown-menu-toggle svg,
.dropdown-menu-toggle svg:hover, .dropdown-menu-toggle svg:hover,
.ide-tree-header:not(.ide-pipeline-header) svg, .ide-tree-header:not(.ide-pipeline-header) svg,
......
...@@ -23,9 +23,9 @@ describe('new dropdown component', () => { ...@@ -23,9 +23,9 @@ describe('new dropdown component', () => {
tree: [], tree: [],
}; };
jest.spyOn(vm, 'openNewEntryModal').mockImplementation(() => {});
vm.$mount(); vm.$mount();
jest.spyOn(vm.$refs.newModal, 'open').mockImplementation(() => {});
}); });
afterEach(() => { afterEach(() => {
...@@ -43,16 +43,16 @@ describe('new dropdown component', () => { ...@@ -43,16 +43,16 @@ describe('new dropdown component', () => {
}); });
describe('createNewItem', () => { describe('createNewItem', () => {
it('sets modalType to blob when new file is clicked', () => { it('opens modal for a blob when new file is clicked', () => {
vm.$el.querySelectorAll('.dropdown-menu button')[0].click(); vm.$el.querySelectorAll('.dropdown-menu button')[0].click();
expect(vm.openNewEntryModal).toHaveBeenCalledWith({ type: 'blob', path: '' }); expect(vm.$refs.newModal.open).toHaveBeenCalledWith('blob', '');
}); });
it('sets modalType to tree when new directory is clicked', () => { it('opens modal for a tree when new directory is clicked', () => {
vm.$el.querySelectorAll('.dropdown-menu button')[2].click(); vm.$el.querySelectorAll('.dropdown-menu button')[2].click();
expect(vm.openNewEntryModal).toHaveBeenCalledWith({ type: 'tree', path: '' }); expect(vm.$refs.newModal.open).toHaveBeenCalledWith('tree', '');
}); });
}); });
......
...@@ -14,55 +14,48 @@ describe('new file modal component', () => { ...@@ -14,55 +14,48 @@ describe('new file modal component', () => {
vm.$destroy(); vm.$destroy();
}); });
describe.each(['tree', 'blob'])('%s', type => { describe.each`
beforeEach(() => { entryType | modalTitle | btnTitle | showsFileTemplates
${'tree'} | ${'Create new directory'} | ${'Create directory'} | ${false}
${'blob'} | ${'Create new file'} | ${'Create file'} | ${true}
`('$entryType', ({ entryType, modalTitle, btnTitle, showsFileTemplates }) => {
beforeEach(done => {
const store = createStore(); const store = createStore();
store.state.entryModal = {
type,
path: '',
entry: {
path: '',
},
};
vm = createComponentWithStore(Component, store).$mount(); vm = createComponentWithStore(Component, store).$mount();
vm.open(entryType);
vm.name = 'testing'; vm.name = 'testing';
});
it(`sets modal title as ${type}`, () => { vm.$nextTick(done);
const title = type === 'tree' ? 'directory' : 'file'; });
expect(vm.$el.querySelector('.modal-title').textContent.trim()).toBe(`Create new ${title}`); afterEach(() => {
vm.close();
}); });
it(`sets button label as ${type}`, () => { it(`sets modal title as ${entryType}`, () => {
const title = type === 'tree' ? 'directory' : 'file'; expect(document.querySelector('.modal-title').textContent.trim()).toBe(modalTitle);
});
expect(vm.$el.querySelector('.btn-success').textContent.trim()).toBe(`Create ${title}`); it(`sets button label as ${entryType}`, () => {
expect(document.querySelector('.btn-success').textContent.trim()).toBe(btnTitle);
}); });
it(`sets form label as ${type}`, () => { it(`sets form label as ${entryType}`, () => {
expect(vm.$el.querySelector('.label-bold').textContent.trim()).toBe('Name'); expect(document.querySelector('.label-bold').textContent.trim()).toBe('Name');
}); });
it(`${type === 'tree' ? 'does not show' : 'shows'} file templates`, () => { it(`shows file templates: ${showsFileTemplates}`, () => {
const templateFilesEl = vm.$el.querySelector('.file-templates'); const templateFilesEl = document.querySelector('.file-templates');
if (type === 'tree') { expect(Boolean(templateFilesEl)).toBe(showsFileTemplates);
expect(templateFilesEl).toBeNull();
} else {
expect(templateFilesEl instanceof Element).toBeTruthy();
}
}); });
}); });
describe('rename entry', () => { describe('rename entry', () => {
beforeEach(() => { beforeEach(() => {
const store = createStore(); const store = createStore();
store.state.entryModal = { store.state.entries = {
type: 'rename', 'test-path': {
path: '',
entry: {
name: 'test', name: 'test',
type: 'blob', type: 'blob',
path: 'test-path', path: 'test-path',
...@@ -72,23 +65,29 @@ describe('new file modal component', () => { ...@@ -72,23 +65,29 @@ describe('new file modal component', () => {
vm = createComponentWithStore(Component, store).$mount(); vm = createComponentWithStore(Component, store).$mount();
}); });
['tree', 'blob'].forEach(type => { it.each`
it(`renders title and button for renaming ${type}`, done => { entryType | modalTitle | btnTitle
const text = type === 'tree' ? 'folder' : 'file'; ${'tree'} | ${'Rename folder'} | ${'Rename folder'}
${'blob'} | ${'Rename file'} | ${'Rename file'}
vm.$store.state.entryModal.entry.type = type; `(
'renders title and button for renaming $entryType',
({ entryType, modalTitle, btnTitle }, done) => {
vm.$store.state.entries['test-path'].type = entryType;
vm.open('rename', 'test-path');
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.querySelector('.modal-title').textContent.trim()).toBe(`Rename ${text}`); expect(document.querySelector('.modal-title').textContent.trim()).toBe(modalTitle);
expect(vm.$el.querySelector('.btn-success').textContent.trim()).toBe(`Rename ${text}`); expect(document.querySelector('.btn-success').textContent.trim()).toBe(btnTitle);
done(); done();
}); });
}); },
}); );
describe('entryName', () => { describe('entryName', () => {
it('returns entries name', () => { it('returns entries name', () => {
vm.open('rename', 'test-path');
expect(vm.entryName).toBe('test-path'); expect(vm.entryName).toBe('test-path');
}); });
...@@ -115,15 +114,6 @@ describe('new file modal component', () => { ...@@ -115,15 +114,6 @@ describe('new file modal component', () => {
describe('submitForm', () => { describe('submitForm', () => {
it('throws an error when target entry exists', () => { it('throws an error when target entry exists', () => {
const store = createStore(); const store = createStore();
store.state.entryModal = {
type: 'rename',
path: 'test-path/test',
entry: {
name: 'test',
type: 'blob',
path: 'test-path/test',
},
};
store.state.entries = { store.state.entries = {
'test-path/test': { 'test-path/test': {
name: 'test', name: 'test',
...@@ -132,6 +122,7 @@ describe('new file modal component', () => { ...@@ -132,6 +122,7 @@ describe('new file modal component', () => {
}; };
vm = createComponentWithStore(Component, store).$mount(); vm = createComponentWithStore(Component, store).$mount();
vm.open('rename', 'test-path/test');
expect(createFlash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
......
...@@ -339,23 +339,6 @@ describe('Multi-file store mutations', () => { ...@@ -339,23 +339,6 @@ describe('Multi-file store mutations', () => {
}); });
}); });
describe('OPEN_NEW_ENTRY_MODAL', () => {
it('sets entryModal', () => {
localState.entries.testPath = file();
mutations.OPEN_NEW_ENTRY_MODAL(localState, {
type: 'test',
path: 'testPath',
});
expect(localState.entryModal).toEqual({
type: 'test',
path: 'testPath',
entry: localState.entries.testPath,
});
});
});
describe('RENAME_ENTRY', () => { describe('RENAME_ENTRY', () => {
beforeEach(() => { beforeEach(() => {
localState.trees = { localState.trees = {
......
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