2018-03-20 10:12:48 -04:00
|
|
|
<script>
|
2018-02-28 16:47:44 -05:00
|
|
|
import { __ } from '~/locale';
|
2018-07-10 09:56:50 -04:00
|
|
|
import { mapActions, mapState } from 'vuex';
|
|
|
|
import GlModal from '~/vue_shared/components/gl_modal.vue';
|
2018-03-20 10:12:48 -04:00
|
|
|
|
2018-02-28 16:47:44 -05:00
|
|
|
export default {
|
|
|
|
components: {
|
2018-07-10 09:56:50 -04:00
|
|
|
GlModal,
|
2018-02-28 16:47:44 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2018-07-10 09:56:50 -04:00
|
|
|
name: '',
|
2018-02-28 16:47:44 -05:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2018-07-10 09:56:50 -04:00
|
|
|
...mapState(['newEntryModal']),
|
|
|
|
entryName: {
|
|
|
|
get() {
|
|
|
|
return this.name || (this.newEntryModal.path !== '' ? `${this.newEntryModal.path}/` : '');
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.name = val;
|
|
|
|
},
|
|
|
|
},
|
2018-02-28 16:47:44 -05:00
|
|
|
modalTitle() {
|
2018-07-10 09:56:50 -04:00
|
|
|
if (this.newEntryModal.type === 'tree') {
|
2018-02-28 16:47:44 -05:00
|
|
|
return __('Create new directory');
|
|
|
|
}
|
2018-03-20 10:12:48 -04:00
|
|
|
|
2018-02-28 16:47:44 -05:00
|
|
|
return __('Create new file');
|
|
|
|
},
|
|
|
|
buttonLabel() {
|
2018-07-10 09:56:50 -04:00
|
|
|
if (this.newEntryModal.type === 'tree') {
|
2018-02-28 16:47:44 -05:00
|
|
|
return __('Create directory');
|
|
|
|
}
|
2018-03-20 10:12:48 -04:00
|
|
|
|
2018-02-28 16:47:44 -05:00
|
|
|
return __('Create file');
|
2018-03-20 10:12:48 -04:00
|
|
|
},
|
2018-02-28 16:47:44 -05:00
|
|
|
},
|
|
|
|
methods: {
|
2018-07-10 09:56:50 -04:00
|
|
|
...mapActions(['createTempEntry']),
|
2018-02-28 16:47:44 -05:00
|
|
|
createEntryInStore() {
|
2018-07-10 09:56:50 -04:00
|
|
|
this.createTempEntry({
|
|
|
|
name: this.name,
|
|
|
|
type: this.newEntryModal.type,
|
2018-02-28 16:47:44 -05:00
|
|
|
});
|
|
|
|
},
|
2018-07-10 09:56:50 -04:00
|
|
|
focusInput() {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.$refs.fieldName.focus();
|
|
|
|
});
|
2018-03-20 10:12:48 -04:00
|
|
|
},
|
2018-02-28 16:47:44 -05:00
|
|
|
},
|
|
|
|
};
|
2018-03-20 10:12:48 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-07-10 09:56:50 -04:00
|
|
|
<gl-modal
|
|
|
|
id="ide-new-entry"
|
|
|
|
:header-title-text="modalTitle"
|
|
|
|
:footer-primary-button-text="buttonLabel"
|
|
|
|
footer-primary-button-variant="success"
|
2018-03-20 10:12:48 -04:00
|
|
|
@submit="createEntryInStore"
|
2018-07-10 09:56:50 -04:00
|
|
|
@open="focusInput"
|
2018-03-20 10:12:48 -04:00
|
|
|
>
|
2018-07-10 09:56:50 -04:00
|
|
|
<div
|
2018-05-29 12:31:58 -04:00
|
|
|
class="form-group row"
|
2018-03-20 10:12:48 -04:00
|
|
|
>
|
2018-07-19 18:11:31 -04:00
|
|
|
<label class="label-bold col-form-label col-sm-3">
|
2018-05-29 12:31:58 -04:00
|
|
|
{{ __('Name') }}
|
|
|
|
</label>
|
|
|
|
<div class="col-sm-9">
|
|
|
|
<input
|
2018-06-11 05:49:47 -04:00
|
|
|
ref="fieldName"
|
|
|
|
v-model="entryName"
|
2018-05-29 12:31:58 -04:00
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
/>
|
|
|
|
</div>
|
2018-07-10 09:56:50 -04:00
|
|
|
</div>
|
|
|
|
</gl-modal>
|
2018-03-20 10:12:48 -04:00
|
|
|
</template>
|