diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/assets/javascripts/sidebar/mount_sidebar.js | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/assets/javascripts/sidebar/mount_sidebar.js')
-rw-r--r-- | app/assets/javascripts/sidebar/mount_sidebar.js | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/app/assets/javascripts/sidebar/mount_sidebar.js b/app/assets/javascripts/sidebar/mount_sidebar.js index 2760bf431ea..662edbc4f8d 100644 --- a/app/assets/javascripts/sidebar/mount_sidebar.js +++ b/app/assets/javascripts/sidebar/mount_sidebar.js @@ -1,22 +1,27 @@ import $ from 'jquery'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; -import SidebarTimeTracking from './components/time_tracking/sidebar_time_tracking.vue'; +import createFlash from '~/flash'; +import createDefaultClient from '~/lib/graphql'; +import { + isInIssuePage, + isInDesignPage, + isInIncidentPage, + parseBoolean, +} from '~/lib/utils/common_utils'; +import { __ } from '~/locale'; +import Translate from '../vue_shared/translate'; import SidebarAssignees from './components/assignees/sidebar_assignees.vue'; -import SidebarLabels from './components/labels/sidebar_labels.vue'; -import SidebarReviewers from './components/reviewers/sidebar_reviewers.vue'; import ConfidentialIssueSidebar from './components/confidential/confidential_issue_sidebar.vue'; -import SidebarMoveIssue from './lib/sidebar_move_issue'; +import CopyEmailToClipboard from './components/copy_email_to_clipboard.vue'; +import SidebarLabels from './components/labels/sidebar_labels.vue'; import IssuableLockForm from './components/lock/issuable_lock_form.vue'; import sidebarParticipants from './components/participants/sidebar_participants.vue'; -import sidebarSubscriptions from './components/subscriptions/sidebar_subscriptions.vue'; +import SidebarReviewers from './components/reviewers/sidebar_reviewers.vue'; import SidebarSeverity from './components/severity/sidebar_severity.vue'; -import Translate from '../vue_shared/translate'; -import CopyEmailToClipboard from './components/copy_email_to_clipboard.vue'; -import createDefaultClient from '~/lib/graphql'; -import { isInIssuePage, isInIncidentPage, parseBoolean } from '~/lib/utils/common_utils'; -import createFlash from '~/flash'; -import { __ } from '~/locale'; +import sidebarSubscriptions from './components/subscriptions/sidebar_subscriptions.vue'; +import SidebarTimeTracking from './components/time_tracking/sidebar_time_tracking.vue'; +import SidebarMoveIssue from './lib/sidebar_move_issue'; Vue.use(Translate); Vue.use(VueApollo); @@ -25,6 +30,28 @@ function getSidebarOptions(sidebarOptEl = document.querySelector('.js-sidebar-op return JSON.parse(sidebarOptEl.innerHTML); } +/** + * Extracts the list of assignees with availability information from a hidden input + * field and converts to a key:value pair for use in the sidebar assignees component. + * The assignee username is used as the key and their busy status is the value + * + * e.g { root: 'busy', admin: '' } + * + * @returns {Object} + */ +function getSidebarAssigneeAvailabilityData() { + const sidebarAssigneeEl = document.querySelectorAll('.js-sidebar-assignee-data input'); + return Array.from(sidebarAssigneeEl) + .map((el) => el.dataset) + .reduce( + (acc, { username, availability = '' }) => ({ + ...acc, + [username]: availability, + }), + {}, + ); +} + function mountAssigneesComponent(mediator) { const el = document.getElementById('js-vue-sidebar-assignees'); const apolloProvider = new VueApollo({ @@ -34,6 +61,7 @@ function mountAssigneesComponent(mediator) { if (!el) return; const { iid, fullPath } = getSidebarOptions(); + const assigneeAvailabilityStatus = getSidebarAssigneeAvailabilityData(); // eslint-disable-next-line no-new new Vue({ el, @@ -49,7 +77,9 @@ function mountAssigneesComponent(mediator) { projectPath: fullPath, field: el.dataset.field, signedIn: el.hasAttribute('data-signed-in'), - issuableType: isInIssuePage() || isInIncidentPage() ? 'issue' : 'merge_request', + issuableType: + isInIssuePage() || isInIncidentPage() || isInDesignPage() ? 'issue' : 'merge_request', + assigneeAvailabilityStatus, }, }), }); @@ -78,7 +108,7 @@ function mountReviewersComponent(mediator) { issuableIid: String(iid), projectPath: fullPath, field: el.dataset.field, - issuableType: isInIssuePage() ? 'issue' : 'merge_request', + issuableType: isInIssuePage() || isInDesignPage() ? 'issue' : 'merge_request', }, }), }); |