Commit 5d6103e2 authored by Phil Hughes's avatar Phil Hughes

added constants for modal type

parent bc827dfd
......@@ -4,6 +4,7 @@ import icon from '~/vue_shared/components/icon.vue';
import newModal from './modal.vue';
import upload from './upload.vue';
import ItemButton from './button.vue';
import { modalTypes } from '../../constants';
export default {
components: {
......@@ -54,6 +55,7 @@ export default {
this.dropdownOpen = !this.dropdownOpen;
},
},
modalTypes,
};
</script>
......@@ -104,7 +106,7 @@ export default {
class="d-flex"
icon="folder-new"
icon-classes="mr-2"
@click="createNewItem('tree')"
@click="createNewItem($options.modalTypes.tree)"
/>
</li>
<li class="divider"></li>
......@@ -115,7 +117,7 @@ export default {
class="d-flex"
icon="pencil"
icon-classes="mr-2"
@click="createNewItem('rename')"
@click="createNewItem($options.modalTypes.rename)"
/>
</li>
<li>
......
......@@ -2,6 +2,7 @@
import { __ } from '~/locale';
import { mapActions, mapState } from 'vuex';
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { modalTypes } from '../../constants';
export default {
components: {
......@@ -16,7 +17,9 @@ export default {
...mapState(['entryModal']),
entryName: {
get() {
if (this.entryModal.type === 'rename') return this.name || this.entryModal.entry.name;
if (this.entryModal.type === modalTypes.rename) {
return this.name || this.entryModal.entry.name;
}
return this.name || (this.entryModal.path !== '' ? `${this.entryModal.path}/` : '');
},
......@@ -25,19 +28,19 @@ export default {
},
},
modalTitle() {
if (this.entryModal.type === 'tree') {
if (this.entryModal.type === modalTypes.tree) {
return __('Create new directory');
} else if (this.entryModal.type === 'rename') {
return this.entryModal.entry.type === 'tree' ? __('Rename folder') : __('Rename file');
} else if (this.entryModal.type === modalTypes.rename) {
return this.entryModal.entry.type === modalTypes.tree ? __('Rename folder') : __('Rename file');
}
return __('Create new file');
},
buttonLabel() {
if (this.entryModal.type === 'tree') {
if (this.entryModal.type === modalTypes.tree) {
return __('Create directory');
} else if (this.entryModal.type === 'rename') {
return this.entryModal.entry.type === 'tree' ? __('Rename folder') : __('Rename file');
} else if (this.entryModal.type === modalTypes.rename) {
return this.entryModal.entry.type === modalTypes.tree ? __('Rename folder') : __('Rename file');
}
return __('Create file');
......@@ -46,7 +49,7 @@ export default {
methods: {
...mapActions(['createTempEntry', 'renameEntry']),
submitForm() {
if (this.entryModal.type === 'rename') {
if (this.entryModal.type === modalTypes.rename) {
this.renameEntry({
path: this.entryModal.entry.path,
name: this.entryName,
......
......@@ -53,3 +53,8 @@ export const commitItemIconMap = {
class: 'ide-file-deletion',
},
};
export const modalTypes = {
rename: 'rename',
tree: 'tree',
};
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