diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-21 21:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-21 21:10:08 +0300 |
commit | 5d41ea8c8e83ff6054ba4303ec8dc9bc33556602 (patch) | |
tree | f69079c9fac34f1e5e785d1f18d2f9ad339e4cbc /app/assets/javascripts/sidebar | |
parent | a09c6d7e91de9abab7e2ea8dffce1cbb89bf95d8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/sidebar')
15 files changed, 5 insertions, 347 deletions
diff --git a/app/assets/javascripts/sidebar/components/assignees/assignees.vue b/app/assets/javascripts/sidebar/components/assignees/assignees.vue index 3602b5ec4f6..29ea390a81d 100644 --- a/app/assets/javascripts/sidebar/components/assignees/assignees.vue +++ b/app/assets/javascripts/sidebar/components/assignees/assignees.vue @@ -39,9 +39,6 @@ export default { assignSelf() { this.$emit('assign-self'); }, - toggleAttentionRequested(data) { - this.$emit('toggle-attention-requested', data); - }, }, }; </script> @@ -66,12 +63,7 @@ export default { </template> </span> - <uncollapsed-assignee-list - v-else - :users="sortedAssigness" - :issuable-type="issuableType" - @toggle-attention-requested="toggleAttentionRequested" - /> + <uncollapsed-assignee-list v-else :users="sortedAssigness" :issuable-type="issuableType" /> </div> </div> </template> diff --git a/app/assets/javascripts/sidebar/components/assignees/issuable_assignees.vue b/app/assets/javascripts/sidebar/components/assignees/issuable_assignees.vue index 59a4eb54bbe..a94dd128a1a 100644 --- a/app/assets/javascripts/sidebar/components/assignees/issuable_assignees.vue +++ b/app/assets/javascripts/sidebar/components/assignees/issuable_assignees.vue @@ -32,11 +32,6 @@ export default { return this.users.length === 0; }, }, - methods: { - toggleAttentionRequested(data) { - this.$emit('toggle-attention-requested', data); - }, - }, }; </script> @@ -66,7 +61,6 @@ export default { :users="users" :issuable-type="issuableType" class="gl-text-gray-800 hide-collapsed" - @toggle-attention-requested="toggleAttentionRequested" /> </div> </template> diff --git a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue index e596d6292bf..18b26c7d8bd 100644 --- a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue +++ b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.vue @@ -125,9 +125,6 @@ export default { availability: this.assigneeAvailabilityStatus[username] || '', })); }, - toggleAttentionRequested(data) { - this.mediator.toggleAttentionRequested('assignee', data); - }, }, }; </script> @@ -155,7 +152,6 @@ export default { :editable="store.editable" :issuable-type="issuableType" @assign-self="assignSelf" - @toggle-attention-requested="toggleAttentionRequested" /> </div> </template> diff --git a/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue b/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue index b6260418837..0e4d4c74160 100644 --- a/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue +++ b/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue @@ -2,7 +2,6 @@ import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { IssuableType } from '~/issues/constants'; import { __, sprintf } from '~/locale'; -import AttentionRequestedToggle from '../attention_requested_toggle.vue'; import AssigneeAvatarLink from './assignee_avatar_link.vue'; import UserNameWithStatus from './user_name_with_status.vue'; @@ -10,7 +9,6 @@ const DEFAULT_RENDER_COUNT = 5; export default { components: { - AttentionRequestedToggle, AssigneeAvatarLink, UserNameWithStatus, }, @@ -46,10 +44,6 @@ export default { return this.users.length - DEFAULT_RENDER_COUNT; }, uncollapsedUsers() { - if (this.showVerticalList) { - return this.users; - } - const uncollapsedLength = this.showLess ? Math.min(this.users.length, DEFAULT_RENDER_COUNT) : this.users.length; @@ -58,9 +52,6 @@ export default { username() { return `@${this.firstUser.username}`; }, - showVerticalList() { - return this.glFeatures.mrAttentionRequests && this.isMergeRequest; - }, isMergeRequest() { return this.issuableType === IssuableType.MergeRequest; }, @@ -75,9 +66,6 @@ export default { } return u?.status?.availability || ''; }, - toggleAttentionRequested(data) { - this.$emit('toggle-attention-requested', data); - }, }, }; </script> @@ -96,7 +84,7 @@ export default { <assignee-avatar-link :user="user" :issuable-type="issuableType" - :tooltip-has-name="!showVerticalList" + :tooltip-has-name="!isMergeRequest" class="gl-word-break-word" data-css-area="user" > @@ -107,14 +95,6 @@ export default { <user-name-with-status :name="user.name" :availability="userAvailability(user)" /> </div> </assignee-avatar-link> - <attention-requested-toggle - v-if="showVerticalList" - :user="user" - type="assignee" - class="gl-mr-2" - data-css-area="attention" - @toggle-attention-requested="toggleAttentionRequested" - /> </div> </div> <div v-if="renderShowMoreSection" class="user-list-more gl-hover-text-blue-800"> diff --git a/app/assets/javascripts/sidebar/components/attention_requested_toggle.vue b/app/assets/javascripts/sidebar/components/attention_requested_toggle.vue deleted file mode 100644 index 974ad189f32..00000000000 --- a/app/assets/javascripts/sidebar/components/attention_requested_toggle.vue +++ /dev/null @@ -1,105 +0,0 @@ -<script> -import { GlButton, GlTooltipDirective } from '@gitlab/ui'; -import { __ } from '~/locale'; -import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants'; - -export default { - i18n: { - addAttentionRequest: __('Add attention request'), - removeAttentionRequest: __('Remove attention request'), - attentionRequestedNoPermission: __('Attention requested'), - noAttentionRequestedNoPermission: __('No attention request'), - }, - components: { - GlButton, - }, - directives: { - GlTooltip: GlTooltipDirective, - }, - props: { - type: { - type: String, - required: true, - }, - user: { - type: Object, - required: true, - }, - }, - data() { - return { - loading: false, - }; - }, - computed: { - tooltipTitle() { - if (this.user.attention_requested) { - if (this.user.can_update_merge_request) { - return this.$options.i18n.removeAttentionRequest; - } - - return this.$options.i18n.attentionRequestedNoPermission; - } - - if (this.user.can_update_merge_request) { - return this.$options.i18n.addAttentionRequest; - } - - return this.$options.i18n.noAttentionRequestedNoPermission; - }, - request() { - const state = { - selected: false, - icon: 'attention', - direction: 'add', - }; - - if (this.user.attention_requested) { - Object.assign(state, { - selected: true, - icon: 'attention-solid', - direction: 'remove', - }); - } - - return state; - }, - }, - methods: { - toggleAttentionRequired() { - if (this.loading || !this.user.can_update_merge_request) return; - - this.$root.$emit(BV_HIDE_TOOLTIP); - this.loading = true; - this.$emit('toggle-attention-requested', { - user: this.user, - callback: this.toggleAttentionRequiredComplete, - direction: this.request.direction, - }); - }, - toggleAttentionRequiredComplete() { - this.loading = false; - }, - }, -}; -</script> - -<template> - <div> - <span - v-gl-tooltip.left.viewport="tooltipTitle" - class="gl-display-inline-block js-attention-request-toggle" - > - <gl-button - :loading="loading" - :selected="request.selected" - :icon="request.icon" - :aria-label="tooltipTitle" - :class="{ 'gl-pointer-events-none': !user.can_update_merge_request }" - size="small" - category="tertiary" - @click="toggleAttentionRequired" - /> - </span> - </div> -</template> diff --git a/app/assets/javascripts/sidebar/components/reviewers/reviewers.vue b/app/assets/javascripts/sidebar/components/reviewers/reviewers.vue index b07fd944ff9..5729b958b5d 100644 --- a/app/assets/javascripts/sidebar/components/reviewers/reviewers.vue +++ b/app/assets/javascripts/sidebar/components/reviewers/reviewers.vue @@ -49,9 +49,6 @@ export default { requestReview(data) { this.$emit('request-review', data); }, - toggleAttentionRequested(data) { - this.$emit('toggle-attention-requested', data); - }, }, }; </script> @@ -73,7 +70,6 @@ export default { :root-path="rootPath" :issuable-type="issuableType" @request-review="requestReview" - @toggle-attention-requested="toggleAttentionRequested" /> </div> </div> diff --git a/app/assets/javascripts/sidebar/components/reviewers/sidebar_reviewers.vue b/app/assets/javascripts/sidebar/components/reviewers/sidebar_reviewers.vue index 2ea63219e92..e414aaf719b 100644 --- a/app/assets/javascripts/sidebar/components/reviewers/sidebar_reviewers.vue +++ b/app/assets/javascripts/sidebar/components/reviewers/sidebar_reviewers.vue @@ -88,9 +88,6 @@ export default { requestReview(data) { this.mediator.requestReview(data); }, - toggleAttentionRequested(data) { - this.mediator.toggleAttentionRequested('reviewer', data); - }, }, }; </script> @@ -109,7 +106,6 @@ export default { :editable="store.editable" :issuable-type="issuableType" @request-review="requestReview" - @toggle-attention-requested="toggleAttentionRequested" /> </div> </template> diff --git a/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue b/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue index 2f58e11c00f..3aeb49eb422 100644 --- a/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue +++ b/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue @@ -1,8 +1,6 @@ <script> import { GlButton, GlTooltipDirective, GlIcon } from '@gitlab/ui'; -import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { __, sprintf, s__ } from '~/locale'; -import AttentionRequestedToggle from '../attention_requested_toggle.vue'; import ReviewerAvatarLink from './reviewer_avatar_link.vue'; const LOADING_STATE = 'loading'; @@ -16,12 +14,10 @@ export default { GlButton, GlIcon, ReviewerAvatarLink, - AttentionRequestedToggle, }, directives: { GlTooltip: GlTooltipDirective, }, - mixins: [glFeatureFlagsMixin()], props: { users: { type: Array, @@ -80,9 +76,6 @@ export default { this.loadingStates[userId] = null; } }, - toggleAttentionRequested(data) { - this.$emit('toggle-attention-requested', data); - }, }, LOADING_STATE, SUCCESS_STATE, @@ -96,7 +89,6 @@ export default { :key="user.id" :class="{ 'gl-mb-3': index !== users.length - 1, - 'attention-requests': glFeatures.mrAttentionRequests, }" class="gl-display-grid gl-align-items-center reviewer-grid gl-mr-2" data-testid="reviewer" @@ -112,14 +104,6 @@ export default { {{ user.name }} </div> </reviewer-avatar-link> - <attention-requested-toggle - v-if="glFeatures.mrAttentionRequests" - :user="user" - type="reviewer" - class="gl-mr-2" - data-css-area="attention" - @toggle-attention-requested="toggleAttentionRequested" - /> <gl-icon v-if="user.approved" v-gl-tooltip.left @@ -137,9 +121,7 @@ export default { data-testid="re-request-success" /> <gl-button - v-else-if=" - user.can_update_merge_request && user.reviewed && !glFeatures.mrAttentionRequests - " + v-else-if="user.can_update_merge_request && user.reviewed" v-gl-tooltip.left :title="$options.i18n.reRequestReview" :aria-label="$options.i18n.reRequestReview" diff --git a/app/assets/javascripts/sidebar/mount_sidebar.js b/app/assets/javascripts/sidebar/mount_sidebar.js index 3f82fe5ce87..84e7c0f876a 100644 --- a/app/assets/javascripts/sidebar/mount_sidebar.js +++ b/app/assets/javascripts/sidebar/mount_sidebar.js @@ -27,8 +27,6 @@ import trackShowInviteMemberLink from '~/sidebar/track_invite_members'; import { DropdownVariant } from '~/vue_shared/components/sidebar/labels_select_vue/constants'; import LabelsSelectWidget from '~/vue_shared/components/sidebar/labels_select_widget/labels_select_root.vue'; import { LabelType } from '~/vue_shared/components/sidebar/labels_select_widget/constants'; -import eventHub from '~/sidebar/event_hub'; -import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; import Translate from '../vue_shared/translate'; import SidebarAssignees from './components/assignees/sidebar_assignees.vue'; import CopyEmailToClipboard from './components/copy_email_to_clipboard.vue'; @@ -652,13 +650,6 @@ export function mountSidebar(mediator, store) { mountSeverityComponent(); mountEscalationStatusComponent(); - - if (window.gon?.features?.mrAttentionRequests) { - eventHub.$on('removeCurrentUserAttentionRequested', () => { - mediator.removeCurrentUserAttentionRequested(); - refreshUserMergeRequestCounts(); - }); - } } export { getSidebarOptions }; diff --git a/app/assets/javascripts/sidebar/queries/remove_attention_request.mutation.graphql b/app/assets/javascripts/sidebar/queries/remove_attention_request.mutation.graphql deleted file mode 100644 index d9b9c04fd63..00000000000 --- a/app/assets/javascripts/sidebar/queries/remove_attention_request.mutation.graphql +++ /dev/null @@ -1,7 +0,0 @@ -mutation mergeRequestRemoveAttentionRequest($projectPath: ID!, $iid: String!, $userId: UserID!) { - mergeRequestRemoveAttentionRequest( - input: { projectPath: $projectPath, iid: $iid, userId: $userId } - ) { - errors - } -} diff --git a/app/assets/javascripts/sidebar/queries/request_attention.mutation.graphql b/app/assets/javascripts/sidebar/queries/request_attention.mutation.graphql deleted file mode 100644 index 99a86e4fe5c..00000000000 --- a/app/assets/javascripts/sidebar/queries/request_attention.mutation.graphql +++ /dev/null @@ -1,5 +0,0 @@ -mutation mergeRequestRequestAttention($projectPath: ID!, $iid: String!, $userId: UserID!) { - mergeRequestRequestAttention(input: { projectPath: $projectPath, iid: $iid, userId: $userId }) { - errors - } -} diff --git a/app/assets/javascripts/sidebar/services/sidebar_service.js b/app/assets/javascripts/sidebar/services/sidebar_service.js index 05268a5c89c..beacdeb559c 100644 --- a/app/assets/javascripts/sidebar/services/sidebar_service.js +++ b/app/assets/javascripts/sidebar/services/sidebar_service.js @@ -5,8 +5,6 @@ import createGqClient, { fetchPolicies } from '~/lib/graphql'; import axios from '~/lib/utils/axios_utils'; import reviewerRereviewMutation from '../queries/reviewer_rereview.mutation.graphql'; import sidebarDetailsMRQuery from '../queries/sidebar_details_mr.query.graphql'; -import requestAttentionMutation from '../queries/request_attention.mutation.graphql'; -import removeAttentionRequestMutation from '../queries/remove_attention_request.mutation.graphql'; const queries = { merge_request: sidebarDetailsMRQuery, @@ -93,25 +91,4 @@ export default class SidebarService { }, }); } - - requestAttention(userId) { - return gqClient.mutate({ - mutation: requestAttentionMutation, - variables: { - userId: convertToGraphQLId(TYPE_USER, `${userId}`), - projectPath: this.fullPath, - iid: this.iid.toString(), - }, - }); - } - removeAttentionRequest(userId) { - return gqClient.mutate({ - mutation: removeAttentionRequestMutation, - variables: { - userId: convertToGraphQLId(TYPE_USER, `${userId}`), - projectPath: this.fullPath, - iid: this.iid.toString(), - }, - }); - } } diff --git a/app/assets/javascripts/sidebar/sidebar_bundle.js b/app/assets/javascripts/sidebar/sidebar_bundle.js index 74ab65e4e04..1be670f7590 100644 --- a/app/assets/javascripts/sidebar/sidebar_bundle.js +++ b/app/assets/javascripts/sidebar/sidebar_bundle.js @@ -3,17 +3,7 @@ import Mediator from './sidebar_mediator'; export default (store) => { const mediator = new Mediator(getSidebarOptions()); - mediator - .fetch() - .then(() => { - if (window.gon?.features?.mrAttentionRequests) { - return import('~/attention_requests'); - } - - return null; - }) - .then((module) => module?.initSideNavPopover()) - .catch(() => {}); + mediator.fetch(); mountSidebar(mediator, store); }; diff --git a/app/assets/javascripts/sidebar/sidebar_mediator.js b/app/assets/javascripts/sidebar/sidebar_mediator.js index 4df00903ab6..f7c93b6903c 100644 --- a/app/assets/javascripts/sidebar/sidebar_mediator.js +++ b/app/assets/javascripts/sidebar/sidebar_mediator.js @@ -1,8 +1,7 @@ import Store from '~/sidebar/stores/sidebar_store'; import createFlash from '~/flash'; -import { __, sprintf } from '~/locale'; +import { __ } from '~/locale'; import toast from '~/vue_shared/plugins/global_toast'; -import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; import { visitUrl } from '../lib/utils/url_utility'; import Service from './services/sidebar_service'; @@ -42,7 +41,6 @@ export default class SidebarMediator { const data = { assignee_ids: assignees }; try { - const { currentUserHasAttention } = this.store; const res = await this.service.update(field, data); this.store.overwrite('assignees', res.data.assignees); @@ -51,10 +49,6 @@ export default class SidebarMediator { this.store.overwrite('reviewers', res.data.reviewers); } - if (currentUserHasAttention && this.store.isAddingAssignee) { - toast(__('Assigned user(s). Your attention request was removed.')); - } - return Promise.resolve(res); } catch (e) { return Promise.reject(e); @@ -70,16 +64,11 @@ export default class SidebarMediator { const data = { reviewer_ids: reviewers }; try { - const { currentUserHasAttention } = this.store; const res = await this.service.update(field, data); this.store.overwrite('reviewers', res.data.reviewers); this.store.overwrite('assignees', res.data.assignees); - if (currentUserHasAttention && this.store.isAddingAssignee) { - toast(__('Requested review. Your attention request was removed.')); - } - return Promise.resolve(res); } catch (e) { return Promise.reject(); @@ -97,80 +86,6 @@ export default class SidebarMediator { .catch(() => callback(userId, false)); } - removeCurrentUserAttentionRequested() { - const currentUserId = gon.current_user_id; - - const currentUserReviewer = this.store.findReviewer({ id: currentUserId }); - const currentUserAssignee = this.store.findAssignee({ id: currentUserId }); - - if (currentUserReviewer?.attention_requested || currentUserAssignee?.attention_requested) { - // Update current users attention_requested state - this.store.updateReviewer(currentUserId, 'attention_requested'); - this.store.updateAssignee(currentUserId, 'attention_requested'); - } - } - - async toggleAttentionRequested(type, { user, callback, direction }) { - const mutations = { - add: (id) => this.service.requestAttention(id), - remove: (id) => this.service.removeAttentionRequest(id), - }; - - try { - const isReviewer = type === 'reviewer'; - const reviewerOrAssignee = isReviewer - ? this.store.findReviewer(user) - : this.store.findAssignee(user); - - await mutations[direction]?.(user.id); - - if (reviewerOrAssignee.attention_requested) { - toast( - sprintf(__('Removed attention request from @%{username}'), { - username: user.username, - }), - ); - } else { - const currentUserId = gon.current_user_id; - const { currentUserHasAttention } = this.store; - - if (currentUserId !== user.id) { - this.removeCurrentUserAttentionRequested(); - } - - toast( - currentUserHasAttention && currentUserId !== user.id - ? sprintf( - __( - 'Requested attention from @%{username}. Your own attention request was removed.', - ), - { username: user.username }, - ) - : sprintf(__('Requested attention from @%{username}'), { username: user.username }), - ); - } - - this.store.updateReviewer(user.id, 'attention_requested'); - this.store.updateAssignee(user.id, 'attention_requested'); - - refreshUserMergeRequestCounts(); - callback(); - } catch (error) { - callback(); - createFlash({ - message: sprintf(__('Updating the attention request for %{username} failed.'), { - username: user.username, - }), - error, - captureError: true, - actionConfig: { - title: __('Try again'), - clickHandler: () => this.toggleAttentionRequired(type, { user, callback, direction }), - }, - }); - } - } - setMoveToProjectId(projectId) { this.store.setMoveToProjectId(projectId); } diff --git a/app/assets/javascripts/sidebar/stores/sidebar_store.js b/app/assets/javascripts/sidebar/stores/sidebar_store.js index 971e2a15c68..e2581a8f30e 100644 --- a/app/assets/javascripts/sidebar/stores/sidebar_store.js +++ b/app/assets/javascripts/sidebar/stores/sidebar_store.js @@ -19,9 +19,7 @@ export default class SidebarStore { this.humanTimeSpent = ''; this.timeTrackingLimitToHours = timeTrackingLimitToHours; this.assignees = []; - this.addingAssignees = []; this.reviewers = []; - this.addingReviewers = []; this.isFetching = { assignees: true, reviewers: true, @@ -77,20 +75,12 @@ export default class SidebarStore { if (!this.findAssignee(assignee)) { this.changing = true; this.assignees.push(assignee); - - if (assignee.id !== this.currentUser.id) { - this.addingAssignees.push(assignee.id); - } } } addReviewer(reviewer) { if (!this.findReviewer(reviewer)) { this.reviewers.push(reviewer); - - if (reviewer.id !== this.currentUser.id) { - this.addingReviewers.push(reviewer.id); - } } } @@ -126,14 +116,12 @@ export default class SidebarStore { if (assignee) { this.changing = true; this.assignees = this.assignees.filter(({ id }) => id !== assignee.id); - this.addingAssignees = this.addingAssignees.filter(({ id }) => id !== assignee.id); } } removeReviewer(reviewer) { if (reviewer) { this.reviewers = this.reviewers.filter(({ id }) => id !== reviewer.id); - this.addingReviewers = this.addingReviewers.filter(({ id }) => id !== reviewer.id); } } @@ -161,26 +149,4 @@ export default class SidebarStore { setMoveToProjectId(moveToProjectId) { this.moveToProjectId = moveToProjectId; } - - get currentUserHasAttention() { - if (!window.gon?.features?.mrAttentionRequests || !this.isMergeRequest) return false; - - const currentUserId = this.currentUser.id; - const currentUserReviewer = this.findReviewer({ id: currentUserId }); - const currentUserAssignee = this.findAssignee({ id: currentUserId }); - - return currentUserReviewer?.attention_requested || currentUserAssignee?.attention_requested; - } - - get isAddingAssignee() { - return this.addingAssignees.length > 0; - } - - get isAddingReviewer() { - return this.addingReviewers.length > 0; - } - - get isMergeRequest() { - return this.issuableType === 'merge_request'; - } } |