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

90 lines
2.7 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
2018-11-08 19:23:39 +05:30
import { mapActions, mapGetters } from 'vuex';
2019-02-13 22:33:31 +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-13 22:33:31 +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-13 22:33:31 +05:30
'resolvableDiscussionsCount',
2018-11-18 11:00:15 +05:30
'firstUnresolvedDiscussionId',
2019-02-13 22:33:31 +05:30
'unresolvedDiscussionsCount',
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
hasNextButton() {
return this.isLoggedIn && !this.allResolved;
},
allResolved() {
2019-02-13 22:33:31 +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;
},
2019-02-13 22:33:31 +05:30
resolvedDiscussionsCount() {
return this.resolvableDiscussionsCount - this.unresolvedDiscussionsCount;
},
2018-05-09 12:01:36 +05:30
},
methods: {
2018-11-08 19:23:39 +05:30
...mapActions(['expandDiscussion']),
jumpToFirstUnresolvedDiscussion() {
2018-11-18 11:00:15 +05:30
const diffTab = window.mrTabs.currentAction === 'diffs';
const discussionId = this.firstUnresolvedDiscussionId(diffTab);
2018-03-27 19:54:05 +05:30
2018-11-18 11:00:15 +05:30
this.jumpToDiscussion(discussionId);
2018-03-27 19:54:05 +05:30
},
2018-05-09 12:01:36 +05:30
},
};
2018-03-27 19:54:05 +05:30
</script>
<template>
2019-02-13 22:33:31 +05:30
<div v-if="resolvableDiscussionsCount > 0" class="line-resolve-all-container prepend-top-8">
2018-03-27 19:54:05 +05:30
<div>
2019-02-13 22:33:31 +05:30
<div :class="{ 'has-next-btn': hasNextButton }" class="line-resolve-all">
2018-03-27 19:54:05 +05:30
<span
:class="{ 'is-active': allResolved }"
class="line-resolve-btn is-disabled"
2018-12-13 13:39:08 +05:30
type="button"
>
<icon name="check-circle" />
2018-03-27 19:54:05 +05:30
</span>
2018-10-15 14:42:47 +05:30
<span class="line-resolve-text">
2019-02-13 22:33:31 +05:30
{{ resolvedDiscussionsCount }}/{{ resolvableDiscussionsCount }}
{{ n__('discussion resolved', 'discussions resolved', resolvableDiscussionsCount) }}
2018-03-27 19:54:05 +05:30
</span>
</div>
2019-02-13 22:33:31 +05:30
<div v-if="resolveAllDiscussionsIssuePath && !allResolved" class="btn-group" role="group">
2018-03-27 19:54:05 +05:30
<a
2019-02-13 22:33:31 +05:30
v-gl-tooltip
2018-11-08 19:23:39 +05:30
:href="resolveAllDiscussionsIssuePath"
:title="s__('Resolve all discussions in new issue')"
2019-02-13 22:33:31 +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-02-13 22:33:31 +05:30
<div v-if="isLoggedIn && !allResolved" class="btn-group" role="group">
2018-03-27 19:54:05 +05:30
<button
2019-02-13 22:33:31 +05:30
v-gl-tooltip
2018-03-27 19:54:05 +05:30
title="Jump to first unresolved discussion"
2018-11-08 19:23:39 +05:30
class="btn btn-default discussion-next-btn"
2019-02-13 22:33:31 +05:30
@click="jumpToFirstUnresolvedDiscussion"
>
2018-12-13 13:39:08 +05:30
<icon name="comment-next" />
2018-03-27 19:54:05 +05:30
</button>
</div>
</div>
</div>
</template>