diff --git a/frontend/src/components/config/index.tsx b/frontend/src/components/config/index.tsx index 0d3f22aa4..3e6a3a646 100644 --- a/frontend/src/components/config/index.tsx +++ b/frontend/src/components/config/index.tsx @@ -78,7 +78,7 @@ export const Config = ({ update: Partial; disabled: boolean; set: React.Dispatch>>; - onSave: () => void; + onSave: () => Promise; selector?: ReactNode; components: Record< string, @@ -98,7 +98,10 @@ export const Config = ({ { + await onSave(); + set({}); + }} onReset={() => set({})} selector={
diff --git a/frontend/src/components/resources/alerter/config.tsx b/frontend/src/components/resources/alerter/config.tsx index f92e86864..e5c72726c 100644 --- a/frontend/src/components/resources/alerter/config.tsx +++ b/frontend/src/components/resources/alerter/config.tsx @@ -20,7 +20,7 @@ export const AlerterConfig = ({ id }: { id: string }) => { const [update, setConfig] = useState< Partial >({}); - const { mutate } = useWrite("UpdateAlerter"); + const { mutateAsync } = useWrite("UpdateAlerter"); if (!config) return null; const disabled = perms !== Types.PermissionLevel.Write; @@ -31,7 +31,10 @@ export const AlerterConfig = ({ id }: { id: string }) => { config={config.params} update={update} set={setConfig} - onSave={() => type && mutate({ id, config: { type, params: update } })} + onSave={async () => { + if (!type) return; + await mutateAsync({ id, config: { type, params: update } }); + }} components={{ general: { general: { diff --git a/frontend/src/components/resources/build/config.tsx b/frontend/src/components/resources/build/config.tsx index 192434dbf..1c4a4a4d0 100644 --- a/frontend/src/components/resources/build/config.tsx +++ b/frontend/src/components/resources/build/config.tsx @@ -28,7 +28,7 @@ export const BuildConfig = ({ id }: { id: string }) => { const config = useRead("GetBuild", { build: id }).data?.config; const docker_organizations = useRead("ListDockerOrganizations", {}).data; const [update, set] = useState>({}); - const { mutate } = useWrite("UpdateBuild"); + const { mutateAsync } = useWrite("UpdateBuild"); if (!config) return null; @@ -40,7 +40,9 @@ export const BuildConfig = ({ id }: { id: string }) => { config={config} update={update} set={set} - onSave={() => mutate({ id, config: update })} + onSave={async () => { + await mutateAsync({ id, config: update }); + }} components={{ general: { general: { diff --git a/frontend/src/components/resources/builder/config.tsx b/frontend/src/components/resources/builder/config.tsx index f44f35688..1d8ed7358 100644 --- a/frontend/src/components/resources/builder/config.tsx +++ b/frontend/src/components/resources/builder/config.tsx @@ -17,7 +17,7 @@ const AwsBuilderConfig = ({ id }: { id: string }) => { }).data; const config = useRead("GetBuilder", { builder: id }).data?.config; const [update, set] = useState>({}); - const { mutate } = useWrite("UpdateBuilder"); + const { mutateAsync } = useWrite("UpdateBuilder"); if (!config) return null; const disabled = perms !== Types.PermissionLevel.Write; @@ -28,7 +28,9 @@ const AwsBuilderConfig = ({ id }: { id: string }) => { config={config.params as Types.AwsBuilderConfig} update={update} set={set} - onSave={() => mutate({ id, config: { type: "Aws", params: update } })} + onSave={async () => { + await mutateAsync({ id, config: { type: "Aws", params: update } }); + }} components={{ general: { general: { @@ -78,7 +80,7 @@ const ServerBuilderConfig = ({ id }: { id: string }) => { }).data; const config = useRead("GetBuilder", { builder: id }).data?.config; const [update, set] = useState>({}); - const { mutate } = useWrite("UpdateBuilder"); + const { mutateAsync } = useWrite("UpdateBuilder"); if (!config) return null; const disabled = perms !== Types.PermissionLevel.Write; @@ -89,7 +91,9 @@ const ServerBuilderConfig = ({ id }: { id: string }) => { config={config.params as Types.ServerBuilderConfig} update={update} set={set} - onSave={() => mutate({ id, config: { type: "Server", params: update } })} + onSave={async () => { + await mutateAsync({ id, config: { type: "Server", params: update } }); + }} components={{ general: { general: { diff --git a/frontend/src/components/resources/deployment/config/index.tsx b/frontend/src/components/resources/deployment/config/index.tsx index be078d4aa..bedc43171 100644 --- a/frontend/src/components/resources/deployment/config/index.tsx +++ b/frontend/src/components/resources/deployment/config/index.tsx @@ -43,7 +43,7 @@ export const DeploymentConfig = ({ id }: { id: string }) => { }).data; const config = useRead("GetDeployment", { deployment: id }).data?.config; const [update, set] = useState>({}); - const { mutate } = useWrite("UpdateDeployment"); + const { mutateAsync } = useWrite("UpdateDeployment"); if (!config) return null; @@ -61,7 +61,9 @@ export const DeploymentConfig = ({ id }: { id: string }) => { config={config} update={update} set={set} - onSave={() => mutate({ id, config: update })} + onSave={async () => { + await mutateAsync({ id, config: update }); + }} components={{ general: { "": { diff --git a/frontend/src/components/resources/procedure/config.tsx b/frontend/src/components/resources/procedure/config.tsx index fe8832b53..67c3645de 100644 --- a/frontend/src/components/resources/procedure/config.tsx +++ b/frontend/src/components/resources/procedure/config.tsx @@ -56,7 +56,7 @@ const ProcedureConfigInner = ({ target: { type: "Procedure", id: procedure._id?.$oid! }, }).data; const [config, setConfig] = useState>({}); - const { mutate } = useWrite("UpdateProcedure"); + const { mutateAsync } = useWrite("UpdateProcedure"); const executions = config.executions || procedure.config.executions || []; const disabled = perms !== Types.PermissionLevel.Write; @@ -65,7 +65,10 @@ const ProcedureConfigInner = ({ mutate({ id: procedure._id!.$oid, config })} + onConfirm={async () => { + await mutateAsync({ id: procedure._id!.$oid, config }); + setConfig({}); + }} onReset={() => setConfig(procedure.config)} selector={
@@ -442,7 +445,7 @@ const TARGET_COMPONENTS: ExecutionConfigs = { Deploy: { params: { deployment: "" }, Component: ({ params, setParams, disabled }) => { - console.log(params.deployment) + console.log(params.deployment); return ( { }).data; const config = useRead("GetRepo", { repo: id }).data?.config; const [update, set] = useState>({}); - const { mutate } = useWrite("UpdateRepo"); + const { mutateAsync } = useWrite("UpdateRepo"); if (!config) return null; const disabled = perms !== Types.PermissionLevel.Write; @@ -29,7 +29,9 @@ export const RepoConfig = ({ id }: { id: string }) => { config={config} update={update} set={set} - onSave={() => mutate({ id, config: update })} + onSave={async () => { + await mutateAsync({ id, config: update }); + }} components={{ general: { general: { diff --git a/frontend/src/components/resources/server-template/config.tsx b/frontend/src/components/resources/server-template/config.tsx index 2590d344b..61b0bf880 100644 --- a/frontend/src/components/resources/server-template/config.tsx +++ b/frontend/src/components/resources/server-template/config.tsx @@ -17,7 +17,7 @@ export const AwsServerTemplateConfig = ({ id }: { id: string }) => { const config = useRead("GetServerTemplate", { server_template: id }).data ?.config; const [update, set] = useState>({}); - const { mutate } = useWrite("UpdateServerTemplate"); + const { mutateAsync } = useWrite("UpdateServerTemplate"); if (!config) return null; const disabled = perms !== Types.PermissionLevel.Write; @@ -28,7 +28,9 @@ export const AwsServerTemplateConfig = ({ id }: { id: string }) => { config={config.params as Types.AwsServerTemplateConfig} update={update} set={set} - onSave={() => mutate({ id, config: { type: "Aws", params: update } })} + onSave={async () => { + await mutateAsync({ id, config: { type: "Aws", params: update } }); + }} components={{ general: { general: { diff --git a/frontend/src/components/resources/server/config.tsx b/frontend/src/components/resources/server/config.tsx index b63b06056..6ce4b4ebe 100644 --- a/frontend/src/components/resources/server/config.tsx +++ b/frontend/src/components/resources/server/config.tsx @@ -10,7 +10,7 @@ export const ServerConfig = ({ id }: { id: string }) => { const invalidate = useInvalidate(); const config = useRead("GetServer", { server: id }).data?.config; const [update, set] = useState>({}); - const { mutate } = useWrite("UpdateServer", { + const { mutateAsync } = useWrite("UpdateServer", { onSuccess: () => { // In case of disabling to resolve unreachable alert invalidate(["ListAlerts"]); @@ -26,7 +26,9 @@ export const ServerConfig = ({ id }: { id: string }) => { config={config} update={update} set={set} - onSave={() => mutate({ id, config: update })} + onSave={async () => { + await mutateAsync({ id, config: update }); + }} components={{ general: { general: {