debian-mirror-gitlab/app/assets/javascripts/notes/components/discussion_counter.vue

109 lines
3.3 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
2021-01-03 14:25:43 +05:30
import { GlTooltipDirective, GlIcon, 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: {
2020-11-24 15:15:51 +05:30
GlIcon,
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],
2018-05-09 12:01:36 +05:30
computed: {
...mapGetters([
'getUserData',
'getNoteableData',
2019-02-15 15:39:39 +05:30
'resolvableDiscussionsCount',
'unresolvedDiscussionsCount',
2020-04-22 19:07:51 +05:30
'discussions',
2018-05-09 12:01:36 +05:30
]),
isLoggedIn() {
return this.getUserData.id;
2018-03-27 19:54:05 +05:30
},
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
},
2018-05-09 12:01:36 +05:30
resolveAllDiscussionsIssuePath() {
return this.getNoteableData.create_issue_to_resolve_discussions_path;
},
2020-04-22 19:07:51 +05:30
toggeableDiscussions() {
2021-03-08 18:12:59 +05:30
return this.discussions.filter((discussion) => !discussion.individual_note);
2020-04-22 19:07:51 +05:30
},
allExpanded() {
2021-03-08 18:12:59 +05:30
return this.toggeableDiscussions.every((discussion) => discussion.expanded);
2020-04-22 19:07:51 +05:30
},
2021-01-03 14:25:43 +05:30
lineResolveClass() {
return this.allResolved ? 'line-resolve-btn is-active' : 'line-resolve-text';
},
toggleThreadsLabel() {
return this.allExpanded ? __('Collapse all threads') : __('Expand all threads');
},
2020-04-22 19:07:51 +05:30
},
methods: {
...mapActions(['setExpandDiscussions']),
handleExpandDiscussions() {
this.setExpandDiscussions({
2021-03-08 18:12:59 +05:30
discussionIds: this.toggeableDiscussions.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"
2021-01-03 14:25:43 +05:30
class="line-resolve-all-container full-width-mobile gl-display-flex d-sm-flex"
2020-04-08 14:13:33 +05:30
>
2021-01-03 14:25:43 +05:30
<div class="line-resolve-all">
<span :class="lineResolveClass">
<template v-if="allResolved">
<gl-icon name="check-circle-filled" />
{{ __('All threads resolved') }}
</template>
<template v-else>
{{ n__('%d unresolved thread', '%d unresolved threads', unresolvedDiscussionsCount) }}
</template>
</span>
2018-03-27 19:54:05 +05:30
</div>
2021-01-03 14:25:43 +05:30
<gl-button-group>
<gl-button
v-if="resolveAllDiscussionsIssuePath && !allResolved"
v-gl-tooltip
:href="resolveAllDiscussionsIssuePath"
:title="s__('Resolve all threads in new issue')"
:aria-label="s__('Resolve all threads in new issue')"
class="new-issue-for-discussion discussion-create-issue-btn"
icon="issue-new"
/>
<gl-button
v-if="isLoggedIn && !allResolved"
v-gl-tooltip
:title="__('Jump to next unresolved thread')"
:aria-label="__('Jump to next unresolved thread')"
class="discussion-next-btn"
data-track-event="click_button"
data-track-label="mr_next_unresolved_thread"
data-track-property="click_next_unresolved_thread_top"
icon="comment-next"
@click="jumpToNextDiscussion"
/>
<gl-button
v-gl-tooltip
:title="toggleThreadsLabel"
:aria-label="toggleThreadsLabel"
class="toggle-all-discussions-btn"
:icon="allExpanded ? 'angle-up' : 'angle-down'"
@click="handleExpandDiscussions"
/>
</gl-button-group>
2018-03-27 19:54:05 +05:30
</div>
</template>