2021-01-03 14:25:43 +05:30
|
|
|
<script>
|
|
|
|
// NOTE! For the first iteration, we are simply copying the implementation of Assignees
|
|
|
|
// It will soon be overhauled in Issue https://gitlab.com/gitlab-org/gitlab/-/issues/233736
|
2021-03-08 18:12:59 +05:30
|
|
|
import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests';
|
2021-09-30 23:02:18 +05:30
|
|
|
import createFlash from '~/flash';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { __ } from '~/locale';
|
2021-01-03 14:25:43 +05:30
|
|
|
import eventHub from '~/sidebar/event_hub';
|
|
|
|
import Store from '~/sidebar/stores/sidebar_store';
|
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
|
|
|
import ReviewerTitle from './reviewer_title.vue';
|
|
|
|
import Reviewers from './reviewers.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'SidebarReviewers',
|
|
|
|
components: {
|
|
|
|
ReviewerTitle,
|
|
|
|
Reviewers,
|
|
|
|
},
|
|
|
|
mixins: [glFeatureFlagsMixin()],
|
|
|
|
props: {
|
|
|
|
mediator: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
field: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
issuableType: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'issue',
|
|
|
|
},
|
|
|
|
issuableIid: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
projectPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
store: new Store(),
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
relativeUrlRoot() {
|
|
|
|
return gon.relative_url_root ?? '';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.removeReviewer = this.store.removeReviewer.bind(this.store);
|
|
|
|
this.addReviewer = this.store.addReviewer.bind(this.store);
|
|
|
|
this.removeAllReviewers = this.store.removeAllReviewers.bind(this.store);
|
|
|
|
|
|
|
|
// Get events from deprecatedJQueryDropdown
|
|
|
|
eventHub.$on('sidebar.removeReviewer', this.removeReviewer);
|
|
|
|
eventHub.$on('sidebar.addReviewer', this.addReviewer);
|
|
|
|
eventHub.$on('sidebar.removeAllReviewers', this.removeAllReviewers);
|
|
|
|
eventHub.$on('sidebar.saveReviewers', this.saveReviewers);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
eventHub.$off('sidebar.removeReviewer', this.removeReviewer);
|
|
|
|
eventHub.$off('sidebar.addReviewer', this.addReviewer);
|
|
|
|
eventHub.$off('sidebar.removeAllReviewers', this.removeAllReviewers);
|
|
|
|
eventHub.$off('sidebar.saveReviewers', this.saveReviewers);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
saveReviewers() {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
this.mediator
|
|
|
|
.saveReviewers(this.field)
|
|
|
|
.then(() => {
|
|
|
|
this.loading = false;
|
2021-03-08 18:12:59 +05:30
|
|
|
refreshUserMergeRequestCounts();
|
2021-01-03 14:25:43 +05:30
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false;
|
2021-09-30 23:02:18 +05:30
|
|
|
return createFlash({
|
|
|
|
message: __('Error occurred when saving reviewers'),
|
|
|
|
});
|
2021-01-03 14:25:43 +05:30
|
|
|
});
|
|
|
|
},
|
2021-03-11 19:13:27 +05:30
|
|
|
requestReview(data) {
|
|
|
|
this.mediator.requestReview(data);
|
|
|
|
},
|
2021-01-03 14:25:43 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<reviewer-title
|
|
|
|
:number-of-reviewers="store.reviewers.length"
|
|
|
|
:loading="loading || store.isFetching.reviewers"
|
|
|
|
:editable="store.editable"
|
|
|
|
/>
|
|
|
|
<reviewers
|
|
|
|
v-if="!store.isFetching.reviewers"
|
|
|
|
:root-path="relativeUrlRoot"
|
|
|
|
:users="store.reviewers"
|
|
|
|
:editable="store.editable"
|
|
|
|
:issuable-type="issuableType"
|
2021-03-11 19:13:27 +05:30
|
|
|
@request-review="requestReview"
|
2021-01-03 14:25:43 +05:30
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|