diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-08 12:17:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-08 12:17:44 +0300 |
commit | 60028378dd5e5e7844810e4a2aa2934a58f738ca (patch) | |
tree | 61db78141f7684741a0ed22ac5b43361c571f4db /app/assets/javascripts/boards | |
parent | 8986fe34837f7af1df90482c049a1578610cdb94 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/boards')
-rw-r--r-- | app/assets/javascripts/boards/boards_util.js | 14 | ||||
-rw-r--r-- | app/assets/javascripts/boards/components/board_form.vue | 30 | ||||
-rw-r--r-- | app/assets/javascripts/boards/components/boards_selector.vue | 3 | ||||
-rw-r--r-- | app/assets/javascripts/boards/index.js | 17 | ||||
-rw-r--r-- | app/assets/javascripts/boards/stores/actions.js | 36 | ||||
-rw-r--r-- | app/assets/javascripts/boards/stores/mutation_types.js | 3 | ||||
-rw-r--r-- | app/assets/javascripts/boards/stores/mutations.js | 17 | ||||
-rw-r--r-- | app/assets/javascripts/boards/stores/state.js | 1 |
8 files changed, 73 insertions, 48 deletions
diff --git a/app/assets/javascripts/boards/boards_util.js b/app/assets/javascripts/boards/boards_util.js index 7e4d3ebb686..96cc774a280 100644 --- a/app/assets/javascripts/boards/boards_util.js +++ b/app/assets/javascripts/boards/boards_util.js @@ -1,5 +1,6 @@ import { sortBy, cloneDeep } from 'lodash'; -import { isGid } from '~/graphql_shared/utils'; +import { TYPE_BOARD, TYPE_ITERATION, TYPE_MILESTONE, TYPE_USER } from '~/graphql_shared/constants'; +import { isGid, convertToGraphQLId } from '~/graphql_shared/utils'; import { ListType, MilestoneIDs, AssigneeFilterType, MilestoneFilterType } from './constants'; export function getMilestone() { @@ -80,19 +81,22 @@ export function formatListsPageInfo(lists) { } export function fullBoardId(boardId) { - return `gid://gitlab/Board/${boardId}`; + if (!boardId) { + return null; + } + return convertToGraphQLId(TYPE_BOARD, boardId); } export function fullIterationId(id) { - return `gid://gitlab/Iteration/${id}`; + return convertToGraphQLId(TYPE_ITERATION, id); } export function fullUserId(id) { - return `gid://gitlab/User/${id}`; + return convertToGraphQLId(TYPE_USER, id); } export function fullMilestoneId(id) { - return `gid://gitlab/Milestone/${id}`; + return convertToGraphQLId(TYPE_MILESTONE, id); } export function fullLabelId(label) { diff --git a/app/assets/javascripts/boards/components/board_form.vue b/app/assets/javascripts/boards/components/board_form.vue index cc048e2af1a..f39f9751c83 100644 --- a/app/assets/javascripts/boards/components/board_form.vue +++ b/app/assets/javascripts/boards/components/board_form.vue @@ -1,11 +1,8 @@ <script> import { GlModal, GlAlert } from '@gitlab/ui'; import { mapGetters, mapActions, mapState } from 'vuex'; -import { TYPE_USER, TYPE_ITERATION, TYPE_MILESTONE } from '~/graphql_shared/constants'; -import { convertToGraphQLId, getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getParameterByName, visitUrl } from '~/lib/utils/url_utility'; import { __, s__ } from '~/locale'; -import { fullLabelId } from '../boards_util'; import { formType } from '../constants'; import createBoardMutation from '../graphql/board_create.mutation.graphql'; @@ -158,33 +155,8 @@ export default { groupPath: this.isGroupBoard ? this.fullPath : undefined, }; }, - issueBoardScopeMutationVariables() { - return { - weight: this.board.weight, - assigneeId: this.board.assignee?.id - ? convertToGraphQLId(TYPE_USER, this.board.assignee.id) - : null, - // Temporarily converting to milestone ID due to https://gitlab.com/gitlab-org/gitlab/-/issues/344779 - milestoneId: this.board.milestone?.id - ? convertToGraphQLId(TYPE_MILESTONE, getIdFromGraphQLId(this.board.milestone.id)) - : null, - // Temporarily converting to iteration ID due to https://gitlab.com/gitlab-org/gitlab/-/issues/344779 - iterationId: this.board.iteration?.id - ? convertToGraphQLId(TYPE_ITERATION, getIdFromGraphQLId(this.board.iteration.id)) - : null, - }; - }, - boardScopeMutationVariables() { - return { - labelIds: this.board.labels.map(fullLabelId), - ...(this.isIssueBoard && this.issueBoardScopeMutationVariables), - }; - }, mutationVariables() { - return { - ...this.baseMutationVariables, - ...(this.scopedIssueBoardFeatureEnabled ? this.boardScopeMutationVariables : {}), - }; + return this.baseMutationVariables; }, }, mounted() { diff --git a/app/assets/javascripts/boards/components/boards_selector.vue b/app/assets/javascripts/boards/components/boards_selector.vue index 5d37cd4930f..91fdfd668fc 100644 --- a/app/assets/javascripts/boards/components/boards_selector.vue +++ b/app/assets/javascripts/boards/components/boards_selector.vue @@ -101,6 +101,7 @@ export default { }, update(data) { const board = data.workspace?.board; + this.setBoardConfig(board); return { ...board, labels: board?.labels?.nodes, @@ -170,7 +171,7 @@ export default { eventHub.$off('showBoardModal', this.showPage); }, methods: { - ...mapActions(['setError']), + ...mapActions(['setError', 'setBoardConfig']), showPage(page) { this.currentPage = page; }, diff --git a/app/assets/javascripts/boards/index.js b/app/assets/javascripts/boards/index.js index d2a64246aa7..b31b56e6839 100644 --- a/app/assets/javascripts/boards/index.js +++ b/app/assets/javascripts/boards/index.js @@ -28,6 +28,12 @@ const apolloProvider = new VueApollo({ function mountBoardApp(el) { const { boardId, groupId, fullPath, rootPath } = el.dataset; + store.dispatch('fetchBoard', { + fullPath, + fullBoardId: fullBoardId(boardId), + boardType: el.dataset.parent, + }); + store.dispatch('setInitialBoardData', { boardId, fullBoardId: fullBoardId(boardId), @@ -35,17 +41,6 @@ function mountBoardApp(el) { boardType: el.dataset.parent, disabled: parseBoolean(el.dataset.disabled) || true, issuableType: issuableTypes.issue, - boardConfig: { - milestoneId: parseInt(el.dataset.boardMilestoneId, 10), - milestoneTitle: el.dataset.boardMilestoneTitle || '', - iterationId: parseInt(el.dataset.boardIterationId, 10), - iterationTitle: el.dataset.boardIterationTitle || '', - assigneeId: el.dataset.boardAssigneeId, - assigneeUsername: el.dataset.boardAssigneeUsername, - labels: el.dataset.labels ? JSON.parse(el.dataset.labels) : [], - labelIds: el.dataset.labelIds ? JSON.parse(el.dataset.labelIds) : [], - weight: el.dataset.boardWeight ? parseInt(el.dataset.boardWeight, 10) : null, - }, }); // eslint-disable-next-line no-new diff --git a/app/assets/javascripts/boards/stores/actions.js b/app/assets/javascripts/boards/stores/actions.js index 1ebfcfc331b..82307da2572 100644 --- a/app/assets/javascripts/boards/stores/actions.js +++ b/app/assets/javascripts/boards/stores/actions.js @@ -36,6 +36,8 @@ import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { queryToObject } from '~/lib/utils/url_utility'; import { s__ } from '~/locale'; import { gqlClient } from '../graphql'; +import projectBoardQuery from '../graphql/project_board.query.graphql'; +import groupBoardQuery from '../graphql/group_board.query.graphql'; import boardLabelsQuery from '../graphql/board_labels.query.graphql'; import groupBoardMilestonesQuery from '../graphql/group_board_milestones.query.graphql'; import groupProjectsQuery from '../graphql/group_projects.query.graphql'; @@ -46,10 +48,44 @@ import projectBoardMilestonesQuery from '../graphql/project_board_milestones.que import * as types from './mutation_types'; export default { + fetchBoard: ({ commit, dispatch }, { fullPath, fullBoardId, boardType }) => { + const variables = { + fullPath, + boardId: fullBoardId, + }; + + return gqlClient + .query({ + query: boardType === BoardType.group ? groupBoardQuery : projectBoardQuery, + variables, + }) + .then(({ data }) => { + const board = data.workspace?.board; + commit(types.RECEIVE_BOARD_SUCCESS, board); + dispatch('setBoardConfig', board); + }) + .catch(() => commit(types.RECEIVE_BOARD_FAILURE)); + }, + setInitialBoardData: ({ commit }, data) => { commit(types.SET_INITIAL_BOARD_DATA, data); }, + setBoardConfig: ({ commit }, board) => { + const config = { + milestoneId: board.milestone?.id || null, + milestoneTitle: board.milestone?.title || null, + iterationId: board.iteration?.id || null, + iterationTitle: board.iteration?.title || null, + assigneeId: board.assignee?.id || null, + assigneeUsername: board.assignee?.username || null, + labels: board.labels?.nodes || [], + labelIds: board.labels?.nodes?.map((label) => label.id) || [], + weight: board.weight, + }; + commit(types.SET_BOARD_CONFIG, config); + }, + setActiveId({ commit }, { id, sidebarType }) { commit(types.SET_ACTIVE_ID, { id, sidebarType }); }, diff --git a/app/assets/javascripts/boards/stores/mutation_types.js b/app/assets/javascripts/boards/stores/mutation_types.js index 31b78014525..668a3b5e0f9 100644 --- a/app/assets/javascripts/boards/stores/mutation_types.js +++ b/app/assets/javascripts/boards/stores/mutation_types.js @@ -1,4 +1,7 @@ +export const RECEIVE_BOARD_SUCCESS = 'RECEIVE_BOARD_SUCCESS'; +export const RECEIVE_BOARD_FAILURE = 'RECEIVE_BOARD_FAILURE'; export const SET_INITIAL_BOARD_DATA = 'SET_INITIAL_BOARD_DATA'; +export const SET_BOARD_CONFIG = 'SET_BOARD_CONFIG'; export const SET_FILTERS = 'SET_FILTERS'; export const CREATE_LIST_SUCCESS = 'CREATE_LIST_SUCCESS'; export const CREATE_LIST_FAILURE = 'CREATE_LIST_FAILURE'; diff --git a/app/assets/javascripts/boards/stores/mutations.js b/app/assets/javascripts/boards/stores/mutations.js index 2a2ce7652e6..9a50dcf05b8 100644 --- a/app/assets/javascripts/boards/stores/mutations.js +++ b/app/assets/javascripts/boards/stores/mutations.js @@ -33,10 +33,20 @@ export const addItemToList = ({ state, listId, itemId, moveBeforeId, moveAfterId }; export default { + [mutationTypes.RECEIVE_BOARD_SUCCESS]: (state, board) => { + state.board = { + ...board, + labels: board?.labels?.nodes || [], + }; + }, + + [mutationTypes.RECEIVE_BOARD_FAILURE]: (state) => { + state.error = s__('Boards|An error occurred while fetching the board. Please reload the page.'); + }, + [mutationTypes.SET_INITIAL_BOARD_DATA](state, data) { const { allowSubEpics, - boardConfig, boardId, boardType, disabled, @@ -45,7 +55,6 @@ export default { issuableType, } = data; state.allowSubEpics = allowSubEpics; - state.boardConfig = boardConfig; state.boardId = boardId; state.boardType = boardType; state.disabled = disabled; @@ -54,6 +63,10 @@ export default { state.issuableType = issuableType; }, + [mutationTypes.SET_BOARD_CONFIG](state, boardConfig) { + state.boardConfig = boardConfig; + }, + [mutationTypes.RECEIVE_BOARD_LISTS_SUCCESS]: (state, lists) => { state.boardLists = lists; }, diff --git a/app/assets/javascripts/boards/stores/state.js b/app/assets/javascripts/boards/stores/state.js index 80c51c966d2..7af4e5a8798 100644 --- a/app/assets/javascripts/boards/stores/state.js +++ b/app/assets/javascripts/boards/stores/state.js @@ -1,6 +1,7 @@ import { inactiveId, ListType } from '~/boards/constants'; export default () => ({ + board: {}, boardType: null, issuableType: null, fullPath: null, |