2018-05-09 12:01:36 +05:30
|
|
|
<script>
|
2018-10-15 14:42:47 +05:30
|
|
|
import { mapActions } from 'vuex';
|
|
|
|
import icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import upload from './upload.vue';
|
2018-11-18 11:00:15 +05:30
|
|
|
import ItemButton from './button.vue';
|
|
|
|
import { modalTypes } from '../../constants';
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
icon,
|
|
|
|
upload,
|
2018-11-18 11:00:15 +05:30
|
|
|
ItemButton,
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
props: {
|
2018-11-18 11:00:15 +05:30
|
|
|
type: {
|
2018-10-15 14:42:47 +05:30
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
path: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2019-07-07 11:18:12 +05:30
|
|
|
isOpen: {
|
2018-11-18 11:00:15 +05:30
|
|
|
type: Boolean,
|
2019-07-07 11:18:12 +05:30
|
|
|
required: false,
|
|
|
|
default: false,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
watch: {
|
2019-07-07 11:18:12 +05:30
|
|
|
isOpen() {
|
2018-10-15 14:42:47 +05:30
|
|
|
this.$nextTick(() => {
|
2018-11-18 11:00:15 +05:30
|
|
|
this.$refs.dropdownMenu.scrollIntoView({
|
|
|
|
block: 'nearest',
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
});
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2018-11-18 11:00:15 +05:30
|
|
|
...mapActions(['createTempEntry', 'openNewEntryModal', 'deleteEntry']),
|
2018-10-15 14:42:47 +05:30
|
|
|
createNewItem(type) {
|
2018-11-18 11:00:15 +05:30
|
|
|
this.openNewEntryModal({ type, path: this.path });
|
2019-07-07 11:18:12 +05:30
|
|
|
this.$emit('toggle', false);
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
openDropdown() {
|
2019-07-07 11:18:12 +05:30
|
|
|
this.$emit('toggle', !this.isOpen);
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
modalTypes,
|
2018-10-15 14:42:47 +05:30
|
|
|
};
|
2018-05-09 12:01:36 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="ide-new-btn">
|
|
|
|
<div
|
|
|
|
:class="{
|
2019-07-07 11:18:12 +05:30
|
|
|
show: isOpen,
|
2018-05-09 12:01:36 +05:30
|
|
|
}"
|
2018-11-18 11:00:15 +05:30
|
|
|
class="dropdown d-flex"
|
2018-05-09 12:01:36 +05:30
|
|
|
>
|
|
|
|
<button
|
2018-11-18 11:00:15 +05:30
|
|
|
:aria-label="__('Create new file or directory')"
|
2018-05-09 12:01:36 +05:30
|
|
|
type="button"
|
2018-11-18 11:00:15 +05:30
|
|
|
class="rounded border-0 d-flex ide-entry-dropdown-toggle"
|
2019-03-02 22:35:43 +05:30
|
|
|
@click.stop="openDropdown()"
|
2018-05-09 12:01:36 +05:30
|
|
|
>
|
2019-02-15 15:39:39 +05:30
|
|
|
<icon name="ellipsis_v" /> <icon name="arrow-down" />
|
2018-05-09 12:01:36 +05:30
|
|
|
</button>
|
2019-02-15 15:39:39 +05:30
|
|
|
<ul ref="dropdownMenu" class="dropdown-menu dropdown-menu-right">
|
2018-11-18 11:00:15 +05:30
|
|
|
<template v-if="type === 'tree'">
|
|
|
|
<li>
|
|
|
|
<item-button
|
|
|
|
:label="__('New file')"
|
|
|
|
class="d-flex"
|
|
|
|
icon="doc-new"
|
|
|
|
icon-classes="mr-2"
|
2019-03-02 22:35:43 +05:30
|
|
|
@click="createNewItem('blob')"
|
2018-11-18 11:00:15 +05:30
|
|
|
/>
|
|
|
|
</li>
|
2019-02-15 15:39:39 +05:30
|
|
|
<li><upload :path="path" @create="createTempEntry" /></li>
|
2018-11-18 11:00:15 +05:30
|
|
|
<li>
|
|
|
|
<item-button
|
|
|
|
:label="__('New directory')"
|
|
|
|
class="d-flex"
|
|
|
|
icon="folder-new"
|
|
|
|
icon-classes="mr-2"
|
2019-03-02 22:35:43 +05:30
|
|
|
@click="createNewItem($options.modalTypes.tree)"
|
2018-11-18 11:00:15 +05:30
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li class="divider"></li>
|
|
|
|
</template>
|
2018-05-09 12:01:36 +05:30
|
|
|
<li>
|
2018-11-18 11:00:15 +05:30
|
|
|
<item-button
|
|
|
|
:label="__('Rename')"
|
|
|
|
class="d-flex"
|
|
|
|
icon="pencil"
|
|
|
|
icon-classes="mr-2"
|
2019-03-02 22:35:43 +05:30
|
|
|
@click="createNewItem($options.modalTypes.rename)"
|
2018-05-09 12:01:36 +05:30
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li>
|
2018-11-18 11:00:15 +05:30
|
|
|
<item-button
|
|
|
|
:label="__('Delete')"
|
|
|
|
class="d-flex"
|
|
|
|
icon="remove"
|
|
|
|
icon-classes="mr-2"
|
2019-03-02 22:35:43 +05:30
|
|
|
@click="deleteEntry(path)"
|
2018-11-18 11:00:15 +05:30
|
|
|
/>
|
2018-05-09 12:01:36 +05:30
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|