diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /app/assets/javascripts/pages/shared | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'app/assets/javascripts/pages/shared')
8 files changed, 76 insertions, 101 deletions
diff --git a/app/assets/javascripts/pages/shared/nav/sidebar_tracking.js b/app/assets/javascripts/pages/shared/nav/sidebar_tracking.js deleted file mode 100644 index 47aae36ecbb..00000000000 --- a/app/assets/javascripts/pages/shared/nav/sidebar_tracking.js +++ /dev/null @@ -1,44 +0,0 @@ -function onSidebarLinkClick() { - const setDataTrackAction = (element, action) => { - element.dataset.trackAction = action; - }; - - const setDataTrackExtra = (element, value) => { - const SIDEBAR_COLLAPSED = 'Collapsed'; - const SIDEBAR_EXPANDED = 'Expanded'; - const sidebarCollapsed = document - .querySelector('.nav-sidebar') - .classList.contains('js-sidebar-collapsed') - ? SIDEBAR_COLLAPSED - : SIDEBAR_EXPANDED; - - element.dataset.trackExtra = JSON.stringify({ - sidebar_display: sidebarCollapsed, - menu_display: value, - }); - }; - - const EXPANDED = 'Expanded'; - const FLY_OUT = 'Fly out'; - const CLICK_MENU_ACTION = 'click_menu'; - const CLICK_MENU_ITEM_ACTION = 'click_menu_item'; - const parentElement = this.parentNode; - const subMenuList = parentElement.closest('.sidebar-sub-level-items'); - - if (subMenuList) { - const isFlyOut = subMenuList.classList.contains('fly-out-list') ? FLY_OUT : EXPANDED; - - setDataTrackExtra(parentElement, isFlyOut); - setDataTrackAction(parentElement, CLICK_MENU_ITEM_ACTION); - } else { - const isFlyOut = parentElement.classList.contains('is-showing-fly-out') ? FLY_OUT : EXPANDED; - - setDataTrackExtra(parentElement, isFlyOut); - setDataTrackAction(parentElement, CLICK_MENU_ACTION); - } -} -export const initSidebarTracking = () => { - document.querySelectorAll('.nav-sidebar li[data-track-label] > a').forEach((link) => { - link.addEventListener('click', onSidebarLinkClick); - }); -}; diff --git a/app/assets/javascripts/pages/shared/wikis/components/delete_wiki_modal.vue b/app/assets/javascripts/pages/shared/wikis/components/delete_wiki_modal.vue index 3c070d2708d..de85420a976 100644 --- a/app/assets/javascripts/pages/shared/wikis/components/delete_wiki_modal.vue +++ b/app/assets/javascripts/pages/shared/wikis/components/delete_wiki_modal.vue @@ -43,8 +43,7 @@ export default { text: this.$options.i18n.deletePageText, attributes: { variant: 'danger', - 'data-qa-selector': 'confirm_deletion_button', - 'data-testid': 'confirm_deletion_button', + 'data-testid': 'confirm-deletion-button', }, }; }, @@ -77,7 +76,7 @@ export default { v-gl-modal="$options.modal.modalId" category="secondary" variant="danger" - data-qa-selector="delete-button" + data-testid="delete-button" > {{ $options.i18n.deletePageText }} </gl-button> diff --git a/app/assets/javascripts/pages/shared/wikis/components/wiki_content.vue b/app/assets/javascripts/pages/shared/wikis/components/wiki_content.vue index 8491d667213..0b31c9b0e16 100644 --- a/app/assets/javascripts/pages/shared/wikis/components/wiki_content.vue +++ b/app/assets/javascripts/pages/shared/wikis/components/wiki_content.vue @@ -88,7 +88,6 @@ export default { v-else-if="!loadingContentFailed && !isLoadingContent" ref="content" v-safe-html="content" - data-qa-selector="wiki_page_content" data-testid="wiki-page-content" class="js-wiki-page-content md" ></div> diff --git a/app/assets/javascripts/pages/shared/wikis/components/wiki_export.vue b/app/assets/javascripts/pages/shared/wikis/components/wiki_export.vue deleted file mode 100644 index 4d13f25c4cb..00000000000 --- a/app/assets/javascripts/pages/shared/wikis/components/wiki_export.vue +++ /dev/null @@ -1,40 +0,0 @@ -<script> -import { GlDisclosureDropdown } from '@gitlab/ui'; -import { __ } from '~/locale'; -import printMarkdownDom from '~/lib/print_markdown_dom'; - -export default { - components: { - GlDisclosureDropdown, - }, - inject: ['target', 'title', 'stylesheet'], - computed: { - dropdownItems() { - return [ - { - text: __('Print as PDF'), - action: this.print, - }, - ]; - }, - }, - methods: { - print() { - printMarkdownDom({ - target: document.querySelector(this.target), - title: this.title, - stylesheet: this.stylesheet, - }); - }, - }, -}; -</script> -<template> - <gl-disclosure-dropdown - :items="dropdownItems" - icon="ellipsis_v" - category="tertiary" - placement="right" - no-caret - /> -</template> diff --git a/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue b/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue index eaa99556994..855c7c4105f 100644 --- a/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue +++ b/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue @@ -187,6 +187,11 @@ export default { return typeof this.drawioUrl === 'string' && this.drawioUrl.length > 0; }, }, + watch: { + title() { + this.updateCommitMessage(); + }, + }, mounted() { if (!this.commitMessage) this.updateCommitMessage(); @@ -302,7 +307,7 @@ export default { /> <div class="row"> - <div class="col-sm-9"> + <div class="col-12"> <gl-form-group :label="$options.i18n.title.label" label-for="wiki_title"> <template #description> <gl-icon class="gl-mr-n1" name="bulb" /> @@ -321,7 +326,6 @@ export default { :required="true" :autofocus="!pageInfo.persisted" :placeholder="$options.i18n.title.placeholder" - @input="updateCommitMessage" /> </gl-form-group> </div> @@ -361,8 +365,8 @@ export default { :drawio-enabled="drawioEnabled" @contentEditor="notifyContentEditorActive" @markdownField="notifyContentEditorInactive" - @keydown.ctrl.enter="submitFormShortcut" - @keydown.meta.enter="submitFormShortcut" + @keydown.ctrl.enter="submitFormWithShortcut" + @keydown.meta.enter="submitFormWithShortcut" /> <div class="form-text gl-text-gray-600"> <gl-sprintf @@ -404,7 +408,7 @@ export default { </div> </div> - <div class="form-actions"> + <div class="gl-display-flex gl-gap-3" data-testid="wiki-form-actions"> <gl-button category="primary" variant="confirm" @@ -416,7 +420,6 @@ export default { <gl-button data-testid="wiki-cancel-button" :href="cancelFormPath" - class="float-right" @click="isFormDirty = false" > {{ $options.i18n.cancel }}</gl-button 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> diff --git a/app/assets/javascripts/pages/shared/wikis/show.js b/app/assets/javascripts/pages/shared/wikis/show.js index 9bc399d07b3..89ed395f742 100644 --- a/app/assets/javascripts/pages/shared/wikis/show.js +++ b/app/assets/javascripts/pages/shared/wikis/show.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Wikis from './wikis'; import WikiContent from './components/wiki_content.vue'; -import WikiExport from './components/wiki_export.vue'; +import WikiMoreDropdown from './components/wiki_more_dropdown.vue'; const mountWikiContentApp = () => { const el = document.querySelector('.js-async-wiki-page-content'); @@ -25,17 +25,16 @@ const mountWikiExportApp = () => { const el = document.querySelector('#js-export-actions'); if (!el) return false; - const { target, title, stylesheet } = JSON.parse(el.dataset.options); + const { history, print } = JSON.parse(el.dataset.options); return new Vue({ el, provide: { - target, - title, - stylesheet, + history, + print, }, render(createElement) { - return createElement(WikiExport); + return createElement(WikiMoreDropdown); }, }); }; diff --git a/app/assets/javascripts/pages/shared/wikis/wikis.js b/app/assets/javascripts/pages/shared/wikis/wikis.js index b32cc700e16..c98cda92a94 100644 --- a/app/assets/javascripts/pages/shared/wikis/wikis.js +++ b/app/assets/javascripts/pages/shared/wikis/wikis.js @@ -1,5 +1,6 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import Tracking from '~/tracking'; +import { addShortcutsExtension } from '~/behaviors/shortcuts'; import ShortcutsWiki from '~/behaviors/shortcuts/shortcuts_wiki'; const TRACKING_EVENT_NAME = 'view_wiki_page'; @@ -72,6 +73,6 @@ export default class Wikis { } static initShortcuts() { - new ShortcutsWiki(); // eslint-disable-line no-new + addShortcutsExtension(ShortcutsWiki); } } |