debian-mirror-gitlab/app/assets/javascripts/boards/components/board_settings_sidebar.vue

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

151 lines
4.6 KiB
Vue
Raw Normal View History

2020-10-24 23:57:45 +05:30
<script>
2022-04-04 11:22:00 +05:30
import { GlButton, GlDrawer, GlLabel, GlModal, GlModalDirective } from '@gitlab/ui';
2021-09-30 23:02:18 +05:30
import { MountingPortal } from 'portal-vue';
2020-11-24 15:15:51 +05:30
import { mapActions, mapState, mapGetters } from 'vuex';
2021-03-11 19:13:27 +05:30
import { LIST, ListType, ListTypeTitles } from '~/boards/constants';
2020-10-24 23:57:45 +05:30
import { isScopedLabel } from '~/lib/utils/common_utils';
2021-03-11 19:13:27 +05:30
import { __ } from '~/locale';
import eventHub from '~/sidebar/event_hub';
2021-09-04 01:27:46 +05:30
import Tracking from '~/tracking';
2020-11-24 15:15:51 +05:30
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2020-10-24 23:57:45 +05:30
export default {
listSettingsText: __('List settings'),
2022-04-04 11:22:00 +05:30
i18n: {
modalAction: __('Remove list'),
modalCopy: __('Are you sure you want to remove this list?'),
modalCancel: __('Cancel'),
},
2020-10-24 23:57:45 +05:30
components: {
2021-01-03 14:25:43 +05:30
GlButton,
2022-04-04 11:22:00 +05:30
GlModal,
2020-10-24 23:57:45 +05:30
GlDrawer,
GlLabel,
2021-09-30 23:02:18 +05:30
MountingPortal,
2020-10-24 23:57:45 +05:30
BoardSettingsSidebarWipLimit: () =>
import('ee_component/boards/components/board_settings_wip_limit.vue'),
BoardSettingsListTypes: () =>
import('ee_component/boards/components/board_settings_list_types.vue'),
},
2022-04-04 11:22:00 +05:30
directives: {
GlModal: GlModalDirective,
},
2021-09-04 01:27:46 +05:30
mixins: [glFeatureFlagMixin(), Tracking.mixin()],
2021-11-11 11:23:49 +05:30
inject: ['canAdminList', 'scopedLabelsAvailable'],
2021-09-30 23:02:18 +05:30
inheritAttrs: false,
2021-03-11 19:13:27 +05:30
data() {
return {
ListType,
};
},
2022-04-04 11:22:00 +05:30
modalId: 'board-settings-sidebar-modal',
2020-10-24 23:57:45 +05:30
computed: {
2021-11-11 11:23:49 +05:30
...mapGetters(['isSidebarOpen', 'isEpicBoard']),
2020-11-24 15:15:51 +05:30
...mapState(['activeId', 'sidebarType', 'boardLists']),
2021-01-29 00:20:46 +05:30
isWipLimitsOn() {
2021-06-08 01:23:25 +05:30
return this.glFeatures.wipLimits && !this.isEpicBoard;
2021-01-29 00:20:46 +05:30
},
2020-10-24 23:57:45 +05:30
activeList() {
2021-11-11 11:23:49 +05:30
return this.boardLists[this.activeId] || {};
2020-10-24 23:57:45 +05:30
},
activeListLabel() {
return this.activeList.label;
},
boardListType() {
2021-02-22 17:27:13 +05:30
return this.activeList.type || this.activeList.listType || null;
2020-10-24 23:57:45 +05:30
},
listTypeTitle() {
2021-03-11 19:13:27 +05:30
return ListTypeTitles[ListType.label];
2020-10-24 23:57:45 +05:30
},
2020-11-24 15:15:51 +05:30
showSidebar() {
2022-08-27 11:52:29 +05:30
return this.sidebarType === LIST && this.isSidebarOpen;
2020-11-24 15:15:51 +05:30
},
2020-10-24 23:57:45 +05:30
},
created() {
2020-11-24 15:15:51 +05:30
eventHub.$on('sidebar.closeAll', this.unsetActiveId);
2020-10-24 23:57:45 +05:30
},
beforeDestroy() {
2020-11-24 15:15:51 +05:30
eventHub.$off('sidebar.closeAll', this.unsetActiveId);
2020-10-24 23:57:45 +05:30
},
methods: {
2021-01-29 00:20:46 +05:30
...mapActions(['unsetActiveId', 'removeList']),
2022-04-04 11:22:00 +05:30
handleModalPrimary() {
this.deleteBoard();
},
2020-10-24 23:57:45 +05:30
showScopedLabels(label) {
2021-11-11 11:23:49 +05:30
return this.scopedLabelsAvailable && isScopedLabel(label);
2020-10-24 23:57:45 +05:30
},
2021-01-03 14:25:43 +05:30
deleteBoard() {
2022-04-04 11:22:00 +05:30
this.track('click_button', { label: 'remove_list' });
this.removeList(this.activeId);
this.unsetActiveId();
2021-01-03 14:25:43 +05:30
},
2020-10-24 23:57:45 +05:30
},
};
</script>
<template>
2021-09-30 23:02:18 +05:30
<mounting-portal mount-to="#js-right-sidebar-portal" name="board-settings-sidebar" append>
<gl-drawer
v-bind="$attrs"
class="js-board-settings-sidebar gl-absolute"
2022-08-27 11:52:29 +05:30
:open="showSidebar"
2021-11-11 11:23:49 +05:30
variant="sidebar"
2021-09-30 23:02:18 +05:30
@close="unsetActiveId"
>
2021-11-11 11:23:49 +05:30
<template #title>
<h2 class="gl-my-0 gl-font-size-h2 gl-line-height-24">
{{ $options.listSettingsText }}
</h2>
</template>
<template #header>
<div v-if="canAdminList && activeList.id" class="gl-mt-3">
<gl-button
2022-04-04 11:22:00 +05:30
v-gl-modal="$options.modalId"
2021-11-11 11:23:49 +05:30
variant="danger"
category="secondary"
size="small"
>{{ __('Remove list') }}
</gl-button>
</div>
</template>
2021-09-30 23:02:18 +05:30
<template v-if="isSidebarOpen">
<div v-if="boardListType === ListType.label">
<label class="js-list-label gl-display-block">{{ listTypeTitle }}</label>
<gl-label
:title="activeListLabel.title"
:background-color="activeListLabel.color"
:scoped="showScopedLabels(activeListLabel)"
/>
</div>
2020-10-24 23:57:45 +05:30
2021-09-30 23:02:18 +05:30
<board-settings-list-types
v-else
:active-list="activeList"
:board-list-type="boardListType"
/>
<board-settings-sidebar-wip-limit
v-if="isWipLimitsOn"
:max-issue-count="activeList.maxIssueCount"
/>
</template>
</gl-drawer>
2022-04-04 11:22:00 +05:30
<gl-modal
:modal-id="$options.modalId"
:title="$options.i18n.modalAction"
size="sm"
2022-07-16 23:28:13 +05:30
:action-primary="/* eslint-disable @gitlab/vue-no-new-non-primitive-in-template */ {
2022-04-04 11:22:00 +05:30
text: $options.i18n.modalAction,
attributes: [{ variant: 'danger' }],
2022-07-16 23:28:13 +05:30
} /* eslint-enable @gitlab/vue-no-new-non-primitive-in-template */"
:action-secondary="/* eslint-disable @gitlab/vue-no-new-non-primitive-in-template */ {
2022-04-04 11:22:00 +05:30
text: $options.i18n.modalCancel,
attributes: [{ variant: 'default' }],
2022-07-16 23:28:13 +05:30
} /* eslint-enable @gitlab/vue-no-new-non-primitive-in-template */"
2022-04-04 11:22:00 +05:30
@primary="handleModalPrimary"
>
<p>{{ $options.i18n.modalCopy }}</p>
</gl-modal>
2021-09-30 23:02:18 +05:30
</mounting-portal>
2020-10-24 23:57:45 +05:30
</template>