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

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

276 lines
9.3 KiB
Vue
Raw Normal View History

2021-04-29 21:17:54 +05:30
<script>
import { GlDrawer } from '@gitlab/ui';
2021-09-30 23:02:18 +05:30
import { MountingPortal } from 'portal-vue';
2021-04-29 21:17:54 +05:30
import { mapState, mapActions, mapGetters } from 'vuex';
2021-09-04 01:27:46 +05:30
import SidebarDropdownWidget from 'ee_else_ce/sidebar/components/sidebar_dropdown_widget.vue';
2021-11-18 22:05:49 +05:30
import { __, sprintf } from '~/locale';
2021-04-29 21:17:54 +05:30
import BoardSidebarTimeTracker from '~/boards/components/sidebar/board_sidebar_time_tracker.vue';
import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue';
2023-05-27 22:25:52 +05:30
import { ISSUABLE, INCIDENT } from '~/boards/constants';
2021-11-18 22:05:49 +05:30
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
2023-05-27 22:25:52 +05:30
import { TYPE_ISSUE, WORKSPACE_GROUP, WORKSPACE_PROJECT } from '~/issues/constants';
2021-04-29 21:17:54 +05:30
import SidebarAssigneesWidget from '~/sidebar/components/assignees/sidebar_assignees_widget.vue';
2021-06-08 01:23:25 +05:30
import SidebarConfidentialityWidget from '~/sidebar/components/confidential/sidebar_confidentiality_widget.vue';
2021-09-04 01:27:46 +05:30
import SidebarDateWidget from '~/sidebar/components/date/sidebar_date_widget.vue';
2023-04-23 21:23:45 +05:30
import SidebarSeverityWidget from '~/sidebar/components/severity/sidebar_severity_widget.vue';
2021-06-08 01:23:25 +05:30
import SidebarSubscriptionsWidget from '~/sidebar/components/subscriptions/sidebar_subscriptions_widget.vue';
2021-09-30 23:02:18 +05:30
import SidebarTodoWidget from '~/sidebar/components/todo_toggle/sidebar_todo_widget.vue';
2023-03-04 22:38:38 +05:30
import SidebarLabelsWidget from '~/sidebar/components/labels/labels_select_widget/labels_select_root.vue';
2021-09-04 01:27:46 +05:30
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2021-04-29 21:17:54 +05:30
export default {
components: {
GlDrawer,
BoardSidebarTitle,
SidebarAssigneesWidget,
2021-09-04 01:27:46 +05:30
SidebarDateWidget,
2021-06-08 01:23:25 +05:30
SidebarConfidentialityWidget,
2021-04-29 21:17:54 +05:30
BoardSidebarTimeTracker,
2021-11-18 22:05:49 +05:30
SidebarLabelsWidget,
2021-06-08 01:23:25 +05:30
SidebarSubscriptionsWidget,
2021-09-04 01:27:46 +05:30
SidebarDropdownWidget,
2021-09-30 23:02:18 +05:30
SidebarTodoWidget,
2023-04-23 21:23:45 +05:30
SidebarSeverityWidget,
2021-09-30 23:02:18 +05:30
MountingPortal,
2023-03-04 22:38:38 +05:30
SidebarHealthStatusWidget: () =>
import('ee_component/sidebar/components/health_status/sidebar_health_status_widget.vue'),
SidebarIterationWidget: () =>
import('ee_component/sidebar/components/iteration/sidebar_iteration_widget.vue'),
2021-09-30 23:02:18 +05:30
SidebarWeightWidget: () =>
import('ee_component/sidebar/components/weight/sidebar_weight_widget.vue'),
2021-04-29 21:17:54 +05:30
},
2021-09-04 01:27:46 +05:30
mixins: [glFeatureFlagMixin()],
2021-06-08 01:23:25 +05:30
inject: {
multipleAssigneesFeatureAvailable: {
default: false,
},
epicFeatureAvailable: {
default: false,
},
iterationFeatureAvailable: {
default: false,
},
weightFeatureAvailable: {
default: false,
},
2023-03-04 22:38:38 +05:30
healthStatusFeatureAvailable: {
default: false,
},
2021-11-18 22:05:49 +05:30
allowLabelEdit: {
default: false,
},
2021-12-11 22:18:48 +05:30
labelsFilterBasePath: {
default: '',
},
2022-10-11 01:57:18 +05:30
canUpdate: {
default: false,
},
2023-03-17 16:20:25 +05:30
issuableType: {
2023-04-23 21:23:45 +05:30
default: TYPE_ISSUE,
2023-03-17 16:20:25 +05:30
},
isGroupBoard: {
default: false,
},
2021-06-08 01:23:25 +05:30
},
2021-09-30 23:02:18 +05:30
inheritAttrs: false,
2021-04-29 21:17:54 +05:30
computed: {
...mapGetters([
'isSidebarOpen',
'activeBoardItem',
'groupPathForActiveIssue',
'projectPathForActiveIssue',
]),
2023-03-17 16:20:25 +05:30
...mapState(['sidebarType']),
2021-04-29 21:17:54 +05:30
isIssuableSidebar() {
return this.sidebarType === ISSUABLE;
},
2022-03-02 08:16:31 +05:30
isIncidentSidebar() {
return this.activeBoardItem.type === INCIDENT;
},
2021-04-29 21:17:54 +05:30
showSidebar() {
return this.isIssuableSidebar && this.isSidebarOpen;
},
2022-03-02 08:16:31 +05:30
sidebarTitle() {
return this.isIncidentSidebar ? __('Incident details') : __('Issue details');
},
2021-04-29 21:17:54 +05:30
fullPath() {
return this.activeBoardItem?.referencePath?.split('#')[0] || '';
},
2023-03-17 16:20:25 +05:30
parentType() {
2023-05-27 22:25:52 +05:30
return this.isGroupBoard ? WORKSPACE_GROUP : WORKSPACE_PROJECT;
2023-03-17 16:20:25 +05:30
},
2021-11-18 22:05:49 +05:30
createLabelTitle() {
return sprintf(__('Create %{workspace} label'), {
2023-03-17 16:20:25 +05:30
workspace: this.parentType,
2021-11-18 22:05:49 +05:30
});
},
manageLabelTitle() {
return sprintf(__('Manage %{workspace} labels'), {
2023-03-17 16:20:25 +05:30
workspace: this.parentType,
2021-11-18 22:05:49 +05:30
});
},
attrWorkspacePath() {
2021-12-11 22:18:48 +05:30
return this.isGroupBoard ? this.groupPathForActiveIssue : this.projectPathForActiveIssue;
},
labelType() {
2023-05-27 22:25:52 +05:30
return this.isGroupBoard ? WORKSPACE_GROUP : WORKSPACE_PROJECT;
2021-12-11 22:18:48 +05:30
},
labelsFilterPath() {
return this.isGroupBoard
? this.labelsFilterBasePath.replace(':project_path', this.projectPathForActiveIssue)
: this.labelsFilterBasePath;
2021-11-18 22:05:49 +05:30
},
2021-04-29 21:17:54 +05:30
},
methods: {
2021-09-30 23:02:18 +05:30
...mapActions([
'toggleBoardItem',
'setAssignees',
'setActiveItemConfidential',
2021-11-18 22:05:49 +05:30
'setActiveBoardItemLabels',
2021-09-30 23:02:18 +05:30
'setActiveItemWeight',
2023-03-04 22:38:38 +05:30
'setActiveItemHealthStatus',
2021-09-30 23:02:18 +05:30
]),
2021-04-29 21:17:54 +05:30
handleClose() {
this.toggleBoardItem({ boardItem: this.activeBoardItem, sidebarType: this.sidebarType });
},
2021-12-11 22:18:48 +05:30
handleUpdateSelectedLabels({ labels, id }) {
2021-11-18 22:05:49 +05:30
this.setActiveBoardItemLabels({
2021-12-11 22:18:48 +05:30
id,
2021-11-18 22:05:49 +05:30
projectPath: this.projectPathForActiveIssue,
2021-12-11 22:18:48 +05:30
labelIds: labels.map((label) => getIdFromGraphQLId(label.id)),
labels,
2021-11-18 22:05:49 +05:30
});
},
2021-12-11 22:18:48 +05:30
handleLabelRemove(removeLabelId) {
2021-11-18 22:05:49 +05:30
this.setActiveBoardItemLabels({
iid: this.activeBoardItem.iid,
projectPath: this.projectPathForActiveIssue,
2021-12-11 22:18:48 +05:30
removeLabelIds: [removeLabelId],
2021-11-18 22:05:49 +05:30
});
},
2021-04-29 21:17:54 +05:30
},
};
</script>
<template>
2021-09-30 23:02:18 +05:30
<mounting-portal mount-to="#js-right-sidebar-portal" name="board-content-sidebar" append>
<gl-drawer
v-bind="$attrs"
2022-08-27 11:52:29 +05:30
:open="showSidebar"
2023-03-04 22:38:38 +05:30
class="boards-sidebar"
2021-10-27 15:23:28 +05:30
variant="sidebar"
2021-09-30 23:02:18 +05:30
@close="handleClose"
>
<template #title>
2022-03-02 08:16:31 +05:30
<h2 class="gl-my-0 gl-font-size-h2 gl-line-height-24">{{ sidebarTitle }}</h2>
2021-09-30 23:02:18 +05:30
</template>
<template #header>
<sidebar-todo-widget
class="gl-mt-3"
2021-11-11 11:23:49 +05:30
:issuable-id="activeBoardItem.id"
2021-09-30 23:02:18 +05:30
:issuable-iid="activeBoardItem.iid"
:full-path="fullPath"
:issuable-type="issuableType"
/>
</template>
<template #default>
2023-04-23 21:23:45 +05:30
<board-sidebar-title data-testid="sidebar-title" />
2021-09-30 23:02:18 +05:30
<sidebar-assignees-widget
:iid="activeBoardItem.iid"
:full-path="fullPath"
:initial-assignees="activeBoardItem.assignees"
:allow-multiple-assignees="multipleAssigneesFeatureAvailable"
2022-10-11 01:57:18 +05:30
:editable="canUpdate"
2021-09-30 23:02:18 +05:30
@assignees-updated="setAssignees"
/>
2021-09-04 01:27:46 +05:30
<sidebar-dropdown-widget
2022-03-02 08:16:31 +05:30
v-if="epicFeatureAvailable && !isIncidentSidebar"
2021-04-29 21:17:54 +05:30
:iid="activeBoardItem.iid"
2021-09-30 23:02:18 +05:30
issuable-attribute="epic"
2021-04-29 21:17:54 +05:30
:workspace-path="projectPathForActiveIssue"
2021-09-30 23:02:18 +05:30
:attr-workspace-path="groupPathForActiveIssue"
2021-04-29 21:17:54 +05:30
:issuable-type="issuableType"
2021-09-30 23:02:18 +05:30
data-testid="sidebar-epic"
2021-04-29 21:17:54 +05:30
/>
2021-09-30 23:02:18 +05:30
<div>
2021-09-04 01:27:46 +05:30
<sidebar-dropdown-widget
:iid="activeBoardItem.iid"
2021-09-30 23:02:18 +05:30
issuable-attribute="milestone"
2021-09-04 01:27:46 +05:30
:workspace-path="projectPathForActiveIssue"
2021-09-30 23:02:18 +05:30
:attr-workspace-path="projectPathForActiveIssue"
2021-09-04 01:27:46 +05:30
:issuable-type="issuableType"
2021-09-30 23:02:18 +05:30
data-testid="sidebar-milestones"
2021-09-04 01:27:46 +05:30
/>
2023-03-04 22:38:38 +05:30
<sidebar-iteration-widget
2022-04-04 11:22:00 +05:30
v-if="iterationFeatureAvailable && !isIncidentSidebar"
:iid="activeBoardItem.iid"
:workspace-path="projectPathForActiveIssue"
:attr-workspace-path="groupPathForActiveIssue"
:issuable-type="issuableType"
class="gl-mt-5"
data-testid="iteration-edit"
/>
2021-09-30 23:02:18 +05:30
</div>
2022-03-02 08:16:31 +05:30
<board-sidebar-time-tracker />
2021-09-30 23:02:18 +05:30
<sidebar-date-widget
:iid="activeBoardItem.iid"
:full-path="fullPath"
:issuable-type="issuableType"
data-testid="sidebar-due-date"
/>
2021-11-18 22:05:49 +05:30
<sidebar-labels-widget
class="block labels"
:iid="activeBoardItem.iid"
:full-path="projectPathForActiveIssue"
:allow-label-remove="allowLabelEdit"
:allow-multiselect="true"
:footer-create-label-title="createLabelTitle"
:footer-manage-label-title="manageLabelTitle"
:labels-create-title="createLabelTitle"
2021-12-11 22:18:48 +05:30
:labels-filter-base-path="labelsFilterPath"
2021-11-18 22:05:49 +05:30
:attr-workspace-path="attrWorkspacePath"
2021-12-11 22:18:48 +05:30
workspace-type="project"
2021-11-18 22:05:49 +05:30
:issuable-type="issuableType"
2021-12-11 22:18:48 +05:30
:label-create-type="labelType"
2021-11-18 22:05:49 +05:30
@onLabelRemove="handleLabelRemove"
@updateSelectedLabels="handleUpdateSelectedLabels"
>
{{ __('None') }}
</sidebar-labels-widget>
2023-04-23 21:23:45 +05:30
<sidebar-severity-widget
2022-03-02 08:16:31 +05:30
v-if="isIncidentSidebar"
:iid="activeBoardItem.iid"
:project-path="fullPath"
:initial-severity="activeBoardItem.severity"
/>
2021-09-30 23:02:18 +05:30
<sidebar-weight-widget
2022-03-02 08:16:31 +05:30
v-if="weightFeatureAvailable && !isIncidentSidebar"
2021-09-30 23:02:18 +05:30
:iid="activeBoardItem.iid"
:full-path="fullPath"
:issuable-type="issuableType"
@weightUpdated="setActiveItemWeight($event)"
/>
2023-03-04 22:38:38 +05:30
<sidebar-health-status-widget
v-if="healthStatusFeatureAvailable"
:iid="activeBoardItem.iid"
:full-path="fullPath"
:issuable-type="issuableType"
@statusUpdated="setActiveItemHealthStatus($event)"
/>
2021-09-30 23:02:18 +05:30
<sidebar-confidentiality-widget
:iid="activeBoardItem.iid"
:full-path="fullPath"
:issuable-type="issuableType"
@confidentialityUpdated="setActiveItemConfidential($event)"
/>
<sidebar-subscriptions-widget
:iid="activeBoardItem.iid"
:full-path="fullPath"
:issuable-type="issuableType"
data-testid="sidebar-notifications"
/>
</template>
</gl-drawer>
</mounting-portal>
2021-04-29 21:17:54 +05:30
</template>