diff --git a/web/src/DeployPage.tsx b/web/src/DeployPage.tsx index f71560d..40eb0e7 100644 --- a/web/src/DeployPage.tsx +++ b/web/src/DeployPage.tsx @@ -24,6 +24,7 @@ export default function DeployPage() { const [deploy, setDeploy] = useState(null); const [server, setServer] = useState(null); const [services, setServices] = useState([]); + const [loadingNewService, setLoadingNewService] = useState(false); async function fetchDeployById(id: string) { const res = await getDeployByIdApi(id); @@ -79,11 +80,13 @@ export default function DeployPage() { diff --git a/web/src/components/AddServices.tsx b/web/src/components/AddServices.tsx index 823df86..bcb757f 100644 --- a/web/src/components/AddServices.tsx +++ b/web/src/components/AddServices.tsx @@ -17,12 +17,14 @@ import { createServiceApi } from "@/services/createServiceApi"; type AddServiceProps = { deployId: string; + setLoading: (loading: boolean) => void; fetchServiceList: (deployId: string) => Promise; }; export default function AddService({ deployId, fetchServiceList, + setLoading, }: AddServiceProps) { const [services, setServices] = useState>([]); const [open, setOpen] = useState(false); @@ -46,12 +48,14 @@ export default function AddService({ async function createService(serviceName: string) { try { + setLoading(true); setOpen(false); await createServiceApi(serviceName, deployId); await fetchServiceList(deployId); } catch (e) { console.error(e); } + setLoading(false); } return ( @@ -81,6 +85,7 @@ export default function AddService({ {services.map((s) => ( ))} + {/* TODO: command item to add new service link to github issue template */} diff --git a/web/src/components/ServiceListDeploy.tsx b/web/src/components/ServiceListDeploy.tsx index 210473b..d4cd0d0 100644 --- a/web/src/components/ServiceListDeploy.tsx +++ b/web/src/components/ServiceListDeploy.tsx @@ -11,16 +11,19 @@ import { } from "./ui/dialog"; import { deleteServiceApi } from "@/services/deleteServiceApi"; import { DialogTitle } from "@radix-ui/react-dialog"; +import { Skeleton } from "@/components/ui/skeleton"; type ServiceListDeployProps = { deployId: string; services: Service[]; + loadingNewService: boolean; fetchServiceList: (deployId: string) => Promise; }; export default function ServiceListDeploy({ deployId, services, + loadingNewService, fetchServiceList, }: ServiceListDeployProps) { const [serviceToDelete, setServiceToDelete] = useState(null); @@ -38,7 +41,7 @@ export default function ServiceListDeploy({ useEffect(() => { fetchServiceList(deployId); - }, [deployId, fetchServiceList]); + }, [deployId]); return (
@@ -73,7 +76,7 @@ export default function ServiceListDeploy({ {services.map((s) => ( - +
{s.name}
@@ -88,6 +91,17 @@ export default function ServiceListDeploy({
))} + {loadingNewService && ( + +
+
+ + +
+ +
+
+ )}
); } diff --git a/web/src/components/ui/skeleton.tsx b/web/src/components/ui/skeleton.tsx new file mode 100644 index 0000000..01b8b6d --- /dev/null +++ b/web/src/components/ui/skeleton.tsx @@ -0,0 +1,15 @@ +import { cn } from "@/lib/utils" + +function Skeleton({ + className, + ...props +}: React.HTMLAttributes) { + return ( +
+ ) +} + +export { Skeleton }