2020-06-23 00:09:42 +05:30
|
|
|
<script>
|
|
|
|
import { GlCollapse, GlButton, GlPopover } from '@gitlab/ui';
|
2022-04-04 11:22:00 +05:30
|
|
|
import { getCookie, setCookie, parseBoolean, isLoggedIn } from '~/lib/utils/common_utils';
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
import { s__ } from '~/locale';
|
|
|
|
import Participants from '~/sidebar/components/participants/participants.vue';
|
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
|
|
|
import { ACTIVE_DISCUSSION_SOURCE_TYPES } from '../constants';
|
2020-06-23 00:09:42 +05:30
|
|
|
import updateActiveDiscussionMutation from '../graphql/mutations/update_active_discussion.mutation.graphql';
|
|
|
|
import { extractDiscussions, extractParticipants } from '../utils/design_management_utils';
|
|
|
|
import DesignDiscussion from './design_notes/design_discussion.vue';
|
2022-03-02 08:16:31 +05:30
|
|
|
import DesignNoteSignedOut from './design_notes/design_note_signed_out.vue';
|
2020-11-24 15:15:51 +05:30
|
|
|
import DesignTodoButton from './design_todo_button.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
DesignDiscussion,
|
2022-03-02 08:16:31 +05:30
|
|
|
DesignNoteSignedOut,
|
2020-06-23 00:09:42 +05:30
|
|
|
Participants,
|
|
|
|
GlCollapse,
|
|
|
|
GlButton,
|
|
|
|
GlPopover,
|
2020-11-24 15:15:51 +05:30
|
|
|
DesignTodoButton,
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
mixins: [glFeatureFlagsMixin()],
|
2021-03-08 18:12:59 +05:30
|
|
|
inject: {
|
|
|
|
projectPath: {
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
issueIid: {
|
|
|
|
default: '',
|
|
|
|
},
|
2022-03-02 08:16:31 +05:30
|
|
|
registerPath: {
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
signInPath: {
|
|
|
|
default: '',
|
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
props: {
|
|
|
|
design: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
resolvedDiscussionsExpanded: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
markdownPreviewPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-04-04 11:22:00 +05:30
|
|
|
isResolvedCommentsPopoverHidden: parseBoolean(getCookie(this.$options.cookieKey)),
|
2020-06-23 00:09:42 +05:30
|
|
|
discussionWithOpenForm: '',
|
2022-03-02 08:16:31 +05:30
|
|
|
isLoggedIn: isLoggedIn(),
|
2020-06-23 00:09:42 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
discussions() {
|
|
|
|
return extractDiscussions(this.design.discussions);
|
|
|
|
},
|
|
|
|
issue() {
|
|
|
|
return {
|
|
|
|
...this.design.issue,
|
|
|
|
webPath: this.design.issue.webPath.substr(1),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
discussionParticipants() {
|
2020-10-24 23:57:45 +05:30
|
|
|
return extractParticipants(this.issue.participants.nodes);
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
resolvedDiscussions() {
|
2021-03-08 18:12:59 +05:30
|
|
|
return this.discussions.filter((discussion) => discussion.resolved);
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
unresolvedDiscussions() {
|
2021-03-08 18:12:59 +05:30
|
|
|
return this.discussions.filter((discussion) => !discussion.resolved);
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
resolvedCommentsToggleIcon() {
|
|
|
|
return this.resolvedDiscussionsExpanded ? 'chevron-down' : 'chevron-right';
|
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
isResolvedCommentsPopoverHidden(newVal) {
|
|
|
|
if (!newVal) {
|
|
|
|
this.$refs.resolvedComments.scrollIntoView();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (!this.isResolvedCommentsPopoverHidden && this.$refs.resolvedComments) {
|
|
|
|
this.$refs.resolvedComments.$el.scrollIntoView();
|
|
|
|
}
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleSidebarClick() {
|
|
|
|
this.isResolvedCommentsPopoverHidden = true;
|
2022-04-04 11:22:00 +05:30
|
|
|
setCookie(this.$options.cookieKey, 'true', { expires: 365 * 10 });
|
2020-06-23 00:09:42 +05:30
|
|
|
this.updateActiveDiscussion();
|
|
|
|
},
|
|
|
|
updateActiveDiscussion(id) {
|
|
|
|
this.$apollo.mutate({
|
|
|
|
mutation: updateActiveDiscussionMutation,
|
|
|
|
variables: {
|
|
|
|
id,
|
|
|
|
source: ACTIVE_DISCUSSION_SOURCE_TYPES.discussion,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
closeCommentForm() {
|
|
|
|
this.comment = '';
|
|
|
|
this.$emit('closeCommentForm');
|
|
|
|
},
|
|
|
|
updateDiscussionWithOpenForm(id) {
|
|
|
|
this.discussionWithOpenForm = id;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
resolveCommentsToggleText: s__('DesignManagement|Resolved Comments'),
|
|
|
|
cookieKey: 'hide_design_resolved_comments_popover',
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-01-03 14:25:43 +05:30
|
|
|
<div class="image-notes gl-pt-0" @click="handleSidebarClick">
|
2020-11-24 15:15:51 +05:30
|
|
|
<div
|
|
|
|
class="gl-py-4 gl-mb-4 gl-display-flex gl-justify-content-space-between gl-align-items-center gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
|
|
|
|
>
|
2021-01-03 14:25:43 +05:30
|
|
|
<span>{{ __('To Do') }}</span>
|
2020-11-24 15:15:51 +05:30
|
|
|
<design-todo-button :design="design" @error="$emit('todoError', $event)" />
|
|
|
|
</div>
|
2020-06-23 00:09:42 +05:30
|
|
|
<h2 class="gl-font-weight-bold gl-mt-0">
|
|
|
|
{{ issue.title }}
|
|
|
|
</h2>
|
|
|
|
<a
|
2020-10-24 23:57:45 +05:30
|
|
|
class="gl-text-gray-400 gl-text-decoration-none gl-mb-6 gl-display-block"
|
2020-06-23 00:09:42 +05:30
|
|
|
:href="issue.webUrl"
|
|
|
|
>{{ issue.webPath }}</a
|
|
|
|
>
|
|
|
|
<participants
|
|
|
|
:participants="discussionParticipants"
|
|
|
|
:show-participant-label="false"
|
|
|
|
class="gl-mb-4"
|
|
|
|
/>
|
|
|
|
<h2
|
2022-03-02 08:16:31 +05:30
|
|
|
v-if="isLoggedIn && unresolvedDiscussions.length === 0"
|
2020-06-23 00:09:42 +05:30
|
|
|
class="new-discussion-disclaimer gl-font-base gl-m-0 gl-mb-4"
|
|
|
|
data-testid="new-discussion-disclaimer"
|
|
|
|
>
|
|
|
|
{{ s__("DesignManagement|Click the image where you'd like to start a new discussion") }}
|
|
|
|
</h2>
|
2022-03-02 08:16:31 +05:30
|
|
|
<design-note-signed-out
|
|
|
|
v-if="!isLoggedIn"
|
|
|
|
class="gl-mb-4"
|
|
|
|
:register-path="registerPath"
|
|
|
|
:sign-in-path="signInPath"
|
|
|
|
:is-add-discussion="true"
|
|
|
|
/>
|
2020-06-23 00:09:42 +05:30
|
|
|
<design-discussion
|
|
|
|
v-for="discussion in unresolvedDiscussions"
|
|
|
|
:key="discussion.id"
|
|
|
|
:discussion="discussion"
|
|
|
|
:design-id="$route.params.id"
|
|
|
|
:noteable-id="design.id"
|
|
|
|
:markdown-preview-path="markdownPreviewPath"
|
2022-03-02 08:16:31 +05:30
|
|
|
:register-path="registerPath"
|
|
|
|
:sign-in-path="signInPath"
|
2020-06-23 00:09:42 +05:30
|
|
|
:resolved-discussions-expanded="resolvedDiscussionsExpanded"
|
|
|
|
:discussion-with-open-form="discussionWithOpenForm"
|
|
|
|
data-testid="unresolved-discussion"
|
2020-11-24 15:15:51 +05:30
|
|
|
@create-note-error="$emit('onDesignDiscussionError', $event)"
|
|
|
|
@update-note-error="$emit('updateNoteError', $event)"
|
|
|
|
@resolve-discussion-error="$emit('resolveDiscussionError', $event)"
|
2020-06-23 00:09:42 +05:30
|
|
|
@click.native.stop="updateActiveDiscussion(discussion.notes[0].id)"
|
2020-11-24 15:15:51 +05:30
|
|
|
@open-form="updateDiscussionWithOpenForm"
|
2020-06-23 00:09:42 +05:30
|
|
|
/>
|
|
|
|
<template v-if="resolvedDiscussions.length > 0">
|
|
|
|
<gl-button
|
|
|
|
id="resolved-comments"
|
2020-11-24 15:15:51 +05:30
|
|
|
ref="resolvedComments"
|
2020-06-23 00:09:42 +05:30
|
|
|
data-testid="resolved-comments"
|
|
|
|
:icon="resolvedCommentsToggleIcon"
|
|
|
|
variant="link"
|
2020-10-24 23:57:45 +05:30
|
|
|
class="link-inherit-color gl-text-body gl-text-decoration-none gl-font-weight-bold gl-mb-4"
|
2020-06-23 00:09:42 +05:30
|
|
|
@click="$emit('toggleResolvedComments')"
|
|
|
|
>{{ $options.resolveCommentsToggleText }} ({{ resolvedDiscussions.length }})
|
|
|
|
</gl-button>
|
|
|
|
<gl-popover
|
|
|
|
v-if="!isResolvedCommentsPopoverHidden"
|
|
|
|
:show="!isResolvedCommentsPopoverHidden"
|
|
|
|
target="resolved-comments"
|
|
|
|
container="popovercontainer"
|
|
|
|
placement="top"
|
|
|
|
:title="s__('DesignManagement|Resolved Comments')"
|
|
|
|
>
|
|
|
|
<p>
|
|
|
|
{{
|
|
|
|
s__(
|
|
|
|
'DesignManagement|Comments you resolve can be viewed and unresolved by going to the "Resolved Comments" section below',
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</p>
|
2020-11-24 15:15:51 +05:30
|
|
|
<a
|
|
|
|
href="https://docs.gitlab.com/ee/user/project/issues/design_management.html#resolve-design-threads"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
>{{ s__('DesignManagement|Learn more about resolving comments') }}</a
|
|
|
|
>
|
2020-06-23 00:09:42 +05:30
|
|
|
</gl-popover>
|
|
|
|
<gl-collapse :visible="resolvedDiscussionsExpanded" class="gl-mt-3">
|
|
|
|
<design-discussion
|
|
|
|
v-for="discussion in resolvedDiscussions"
|
|
|
|
:key="discussion.id"
|
|
|
|
:discussion="discussion"
|
|
|
|
:design-id="$route.params.id"
|
|
|
|
:noteable-id="design.id"
|
|
|
|
:markdown-preview-path="markdownPreviewPath"
|
2022-03-02 08:16:31 +05:30
|
|
|
:register-path="registerPath"
|
|
|
|
:sign-in-path="signInPath"
|
2020-06-23 00:09:42 +05:30
|
|
|
:resolved-discussions-expanded="resolvedDiscussionsExpanded"
|
|
|
|
:discussion-with-open-form="discussionWithOpenForm"
|
|
|
|
data-testid="resolved-discussion"
|
|
|
|
@error="$emit('onDesignDiscussionError', $event)"
|
|
|
|
@updateNoteError="$emit('updateNoteError', $event)"
|
2021-11-11 11:23:49 +05:30
|
|
|
@open-form="updateDiscussionWithOpenForm"
|
2020-06-23 00:09:42 +05:30
|
|
|
@click.native.stop="updateActiveDiscussion(discussion.notes[0].id)"
|
|
|
|
/>
|
|
|
|
</gl-collapse>
|
|
|
|
</template>
|
2021-01-29 00:20:46 +05:30
|
|
|
<slot name="reply-form"></slot>
|
2020-06-23 00:09:42 +05:30
|
|
|
</div>
|
|
|
|
</template>
|