refactor(editor): Apply Prettier (no-changelog) (#4920)
* ⚡ Adjust `format` script * 🔥 Remove exemption for `editor-ui` * 🎨 Prettify * 👕 Fix lint
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import { getInstalledCommunityNodes, installNewPackage, uninstallPackage, updatePackage } from "@/api/communityNodes";
|
||||
import { getAvailableCommunityPackageCount } from "@/api/settings";
|
||||
import { defineStore } from "pinia";
|
||||
import { useRootStore } from "./n8nRootStore";
|
||||
import {
|
||||
getInstalledCommunityNodes,
|
||||
installNewPackage,
|
||||
uninstallPackage,
|
||||
updatePackage,
|
||||
} from '@/api/communityNodes';
|
||||
import { getAvailableCommunityPackageCount } from '@/api/settings';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRootStore';
|
||||
import { PublicInstalledPackage } from 'n8n-workflow';
|
||||
import Vue from "vue";
|
||||
import { CommunityNodesState, CommunityPackageMap } from "@/Interface";
|
||||
import { STORES } from "@/constants";
|
||||
import Vue from 'vue';
|
||||
import { CommunityNodesState, CommunityPackageMap } from '@/Interface';
|
||||
import { STORES } from '@/constants';
|
||||
|
||||
const LOADER_DELAY = 300;
|
||||
|
||||
@@ -16,8 +21,10 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, {
|
||||
installedPackages: {},
|
||||
}),
|
||||
getters: {
|
||||
getInstalledPackages() : PublicInstalledPackage[] {
|
||||
return Object.values(this.installedPackages).sort((a, b) => a.packageName.localeCompare(b.packageName));
|
||||
getInstalledPackages(): PublicInstalledPackage[] {
|
||||
return Object.values(this.installedPackages).sort((a, b) =>
|
||||
a.packageName.localeCompare(b.packageName),
|
||||
);
|
||||
},
|
||||
getInstalledPackageByName() {
|
||||
return (name: string): PublicInstalledPackage => this.installedPackages[name];
|
||||
@@ -33,7 +40,7 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, {
|
||||
const rootStore = useRootStore();
|
||||
const installedPackages = await getInstalledCommunityNodes(rootStore.getRestApiContext);
|
||||
this.setInstalledPackages(installedPackages);
|
||||
const timeout = installedPackages.length > 0 ? 0: LOADER_DELAY;
|
||||
const timeout = installedPackages.length > 0 ? 0 : LOADER_DELAY;
|
||||
setTimeout(() => {
|
||||
return;
|
||||
}, timeout);
|
||||
@@ -44,7 +51,7 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, {
|
||||
await installNewPackage(rootStore.getRestApiContext, packageName);
|
||||
await this.fetchInstalledPackages();
|
||||
} catch (error) {
|
||||
throw (error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
async uninstallPackage(packageName: string): Promise<void> {
|
||||
@@ -53,24 +60,30 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, {
|
||||
await uninstallPackage(rootStore.getRestApiContext, packageName);
|
||||
this.removePackageByName(packageName);
|
||||
} catch (error) {
|
||||
throw (error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
async updatePackage(packageName: string): Promise<void> {
|
||||
try {
|
||||
const rootStore = useRootStore();
|
||||
const packageToUpdate: PublicInstalledPackage = this.getInstalledPackageByName(packageName);
|
||||
const updatedPackage: PublicInstalledPackage = await updatePackage(rootStore.getRestApiContext, packageToUpdate.packageName);
|
||||
const updatedPackage: PublicInstalledPackage = await updatePackage(
|
||||
rootStore.getRestApiContext,
|
||||
packageToUpdate.packageName,
|
||||
);
|
||||
this.updatePackageObject(updatedPackage);
|
||||
} catch (error) {
|
||||
throw (error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
setInstalledPackages(packages: PublicInstalledPackage[]) {
|
||||
this.installedPackages = packages.reduce((packageMap: CommunityPackageMap, pack: PublicInstalledPackage) => {
|
||||
packageMap[pack.packageName] = pack;
|
||||
return packageMap;
|
||||
}, {});
|
||||
this.installedPackages = packages.reduce(
|
||||
(packageMap: CommunityPackageMap, pack: PublicInstalledPackage) => {
|
||||
packageMap[pack.packageName] = pack;
|
||||
return packageMap;
|
||||
},
|
||||
{},
|
||||
);
|
||||
},
|
||||
removePackageByName(name: string): void {
|
||||
Vue.delete(this.installedPackages, name);
|
||||
|
||||
Reference in New Issue
Block a user