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 newModal from './modal.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,
|
|
|
|
newModal,
|
|
|
|
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
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
mouseOver: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dropdownOpen: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
dropdownOpen() {
|
|
|
|
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-11-18 11:00:15 +05:30
|
|
|
mouseOver() {
|
|
|
|
if (!this.mouseOver) {
|
|
|
|
this.dropdownOpen = false;
|
|
|
|
}
|
|
|
|
},
|
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 });
|
2018-10-15 14:42:47 +05:30
|
|
|
this.dropdownOpen = false;
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
openDropdown() {
|
|
|
|
this.dropdownOpen = !this.dropdownOpen;
|
|
|
|
},
|
|
|
|
},
|
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="{
|
2018-11-08 19:23:39 +05:30
|
|
|
show: dropdownOpen,
|
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"
|
2018-05-09 12:01:36 +05:30
|
|
|
@click.stop="openDropdown()"
|
|
|
|
>
|
|
|
|
<icon
|
2018-11-18 11:00:15 +05:30
|
|
|
name="ellipsis_v"
|
2018-05-09 12:01:36 +05:30
|
|
|
/>
|
|
|
|
<icon
|
2018-11-08 19:23:39 +05:30
|
|
|
name="arrow-down"
|
2018-05-09 12:01:36 +05:30
|
|
|
/>
|
|
|
|
</button>
|
2018-10-15 14:42:47 +05:30
|
|
|
<ul
|
|
|
|
ref="dropdownMenu"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="dropdown-menu dropdown-menu-right"
|
2018-10-15 14:42:47 +05:30
|
|
|
>
|
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"
|
|
|
|
@click="createNewItem('blob')"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<upload
|
|
|
|
:path="path"
|
|
|
|
@create="createTempEntry"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<item-button
|
|
|
|
:label="__('New directory')"
|
|
|
|
class="d-flex"
|
|
|
|
icon="folder-new"
|
|
|
|
icon-classes="mr-2"
|
|
|
|
@click="createNewItem($options.modalTypes.tree)"
|
|
|
|
/>
|
|
|
|
</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"
|
|
|
|
@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"
|
|
|
|
@click="deleteEntry(path)"
|
|
|
|
/>
|
2018-05-09 12:01:36 +05:30
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|