From bba3f812ac83de5956ad93b317788c45974bf9c7 Mon Sep 17 00:00:00 2001 From: "andy.lee" Date: Fri, 20 Sep 2024 14:33:34 +0800 Subject: [PATCH 1/3] Port app-modal into harvester shell Signed-off-by: andy.lee (cherry picked from commit 85b311da38e6ea8a9c3041727de022014f7cf7d8) --- cypress/e2e/po/prompts/promptRemove.po.ts | 2 +- jest.setup.js | 3 +- package.json | 1 - pkg/harvester/components/HarvesterUpgrade.vue | 13 +- .../novnc/NovncConsoleCustomKeys.vue | 14 +- .../components/novnc/NovncConsoleWrapper.vue | 10 +- .../dialog/HarvesterSupportBundle.vue | 147 +++++++-------- pkg/harvester/dialog/RestartVMDialog.vue | 20 ++- .../harvesterhci.io.host/HarvesterSeeder.vue | 6 +- .../AccessCredentialsUsers.vue | 6 +- .../VirtualMachineCloudConfig/index.vue | 8 +- .../VirtualMachineSSHKey.vue | 8 +- .../VirtualMachineVolume/index.vue | 13 +- .../edit/kubevirt.io.virtualmachine/index.vue | 12 +- pkg/harvester/l10n/en-us.yaml | 2 +- shell/assets/styles/app.scss | 1 - shell/assets/styles/vendor/vue-js-modal.scss | 16 -- shell/components/AppModal.vue | 170 ++++++++++++++++++ shell/components/AssignTo.vue | 11 +- shell/components/CommunityLinks.vue | 15 +- shell/components/Dialog.vue | 10 +- shell/components/DisableAuthProviderModal.vue | 22 ++- shell/components/Inactivity.vue | 6 +- shell/components/ModalWithCard.vue | 13 +- shell/components/MoveModal.vue | 71 ++++---- shell/components/PromptChangePassword.vue | 66 +++---- shell/components/PromptModal.vue | 36 ++-- shell/components/PromptRemove.vue | 38 ++-- shell/components/PromptRestore.vue | 35 ++-- shell/components/ResourceCancelModal.vue | 23 ++- shell/components/nav/Header.vue | 30 ++-- shell/initialize/index.js | 1 - shell/list/management.cattle.io.feature.vue | 16 +- shell/package.json | 1 - .../CatalogList/CatalogLoadDialog.vue | 18 +- .../uiplugins/DeveloperInstallDialog.vue | 13 +- .../c/_cluster/uiplugins/InstallDialog.vue | 13 +- .../c/_cluster/uiplugins/RemoveUIPlugins.vue | 5 +- .../c/_cluster/uiplugins/SetupUIPlugins.vue | 6 +- .../c/_cluster/uiplugins/UninstallDialog.vue | 14 +- shell/plugins/vue-js-modal.js | 4 - shell/public/index.html | 1 + .../stories/components/AppModal.stories.mdx | 49 +++++ yarn.lock | 5 - 44 files changed, 628 insertions(+), 346 deletions(-) delete mode 100644 shell/assets/styles/vendor/vue-js-modal.scss create mode 100644 shell/components/AppModal.vue delete mode 100644 shell/plugins/vue-js-modal.js create mode 100644 storybook/stories/components/AppModal.stories.mdx diff --git a/cypress/e2e/po/prompts/promptRemove.po.ts b/cypress/e2e/po/prompts/promptRemove.po.ts index d4c44045abc..ff5fe1b3dc8 100644 --- a/cypress/e2e/po/prompts/promptRemove.po.ts +++ b/cypress/e2e/po/prompts/promptRemove.po.ts @@ -3,7 +3,7 @@ import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; export default class PromptRemove extends ComponentPo { constructor() { - super(cy.get('main > .remove-modal')); + super(cy.get('body > #modals > .vue-portal-target > .modal-overlay > .remove-modal')); } confirmField() { diff --git a/jest.setup.js b/jest.setup.js index 1f686b4341e..21a6fc1f363 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -1,13 +1,12 @@ import { config } from '@vue/test-utils'; import { directiveSsr as t } from '@shell/plugins/i18n'; import VTooltip from 'v-tooltip'; -import VModal from 'vue-js-modal'; import vSelect from 'vue-select'; import Vue from 'vue'; Vue.config.productionTip = false; -Vue.use(VTooltip).use(VModal); +Vue.use(VTooltip); Vue.component('v-select', vSelect); /** diff --git a/package.json b/package.json index 89baadf1633..bc5fef76fcb 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,6 @@ "v-tooltip": "2.0.3", "vue-client-only": "2.1.0", "vue-codemirror": "4.0.6", - "vue-js-modal": "1.3.35", "vue-meta": "2.4.0", "vue-no-ssr": "1.1.1", "vue-resize": "0.4.5", diff --git a/pkg/harvester/components/HarvesterUpgrade.vue b/pkg/harvester/components/HarvesterUpgrade.vue index 7f174648ae6..9996a6e1dc8 100644 --- a/pkg/harvester/components/HarvesterUpgrade.vue +++ b/pkg/harvester/components/HarvesterUpgrade.vue @@ -34,7 +34,8 @@ export default { selectMode: true, version: '', enableLogging: true, - readyReleaseNote: false + readyReleaseNote: false, + showModal: false, }; }, @@ -121,12 +122,12 @@ export default { }, cancel() { - this.$refs.deleteTip.hide(); + this.showModal = false; this.errors = ''; }, open() { - this.$refs.deleteTip.open(); + this.showModal = true; }, } }; @@ -151,7 +152,11 @@ export default { - + diff --git a/pkg/harvester/components/novnc/NovncConsoleCustomKeys.vue b/pkg/harvester/components/novnc/NovncConsoleCustomKeys.vue index ae393537388..94cadd99c76 100644 --- a/pkg/harvester/components/novnc/NovncConsoleCustomKeys.vue +++ b/pkg/harvester/components/novnc/NovncConsoleCustomKeys.vue @@ -7,6 +7,7 @@ import ModalWithCard from '@shell/components/ModalWithCard'; const PREFERED_SHORTCUT_KEYS = 'prefered-shortcut-keys'; export default { + name: 'NovncConsoleCustomKeys', components: { ModalWithCard, Banner, AsyncButton }, @@ -100,9 +101,11 @@ export default { }, methods: { - show() { - this.$refs.recordShortcutKeys.open(); - }, + // show() { + // // console.log('🚀 ~ NoVNCconsoleCustomKeys ~ show:'); + // // this.showModal = true; + // // this.$refs.recordShortcutKeys.open(); + // }, closeRecordingModal() { window.removeEventListener('keydown', this.handleShortcut); @@ -170,7 +173,10 @@ export default { - +

diff --git a/pkg/harvester/dialog/HarvesterSupportBundle.vue b/pkg/harvester/dialog/HarvesterSupportBundle.vue index 29b226d072e..af905c80e54 100644 --- a/pkg/harvester/dialog/HarvesterSupportBundle.vue +++ b/pkg/harvester/dialog/HarvesterSupportBundle.vue @@ -6,6 +6,7 @@ import { LabeledInput } from '@components/Form/LabeledInput'; import AsyncButton from '@shell/components/AsyncButton'; import GraphCircle from '@shell/components/graph/Circle'; import { Banner } from '@components/Banner'; +import AppModal from '@shell/components/AppModal'; export default { name: 'SupportBundle', @@ -15,6 +16,7 @@ export default { GraphCircle, AsyncButton, Banner, + AppModal }, data() { @@ -22,6 +24,7 @@ export default { url: '', description: '', errors: [], + showModal: false }; }, @@ -44,10 +47,10 @@ export default { handler(show) { if (show) { this.$nextTick(() => { - this.$modal.show('bundle-modal'); + this.showModal = true; }); } else { - this.$modal.hide('bundle-modal'); + this.showModal = false; this.url = ''; this.description = ''; } @@ -60,6 +63,7 @@ export default { stringify, close() { + this.showModal = false; this.$store.commit('harvester-common/toggleBundleModal', false); this.backUpName = ''; }, @@ -102,82 +106,83 @@ export default { diff --git a/shell/components/AssignTo.vue b/shell/components/AssignTo.vue index 7165fd2a903..dfb137ffe38 100644 --- a/shell/components/AssignTo.vue +++ b/shell/components/AssignTo.vue @@ -25,6 +25,7 @@ export default { moveTo: this.workspace, loaded: false, allWorkspaces: [], + showModal: false }; }, @@ -51,9 +52,9 @@ export default { this.allWorkspaces = await this.$store.dispatch('management/findAll', { type: FLEET.WORKSPACE }); this.moveTo = this.workspace; this.loaded = true; - this.$modal.show('assignTo'); + this.showModal = true; } else { - this.$modal.hide('assignTo'); + this.showModal = false; } } }, @@ -105,12 +106,14 @@ export default { diff --git a/shell/components/PromptModal.vue b/shell/components/PromptModal.vue index e8ce71ebe3d..e23358d9591 100644 --- a/shell/components/PromptModal.vue +++ b/shell/components/PromptModal.vue @@ -1,6 +1,7 @@ diff --git a/shell/components/PromptRemove.vue b/shell/components/PromptRemove.vue index 4207d279c41..72cf71eedeb 100644 --- a/shell/components/PromptRemove.vue +++ b/shell/components/PromptRemove.vue @@ -9,11 +9,13 @@ import { uniq } from '@shell/utils/array'; import AsyncButton from '@shell/components/AsyncButton'; import { CATALOG as CATALOG_ANNOTATIONS } from '@shell/config/labels-annotations'; import { CATALOG } from '@shell/config/types'; +import AppModal from '@shell/components/AppModal.vue'; + export default { name: 'PromptRemove', components: { - Card, Checkbox, AsyncButton + Card, Checkbox, AsyncButton, AppModal }, props: { /** @@ -37,7 +39,8 @@ export default { preventDelete: false, removeComponent: this.$store.getters['type-map/importCustomPromptRemove'](resource), chartsToRemoveIsApp: false, - chartsDeleteCrd: false + chartsDeleteCrd: false, + showModal: false, }; }, computed: { @@ -164,7 +167,7 @@ export default { this.chartsToRemoveIsApp = true; } - this.$modal.show('promptRemove'); + this.showModal = true; let { resource } = this.$route.params; @@ -176,7 +179,7 @@ export default { this.removeComponent = this.$store.getters['type-map/importCustomPromptRemove'](resource); } else { - this.$modal.hide('promptRemove'); + this.showModal = false; } }, @@ -244,6 +247,8 @@ export default { // where the custom dialog needs to delete additional resources - it handles those and retrurns false to get us // to delete the main resource if (handled === undefined || handled) { + this.close(); + return; } } @@ -272,9 +277,14 @@ export default { }, async parallelRemove(btnCB) { try { + if (typeof this.toRemove[0].bulkRemove !== 'undefined') { + await this.toRemove[0].bulkRemove(this.toRemove, {}); + } else { + await Promise.all(this.toRemove.map(resource => resource.remove())); + } + const spoofedTypes = this.getSpoofedTypes(this.toRemove); - await Promise.all(this.toRemove.map(resource => resource.remove())); await this.refreshSpoofedTypes(spoofedTypes); this.done(); } catch (err) { @@ -321,13 +331,14 @@ export default { - + diff --git a/shell/components/ResourceCancelModal.vue b/shell/components/ResourceCancelModal.vue index d9f4267cc2c..22741c37ad1 100644 --- a/shell/components/ResourceCancelModal.vue +++ b/shell/components/ResourceCancelModal.vue @@ -1,6 +1,9 @@