debian-mirror-gitlab/app/assets/javascripts/batch_comments/components/preview_dropdown.vue

44 lines
1.1 KiB
Vue
Raw Normal View History

2020-06-23 00:09:42 +05:30
<script>
2021-01-03 14:25:43 +05:30
import { GlDropdown, GlDropdownItem, GlIcon } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions, mapGetters } from 'vuex';
2020-06-23 00:09:42 +05:30
import PreviewItem from './preview_item.vue';
export default {
components: {
2021-01-03 14:25:43 +05:30
GlDropdown,
GlDropdownItem,
2020-11-24 15:15:51 +05:30
GlIcon,
2020-06-23 00:09:42 +05:30
PreviewItem,
},
computed: {
...mapGetters('batchComments', ['draftsCount', 'sortedDrafts']),
},
methods: {
2021-01-03 14:25:43 +05:30
...mapActions('batchComments', ['scrollToDraft']),
2020-06-23 00:09:42 +05:30
isLast(index) {
return index === this.sortedDrafts.length - 1;
},
},
};
</script>
<template>
2021-01-03 14:25:43 +05:30
<gl-dropdown
:header-text="n__('%d pending comment', '%d pending comments', draftsCount)"
dropup
toggle-class="qa-review-preview-toggle"
2020-06-23 00:09:42 +05:30
>
2021-01-03 14:25:43 +05:30
<template #button-content>
{{ __('Pending comments') }}
<gl-icon class="dropdown-chevron" name="chevron-up" />
</template>
<gl-dropdown-item
v-for="(draft, index) in sortedDrafts"
:key="draft.id"
@click="scrollToDraft(draft)"
2020-06-23 00:09:42 +05:30
>
2021-01-03 14:25:43 +05:30
<preview-item :draft="draft" :is-last="isLast(index)" />
</gl-dropdown-item>
</gl-dropdown>
2020-06-23 00:09:42 +05:30
</template>