2022-07-20 07:24:03 -07:00
|
|
|
<template>
|
|
|
|
<SettingsView>
|
|
|
|
<div :class="$style.container">
|
|
|
|
<div :class="$style.headingContainer">
|
|
|
|
<n8n-heading size="2xlarge">{{ $locale.baseText('settings.communityNodes') }}</n8n-heading>
|
|
|
|
<n8n-button
|
2022-11-04 06:04:31 -07:00
|
|
|
v-if="!settingsStore.isQueueModeEnabled && communityNodesStore.getInstalledPackages.length > 0 && !loading"
|
2022-07-20 07:24:03 -07:00
|
|
|
:label="$locale.baseText('settings.communityNodes.installModal.installButton.label')"
|
|
|
|
size="large"
|
|
|
|
@click="openInstallModal"
|
|
|
|
/>
|
|
|
|
</div>
|
2022-11-04 06:04:31 -07:00
|
|
|
<div v-if="settingsStore.isQueueModeEnabled" :class="$style.actionBoxContainer">
|
2022-08-02 01:36:11 -07:00
|
|
|
<n8n-action-box
|
|
|
|
:heading="$locale.baseText('settings.communityNodes.empty.title')"
|
|
|
|
:description="getEmptyStateDescription"
|
|
|
|
:calloutText="actionBoxConfig.calloutText"
|
|
|
|
:calloutTheme="actionBoxConfig.calloutTheme"
|
|
|
|
/>
|
|
|
|
</div>
|
2022-07-20 07:24:03 -07:00
|
|
|
<div
|
|
|
|
:class="$style.cardsContainer"
|
|
|
|
v-else-if="loading"
|
|
|
|
>
|
|
|
|
<community-package-card
|
|
|
|
v-for="n in 2"
|
|
|
|
:key="'index-' + n"
|
|
|
|
:loading="true"
|
|
|
|
></community-package-card>
|
|
|
|
</div>
|
|
|
|
<div
|
2022-11-04 06:04:31 -07:00
|
|
|
v-else-if="communityNodesStore.getInstalledPackages.length === 0"
|
2022-07-20 07:24:03 -07:00
|
|
|
:class="$style.actionBoxContainer"
|
|
|
|
>
|
|
|
|
<n8n-action-box
|
|
|
|
:heading="$locale.baseText('settings.communityNodes.empty.title')"
|
|
|
|
:description="getEmptyStateDescription"
|
2022-08-11 07:39:55 -07:00
|
|
|
:buttonText="
|
2022-10-13 04:42:12 -07:00
|
|
|
shouldShowInstallButton
|
2022-08-11 07:39:55 -07:00
|
|
|
? $locale.baseText('settings.communityNodes.empty.installPackageLabel')
|
|
|
|
: ''
|
|
|
|
"
|
2022-07-20 07:24:03 -07:00
|
|
|
:calloutText="actionBoxConfig.calloutText"
|
|
|
|
:calloutTheme="actionBoxConfig.calloutTheme"
|
|
|
|
@click="openInstallModal"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
:class="$style.cardsContainer"
|
|
|
|
v-else
|
|
|
|
>
|
|
|
|
<community-package-card
|
2022-11-04 06:04:31 -07:00
|
|
|
v-for="communityPackage in communityNodesStore.getInstalledPackages"
|
2022-07-20 07:24:03 -07:00
|
|
|
:key="communityPackage.packageName"
|
|
|
|
:communityPackage="communityPackage"
|
|
|
|
></community-package-card>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</SettingsView>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-08-11 07:39:55 -07:00
|
|
|
import {
|
|
|
|
COMMUNITY_PACKAGE_INSTALL_MODAL_KEY,
|
|
|
|
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
|
|
|
COMMUNITY_NODES_NPM_INSTALLATION_URL,
|
|
|
|
} from '../constants';
|
2022-11-04 06:04:31 -07:00
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import SettingsView from './SettingsView.vue';
|
|
|
|
import CommunityPackageCard from '../components/CommunityPackageCard.vue';
|
|
|
|
import { showMessage } from '@/components/mixins/showMessage';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
2022-07-20 07:24:03 -07:00
|
|
|
import { PublicInstalledPackage } from 'n8n-workflow';
|
|
|
|
|
2022-11-04 06:04:31 -07:00
|
|
|
import { useCommunityNodesStore } from '@/stores/communityNodes';
|
|
|
|
import { useUIStore } from '@/stores/ui';
|
|
|
|
import { mapStores } from 'pinia';
|
|
|
|
import { useSettingsStore } from '@/stores/settings';
|
|
|
|
|
2022-07-20 07:24:03 -07:00
|
|
|
const PACKAGE_COUNT_THRESHOLD = 31;
|
|
|
|
|
|
|
|
export default mixins(
|
|
|
|
showMessage,
|
|
|
|
).extend({
|
|
|
|
name: 'SettingsCommunityNodesView',
|
|
|
|
components: {
|
|
|
|
SettingsView,
|
|
|
|
CommunityPackageCard,
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
try {
|
|
|
|
this.$data.loading = true;
|
2022-11-04 06:04:31 -07:00
|
|
|
await this.communityNodesStore.fetchInstalledPackages();
|
2022-07-20 07:24:03 -07:00
|
|
|
|
2022-11-04 06:04:31 -07:00
|
|
|
const installedPackages: PublicInstalledPackage[] = this.communityNodesStore.getInstalledPackages;
|
2022-07-20 07:24:03 -07:00
|
|
|
const packagesToUpdate: PublicInstalledPackage[] = installedPackages.filter(p => p.updateAvailable );
|
|
|
|
this.$telemetry.track('user viewed cnr settings page', {
|
|
|
|
num_of_packages_installed: installedPackages.length,
|
|
|
|
installed_packages: installedPackages.map(p => {
|
|
|
|
return {
|
|
|
|
package_name: p.packageName,
|
|
|
|
package_version: p.installedVersion,
|
|
|
|
package_nodes: p.installedNodes.map(node => `${node.name}-v${node.latestVersion}`),
|
|
|
|
is_update_available: p.updateAvailable !== undefined,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
packages_to_update: packagesToUpdate.map(p => {
|
|
|
|
return {
|
|
|
|
package_name: p.packageName,
|
|
|
|
package_version_current: p.installedVersion,
|
|
|
|
package_version_available: p.updateAvailable,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
number_of_updates_available: packagesToUpdate.length,
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
this.$showError(
|
|
|
|
error,
|
|
|
|
this.$locale.baseText('settings.communityNodes.fetchError.title'),
|
|
|
|
this.$locale.baseText('settings.communityNodes.fetchError.message'),
|
|
|
|
);
|
|
|
|
} finally {
|
|
|
|
this.$data.loading = false;
|
|
|
|
}
|
|
|
|
try {
|
2022-11-04 06:04:31 -07:00
|
|
|
await this.communityNodesStore.fetchAvailableCommunityPackageCount();
|
2022-07-20 07:24:03 -07:00
|
|
|
} finally {
|
|
|
|
this.$data.loading = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-11-04 06:04:31 -07:00
|
|
|
...mapStores(
|
|
|
|
useCommunityNodesStore,
|
|
|
|
useSettingsStore,
|
|
|
|
useUIStore,
|
|
|
|
),
|
2022-07-20 07:24:03 -07:00
|
|
|
getEmptyStateDescription() {
|
2022-11-04 06:04:31 -07:00
|
|
|
const packageCount = this.communityNodesStore.availablePackageCount;
|
2022-07-20 07:24:03 -07:00
|
|
|
return packageCount < PACKAGE_COUNT_THRESHOLD ?
|
|
|
|
this.$locale.baseText('settings.communityNodes.empty.description.no-packages', {
|
|
|
|
interpolate: {
|
|
|
|
docURL: COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
|
|
|
},
|
|
|
|
}) :
|
|
|
|
this.$locale.baseText('settings.communityNodes.empty.description', {
|
|
|
|
interpolate: {
|
|
|
|
docURL: COMMUNITY_NODES_INSTALLATION_DOCS_URL,
|
|
|
|
count: (Math.floor(packageCount / 10) * 10).toString(),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2022-10-13 04:42:12 -07:00
|
|
|
shouldShowInstallButton() {
|
2022-11-04 06:04:31 -07:00
|
|
|
return !this.settingsStore.isDesktopDeployment && this.settingsStore.isNpmAvailable;
|
2022-10-13 04:42:12 -07:00
|
|
|
},
|
2022-07-20 07:24:03 -07:00
|
|
|
actionBoxConfig() {
|
2022-11-04 06:04:31 -07:00
|
|
|
if (this.settingsStore.isDesktopDeployment) {
|
2022-10-13 04:42:12 -07:00
|
|
|
return {
|
|
|
|
calloutText: this.$locale.baseText('settings.communityNodes.notAvailableOnDesktop'),
|
|
|
|
calloutTheme: 'warning',
|
|
|
|
hideButton: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-11-04 06:04:31 -07:00
|
|
|
if (!this.settingsStore.isNpmAvailable) {
|
2022-08-11 07:39:55 -07:00
|
|
|
return {
|
|
|
|
calloutText: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.npmUnavailable.warning',
|
|
|
|
{ interpolate: { npmUrl: COMMUNITY_NODES_NPM_INSTALLATION_URL } },
|
|
|
|
),
|
|
|
|
calloutTheme: 'warning',
|
|
|
|
hideButton: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-11-04 06:04:31 -07:00
|
|
|
if (this.settingsStore.isQueueModeEnabled) {
|
2022-08-11 07:39:55 -07:00
|
|
|
return {
|
|
|
|
calloutText: this.$locale.baseText(
|
|
|
|
'settings.communityNodes.queueMode.warning',
|
|
|
|
{ interpolate: { docURL: COMMUNITY_NODES_INSTALLATION_DOCS_URL } },
|
|
|
|
),
|
|
|
|
calloutTheme: 'warning',
|
|
|
|
hideButton: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2022-07-20 07:24:03 -07:00
|
|
|
calloutText: '',
|
|
|
|
calloutTheme: '',
|
|
|
|
hideButton: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
openInstallModal(event: MouseEvent) {
|
2022-11-04 06:04:31 -07:00
|
|
|
const telemetryPayload = { is_empty_state: this.communityNodesStore.getInstalledPackages.length === 0 };
|
2022-08-19 06:35:39 -07:00
|
|
|
this.$telemetry.track('user clicked cnr install button', telemetryPayload);
|
|
|
|
this.$externalHooks().run('settingsCommunityNodesView.openInstallModal', telemetryPayload);
|
2022-11-04 06:04:31 -07:00
|
|
|
this.uiStore.openModal(COMMUNITY_PACKAGE_INSTALL_MODAL_KEY);
|
2022-07-20 07:24:03 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.container {
|
|
|
|
height: 100%;
|
|
|
|
padding-right: var(--spacing-2xs);
|
|
|
|
> * {
|
|
|
|
margin-bottom: var(--spacing-2xl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.headingContainer {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loadingContainer {
|
|
|
|
display: flex;
|
|
|
|
gap: var(--spacing-xs);
|
|
|
|
}
|
|
|
|
|
|
|
|
.actionBoxContainer {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cardsContainer {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: var(--spacing-2xs);
|
|
|
|
}
|
|
|
|
</style>
|