Skip to content

Commit

Permalink
Port app-modal into harvester shell
Browse files Browse the repository at this point in the history
Signed-off-by: andy.lee <andy.lee@suse.com>
  • Loading branch information
a110605 committed Sep 24, 2024
1 parent f50a27f commit e2d28d5
Show file tree
Hide file tree
Showing 44 changed files with 628 additions and 346 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/po/prompts/promptRemove.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -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);

/**
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 9 additions & 4 deletions pkg/harvester/components/HarvesterUpgrade.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default {
selectMode: true,
version: '',
enableLogging: true,
readyReleaseNote: false
readyReleaseNote: false,
showModal: false,
};
},
Expand Down Expand Up @@ -121,12 +122,12 @@ export default {
},
cancel() {
this.$refs.deleteTip.hide();
this.showModal = false;
this.errors = '';
},
open() {
this.$refs.deleteTip.open();
this.showModal = true;
},
}
};
Expand All @@ -151,7 +152,11 @@ export default {
</button>
</header>
<ModalWithCard ref="deleteTip" name="deleteTip" :width="850">
<ModalWithCard
v-if="showModal"
name="deleteTip"
:width="850"
>
<template #title>
<t k="harvester.upgradePage.upgradeApp" />
</template>
Expand Down
14 changes: 10 additions & 4 deletions pkg/harvester/components/novnc/NovncConsoleCustomKeys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -170,7 +173,10 @@ export default {
</script>
<template>
<ModalWithCard ref="recordShortcutKeys" name="recordShortcutKeys" :width="550">
<ModalWithCard
name="recordShortcutKeys"
:width="550"
>
<template #title>
<t k="harvester.virtualMachine.detail.console.customShortcutKeys" />
</template>
Expand Down
10 changes: 6 additions & 4 deletions pkg/harvester/components/novnc/NovncConsoleWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const F_KEYS = {
};
export default {
name: 'NovncConsoleWrapper',
components: {
NovncConsole, NovncConsoleItem, NovncConsoleCustomKeys
},
Expand Down Expand Up @@ -261,9 +262,6 @@ export default {
showKeysModal() {
this.renderKeysModal = true;
this.$nextTick(() => {
this.$refs.keysModal.show();
});
},
hideKeysModal() {
Expand Down Expand Up @@ -325,7 +323,11 @@ export default {
</template>
</v-popover>
<NovncConsoleCustomKeys v-if="renderKeysModal" ref="keysModal" :current-user="currentUser" @close="hideKeysModal" />
<NovncConsoleCustomKeys
v-if="renderKeysModal"
:current-user="currentUser"
@close="hideKeysModal"
/>
</div>
<NovncConsole v-if="url && !isDown" ref="novncConsole" :url="url" />
<p v-if="isDown">
Expand Down
147 changes: 76 additions & 71 deletions pkg/harvester/dialog/HarvesterSupportBundle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -15,13 +16,15 @@ export default {
GraphCircle,
AsyncButton,
Banner,
AppModal
},
data() {
return {
url: '',
description: '',
errors: [],
showModal: false
};
},
Expand All @@ -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 = '';
}
Expand All @@ -60,6 +63,7 @@ export default {
stringify,
close() {
this.showModal = false;
this.$store.commit('harvester-common/toggleBundleModal', false);
this.backUpName = '';
},
Expand Down Expand Up @@ -102,82 +106,83 @@ export default {
</script>

<template>
<div class="bundleModal">
<modal
name="bundle-modal"
:click-to-close="false"
:width="550"
:height="390"
class="remove-modal support-modal"
>
<div class="p-20">
<h2>
{{ t('harvester.modal.bundle.title') }}
</h2>

<div
v-if="!bundlePending"
class="content"
>
<LabeledInput
v-model="url"
:label="t('harvester.modal.bundle.url')"
class="mb-20"
/>
<app-modal
v-if="showModal"
custom-class="bundleModal"
name="bundle-modal andy"
:click-to-close="false"
:width="550"
:height="390"
class="remove-modal support-modal"
@close="close"
>
<div class="p-20">
<h2>
{{ t('harvester.modal.bundle.title') }}
</h2>

<div
v-if="!bundlePending"
class="content"
>
<LabeledInput
v-model="url"
:label="t('harvester.modal.bundle.url')"
class="mb-20"
/>

<LabeledInput
v-model="description"
:label="t('harvester.modal.bundle.description')"
type="multiline"
:min-height="120"
required
/>
</div>

<LabeledInput
v-model="description"
:label="t('harvester.modal.bundle.description')"
type="multiline"
:min-height="120"
required
<div
v-else
class="content"
>
<div class="circle">
<GraphCircle
primary-stroke-color="green"
secondary-stroke-color="white"
:stroke-width="6"
:percentage="percentage"
:show-text="true"
/>
</div>
</div>

<div
v-else
class="content"
>
<div class="circle">
<GraphCircle
primary-stroke-color="green"
secondary-stroke-color="white"
:stroke-width="6"
:percentage="percentage"
:show-text="true"
/>
</div>
</div>
<div
v-for="(err, idx) in errors"
:key="idx"
>
<Banner
color="error"
:label="stringify(err)"
/>
</div>

<div
v-for="(err, idx) in errors"
:key="idx"
<div class="footer mt-20">
<button
class="btn btn-sm role-secondary mr-10"
@click="close"
>
<Banner
color="error"
:label="stringify(err)"
/>
</div>

<div class="footer mt-20">
<button
class="btn btn-sm role-secondary mr-10"
@click="close"
>
{{ t('generic.close') }}
</button>

<AsyncButton
type="submit"
mode="generate"
class="btn btn-sm bg-primary"
:disabled="bundlePending"
@click="save"
/>
</div>
{{ t('generic.close') }}
</button>

<AsyncButton
type="submit"
mode="generate"
class="btn btn-sm bg-primary"
:disabled="bundlePending"
@click="save"
/>
</div>
</modal>
</div>
</div>
</app-modal>
</template>

<style lang="scss" scoped>
Expand Down
20 changes: 16 additions & 4 deletions pkg/harvester/dialog/RestartVMDialog.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<script>
import { mapGetters } from 'vuex';
import AsyncButton from '@shell/components/AsyncButton';
import AppModal from '@shell/components/AppModal';
import { Card } from '@components/Card';
import { Banner } from '@components/Banner';
import { exceptionToErrorsArray } from '@shell/utils/error';
export default {
components: {
Card,
AsyncButton,
Banner,
AppModal
},
props: {
vm: {
Expand All @@ -17,11 +20,19 @@ export default {
},
},
data() {
return { errors: [], resolve: null };
return {
errors: [],
resolve: null,
isOpen: false
};
},
computed: { ...mapGetters({ t: 'i18n/t' }) },
methods: {
open() {
this.isOpen = true;
},
close() {
this.isOpen = false;
this.resolve();
this.$emit('close');
},
Expand All @@ -42,13 +53,14 @@ export default {
</script>

<template>
<modal
<app-modal
v-if="isOpen"
class="restart-modal"
name="restartDialog"
:width="600"
height="auto"
:click-to-close="false"
@closed="close"
@close="close"
>
<Card class="prompt-restart" :show-highlight-border="false">
<h4 slot="title" v-clean-html="t('harvester.modal.restart.title')" class="text-default-text" />
Expand All @@ -74,7 +86,7 @@ export default {
</div>
</div>
</Card>
</modal>
</app-modal>
</template>
<style lang='scss' scoped>
.restart-modal {
Expand Down
Loading

0 comments on commit e2d28d5

Please sign in to comment.