2022-07-20 07:24:03 -07:00
|
|
|
<template>
|
|
|
|
<div :class="$style.cardContainer">
|
|
|
|
<div v-if="loading" :class="$style.cardSkeleton">
|
|
|
|
<n8n-loading :class="$style.loader" variant="p" :rows="1" />
|
|
|
|
<n8n-loading :class="$style.loader" variant="p" :rows="1" />
|
|
|
|
</div>
|
|
|
|
<div v-else :class="$style.packageCard">
|
|
|
|
<div :class="$style.cardInfoContainer">
|
|
|
|
<div :class="$style.cardTitle">
|
|
|
|
<n8n-text :bold="true" size="large">{{ communityPackage.packageName }}</n8n-text>
|
|
|
|
</div>
|
|
|
|
<div :class="$style.cardSubtitle">
|
|
|
|
<n8n-text :bold="true" size="small" color="text-light">
|
|
|
|
{{
|
|
|
|
$locale.baseText('settings.communityNodes.packageNodes.label', {
|
|
|
|
adjustToNumber: communityPackage.installedNodes.length,
|
|
|
|
})
|
|
|
|
}}:
|
|
|
|
</n8n-text>
|
|
|
|
<n8n-text size="small" color="text-light">
|
|
|
|
<span v-for="(node, index) in communityPackage.installedNodes" :key="node.name">
|
2022-12-14 01:04:10 -08:00
|
|
|
{{ node.name
|
|
|
|
}}<span v-if="index != communityPackage.installedNodes.length - 1">,</span>
|
2022-07-20 07:24:03 -07:00
|
|
|
</span>
|
|
|
|
</n8n-text>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div :class="$style.cardControlsContainer">
|
|
|
|
<n8n-text :bold="true" size="large" color="text-light">
|
|
|
|
v{{ communityPackage.installedVersion }}
|
|
|
|
</n8n-text>
|
|
|
|
<n8n-tooltip v-if="communityPackage.failedLoading === true" placement="top">
|
2022-11-18 05:59:31 -08:00
|
|
|
<template #content>
|
|
|
|
<div>
|
|
|
|
{{ $locale.baseText('settings.communityNodes.failedToLoad.tooltip') }}
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-07-20 07:24:03 -07:00
|
|
|
<n8n-icon icon="exclamation-triangle" color="danger" size="large" />
|
|
|
|
</n8n-tooltip>
|
|
|
|
<n8n-tooltip v-else-if="communityPackage.updateAvailable" placement="top">
|
2022-11-18 05:59:31 -08:00
|
|
|
<template #content>
|
|
|
|
<div>
|
|
|
|
{{ $locale.baseText('settings.communityNodes.updateAvailable.tooltip') }}
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-12-14 01:04:10 -08:00
|
|
|
<n8n-button type="outline" label="Update" @click="onUpdateClick" />
|
2022-07-20 07:24:03 -07:00
|
|
|
</n8n-tooltip>
|
|
|
|
<n8n-tooltip v-else placement="top">
|
2022-11-18 05:59:31 -08:00
|
|
|
<template #content>
|
|
|
|
<div>
|
|
|
|
{{ $locale.baseText('settings.communityNodes.upToDate.tooltip') }}
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-07-20 07:24:03 -07:00
|
|
|
<n8n-icon icon="check-circle" color="text-light" size="large" />
|
|
|
|
</n8n-tooltip>
|
|
|
|
<div :class="$style.cardActions">
|
|
|
|
<n8n-action-toggle :actions="packageActions" @action="onAction"></n8n-action-toggle>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-05-05 01:41:54 -07:00
|
|
|
import { useUIStore } from '@/stores/ui.store';
|
2023-04-24 03:18:24 -07:00
|
|
|
import type { PublicInstalledPackage } from 'n8n-workflow';
|
2022-11-04 06:04:31 -07:00
|
|
|
import { mapStores } from 'pinia';
|
2023-05-12 07:43:34 -07:00
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
import { NPM_PACKAGE_DOCS_BASE_URL, COMMUNITY_PACKAGE_MANAGE_ACTIONS } from '../constants';
|
|
|
|
import { showMessage } from '@/mixins/showMessage';
|
2022-07-20 07:24:03 -07:00
|
|
|
|
2023-05-12 07:43:34 -07:00
|
|
|
export default mixins(showMessage).extend({
|
2022-07-20 07:24:03 -07:00
|
|
|
name: 'CommunityPackageCard',
|
|
|
|
props: {
|
|
|
|
communityPackage: {
|
|
|
|
type: Object as () => PublicInstalledPackage,
|
|
|
|
},
|
|
|
|
loading: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
packageActions: [
|
|
|
|
{
|
|
|
|
label: this.$locale.baseText('settings.communityNodes.viewDocsAction.label'),
|
|
|
|
value: COMMUNITY_PACKAGE_MANAGE_ACTIONS.VIEW_DOCS,
|
|
|
|
type: 'external-link',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.$locale.baseText('settings.communityNodes.uninstallAction.label'),
|
|
|
|
value: COMMUNITY_PACKAGE_MANAGE_ACTIONS.UNINSTALL,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
},
|
2022-11-04 06:04:31 -07:00
|
|
|
computed: {
|
|
|
|
...mapStores(useUIStore),
|
|
|
|
},
|
2022-07-20 07:24:03 -07:00
|
|
|
methods: {
|
|
|
|
async onAction(value: string) {
|
|
|
|
switch (value) {
|
|
|
|
case COMMUNITY_PACKAGE_MANAGE_ACTIONS.VIEW_DOCS:
|
|
|
|
this.$telemetry.track('user clicked to browse the cnr package documentation', {
|
|
|
|
package_name: this.communityPackage.packageName,
|
|
|
|
package_version: this.communityPackage.installedVersion,
|
|
|
|
});
|
|
|
|
window.open(`${NPM_PACKAGE_DOCS_BASE_URL}${this.communityPackage.packageName}`, '_blank');
|
|
|
|
break;
|
|
|
|
case COMMUNITY_PACKAGE_MANAGE_ACTIONS.UNINSTALL:
|
2022-11-04 06:04:31 -07:00
|
|
|
this.uiStore.openCommunityPackageUninstallConfirmModal(this.communityPackage.packageName);
|
2022-07-20 07:24:03 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onUpdateClick() {
|
2022-11-04 06:04:31 -07:00
|
|
|
this.uiStore.openCommunityPackageUpdateConfirmModal(this.communityPackage.packageName);
|
2022-07-20 07:24:03 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.cardContainer {
|
|
|
|
display: flex;
|
|
|
|
padding: var(--spacing-s);
|
|
|
|
border: var(--border-width-base) var(--border-style-base) var(--color-info-tint-1);
|
|
|
|
border-radius: var(--border-radius-large);
|
|
|
|
background-color: var(--color-background-xlight);
|
|
|
|
}
|
|
|
|
|
2022-12-14 01:04:10 -08:00
|
|
|
.packageCard,
|
|
|
|
.cardSkeleton {
|
2022-07-20 07:24:03 -07:00
|
|
|
display: flex;
|
|
|
|
flex-basis: 100%;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
|
|
|
|
.packageCard {
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cardSkeleton {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loader {
|
|
|
|
width: 50%;
|
|
|
|
transform: scaleY(-1);
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
width: 70%;
|
|
|
|
|
|
|
|
div {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.cardInfoContainer {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cardTitle {
|
|
|
|
flex-basis: 100%;
|
|
|
|
|
|
|
|
span {
|
|
|
|
line-height: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.cardSubtitle {
|
|
|
|
margin-top: 2px;
|
|
|
|
padding-right: var(--spacing-m);
|
|
|
|
}
|
|
|
|
|
|
|
|
.cardControlsContainer {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
gap: var(--spacing-3xs);
|
|
|
|
}
|
|
|
|
|
|
|
|
.cardActions {
|
|
|
|
padding-left: var(--spacing-3xs);
|
|
|
|
}
|
|
|
|
</style>
|