2020-06-23 00:09:42 +05:30
|
|
|
<script>
|
2023-04-23 21:23:45 +05:30
|
|
|
import { GlIcon, GlDisclosureDropdown, GlButton } from '@gitlab/ui';
|
2021-06-08 01:23:25 +05:30
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex';
|
2022-08-13 15:12:31 +05:30
|
|
|
import { setUrlParams, visitUrl } from '~/lib/utils/url_utility';
|
2020-06-23 00:09:42 +05:30
|
|
|
import PreviewItem from './preview_item.vue';
|
2022-07-23 23:45:48 +05:30
|
|
|
import DraftsCount from './drafts_count.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-11-24 15:15:51 +05:30
|
|
|
GlIcon,
|
2020-06-23 00:09:42 +05:30
|
|
|
PreviewItem,
|
2022-07-23 23:45:48 +05:30
|
|
|
DraftsCount,
|
2023-04-23 21:23:45 +05:30
|
|
|
GlDisclosureDropdown,
|
|
|
|
GlButton,
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
computed: {
|
2021-06-08 01:23:25 +05:30
|
|
|
...mapState('diffs', ['viewDiffsFileByFile']),
|
2020-06-23 00:09:42 +05:30
|
|
|
...mapGetters('batchComments', ['draftsCount', 'sortedDrafts']),
|
2022-08-13 15:12:31 +05:30
|
|
|
...mapGetters(['getNoteableData']),
|
2023-04-23 21:23:45 +05:30
|
|
|
listItems() {
|
|
|
|
const sortedDraftCount = this.sortedDrafts.length - 1;
|
|
|
|
return this.sortedDrafts.map((item, index) => ({
|
|
|
|
text: item.id.toString(),
|
|
|
|
action: () => {
|
|
|
|
this.onClickDraft(item);
|
|
|
|
},
|
|
|
|
last: index === sortedDraftCount,
|
|
|
|
...item,
|
|
|
|
}));
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2021-12-11 22:18:48 +05:30
|
|
|
...mapActions('diffs', ['setCurrentFileHash']),
|
2021-01-03 14:25:43 +05:30
|
|
|
...mapActions('batchComments', ['scrollToDraft']),
|
2022-08-13 15:12:31 +05:30
|
|
|
isOnLatestDiff(draft) {
|
|
|
|
return draft.position?.head_sha === this.getNoteableData.diff_head_sha;
|
|
|
|
},
|
2021-06-08 01:23:25 +05:30
|
|
|
async onClickDraft(draft) {
|
|
|
|
if (this.viewDiffsFileByFile && draft.file_hash) {
|
2021-12-11 22:18:48 +05:30
|
|
|
await this.setCurrentFileHash(draft.file_hash);
|
2021-06-08 01:23:25 +05:30
|
|
|
}
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
if (draft.position && !this.isOnLatestDiff(draft)) {
|
|
|
|
const url = new URL(setUrlParams({ commit_id: draft.position.head_sha }));
|
|
|
|
url.hash = `note_${draft.id}`;
|
|
|
|
visitUrl(url.toString());
|
|
|
|
} else {
|
|
|
|
await this.scrollToDraft(draft);
|
|
|
|
}
|
2021-06-08 01:23:25 +05:30
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-04-23 21:23:45 +05:30
|
|
|
<gl-disclosure-dropdown :items="listItems" dropup data-qa-selector="review_preview_dropdown">
|
|
|
|
<template #toggle>
|
|
|
|
<gl-button
|
|
|
|
>{{ __('Pending comments') }} <drafts-count variant="neutral" /><gl-icon
|
|
|
|
class="dropdown-chevron"
|
|
|
|
name="chevron-up"
|
|
|
|
/></gl-button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #header>
|
|
|
|
<p class="gl-dropdown-header-top">
|
|
|
|
{{ n__('%d pending comment', '%d pending comments', draftsCount) }}
|
|
|
|
</p>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #list-item="{ item }">
|
|
|
|
<preview-item :draft="item" :is-last="item.last" @click="onClickDraft(item)" />
|
2021-01-03 14:25:43 +05:30
|
|
|
</template>
|
2023-04-23 21:23:45 +05:30
|
|
|
</gl-disclosure-dropdown>
|
2020-06-23 00:09:42 +05:30
|
|
|
</template>
|