Merge pull request 'feat(ui): refresh state after machine install or update' (#5081) from ui/refresh-state into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/5081
This commit is contained in:
@@ -13,6 +13,7 @@ import { installSteps } from "./steps/installSteps";
|
|||||||
import { ApiCall } from "@/src/hooks/api";
|
import { ApiCall } from "@/src/hooks/api";
|
||||||
|
|
||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
|
import { useClanContext } from "@/src/routes/Clan/Clan";
|
||||||
|
|
||||||
interface InstallStepperProps {
|
interface InstallStepperProps {
|
||||||
onDone: () => void;
|
onDone: () => void;
|
||||||
@@ -66,6 +67,8 @@ export interface InstallStoreType {
|
|||||||
export type PromptValues = Record<string, Record<string, string>>;
|
export type PromptValues = Record<string, Record<string, string>>;
|
||||||
|
|
||||||
export const InstallModal = (props: InstallModalProps) => {
|
export const InstallModal = (props: InstallModalProps) => {
|
||||||
|
const ctx = useClanContext();
|
||||||
|
|
||||||
const stepper = createStepper(
|
const stepper = createStepper(
|
||||||
{
|
{
|
||||||
steps,
|
steps,
|
||||||
@@ -107,22 +110,27 @@ export const InstallModal = (props: InstallModalProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onClose = async () => {
|
||||||
|
// refresh some queries
|
||||||
|
await ctx.machinesQuery.refetch();
|
||||||
|
await ctx.serviceInstancesQuery.refetch();
|
||||||
|
|
||||||
|
props.onClose?.();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StepperProvider stepper={stepper}>
|
<StepperProvider stepper={stepper}>
|
||||||
<Modal
|
<Modal
|
||||||
class={cx("w-screen", sizeClasses())}
|
class={cx("w-screen", sizeClasses())}
|
||||||
title="Install machine"
|
title="Install machine"
|
||||||
onClose={() => {
|
onClose={onClose}
|
||||||
console.log("Install modal closed");
|
|
||||||
props.onClose?.();
|
|
||||||
}}
|
|
||||||
open={props.open}
|
open={props.open}
|
||||||
// @ts-expect-error some steps might not have
|
// @ts-expect-error some steps might not have
|
||||||
metaHeader={stepper.currentStep()?.title ? <MetaHeader /> : undefined}
|
metaHeader={stepper.currentStep()?.title ? <MetaHeader /> : undefined}
|
||||||
// @ts-expect-error some steps might not have
|
// @ts-expect-error some steps might not have
|
||||||
disablePadding={stepper.currentStep()?.isSplash}
|
disablePadding={stepper.currentStep()?.isSplash}
|
||||||
>
|
>
|
||||||
<InstallStepper onDone={() => props.onClose?.()} />
|
<InstallStepper onDone={onClose} />
|
||||||
</Modal>
|
</Modal>
|
||||||
</StepperProvider>
|
</StepperProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { LoadingBar } from "@/src/components/LoadingBar/LoadingBar";
|
|||||||
import { useApiClient } from "@/src/hooks/ApiClient";
|
import { useApiClient } from "@/src/hooks/ApiClient";
|
||||||
import { useClanURI } from "@/src/hooks/clan";
|
import { useClanURI } from "@/src/hooks/clan";
|
||||||
import { AlertProps } from "@/src/components/Alert/Alert";
|
import { AlertProps } from "@/src/components/Alert/Alert";
|
||||||
|
import { useClanContext } from "@/src/routes/Clan/Clan";
|
||||||
|
|
||||||
// TODO: Deduplicate
|
// TODO: Deduplicate
|
||||||
interface UpdateStepperProps {
|
interface UpdateStepperProps {
|
||||||
@@ -237,6 +238,8 @@ export type UpdateSteps = typeof steps;
|
|||||||
export type PromptValues = Record<string, Record<string, string>>;
|
export type PromptValues = Record<string, Record<string, string>>;
|
||||||
|
|
||||||
export const UpdateModal = (props: UpdateModalProps) => {
|
export const UpdateModal = (props: UpdateModalProps) => {
|
||||||
|
const ctx = useClanContext();
|
||||||
|
|
||||||
const stepper = createStepper(
|
const stepper = createStepper(
|
||||||
{
|
{
|
||||||
steps,
|
steps,
|
||||||
@@ -281,22 +284,27 @@ export const UpdateModal = (props: UpdateModalProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onClose = async () => {
|
||||||
|
// refresh some queries
|
||||||
|
await ctx.machinesQuery.refetch();
|
||||||
|
await ctx.serviceInstancesQuery.refetch();
|
||||||
|
|
||||||
|
props.onClose?.();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StepperProvider stepper={stepper}>
|
<StepperProvider stepper={stepper}>
|
||||||
<Modal
|
<Modal
|
||||||
class={cx("w-screen", sizeClasses())}
|
class={cx("w-screen", sizeClasses())}
|
||||||
title="Update machine"
|
title="Update machine"
|
||||||
onClose={() => {
|
onClose={onClose}
|
||||||
console.log("Update modal closed");
|
|
||||||
props.onClose?.();
|
|
||||||
}}
|
|
||||||
open={props.open}
|
open={props.open}
|
||||||
// @ts-expect-error some steps might not have
|
// @ts-expect-error some steps might not have
|
||||||
metaHeader={stepper.currentStep()?.title ? <MetaHeader /> : undefined}
|
metaHeader={stepper.currentStep()?.title ? <MetaHeader /> : undefined}
|
||||||
// @ts-expect-error some steps might not have
|
// @ts-expect-error some steps might not have
|
||||||
disablePadding={stepper.currentStep()?.isSplash}
|
disablePadding={stepper.currentStep()?.isSplash}
|
||||||
>
|
>
|
||||||
<UpdateStepper onDone={() => props.onClose?.()} />
|
<UpdateStepper onDone={onClose} />
|
||||||
</Modal>
|
</Modal>
|
||||||
</StepperProvider>
|
</StepperProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user