2020-06-23 00:09:42 +05:30
|
|
|
<script>
|
2021-03-11 19:13:27 +05:30
|
|
|
import { GlAlert } from '@gitlab/ui';
|
2023-03-04 22:38:38 +05:30
|
|
|
import { breakpoints } from '@gitlab/ui/dist/utils';
|
2023-01-13 00:05:48 +05:30
|
|
|
import { sortBy, throttle } from 'lodash';
|
2021-02-22 17:27:13 +05:30
|
|
|
import Draggable from 'vuedraggable';
|
2020-11-24 15:15:51 +05:30
|
|
|
import { mapState, mapGetters, mapActions } from 'vuex';
|
2023-03-04 22:38:38 +05:30
|
|
|
import { contentTop } from '~/lib/utils/common_utils';
|
2023-01-13 00:05:48 +05:30
|
|
|
import { s__ } from '~/locale';
|
|
|
|
import { formatBoardLists } from 'ee_else_ce/boards/boards_util';
|
2021-04-17 20:07:23 +05:30
|
|
|
import BoardAddNewColumn from 'ee_else_ce/boards/components/board_add_new_column.vue';
|
2022-06-21 17:19:12 +05:30
|
|
|
import { defaultSortableOptions } from '~/sortable/constants';
|
2023-01-13 00:05:48 +05:30
|
|
|
import { DraggableItemTypes, BoardType, listsQuery } from 'ee_else_ce/boards/constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import BoardColumn from './board_column.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
export default {
|
2023-01-13 00:05:48 +05:30
|
|
|
i18n: {
|
|
|
|
fetchError: s__(
|
|
|
|
'Boards|An error occurred while fetching the board lists. Please reload the page.',
|
|
|
|
),
|
|
|
|
},
|
2021-10-27 15:23:28 +05:30
|
|
|
draggableItemTypes: DraggableItemTypes,
|
2020-06-23 00:09:42 +05:30
|
|
|
components: {
|
2021-04-17 20:07:23 +05:30
|
|
|
BoardAddNewColumn,
|
2021-09-30 23:02:18 +05:30
|
|
|
BoardColumn,
|
2021-04-29 21:17:54 +05:30
|
|
|
BoardContentSidebar: () => import('~/boards/components/board_content_sidebar.vue'),
|
|
|
|
EpicBoardContentSidebar: () =>
|
|
|
|
import('ee_component/boards/components/epic_board_content_sidebar.vue'),
|
2020-11-24 15:15:51 +05:30
|
|
|
EpicsSwimlanes: () => import('ee_component/boards/components/epics_swimlanes.vue'),
|
|
|
|
GlAlert,
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
2023-01-13 00:05:48 +05:30
|
|
|
inject: [
|
|
|
|
'canAdminList',
|
|
|
|
'boardType',
|
|
|
|
'fullPath',
|
|
|
|
'issuableType',
|
|
|
|
'isIssueBoard',
|
|
|
|
'isEpicBoard',
|
|
|
|
'isApolloBoard',
|
|
|
|
],
|
2020-06-23 00:09:42 +05:30
|
|
|
props: {
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2023-01-13 00:05:48 +05:30
|
|
|
boardId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
boardHeight: null,
|
|
|
|
boardListsApollo: {},
|
|
|
|
apolloError: null,
|
|
|
|
updatedBoardId: this.boardId,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
boardListsApollo: {
|
|
|
|
query() {
|
|
|
|
return listsQuery[this.issuableType].query;
|
|
|
|
},
|
|
|
|
variables() {
|
|
|
|
return this.queryVariables;
|
|
|
|
},
|
|
|
|
skip() {
|
|
|
|
return !this.isApolloBoard;
|
|
|
|
},
|
|
|
|
update(data) {
|
|
|
|
const { lists } = data[this.boardType].board;
|
|
|
|
return formatBoardLists(lists);
|
|
|
|
},
|
|
|
|
result() {
|
|
|
|
// this allows us to delay fetching lists when we switch a board to fetch the actual board lists
|
|
|
|
// instead of fetching lists for the "previous" board
|
|
|
|
this.updatedBoardId = this.boardId;
|
|
|
|
},
|
|
|
|
error() {
|
|
|
|
this.apolloError = this.$options.i18n.fetchError;
|
|
|
|
},
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
computed: {
|
2021-04-17 20:07:23 +05:30
|
|
|
...mapState(['boardLists', 'error', 'addColumnForm']),
|
2023-01-13 00:05:48 +05:30
|
|
|
...mapGetters(['isSwimlanesOn']),
|
2021-04-17 20:07:23 +05:30
|
|
|
addColumnFormVisible() {
|
|
|
|
return this.addColumnForm?.visible;
|
|
|
|
},
|
2023-01-13 00:05:48 +05:30
|
|
|
queryVariables() {
|
|
|
|
return {
|
|
|
|
...(this.isIssueBoard && {
|
|
|
|
isGroup: this.boardType === BoardType.group,
|
|
|
|
isProject: this.boardType === BoardType.project,
|
|
|
|
}),
|
|
|
|
fullPath: this.fullPath,
|
|
|
|
boardId: this.boardId,
|
|
|
|
filterParams: this.filterParams,
|
|
|
|
};
|
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
boardListsToUse() {
|
2023-01-13 00:05:48 +05:30
|
|
|
const lists = this.isApolloBoard ? this.boardListsApollo : this.boardLists;
|
|
|
|
return sortBy([...Object.values(lists)], 'position');
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
|
|
|
canDragColumns() {
|
2021-11-11 11:23:49 +05:30
|
|
|
return this.canAdminList;
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
|
|
|
boardColumnWrapper() {
|
|
|
|
return this.canDragColumns ? Draggable : 'div';
|
|
|
|
},
|
|
|
|
draggableOptions() {
|
|
|
|
const options = {
|
2022-06-21 17:19:12 +05:30
|
|
|
...defaultSortableOptions,
|
2021-02-22 17:27:13 +05:30
|
|
|
disabled: this.disabled,
|
|
|
|
draggable: '.is-draggable',
|
|
|
|
fallbackOnBody: false,
|
|
|
|
group: 'boards-list',
|
|
|
|
tag: 'div',
|
2021-03-08 18:12:59 +05:30
|
|
|
value: this.boardListsToUse,
|
2023-03-04 22:38:38 +05:30
|
|
|
delay: 100,
|
|
|
|
delayOnTouchOnly: true,
|
2021-02-22 17:27:13 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
return this.canDragColumns ? options : {};
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
2023-01-13 00:05:48 +05:30
|
|
|
errorToDisplay() {
|
|
|
|
return this.isApolloBoard ? this.apolloError : this.error;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setBoardHeight();
|
|
|
|
|
|
|
|
this.resizeObserver = new ResizeObserver(
|
|
|
|
throttle(() => {
|
|
|
|
this.setBoardHeight();
|
|
|
|
}, 150),
|
|
|
|
);
|
|
|
|
this.resizeObserver.observe(document.body);
|
|
|
|
},
|
|
|
|
unmounted() {
|
|
|
|
this.resizeObserver.disconnect();
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2021-04-29 21:17:54 +05:30
|
|
|
...mapActions(['moveList', 'unsetError']),
|
2021-04-17 20:07:23 +05:30
|
|
|
afterFormEnters() {
|
|
|
|
const el = this.canDragColumns ? this.$refs.list.$el : this.$refs.list;
|
|
|
|
el.scrollTo({ left: el.scrollWidth, behavior: 'smooth' });
|
|
|
|
},
|
2023-01-13 00:05:48 +05:30
|
|
|
setBoardHeight() {
|
2023-03-04 22:38:38 +05:30
|
|
|
if (window.innerWidth < breakpoints.md) {
|
|
|
|
this.boardHeight = `${window.innerHeight - contentTop()}px`;
|
|
|
|
} else {
|
|
|
|
this.boardHeight = `${window.innerHeight - this.$el.getBoundingClientRect().top}px`;
|
|
|
|
}
|
2023-01-13 00:05:48 +05:30
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-04-29 21:17:54 +05:30
|
|
|
<div v-cloak data-qa-selector="boards_list">
|
2023-01-13 00:05:48 +05:30
|
|
|
<gl-alert v-if="errorToDisplay" variant="danger" :dismissible="true" @dismiss="unsetError">
|
|
|
|
{{ errorToDisplay }}
|
2020-11-24 15:15:51 +05:30
|
|
|
</gl-alert>
|
2021-02-22 17:27:13 +05:30
|
|
|
<component
|
|
|
|
:is="boardColumnWrapper"
|
2020-06-23 00:09:42 +05:30
|
|
|
v-if="!isSwimlanesOn"
|
2021-02-22 17:27:13 +05:30
|
|
|
ref="list"
|
|
|
|
v-bind="draggableOptions"
|
2022-10-11 01:57:18 +05:30
|
|
|
class="boards-list gl-w-full gl-py-5 gl-pr-3 gl-white-space-nowrap gl-overflow-x-scroll"
|
2023-01-13 00:05:48 +05:30
|
|
|
:style="{ height: boardHeight }"
|
2021-10-27 15:23:28 +05:30
|
|
|
@end="moveList"
|
2020-06-23 00:09:42 +05:30
|
|
|
>
|
2021-11-11 11:23:49 +05:30
|
|
|
<board-column
|
2021-04-17 20:07:23 +05:30
|
|
|
v-for="(list, index) in boardListsToUse"
|
|
|
|
:key="index"
|
2020-06-23 00:09:42 +05:30
|
|
|
ref="board"
|
|
|
|
:list="list"
|
2021-10-27 15:23:28 +05:30
|
|
|
:data-draggable-item-type="$options.draggableItemTypes.list"
|
2020-06-23 00:09:42 +05:30
|
|
|
:disabled="disabled"
|
2022-07-16 23:28:13 +05:30
|
|
|
:class="{ 'gl-xs-display-none!': addColumnFormVisible }"
|
2020-06-23 00:09:42 +05:30
|
|
|
/>
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
<transition name="slide" @after-enter="afterFormEnters">
|
2022-07-16 23:28:13 +05:30
|
|
|
<board-add-new-column v-if="addColumnFormVisible" class="gl-xs-w-full!" />
|
2021-04-17 20:07:23 +05:30
|
|
|
</transition>
|
2021-02-22 17:27:13 +05:30
|
|
|
</component>
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
<epics-swimlanes
|
2021-04-29 21:17:54 +05:30
|
|
|
v-else-if="boardListsToUse.length"
|
2021-03-08 18:12:59 +05:30
|
|
|
ref="swimlanes"
|
|
|
|
:lists="boardListsToUse"
|
|
|
|
:can-admin-list="canAdminList"
|
|
|
|
:disabled="disabled"
|
2023-01-13 00:05:48 +05:30
|
|
|
:style="{ height: boardHeight }"
|
2021-03-08 18:12:59 +05:30
|
|
|
/>
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
<board-content-sidebar v-if="isIssueBoard" data-testid="issue-boards-sidebar" />
|
2021-04-29 21:17:54 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
<epic-board-content-sidebar v-else-if="isEpicBoard" data-testid="epic-boards-sidebar" />
|
2020-06-23 00:09:42 +05:30
|
|
|
</div>
|
|
|
|
</template>
|