diff options
Diffstat (limited to 'app/assets/javascripts/pages/shared/wikis/components/wiki_more_dropdown.vue')
-rw-r--r-- | app/assets/javascripts/pages/shared/wikis/components/wiki_more_dropdown.vue | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/app/assets/javascripts/pages/shared/wikis/components/wiki_more_dropdown.vue b/app/assets/javascripts/pages/shared/wikis/components/wiki_more_dropdown.vue new file mode 100644 index 00000000000..18b11d46bca --- /dev/null +++ b/app/assets/javascripts/pages/shared/wikis/components/wiki_more_dropdown.vue @@ -0,0 +1,58 @@ +<script> +import { GlDisclosureDropdown } from '@gitlab/ui'; +import { s__, __ } from '~/locale'; +import printMarkdownDom from '~/lib/print_markdown_dom'; + +export default { + components: { + GlDisclosureDropdown, + }, + inject: ['print', 'history'], + computed: { + dropdownItems() { + const items = []; + + if (this.history) { + items.push({ + text: s__('Wiki|Page history'), + href: this.history, + extraAttrs: { + 'data-testid': 'page-history-button', + }, + }); + } + + if (this.print) { + items.push({ + text: __('Print as PDF'), + action: this.printPage, + extraAttrs: { + 'data-testid': 'page-print-button', + }, + }); + } + + return items; + }, + }, + methods: { + printPage() { + printMarkdownDom({ + target: document.querySelector(this.print.target), + title: this.print.title, + stylesheet: this.print.stylesheet, + }); + }, + }, +}; +</script> +<template> + <gl-disclosure-dropdown + :items="dropdownItems" + icon="ellipsis_v" + category="tertiary" + placement="right" + no-caret + data-testid="wiki-more-dropdown" + /> +</template> |