debian-mirror-gitlab/app/assets/javascripts/super_sidebar/components/create_menu.vue

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

67 lines
1.3 KiB
Vue
Raw Normal View History

2023-04-23 21:23:45 +05:30
<script>
import { GlDisclosureDropdown, GlTooltip } from '@gitlab/ui';
import { __ } from '~/locale';
2023-06-20 00:43:36 +05:30
import { DROPDOWN_Y_OFFSET } from '../constants';
// Left offset required for the dropdown to be aligned with the super sidebar
const DROPDOWN_X_OFFSET = -147;
2023-04-23 21:23:45 +05:30
export default {
components: {
GlDisclosureDropdown,
GlTooltip,
},
i18n: {
createNew: __('Create new...'),
},
props: {
groups: {
type: Array,
required: true,
},
},
2023-06-20 00:43:36 +05:30
data() {
return {
dropdownOpen: false,
};
},
2023-04-23 21:23:45 +05:30
toggleId: 'create-menu-toggle',
2023-06-20 00:43:36 +05:30
popperOptions: {
modifiers: [
{
name: 'offset',
options: {
offset: [DROPDOWN_X_OFFSET, DROPDOWN_Y_OFFSET],
},
},
],
},
2023-04-23 21:23:45 +05:30
};
</script>
<template>
<div>
<gl-disclosure-dropdown
category="tertiary"
icon="plus"
:items="groups"
no-caret
text-sr-only
:toggle-text="$options.i18n.createNew"
:toggle-id="$options.toggleId"
2023-06-20 00:43:36 +05:30
:popper-options="$options.popperOptions"
2023-05-27 22:25:52 +05:30
data-qa-selector="new_menu_toggle"
2023-06-20 00:43:36 +05:30
@shown="dropdownOpen = true"
@hidden="dropdownOpen = false"
2023-04-23 21:23:45 +05:30
/>
2023-06-20 00:43:36 +05:30
<gl-tooltip
v-if="!dropdownOpen"
:target="`#${$options.toggleId}`"
placement="bottom"
container="#super-sidebar"
>
2023-04-23 21:23:45 +05:30
{{ $options.i18n.createNew }}
</gl-tooltip>
</div>
</template>