debian-mirror-gitlab/app/assets/javascripts/design_management/components/design_sidebar.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

215 lines
6.7 KiB
Vue
Raw Normal View History

2020-06-23 00:09:42 +05:30
<script>
2022-08-13 15:12:31 +05:30
import { GlAccordion, GlAccordionItem, GlSkeletonLoader } from '@gitlab/ui';
import { isLoggedIn } from '~/lib/utils/common_utils';
2022-04-04 11:22:00 +05:30
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,
2022-08-13 15:12:31 +05:30
GlAccordion,
GlAccordionItem,
2022-07-23 23:45:48 +05:30
GlSkeletonLoader,
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,
},
2022-07-23 23:45:48 +05:30
isLoading: {
type: Boolean,
required: true,
},
2020-06-23 00:09:42 +05:30
},
data() {
return {
2022-08-13 15:12:31 +05:30
isResolvedDiscussionsExpanded: this.resolvedDiscussionsExpanded,
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,
2022-07-23 23:45:48 +05:30
webPath: this.design.issue?.webPath.substr(1),
2020-06-23 00:09:42 +05:30
};
},
discussionParticipants() {
2022-07-23 23:45:48 +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
},
2022-08-13 15:12:31 +05:30
hasResolvedDiscussions() {
return this.resolvedDiscussions.length > 0;
},
resolvedDiscussionsTitle() {
return `${this.$options.i18n.resolveCommentsToggleText} (${this.resolvedDiscussions.length})`;
},
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
},
2020-11-24 15:15:51 +05:30
},
watch: {
2022-08-13 15:12:31 +05:30
resolvedDiscussionsExpanded(resolvedDiscussionsExpanded) {
this.isResolvedDiscussionsExpanded = resolvedDiscussionsExpanded;
},
isResolvedDiscussionsExpanded() {
this.$emit('toggleResolvedComments');
2020-11-24 15:15:51 +05:30
},
},
mounted() {
if (!this.isResolvedCommentsPopoverHidden && this.$refs.resolvedComments) {
this.$refs.resolvedComments.$el.scrollIntoView();
}
2020-06-23 00:09:42 +05:30
},
methods: {
handleSidebarClick() {
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;
},
},
2022-08-13 15:12:31 +05:30
i18n: {
resolveCommentsToggleText: s__('DesignManagement|Resolved Comments'),
},
2020-06-23 00:09:42 +05:30
};
</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"
/>
2022-07-23 23:45:48 +05:30
<gl-skeleton-loader v-if="isLoading" />
<template v-else>
<h2
v-if="isLoggedIn && unresolvedDiscussions.length === 0"
class="new-discussion-disclaimer gl-font-base gl-m-0 gl-mb-4"
data-testid="new-discussion-disclaimer"
2020-06-23 00:09:42 +05:30
>
2022-07-23 23:45:48 +05:30
{{ s__("DesignManagement|Click the image where you'd like to start a new discussion") }}
</h2>
<design-note-signed-out
v-if="!isLoggedIn"
class="gl-mb-4"
:register-path="registerPath"
:sign-in-path="signInPath"
:is-add-discussion="true"
/>
<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"
:register-path="registerPath"
:sign-in-path="signInPath"
:resolved-discussions-expanded="resolvedDiscussionsExpanded"
:discussion-with-open-form="discussionWithOpenForm"
data-testid="unresolved-discussion"
@create-note-error="$emit('onDesignDiscussionError', $event)"
@update-note-error="$emit('updateNoteError', $event)"
@resolve-discussion-error="$emit('resolveDiscussionError', $event)"
@click.native.stop="updateActiveDiscussion(discussion.notes[0].id)"
@open-form="updateDiscussionWithOpenForm"
/>
2022-08-13 15:12:31 +05:30
<gl-accordion v-if="hasResolvedDiscussions" :header-level="3" class="gl-mb-5">
<gl-accordion-item
v-model="isResolvedDiscussionsExpanded"
:title="resolvedDiscussionsTitle"
header-class="gl-mb-5!"
2020-11-24 15:15:51 +05:30
>
2022-07-23 23:45:48 +05:30
<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"
:register-path="registerPath"
:sign-in-path="signInPath"
:resolved-discussions-expanded="resolvedDiscussionsExpanded"
:discussion-with-open-form="discussionWithOpenForm"
data-testid="resolved-discussion"
@error="$emit('onDesignDiscussionError', $event)"
@updateNoteError="$emit('updateNoteError', $event)"
@open-form="updateDiscussionWithOpenForm"
@click.native.stop="updateActiveDiscussion(discussion.notes[0].id)"
/>
2022-08-13 15:12:31 +05:30
</gl-accordion-item>
</gl-accordion>
2022-07-23 23:45:48 +05:30
<slot name="reply-form"></slot>
2020-06-23 00:09:42 +05:30
</template>
</div>
</template>