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-11-21 05:11:29 -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';
|
|
|
|
import { COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY, COMMUNITY_PACKAGE_MANAGE_ACTIONS } from '../constants';
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
buttonLabel: this.$locale.baseText('settings.communityNodes.confirmModal.uninstall.buttonLabel'),
|
|
|
|
buttonLoadingLabel: this.$locale.baseText('settings.communityNodes.confirmModal.uninstall.buttonLoadingLabel'),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
title: this.$locale.baseText('settings.communityNodes.confirmModal.update.title', {
|
|
|
|
interpolate: {
|
|
|
|
packageName: this.activePackageName,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
description: this.$locale.baseText('settings.communityNodes.confirmModal.update.description'),
|
|
|
|
message: this.$locale.baseText('settings.communityNodes.confirmModal.update.message', {
|
|
|
|
interpolate: {
|
|
|
|
packageName: this.activePackageName,
|
|
|
|
version: this.activePackage.updateAvailable,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
buttonLabel: this.$locale.baseText('settings.communityNodes.confirmModal.update.buttonLabel'),
|
|
|
|
buttonLoadingLabel: this.$locale.baseText('settings.communityNodes.confirmModal.update.buttonLoadingLabel'),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
package_node_names: this.activePackage.installedNodes.map(node => node.name),
|
|
|
|
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) {
|
|
|
|
this.$showError(error, this.$locale.baseText('settings.communityNodes.messages.uninstall.error'));
|
|
|
|
} finally {
|
|
|
|
this.loading = false;
|
|
|
|
this.modalBus.$emit('close');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async onUpdate() {
|
|
|
|
try {
|
|
|
|
this.$telemetry.track('user started cnr package update', {
|
|
|
|
package_name: this.activePackage.packageName,
|
|
|
|
package_node_names: this.activePackage.installedNodes.map(node => node.name),
|
|
|
|
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'),
|
|
|
|
message: this.$locale.baseText('settings.communityNodes.messages.update.success.message', {
|
|
|
|
interpolate: {
|
|
|
|
packageName: this.activePackageName,
|
|
|
|
version: updatedVersion,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
type: 'success',
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
this.$showError(error, this.$locale.baseText('settings.communityNodes.messages.update.error.title'));
|
|
|
|
} finally {
|
|
|
|
this.loading = false;
|
|
|
|
this.modalBus.$emit('close');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style module lang="scss">
|
|
|
|
.descriptionContainer {
|
|
|
|
display: flex;
|
|
|
|
margin: var(--spacing-s) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.descriptionIcon {
|
|
|
|
align-self: center;
|
|
|
|
color: var(--color-text-lighter);
|
|
|
|
}
|
|
|
|
|
|
|
|
.descriptionText {
|
|
|
|
padding: 0 var(--spacing-xs);
|
|
|
|
}
|
|
|
|
</style>
|