mirror of
https://github.com/moghtech/komodo.git
synced 2026-07-25 16:33:01 -05:00
resources clear their config after update completes
This commit is contained in:
@@ -78,7 +78,7 @@ export const Config = <T,>({
|
||||
update: Partial<T>;
|
||||
disabled: boolean;
|
||||
set: React.Dispatch<SetStateAction<Partial<T>>>;
|
||||
onSave: () => void;
|
||||
onSave: () => Promise<void>;
|
||||
selector?: ReactNode;
|
||||
components: Record<
|
||||
string,
|
||||
@@ -98,7 +98,10 @@ export const Config = <T,>({
|
||||
<ConfigLayout
|
||||
config={update}
|
||||
disabled={disabled}
|
||||
onConfirm={onSave}
|
||||
onConfirm={async () => {
|
||||
await onSave();
|
||||
set({});
|
||||
}}
|
||||
onReset={() => set({})}
|
||||
selector={
|
||||
<div className="flex gap-4 items-center">
|
||||
|
||||
@@ -20,7 +20,7 @@ export const AlerterConfig = ({ id }: { id: string }) => {
|
||||
const [update, setConfig] = useState<
|
||||
Partial<Types.SlackAlerterConfig | Types.CustomAlerterConfig>
|
||||
>({});
|
||||
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: {
|
||||
|
||||
@@ -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<Partial<Types.BuildConfig>>({});
|
||||
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: {
|
||||
|
||||
@@ -17,7 +17,7 @@ const AwsBuilderConfig = ({ id }: { id: string }) => {
|
||||
}).data;
|
||||
const config = useRead("GetBuilder", { builder: id }).data?.config;
|
||||
const [update, set] = useState<Partial<Types.AwsBuilderConfig>>({});
|
||||
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<Partial<Types.ServerBuilderConfig>>({});
|
||||
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: {
|
||||
|
||||
@@ -43,7 +43,7 @@ export const DeploymentConfig = ({ id }: { id: string }) => {
|
||||
}).data;
|
||||
const config = useRead("GetDeployment", { deployment: id }).data?.config;
|
||||
const [update, set] = useState<Partial<Types.DeploymentConfig>>({});
|
||||
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: {
|
||||
"": {
|
||||
|
||||
@@ -56,7 +56,7 @@ const ProcedureConfigInner = ({
|
||||
target: { type: "Procedure", id: procedure._id?.$oid! },
|
||||
}).data;
|
||||
const [config, setConfig] = useState<Partial<Types.ProcedureConfig>>({});
|
||||
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 = ({
|
||||
<ConfigLayout
|
||||
disabled={disabled}
|
||||
config={config as any}
|
||||
onConfirm={() => mutate({ id: procedure._id!.$oid, config })}
|
||||
onConfirm={async () => {
|
||||
await mutateAsync({ id: procedure._id!.$oid, config });
|
||||
setConfig({});
|
||||
}}
|
||||
onReset={() => setConfig(procedure.config)}
|
||||
selector={
|
||||
<div className="flex gap-2 items-center text-sm">
|
||||
@@ -442,7 +445,7 @@ const TARGET_COMPONENTS: ExecutionConfigs = {
|
||||
Deploy: {
|
||||
params: { deployment: "" },
|
||||
Component: ({ params, setParams, disabled }) => {
|
||||
console.log(params.deployment)
|
||||
console.log(params.deployment);
|
||||
return (
|
||||
<ResourceSelector
|
||||
type="Deployment"
|
||||
|
||||
@@ -18,7 +18,7 @@ export const RepoConfig = ({ id }: { id: string }) => {
|
||||
}).data;
|
||||
const config = useRead("GetRepo", { repo: id }).data?.config;
|
||||
const [update, set] = useState<Partial<Types.RepoConfig>>({});
|
||||
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: {
|
||||
|
||||
@@ -17,7 +17,7 @@ export const AwsServerTemplateConfig = ({ id }: { id: string }) => {
|
||||
const config = useRead("GetServerTemplate", { server_template: id }).data
|
||||
?.config;
|
||||
const [update, set] = useState<Partial<Types.AwsServerTemplateConfig>>({});
|
||||
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: {
|
||||
|
||||
@@ -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<Partial<Types.ServerConfig>>({});
|
||||
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: {
|
||||
|
||||
Reference in New Issue
Block a user