refactor(editor): Migrate AboutModal.vue to composition API (#10722)

This commit is contained in:
Ricardo Espinoza 2024-09-10 10:20:12 -04:00 committed by GitHub
parent 14580dadde
commit 8d4afddcf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,50 +1,39 @@
<script lang="ts"> <script setup lang="ts">
import { defineComponent } from 'vue';
import { mapStores } from 'pinia';
import { createEventBus } from 'n8n-design-system/utils'; import { createEventBus } from 'n8n-design-system/utils';
import Modal from './Modal.vue'; import Modal from './Modal.vue';
import { ABOUT_MODAL_KEY } from '../constants'; import { ABOUT_MODAL_KEY } from '../constants';
import { useSettingsStore } from '@/stores/settings.store';
import { useRootStore } from '@/stores/root.store'; import { useRootStore } from '@/stores/root.store';
import { useToast } from '@/composables/useToast'; import { useToast } from '@/composables/useToast';
import { useClipboard } from '@/composables/useClipboard'; import { useClipboard } from '@/composables/useClipboard';
import { useDebugInfo } from '@/composables/useDebugInfo'; import { useDebugInfo } from '@/composables/useDebugInfo';
import { useI18n } from '@/composables/useI18n';
export default defineComponent({ const modalBus = createEventBus();
name: 'About', const toast = useToast();
components: { const i18n = useI18n();
Modal, const debugInfo = useDebugInfo();
}, const clipboard = useClipboard();
data() { const rootStore = useRootStore();
return {
ABOUT_MODAL_KEY, const closeDialog = () => {
modalBus: createEventBus(), modalBus.emit('close');
}; };
},
computed: { const copyDebugInfoToClipboard = async () => {
...mapStores(useRootStore, useSettingsStore), toast.showToast({
}, title: i18n.baseText('about.debug.toast.title'),
methods: { message: i18n.baseText('about.debug.toast.message'),
closeDialog() {
this.modalBus.emit('close');
},
async copyDebugInfoToClipboard() {
useToast().showToast({
title: this.$locale.baseText('about.debug.toast.title'),
message: this.$locale.baseText('about.debug.toast.message'),
type: 'info', type: 'info',
duration: 5000, duration: 5000,
}); });
await useClipboard().copy(useDebugInfo().generateDebugInfo()); await clipboard.copy(debugInfo.generateDebugInfo());
}, };
},
});
</script> </script>
<template> <template>
<Modal <Modal
max-width="540px" max-width="540px"
:title="$locale.baseText('about.aboutN8n')" :title="i18n.baseText('about.aboutN8n')"
:event-bus="modalBus" :event-bus="modalBus"
:name="ABOUT_MODAL_KEY" :name="ABOUT_MODAL_KEY"
:center="true" :center="true"
@ -53,7 +42,7 @@ export default defineComponent({
<div :class="$style.container"> <div :class="$style.container">
<el-row> <el-row>
<el-col :span="8" class="info-name"> <el-col :span="8" class="info-name">
<n8n-text>{{ $locale.baseText('about.n8nVersion') }}</n8n-text> <n8n-text>{{ i18n.baseText('about.n8nVersion') }}</n8n-text>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<n8n-text>{{ rootStore.versionCli }}</n8n-text> <n8n-text>{{ rootStore.versionCli }}</n8n-text>
@ -61,7 +50,7 @@ export default defineComponent({
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8" class="info-name"> <el-col :span="8" class="info-name">
<n8n-text>{{ $locale.baseText('about.sourceCode') }}</n8n-text> <n8n-text>{{ i18n.baseText('about.sourceCode') }}</n8n-text>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<n8n-link to="https://github.com/n8n-io/n8n">https://github.com/n8n-io/n8n</n8n-link> <n8n-link to="https://github.com/n8n-io/n8n">https://github.com/n8n-io/n8n</n8n-link>
@ -69,17 +58,17 @@ export default defineComponent({
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8" class="info-name"> <el-col :span="8" class="info-name">
<n8n-text>{{ $locale.baseText('about.license') }}</n8n-text> <n8n-text>{{ i18n.baseText('about.license') }}</n8n-text>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<n8n-link to="https://github.com/n8n-io/n8n/blob/master/LICENSE.md"> <n8n-link to="https://github.com/n8n-io/n8n/blob/master/LICENSE.md">
{{ $locale.baseText('about.n8nLicense') }} {{ i18n.baseText('about.n8nLicense') }}
</n8n-link> </n8n-link>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8" class="info-name"> <el-col :span="8" class="info-name">
<n8n-text>{{ $locale.baseText('about.instanceID') }}</n8n-text> <n8n-text>{{ i18n.baseText('about.instanceID') }}</n8n-text>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<n8n-text>{{ rootStore.instanceId }}</n8n-text> <n8n-text>{{ rootStore.instanceId }}</n8n-text>
@ -87,11 +76,11 @@ export default defineComponent({
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8" class="info-name"> <el-col :span="8" class="info-name">
<n8n-text>{{ $locale.baseText('about.debug.title') }}</n8n-text> <n8n-text>{{ i18n.baseText('about.debug.title') }}</n8n-text>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<div :class="$style.debugInfo" @click="copyDebugInfoToClipboard"> <div :class="$style.debugInfo" @click="copyDebugInfoToClipboard">
<n8n-link>{{ $locale.baseText('about.debug.message') }}</n8n-link> <n8n-link>{{ i18n.baseText('about.debug.message') }}</n8n-link>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -102,7 +91,7 @@ export default defineComponent({
<div class="action-buttons"> <div class="action-buttons">
<n8n-button <n8n-button
float="right" float="right"
:label="$locale.baseText('about.close')" :label="i18n.baseText('about.close')"
data-test-id="close-about-modal-button" data-test-id="close-about-modal-button"
@click="closeDialog" @click="closeDialog"
/> />