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

132 lines
4.1 KiB
Vue
Raw Normal View History

2020-10-24 23:57:45 +05:30
<script>
2021-01-03 14:25:43 +05:30
import { GlButton, GlDrawer, GlLabel } 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 boardsStore from '~/boards/stores/boards_store';
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'),
components: {
2021-01-03 14:25:43 +05:30
GlButton,
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'),
},
2021-09-04 01:27:46 +05:30
mixins: [glFeatureFlagMixin(), Tracking.mixin()],
2021-04-29 21:17:54 +05:30
inject: ['canAdminList'],
2021-09-30 23:02:18 +05:30
inheritAttrs: false,
2021-03-11 19:13:27 +05:30
data() {
return {
ListType,
};
},
2020-10-24 23:57:45 +05:30
computed: {
2021-06-08 01:23:25 +05:30
...mapGetters(['isSidebarOpen', 'shouldUseGraphQL', '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() {
/*
Warning: Though a computed property it is not reactive because we are
referencing a List Model class. Reactivity only applies to plain JS objects
*/
2021-06-08 01:23:25 +05:30
if (this.shouldUseGraphQL || this.isEpicBoard) {
2021-01-03 14:25:43 +05:30
return this.boardLists[this.activeId];
2020-11-24 15:15:51 +05:30
}
2020-10-24 23:57:45 +05:30
return boardsStore.state.lists.find(({ id }) => id === this.activeId);
},
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() {
return this.sidebarType === LIST;
},
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']),
2020-10-24 23:57:45 +05:30
showScopedLabels(label) {
return boardsStore.scopedLabels.enabled && isScopedLabel(label);
},
2021-01-03 14:25:43 +05:30
deleteBoard() {
// eslint-disable-next-line no-alert
2021-01-29 00:20:46 +05:30
if (window.confirm(__('Are you sure you want to remove this list?'))) {
2021-06-08 01:23:25 +05:30
if (this.shouldUseGraphQL || this.isEpicBoard) {
2021-09-04 01:27:46 +05:30
this.track('click_button', { label: 'remove_list' });
2021-01-29 00:20:46 +05:30
this.removeList(this.activeId);
} else {
this.activeList.destroy();
}
2021-01-03 14:25:43 +05:30
this.unsetActiveId();
}
},
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-if="showSidebar"
v-bind="$attrs"
class="js-board-settings-sidebar gl-absolute"
:open="isSidebarOpen"
@close="unsetActiveId"
>
<template #title>{{ $options.listSettingsText }}</template>
<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"
/>
<div v-if="canAdminList && !activeList.preset && activeList.id" class="gl-mt-4">
<gl-button
variant="danger"
category="secondary"
icon="remove"
data-testid="remove-list"
@click.stop="deleteBoard"
>{{ __('Remove list') }}
</gl-button>
</div>
</template>
</gl-drawer>
</mounting-portal>
2020-10-24 23:57:45 +05:30
</template>