2018-03-27 19:54:05 +05:30
|
|
|
<script>
|
2022-07-16 23:28:13 +05:30
|
|
|
import { GlTooltipDirective, GlButton, GlButtonGroup } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mapGetters, mapActions } from 'vuex';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { __ } from '~/locale';
|
2018-11-18 11:00:15 +05:30
|
|
|
import discussionNavigation from '../mixins/discussion_navigation';
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
export default {
|
|
|
|
directives: {
|
2019-02-15 15:39:39 +05:30
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
components: {
|
2021-01-03 14:25:43 +05:30
|
|
|
GlButton,
|
|
|
|
GlButtonGroup,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
mixins: [discussionNavigation],
|
2022-07-16 23:28:13 +05:30
|
|
|
props: {
|
|
|
|
blocksMerge: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
computed: {
|
|
|
|
...mapGetters([
|
|
|
|
'getNoteableData',
|
2019-02-15 15:39:39 +05:30
|
|
|
'resolvableDiscussionsCount',
|
|
|
|
'unresolvedDiscussionsCount',
|
2022-07-16 23:28:13 +05:30
|
|
|
'allResolvableDiscussions',
|
2018-05-09 12:01:36 +05:30
|
|
|
]),
|
|
|
|
allResolved() {
|
2019-02-15 15:39:39 +05:30
|
|
|
return this.unresolvedDiscussionsCount === 0;
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
2020-04-22 19:07:51 +05:30
|
|
|
allExpanded() {
|
2022-07-16 23:28:13 +05:30
|
|
|
return this.allResolvableDiscussions.every((discussion) => discussion.expanded);
|
2021-01-03 14:25:43 +05:30
|
|
|
},
|
|
|
|
toggleThreadsLabel() {
|
|
|
|
return this.allExpanded ? __('Collapse all threads') : __('Expand all threads');
|
|
|
|
},
|
2022-07-16 23:28:13 +05:30
|
|
|
resolveAllDiscussionsIssuePath() {
|
|
|
|
return this.getNoteableData.create_issue_to_resolve_discussions_path;
|
|
|
|
},
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['setExpandDiscussions']),
|
|
|
|
handleExpandDiscussions() {
|
|
|
|
this.setExpandDiscussions({
|
2022-07-16 23:28:13 +05:30
|
|
|
discussionIds: this.allResolvableDiscussions.map((discussion) => discussion.id),
|
2020-04-22 19:07:51 +05:30
|
|
|
expanded: !this.allExpanded,
|
|
|
|
});
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
};
|
2018-03-27 19:54:05 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2020-04-08 14:13:33 +05:30
|
|
|
<div
|
|
|
|
v-if="resolvableDiscussionsCount > 0"
|
|
|
|
ref="discussionCounter"
|
2022-07-16 23:28:13 +05:30
|
|
|
class="gl-display-flex discussions-counter"
|
2020-04-08 14:13:33 +05:30
|
|
|
>
|
2022-07-16 23:28:13 +05:30
|
|
|
<div
|
|
|
|
class="gl-display-flex gl-align-items-center gl-pl-4 gl-rounded-base gl-mr-3"
|
|
|
|
:class="{
|
|
|
|
'gl-bg-orange-50': blocksMerge && !allResolved,
|
|
|
|
'gl-bg-gray-50': !blocksMerge || allResolved,
|
|
|
|
'gl-pr-4': allResolved,
|
|
|
|
'gl-pr-2': !allResolved,
|
|
|
|
}"
|
|
|
|
data-testid="discussions-counter-text"
|
|
|
|
>
|
|
|
|
<template v-if="allResolved">
|
|
|
|
{{ __('All threads resolved!') }}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ n__('%d unresolved thread', '%d unresolved threads', unresolvedDiscussionsCount) }}
|
|
|
|
<gl-button-group class="gl-ml-3">
|
|
|
|
<gl-button
|
|
|
|
v-gl-tooltip.hover
|
|
|
|
:title="__('Jump to previous unresolved thread')"
|
|
|
|
:aria-label="__('Jump to previous unresolved thread')"
|
|
|
|
class="discussion-previous-btn gl-rounded-base! gl-px-2!"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="mr_previous_unresolved_thread"
|
|
|
|
data-track-property="click_previous_unresolved_thread_top"
|
|
|
|
icon="angle-up"
|
|
|
|
category="tertiary"
|
|
|
|
@click="jumpToPreviousDiscussion"
|
|
|
|
/>
|
|
|
|
<gl-button
|
|
|
|
v-gl-tooltip.hover
|
|
|
|
:title="__('Jump to next unresolved thread')"
|
|
|
|
:aria-label="__('Jump to next unresolved thread')"
|
|
|
|
class="discussion-next-btn gl-rounded-base! gl-px-2!"
|
|
|
|
data-track-action="click_button"
|
|
|
|
data-track-label="mr_next_unresolved_thread"
|
|
|
|
data-track-property="click_next_unresolved_thread_top"
|
|
|
|
icon="angle-down"
|
|
|
|
category="tertiary"
|
|
|
|
@click="jumpToNextDiscussion"
|
|
|
|
/>
|
|
|
|
</gl-button-group>
|
|
|
|
</template>
|
2018-03-27 19:54:05 +05:30
|
|
|
</div>
|
2021-01-03 14:25:43 +05:30
|
|
|
<gl-button-group>
|
2022-07-16 23:28:13 +05:30
|
|
|
<gl-button
|
|
|
|
v-gl-tooltip
|
|
|
|
:title="toggleThreadsLabel"
|
|
|
|
:aria-label="toggleThreadsLabel"
|
|
|
|
class="toggle-all-discussions-btn"
|
|
|
|
:icon="allExpanded ? 'collapse' : 'expand'"
|
|
|
|
@click="handleExpandDiscussions"
|
|
|
|
/>
|
2021-01-03 14:25:43 +05:30
|
|
|
<gl-button
|
|
|
|
v-if="resolveAllDiscussionsIssuePath && !allResolved"
|
|
|
|
v-gl-tooltip
|
|
|
|
:href="resolveAllDiscussionsIssuePath"
|
2021-12-11 22:18:48 +05:30
|
|
|
:title="__('Create issue to resolve all threads')"
|
|
|
|
:aria-label="__('Create issue to resolve all threads')"
|
2021-01-03 14:25:43 +05:30
|
|
|
class="new-issue-for-discussion discussion-create-issue-btn"
|
|
|
|
icon="issue-new"
|
|
|
|
/>
|
|
|
|
</gl-button-group>
|
2018-03-27 19:54:05 +05:30
|
|
|
</div>
|
|
|
|
</template>
|