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

111 lines
3.3 KiB
Vue
Raw Normal View History

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