2018-03-27 19:54:05 +05:30
|
|
|
<script>
|
2022-10-11 01:57:18 +05:30
|
|
|
import {
|
|
|
|
GlTooltipDirective,
|
|
|
|
GlButton,
|
|
|
|
GlButtonGroup,
|
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
|
|
|
GlIcon,
|
|
|
|
} from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mapGetters, mapActions } from 'vuex';
|
2022-10-11 01:57:18 +05:30
|
|
|
import { throttle } from 'lodash';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { __ } from '~/locale';
|
2022-10-11 01:57:18 +05:30
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
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,
|
2022-10-11 01:57:18 +05:30
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
|
|
|
GlIcon,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
2022-10-11 01:57:18 +05:30
|
|
|
mixins: [glFeatureFlagsMixin(), discussionNavigation],
|
2022-07-16 23:28:13 +05:30
|
|
|
props: {
|
|
|
|
blocksMerge: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2022-10-11 01:57:18 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
jumpNext: throttle(this.jumpToNextDiscussion, 500),
|
|
|
|
jumpPrevious: throttle(this.jumpToPreviousDiscussion, 500),
|
|
|
|
};
|
|
|
|
},
|
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"
|
2022-10-11 01:57:18 +05:30
|
|
|
id="discussionCounter"
|
2020-04-08 14:13:33 +05:30
|
|
|
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
|
2022-10-11 01:57:18 +05:30
|
|
|
class="gl-display-flex gl-align-items-center gl-pl-4 gl-rounded-base gl-mr-3 gl-min-h-7"
|
2022-07-16 23:28:13 +05:30
|
|
|
:class="{
|
|
|
|
'gl-bg-orange-50': blocksMerge && !allResolved,
|
|
|
|
'gl-bg-gray-50': !blocksMerge || allResolved,
|
|
|
|
}"
|
|
|
|
data-testid="discussions-counter-text"
|
|
|
|
>
|
|
|
|
<template v-if="allResolved">
|
|
|
|
{{ __('All threads resolved!') }}
|
2022-10-11 01:57:18 +05:30
|
|
|
<gl-dropdown
|
2022-11-25 23:54:43 +05:30
|
|
|
v-gl-tooltip:discussionCounter.hover.bottom
|
2022-10-11 01:57:18 +05:30
|
|
|
size="small"
|
|
|
|
category="tertiary"
|
|
|
|
right
|
2022-11-25 23:54:43 +05:30
|
|
|
:title="__('Thread options')"
|
|
|
|
:aria-label="__('Thread options')"
|
2022-10-11 01:57:18 +05:30
|
|
|
toggle-class="btn-icon"
|
|
|
|
class="gl-pt-0! gl-px-2 gl-h-full gl-ml-2"
|
|
|
|
>
|
|
|
|
<template #button-content>
|
|
|
|
<gl-icon name="ellipsis_v" class="mr-0" />
|
|
|
|
</template>
|
|
|
|
<gl-dropdown-item
|
|
|
|
data-testid="toggle-all-discussions-btn"
|
|
|
|
@click="handleExpandDiscussions"
|
|
|
|
>
|
|
|
|
{{ toggleThreadsLabel }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
</gl-dropdown>
|
2022-07-16 23:28:13 +05:30
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ n__('%d unresolved thread', '%d unresolved threads', unresolvedDiscussionsCount) }}
|
|
|
|
<gl-button-group class="gl-ml-3">
|
|
|
|
<gl-button
|
2022-10-11 01:57:18 +05:30
|
|
|
v-gl-tooltip:discussionCounter.hover.bottom
|
2022-07-23 23:45:48 +05:30
|
|
|
:title="__('Go to previous unresolved thread')"
|
|
|
|
:aria-label="__('Go to previous unresolved thread')"
|
2022-07-16 23:28:13 +05:30
|
|
|
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"
|
2022-07-23 23:45:48 +05:30
|
|
|
icon="chevron-lg-up"
|
2022-07-16 23:28:13 +05:30
|
|
|
category="tertiary"
|
2022-10-11 01:57:18 +05:30
|
|
|
@click="jumpPrevious"
|
2022-07-16 23:28:13 +05:30
|
|
|
/>
|
|
|
|
<gl-button
|
2022-10-11 01:57:18 +05:30
|
|
|
v-gl-tooltip:discussionCounter.hover.bottom
|
2022-07-23 23:45:48 +05:30
|
|
|
:title="__('Go to next unresolved thread')"
|
|
|
|
:aria-label="__('Go to next unresolved thread')"
|
2022-07-16 23:28:13 +05:30
|
|
|
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"
|
2022-07-23 23:45:48 +05:30
|
|
|
icon="chevron-lg-down"
|
2022-07-16 23:28:13 +05:30
|
|
|
category="tertiary"
|
2022-10-11 01:57:18 +05:30
|
|
|
@click="jumpNext"
|
2022-07-16 23:28:13 +05:30
|
|
|
/>
|
2022-10-11 01:57:18 +05:30
|
|
|
<gl-dropdown
|
2022-11-25 23:54:43 +05:30
|
|
|
v-gl-tooltip:discussionCounter.hover.bottom
|
2022-10-11 01:57:18 +05:30
|
|
|
size="small"
|
|
|
|
category="tertiary"
|
|
|
|
right
|
2022-11-25 23:54:43 +05:30
|
|
|
:title="__('Thread options')"
|
|
|
|
:aria-label="__('Thread options')"
|
2022-10-11 01:57:18 +05:30
|
|
|
toggle-class="btn-icon"
|
|
|
|
class="gl-pt-0! gl-px-2"
|
|
|
|
>
|
|
|
|
<template #button-content>
|
|
|
|
<gl-icon name="ellipsis_v" class="mr-0" />
|
|
|
|
</template>
|
|
|
|
<gl-dropdown-item
|
|
|
|
data-testid="toggle-all-discussions-btn"
|
|
|
|
@click="handleExpandDiscussions"
|
|
|
|
>
|
|
|
|
{{ toggleThreadsLabel }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
<gl-dropdown-item
|
|
|
|
v-if="resolveAllDiscussionsIssuePath && !allResolved"
|
|
|
|
:href="resolveAllDiscussionsIssuePath"
|
|
|
|
>
|
|
|
|
{{ __('Create issue to resolve all threads') }}
|
|
|
|
</gl-dropdown-item>
|
|
|
|
</gl-dropdown>
|
2022-07-16 23:28:13 +05:30
|
|
|
</gl-button-group>
|
|
|
|
</template>
|
2018-03-27 19:54:05 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|