feat(routes): add route edit and delete actions to the ops routes view
This commit is contained in:
@@ -1441,6 +1441,37 @@ export const createRouteAction = routeManagementStatePart.createAction<{
|
||||
}
|
||||
});
|
||||
|
||||
export const updateRouteAction = routeManagementStatePart.createAction<{
|
||||
id: string;
|
||||
route?: any;
|
||||
enabled?: boolean;
|
||||
metadata?: any;
|
||||
}>(async (statePartArg, dataArg, actionContext): Promise<IRouteManagementState> => {
|
||||
const context = getActionContext();
|
||||
const currentState = statePartArg.getState()!;
|
||||
|
||||
try {
|
||||
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||
interfaces.requests.IReq_UpdateRoute
|
||||
>('/typedrequest', 'updateRoute');
|
||||
|
||||
await request.fire({
|
||||
identity: context.identity!,
|
||||
id: dataArg.id,
|
||||
route: dataArg.route,
|
||||
enabled: dataArg.enabled,
|
||||
metadata: dataArg.metadata,
|
||||
});
|
||||
|
||||
return await actionContext!.dispatch(fetchMergedRoutesAction, null);
|
||||
} catch (error: unknown) {
|
||||
return {
|
||||
...currentState,
|
||||
error: error instanceof Error ? error.message : 'Failed to update route',
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export const deleteRouteAction = routeManagementStatePart.createAction<string>(
|
||||
async (statePartArg, routeId, actionContext): Promise<IRouteManagementState> => {
|
||||
const context = getActionContext();
|
||||
|
||||
Reference in New Issue
Block a user