mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor(editor): Remove getters with arguments from communityNodes.store.ts
(#9964)
This commit is contained in:
parent
cc27b57953
commit
4ff4534454
|
@ -75,7 +75,7 @@ export default defineComponent({
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useCommunityNodesStore),
|
...mapStores(useCommunityNodesStore),
|
||||||
activePackage() {
|
activePackage() {
|
||||||
return this.communityNodesStore.getInstalledPackageByName(this.activePackageName);
|
return this.communityNodesStore.installedPackages[this.activePackageName];
|
||||||
},
|
},
|
||||||
getModalContent() {
|
getModalContent() {
|
||||||
if (this.mode === COMMUNITY_PACKAGE_MANAGE_ACTIONS.UNINSTALL) {
|
if (this.mode === COMMUNITY_PACKAGE_MANAGE_ACTIONS.UNINSTALL) {
|
||||||
|
|
|
@ -11,12 +11,13 @@ const LOADER_DELAY = 300;
|
||||||
|
|
||||||
export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () => {
|
export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () => {
|
||||||
const availablePackageCount = ref(-1);
|
const availablePackageCount = ref(-1);
|
||||||
|
|
||||||
const installedPackages = ref<CommunityPackageMap>({});
|
const installedPackages = ref<CommunityPackageMap>({});
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// Stores
|
||||||
// #region Computed
|
|
||||||
// ---------------------------------------------------------------------------
|
const rootStore = useRootStore();
|
||||||
|
|
||||||
|
// Computed
|
||||||
|
|
||||||
const getInstalledPackages = computed(() => {
|
const getInstalledPackages = computed(() => {
|
||||||
return Object.values(installedPackages.value).sort((a, b) =>
|
return Object.values(installedPackages.value).sort((a, b) =>
|
||||||
|
@ -24,11 +25,7 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// #endregion
|
// Methods
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// #region Methods
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const fetchAvailableCommunityPackageCount = async (): Promise<void> => {
|
const fetchAvailableCommunityPackageCount = async (): Promise<void> => {
|
||||||
if (availablePackageCount.value === -1) {
|
if (availablePackageCount.value === -1) {
|
||||||
|
@ -47,7 +44,6 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchInstalledPackages = async (): Promise<void> => {
|
const fetchInstalledPackages = async (): Promise<void> => {
|
||||||
const rootStore = useRootStore();
|
|
||||||
const installedPackages = await communityNodesApi.getInstalledCommunityNodes(
|
const installedPackages = await communityNodesApi.getInstalledCommunityNodes(
|
||||||
rootStore.restApiContext,
|
rootStore.restApiContext,
|
||||||
);
|
);
|
||||||
|
@ -60,7 +56,6 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||||
|
|
||||||
const installPackage = async (packageName: string): Promise<void> => {
|
const installPackage = async (packageName: string): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const rootStore = useRootStore();
|
|
||||||
await communityNodesApi.installNewPackage(rootStore.restApiContext, packageName);
|
await communityNodesApi.installNewPackage(rootStore.restApiContext, packageName);
|
||||||
await fetchInstalledPackages();
|
await fetchInstalledPackages();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -70,7 +65,6 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||||
|
|
||||||
const uninstallPackage = async (packageName: string): Promise<void> => {
|
const uninstallPackage = async (packageName: string): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const rootStore = useRootStore();
|
|
||||||
await communityNodesApi.uninstallPackage(rootStore.restApiContext, packageName);
|
await communityNodesApi.uninstallPackage(rootStore.restApiContext, packageName);
|
||||||
removePackageByName(packageName);
|
removePackageByName(packageName);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -89,9 +83,8 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||||
|
|
||||||
const updatePackage = async (packageName: string): Promise<void> => {
|
const updatePackage = async (packageName: string): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const rootStore = useRootStore();
|
const packageToUpdate = installedPackages.value[packageName];
|
||||||
const packageToUpdate: PublicInstalledPackage = getInstalledPackageByName.value(packageName);
|
const updatedPackage = await communityNodesApi.updatePackage(
|
||||||
const updatedPackage: PublicInstalledPackage = await communityNodesApi.updatePackage(
|
|
||||||
rootStore.restApiContext,
|
rootStore.restApiContext,
|
||||||
packageToUpdate.packageName,
|
packageToUpdate.packageName,
|
||||||
);
|
);
|
||||||
|
@ -101,14 +94,8 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
const getInstalledPackageByName = computed(() => {
|
|
||||||
return (name: string): PublicInstalledPackage => installedPackages.value[name];
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getInstalledPackageByName,
|
installedPackages,
|
||||||
getInstalledPackages,
|
getInstalledPackages,
|
||||||
availablePackageCount,
|
availablePackageCount,
|
||||||
fetchAvailableCommunityPackageCount,
|
fetchAvailableCommunityPackageCount,
|
||||||
|
|
Loading…
Reference in a new issue