1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
<script>
import { GlIcon } from '@gitlab/ui';
import { mapActions } from 'vuex';
import { modalTypes } from '../../constants';
import ItemButton from './button.vue';
import NewModal from './modal.vue';
import Upload from './upload.vue';
export default {
components: {
GlIcon,
Upload,
ItemButton,
NewModal,
},
props: {
type: {
type: String,
required: true,
},
path: {
type: String,
required: false,
default: '',
},
isOpen: {
type: Boolean,
required: false,
default: false,
},
},
watch: {
isOpen() {
this.$nextTick(() => {
this.$refs.dropdownMenu.scrollIntoView({
block: 'nearest',
});
});
},
},
methods: {
...mapActions(['createTempEntry', 'deleteEntry']),
createNewItem(type) {
this.$refs.newModal.open(type, this.path);
this.$emit('toggle', false);
},
openDropdown() {
this.$emit('toggle', !this.isOpen);
},
},
modalTypes,
};
</script>
<template>
<div class="ide-new-btn">
<div
:class="{
show: isOpen,
}"
class="dropdown d-flex"
>
<button
:aria-label="__('Create new file or directory')"
type="button"
class="rounded border-0 d-flex ide-entry-dropdown-toggle"
data-qa-selector="dropdown_button"
@click.stop="openDropdown()"
>
<gl-icon name="ellipsis_v" />
</button>
<ul ref="dropdownMenu" class="dropdown-menu dropdown-menu-right" data-testid="dropdown-menu">
<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>
<upload :path="path" @create="createTempEntry" />
<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>
<li>
<item-button
:label="__('Rename/Move')"
class="d-flex"
icon="pencil"
icon-classes="mr-2"
data-qa-selector="rename_move_button"
@click="createNewItem($options.modalTypes.rename)"
/>
</li>
<li>
<item-button
:label="__('Delete')"
class="d-flex"
icon="remove"
icon-classes="mr-2"
data-qa-selector="delete_button"
@click="deleteEntry(path)"
/>
</li>
</ul>
</div>
<new-modal ref="newModal" />
</div>
</template>
|