fix(image registry): start work on image registry
This commit is contained in:
@@ -72,7 +72,7 @@ export const dataState = await appstate.getStatePart<IDataState>(
|
||||
);
|
||||
|
||||
// Getting data
|
||||
export const getDataAction = dataState.createAction(async (statePartArg) => {
|
||||
export const getAllDataAction = dataState.createAction(async (statePartArg, partialArg?: 'secrets' | 'images') => {
|
||||
let currentState = statePartArg.getState();
|
||||
// Secrets
|
||||
const trGetSecrets =
|
||||
@@ -88,6 +88,20 @@ export const getDataAction = dataState.createAction(async (statePartArg) => {
|
||||
...response,
|
||||
};
|
||||
|
||||
// images
|
||||
const trGetImages =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.image.IRequest_GetAllImages>(
|
||||
'/typedrequest',
|
||||
'getAllImages'
|
||||
);
|
||||
const responseImages = await trGetImages.fire({
|
||||
jwt: loginStatePart.getState().jwt,
|
||||
});
|
||||
currentState = {
|
||||
...currentState,
|
||||
...responseImages,
|
||||
};
|
||||
|
||||
// Clusters
|
||||
const trGetClusters =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.cluster.IRequest_GetAllClusters>(
|
||||
@@ -120,7 +134,7 @@ export const createSecretGroupAction = dataState.createAction(
|
||||
secretBundles: [],
|
||||
secretGroups: [payloadArg],
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getDataAction, null);
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
return currentState;
|
||||
}
|
||||
@@ -139,7 +153,7 @@ export const deleteSecretGroupAction = dataState.createAction(
|
||||
secretBundleIds: [],
|
||||
secretGroupIds: [payloadArg.secretGroupId],
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getDataAction, null);
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
@@ -158,7 +172,53 @@ export const deleteSecretBundleAction = dataState.createAction(
|
||||
secretBundleIds: [payloadArg.configBundleId],
|
||||
secretGroupIds: [],
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getDataAction, null);
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
// image actions
|
||||
export const createImageAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { imageName: string, description: string }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trCreateImage =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.image.IRequest_CreateImage>(
|
||||
'/typedrequest',
|
||||
'createImage'
|
||||
);
|
||||
const response = await trCreateImage.fire({
|
||||
jwt: loginStatePart.getState().jwt,
|
||||
name: payloadArg.imageName,
|
||||
description: payloadArg.description,
|
||||
});
|
||||
currentState = {
|
||||
...currentState,
|
||||
...{
|
||||
images: [...currentState.images, response.image],
|
||||
},
|
||||
};
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const deleteImageAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { imageId: string }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trDeleteImage =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.image.IRequest_DeleteImage>(
|
||||
'/typedrequest',
|
||||
'deleteImage'
|
||||
);
|
||||
const response = await trDeleteImage.fire({
|
||||
jwt: loginStatePart.getState().jwt,
|
||||
imageId: payloadArg.imageId,
|
||||
});
|
||||
currentState = {
|
||||
...currentState,
|
||||
...{
|
||||
images: currentState.images.filter((image) => image.id !== payloadArg.imageId),
|
||||
},
|
||||
};
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user