debian-mirror-gitlab/app/assets/javascripts/ide/components/new_dropdown/index.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

120 lines
2.8 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlIcon } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions } from 'vuex';
2018-11-18 11:00:15 +05:30
import { modalTypes } from '../../constants';
2021-03-11 19:13:27 +05:30
import ItemButton from './button.vue';
2020-05-24 23:13:21 +05:30
import NewModal from './modal.vue';
2022-10-11 01:57:18 +05:30
import Upload from './upload.vue';
2018-05-09 12:01:36 +05:30
2018-10-15 14:42:47 +05:30
export default {
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2022-10-11 01:57:18 +05:30
Upload,
2018-11-18 11:00:15 +05:30
ItemButton,
2020-05-24 23:13:21 +05:30
NewModal,
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: {
2020-05-24 23:13:21 +05:30
...mapActions(['createTempEntry', 'deleteEntry']),
2018-10-15 14:42:47 +05:30
createNewItem(type) {
2020-05-24 23:13:21 +05:30
this.$refs.newModal.open(type, 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"
2020-07-28 23:09:34 +05:30
data-qa-selector="dropdown_button"
2019-03-02 22:35:43 +05:30
@click.stop="openDropdown()"
2018-05-09 12:01:36 +05:30
>
2022-01-26 12:08:38 +05:30
<gl-icon name="ellipsis_v" />
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
2020-03-13 15:44:24 +05:30
:label="__('Rename/Move')"
2018-11-18 11:00:15 +05:30
class="d-flex"
icon="pencil"
icon-classes="mr-2"
2020-07-28 23:09:34 +05:30
data-qa-selector="rename_move_button"
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"
2021-03-11 19:13:27 +05:30
data-qa-selector="delete_button"
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>
2020-05-24 23:13:21 +05:30
<new-modal ref="newModal" />
2018-05-09 12:01:36 +05:30
</div>
</template>