feat(appstate): Remove helper function for stripping class instances from data fetching
This commit is contained in:
@@ -2,11 +2,6 @@ import * as plugins from './plugins.js';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
const appstate = new plugins.deesDomtools.plugins.smartstate.Smartstate();
|
||||
|
||||
// Helper: strip class instances (with circular refs) to plain objects
|
||||
type IdData<T> = { id: string; data: T };
|
||||
const toPlain = <D>(items: Array<{ id: string; data: D }> = []): Array<IdData<D>> =>
|
||||
items.map(({ id, data }) => ({ id, data }));
|
||||
export interface ILoginState {
|
||||
identity: plugins.interfaces.data.IIdentity;
|
||||
}
|
||||
@@ -107,7 +102,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
const secretGroups = await apiClient.secretgroup.getSecretGroups();
|
||||
currentState = {
|
||||
...currentState,
|
||||
secretGroups: toPlain(secretGroups),
|
||||
secretGroups: secretGroups,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch secret groups:', err);
|
||||
@@ -123,7 +118,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
const responseSecretBundles = await apiClient.secretbundle.getSecretBundles();
|
||||
currentState = {
|
||||
...currentState,
|
||||
secretBundles: toPlain(responseSecretBundles),
|
||||
secretBundles: responseSecretBundles,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch secret bundles:', err);
|
||||
@@ -139,7 +134,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
const images = await apiClient.image.getImages();
|
||||
currentState = {
|
||||
...currentState,
|
||||
images: toPlain(images),
|
||||
images: images,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch images:', err);
|
||||
@@ -155,7 +150,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
const clusters = await apiClient.cluster.getClusters();
|
||||
currentState = {
|
||||
...currentState,
|
||||
clusters: toPlain(clusters),
|
||||
clusters: clusters,
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch clusters:', err);
|
||||
@@ -171,7 +166,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
const registries = await apiClient.externalRegistry.getRegistries();
|
||||
currentState = {
|
||||
...currentState,
|
||||
externalRegistries: toPlain(registries),
|
||||
externalRegistries: registries,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch external registries:', error);
|
||||
@@ -187,7 +182,7 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
const services = await apiClient.services.getServices();
|
||||
currentState = {
|
||||
...currentState,
|
||||
services: toPlain(services),
|
||||
services: services,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch services:', error);
|
||||
|
Reference in New Issue
Block a user