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