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

127 lines
3.7 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 { 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-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,
};
},
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() {
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) {
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() {
// 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-11-11 11:23:49 +05:30
this.track('click_button', { label: 'remove_list' });
this.removeList(this.activeId);
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"
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
variant="danger"
category="secondary"
size="small"
data-testid="remove-list"
@click.stop="deleteBoard"
>{{ __('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>
</mounting-portal>
2020-10-24 23:57:45 +05:30
</template>