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

132 lines
3.9 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';
2020-11-24 15:15:51 +05:30
import { mapActions, mapState, mapGetters } from 'vuex';
2020-10-24 23:57:45 +05:30
import { __ } from '~/locale';
import boardsStore from '~/boards/stores/boards_store';
import eventHub from '~/sidebar/event_hub';
import { isScopedLabel } from '~/lib/utils/common_utils';
2020-11-24 15:15:51 +05:30
import { LIST } from '~/boards/constants';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2020-10-24 23:57:45 +05:30
// NOTE: need to revisit how we handle headerHeight, because we have so many different header and footer options.
export default {
headerHeight: process.env.NODE_ENV === 'development' ? '75px' : '40px',
listSettingsText: __('List settings'),
assignee: 'assignee',
milestone: 'milestone',
label: 'label',
labelListText: __('Label'),
components: {
2021-01-03 14:25:43 +05:30
GlButton,
2020-10-24 23:57:45 +05:30
GlDrawer,
GlLabel,
BoardSettingsSidebarWipLimit: () =>
import('ee_component/boards/components/board_settings_wip_limit.vue'),
BoardSettingsListTypes: () =>
import('ee_component/boards/components/board_settings_list_types.vue'),
},
2020-11-24 15:15:51 +05:30
mixins: [glFeatureFlagMixin()],
2021-01-03 14:25:43 +05:30
props: {
canAdminList: {
type: Boolean,
required: false,
default: false,
},
},
2020-10-24 23:57:45 +05:30
computed: {
2021-01-03 14:25:43 +05:30
...mapGetters(['isSidebarOpen', 'shouldUseGraphQL']),
2020-11-24 15:15:51 +05:30
...mapState(['activeId', 'sidebarType', 'boardLists']),
2021-01-29 00:20:46 +05:30
isWipLimitsOn() {
return this.glFeatures.wipLimits;
},
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-01-03 14:25:43 +05:30
if (this.shouldUseGraphQL) {
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() {
return this.$options.labelListText;
},
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?'))) {
if (this.shouldUseGraphQL) {
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>
<gl-drawer
2020-11-24 15:15:51 +05:30
v-if="showSidebar"
2020-10-24 23:57:45 +05:30
class="js-board-settings-sidebar"
:open="isSidebarOpen"
:header-height="$options.headerHeight"
2020-11-24 15:15:51 +05:30
@close="unsetActiveId"
2020-10-24 23:57:45 +05:30
>
<template #header>{{ $options.listSettingsText }}</template>
<template v-if="isSidebarOpen">
<div v-if="boardListType === $options.label">
<label class="js-list-label gl-display-block">{{ listTypeTitle }}</label>
<gl-label
:title="activeListLabel.title"
:background-color="activeListLabel.color"
:scoped="showScopedLabels(activeListLabel)"
/>
</div>
<board-settings-list-types
v-else
:active-list="activeList"
:board-list-type="boardListType"
/>
2021-01-29 00:20:46 +05:30
<board-settings-sidebar-wip-limit
v-if="isWipLimitsOn"
:max-issue-count="activeList.maxIssueCount"
/>
2021-01-03 14:25:43 +05:30
<div v-if="canAdminList && !activeList.preset && activeList.id" class="gl-m-4">
<gl-button
variant="danger"
category="secondary"
icon="remove"
data-testid="remove-list"
@click.stop="deleteBoard"
>{{ __('Remove list') }}
</gl-button>
</div>
2020-10-24 23:57:45 +05:30
</template>
</gl-drawer>
</template>