2022-07-20 07:24:03 -07:00
|
|
|
<template>
|
|
|
|
<Modal
|
|
|
|
width="540px"
|
|
|
|
:name="COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY"
|
|
|
|
:title="getModalContent.title"
|
|
|
|
:eventBus="modalBus"
|
|
|
|
:center="true"
|
|
|
|
:showClose="!loading"
|
|
|
|
:beforeClose="onModalClose"
|
|
|
|
>
|
2022-11-18 05:59:31 -08:00
|
|
|
<template #content>
|
2022-07-20 07:24:03 -07:00
|
|
|
<n8n-text>{{ getModalContent.message }}</n8n-text>
|
2022-12-14 01:04:10 -08:00
|
|
|
<div
|
|
|
|
:class="$style.descriptionContainer"
|
|
|
|
v-if="mode === COMMUNITY_PACKAGE_MANAGE_ACTIONS.UPDATE"
|
|
|
|
>
|
2022-07-20 07:24:03 -07:00
|
|
|
<n8n-info-tip theme="info" type="note" :bold="false">
|
|
|
|
<template>
|
2022-09-05 07:36:22 -07:00
|
|
|
<span v-text="getModalContent.description"></span>
|
2022-07-20 07:24:03 -07:00
|
|
|
</template>
|
|
|
|
</n8n-info-tip>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-11-18 05:59:31 -08:00
|
|
|
<template #footer>
|
2022-07-20 07:24:03 -07:00
|
|
|
<n8n-button
|
|
|
|
:loading="loading"
|
|
|
|
:disabled="loading"
|
|
|
|
:label="loading ? getModalContent.buttonLoadingLabel : getModalContent.buttonLabel"
|
|
|
|
size="large"
|
|
|
|
float="right"
|
|
|
|
@click="onConfirmButtonClick"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</Modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Vue from 'vue';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
import Modal from './Modal.vue';
|
2022-12-14 01:04:10 -08:00
|
|
|
import {
|
|
|
|
COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY,
|
|
|
|
COMMUNITY_PACKAGE_MANAGE_ACTIONS,
|
|
|
|
} from '../constants';
|
2022-11-23 04:41:53 -08:00
|
|
|
import { showMessage } from '@/mixins/showMessage';
|
2022-11-04 06:04:31 -07:00
|
|
|
import { mapStores } from 'pinia';
|
|
|
|
import { useCommunityNodesStore } from '@/stores/communityNodes';
|
2022-07-20 07:24:03 -07:00
|
|
|
|
|
|
|
export default mixins(showMessage).extend({
|
|
|
|
name: 'CommunityPackageManageConfirmModal',
|
|
|
|
components: {
|
|
|
|
Modal,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
modalName: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
activePackageName: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
mode: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
modalBus: new Vue(),
|
|
|
|
COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY,
|
|
|
|
COMMUNITY_PACKAGE_MANAGE_ACTIONS,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2022-11-04 06:04:31 -07:00
|
|
|
...mapStores(useCommunityNodesStore),
|
2022-07-20 07:24:03 -07:00
|
|
|
activePackage() {
|
2022-11-04 06:04:31 -07:00
|
|
|
return this.communityNodesStore.getInstalledPackageByName(this.activePackageName);
|
2022-07-20 07:24:03 -07:00
|
|
|
},
|
|
|
|
getModalContent() {
|
|
|
|
if (this.mode === COMMUNITY_PACKAGE_MANAGE_ACTIONS.UNINSTALL) {
|
|
|
|
return {
|
|
|
|
title: this.$locale.baseText('settings.communityNodes.confirmModal.uninstall.title'),
|
|
|
|
message: this.$locale.baseText('settings.communityNodes.confirmModal.uninstall.message', {
|
|
|
|
interpolate: {
|
|
|
|
packageName: this.activePackageName,
|
|
|
|
},
|
|
|
|
}),
|
2022-12-14 01:04:10 -08:00
|
|
|
buttonLabel: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.confirmModal.uninstall.buttonLabel',
|
|
|
|
),
|
|
|
|
buttonLoadingLabel: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.confirmModal.uninstall.buttonLoadingLabel',
|
|
|
|
),
|
2022-07-20 07:24:03 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
title: this.$locale.baseText('settings.communityNodes.confirmModal.update.title', {
|
|
|
|
interpolate: {
|
|
|
|
packageName: this.activePackageName,
|
|
|
|
},
|
|
|
|
}),
|
2022-12-14 01:04:10 -08:00
|
|
|
description: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.confirmModal.update.description',
|
|
|
|
),
|
2022-07-20 07:24:03 -07:00
|
|
|
message: this.$locale.baseText('settings.communityNodes.confirmModal.update.message', {
|
|
|
|
interpolate: {
|
|
|
|
packageName: this.activePackageName,
|
|
|
|
version: this.activePackage.updateAvailable,
|
|
|
|
},
|
|
|
|
}),
|
2022-12-14 01:04:10 -08:00
|
|
|
buttonLabel: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.confirmModal.update.buttonLabel',
|
|
|
|
),
|
|
|
|
buttonLoadingLabel: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.confirmModal.update.buttonLoadingLabel',
|
|
|
|
),
|
2022-07-20 07:24:03 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onModalClose() {
|
|
|
|
return !this.loading;
|
|
|
|
},
|
|
|
|
async onConfirmButtonClick() {
|
|
|
|
if (this.mode === COMMUNITY_PACKAGE_MANAGE_ACTIONS.UNINSTALL) {
|
|
|
|
await this.onUninstall();
|
|
|
|
} else if (this.mode === COMMUNITY_PACKAGE_MANAGE_ACTIONS.UPDATE) {
|
|
|
|
await this.onUpdate();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async onUninstall() {
|
|
|
|
try {
|
|
|
|
this.$telemetry.track('user started cnr package deletion', {
|
|
|
|
package_name: this.activePackage.packageName,
|
2022-12-14 01:04:10 -08:00
|
|
|
package_node_names: this.activePackage.installedNodes.map((node) => node.name),
|
2022-07-20 07:24:03 -07:00
|
|
|
package_version: this.activePackage.installedVersion,
|
|
|
|
package_author: this.activePackage.authorName,
|
|
|
|
package_author_email: this.activePackage.authorEmail,
|
|
|
|
});
|
|
|
|
this.loading = true;
|
2022-11-04 06:04:31 -07:00
|
|
|
await this.communityNodesStore.uninstallPackage(this.activePackageName);
|
2022-07-20 07:24:03 -07:00
|
|
|
this.$showMessage({
|
|
|
|
title: this.$locale.baseText('settings.communityNodes.messages.uninstall.success.title'),
|
|
|
|
type: 'success',
|
|
|
|
});
|
|
|
|
} catch (error) {
|
2022-12-14 01:04:10 -08:00
|
|
|
this.$showError(
|
|
|
|
error,
|
|
|
|
this.$locale.baseText('settings.communityNodes.messages.uninstall.error'),
|
|
|
|
);
|
2022-07-20 07:24:03 -07:00
|
|
|
} finally {
|
|
|
|
this.loading = false;
|
|
|
|
this.modalBus.$emit('close');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async onUpdate() {
|
|
|
|
try {
|
|
|
|
this.$telemetry.track('user started cnr package update', {
|
|
|
|
package_name: this.activePackage.packageName,
|
2022-12-14 01:04:10 -08:00
|
|
|
package_node_names: this.activePackage.installedNodes.map((node) => node.name),
|
2022-07-20 07:24:03 -07:00
|
|
|
package_version_current: this.activePackage.installedVersion,
|
|
|
|
package_version_new: this.activePackage.updateAvailable,
|
|
|
|
package_author: this.activePackage.authorName,
|
|
|
|
package_author_email: this.activePackage.authorEmail,
|
|
|
|
});
|
|
|
|
this.loading = true;
|
|
|
|
const updatedVersion = this.activePackage.updateAvailable;
|
2022-11-04 06:04:31 -07:00
|
|
|
await this.communityNodesStore.updatePackage(this.activePackageName);
|
2022-07-20 07:24:03 -07:00
|
|
|
this.$showMessage({
|
|
|
|
title: this.$locale.baseText('settings.communityNodes.messages.update.success.title'),
|
2022-12-14 01:04:10 -08:00
|
|
|
message: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.messages.update.success.message',
|
|
|
|
{
|
|
|
|
interpolate: {
|
|
|
|
packageName: this.activePackageName,
|
|
|
|
version: updatedVersion,
|
|
|
|
},
|
2022-07-20 07:24:03 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
),
|
2022-07-20 07:24:03 -07:00
|
|
|
type: 'success',
|
|
|
|
});
|
|
|
|
} catch (error) {
|
2022-12-14 01:04:10 -08:00
|
|
|
this.$showError(
|
|
|
|
error,
|
|
|
|
this.$locale.baseText('settings.communityNodes.messages.update.error.title'),
|
|
|
|
);
|
2022-07-20 07:24:03 -07:00
|
|
|
} finally {
|
|
|
|
this.loading = false;
|
|
|
|
this.modalBus.$emit('close');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style module lang="scss">
|
2022-12-14 01:04:10 -08:00
|
|
|
.descriptionContainer {
|
|
|
|
display: flex;
|
|
|
|
margin: var(--spacing-s) 0;
|
|
|
|
}
|
2022-07-20 07:24:03 -07:00
|
|
|
|
2022-12-14 01:04:10 -08:00
|
|
|
.descriptionIcon {
|
|
|
|
align-self: center;
|
|
|
|
color: var(--color-text-lighter);
|
|
|
|
}
|
2022-07-20 07:24:03 -07:00
|
|
|
|
2022-12-14 01:04:10 -08:00
|
|
|
.descriptionText {
|
|
|
|
padding: 0 var(--spacing-xs);
|
|
|
|
}
|
2022-07-20 07:24:03 -07:00
|
|
|
</style>
|