diff --git a/frontend/src/components/dashboard/api-keys.tsx b/frontend/src/components/dashboard/api-keys.tsx index 5eba4bfe6..b387fdda7 100644 --- a/frontend/src/components/dashboard/api-keys.tsx +++ b/frontend/src/components/dashboard/api-keys.tsx @@ -8,7 +8,7 @@ export const ApiKeysSummary = () => { return ( - +
diff --git a/frontend/src/components/dashboard/tags.tsx b/frontend/src/components/dashboard/tags.tsx index 8d9442f3e..9dcdbabd5 100644 --- a/frontend/src/components/dashboard/tags.tsx +++ b/frontend/src/components/dashboard/tags.tsx @@ -8,7 +8,7 @@ export const TagsSummary = () => { return ( - +
diff --git a/frontend/src/components/resources/alerter/index.tsx b/frontend/src/components/resources/alerter/index.tsx index fab96a566..3bf9573aa 100644 --- a/frontend/src/components/resources/alerter/index.tsx +++ b/frontend/src/components/resources/alerter/index.tsx @@ -84,7 +84,7 @@ export const AlerterComponents: RequiredResourceComponents = { const alerters_count = useRead("ListAlerters", {}).data?.length; return ( - +
diff --git a/frontend/src/components/resources/build/dashboard.tsx b/frontend/src/components/resources/build/dashboard.tsx index f1b61da66..3e7c4be89 100644 --- a/frontend/src/components/resources/build/dashboard.tsx +++ b/frontend/src/components/resources/build/dashboard.tsx @@ -76,7 +76,7 @@ export const BuildChart = () => { return ( - +
diff --git a/frontend/src/components/resources/builder/index.tsx b/frontend/src/components/resources/builder/index.tsx index ea5b9c486..c26f714ec 100644 --- a/frontend/src/components/resources/builder/index.tsx +++ b/frontend/src/components/resources/builder/index.tsx @@ -145,7 +145,7 @@ export const BuilderComponents: RequiredResourceComponents = { const builders_count = useRead("ListBuilders", {}).data?.length; return ( - +
diff --git a/frontend/src/components/resources/common.tsx b/frontend/src/components/resources/common.tsx index 1675fcc1e..1fd632078 100644 --- a/frontend/src/components/resources/common.tsx +++ b/frontend/src/components/resources/common.tsx @@ -1,8 +1,12 @@ -import { ActionButton, ActionWithDialog, ConfirmButton } from "@components/util"; +import { + ActionButton, + ActionWithDialog, + ConfirmButton, +} from "@components/util"; import { useInvalidate, useRead, useWrite } from "@lib/hooks"; import { UsableResource } from "@types"; import { Button } from "@ui/button"; -import { Card, CardContent } from "@ui/card"; +import { Card, CardHeader } from "@ui/card"; import { Command, CommandEmpty, @@ -21,11 +25,19 @@ import { } from "@ui/dialog"; import { Popover, PopoverContent, PopoverTrigger } from "@ui/popover"; import { Textarea } from "@ui/textarea"; -import { Check, CheckCircle, ChevronsUpDown, Copy, SearchX, Trash } from "lucide-react"; +import { + Check, + CheckCircle, + ChevronsUpDown, + Copy, + SearchX, + Trash, +} from "lucide-react"; import { useEffect, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import { ResourceComponents } from "."; import { Input } from "@ui/input"; +import { useToast } from "@ui/use-toast"; export const ResourceDescription = ({ type, @@ -34,15 +46,22 @@ export const ResourceDescription = ({ type: UsableResource; id: string; }) => { + const { toast } = useToast(); + const inv = useInvalidate(); const [open, setOpen] = useState(false); const [description, setDescription] = useState(); - const { mutate: update_description } = useWrite("UpdateDescription"); - const resource = useRead(`Get${type}`, { [type.toLowerCase()]: id, } as any).data; + const { mutate: update_description } = useWrite("UpdateDescription", { + onSuccess: () => { + inv([`Get${type}`]); + toast({ title: `Updated description on ${type} ${resource?.name}` }); + }, + }); + useEffect( () => setDescription(resource?.description), [resource?.description] @@ -51,10 +70,10 @@ export const ResourceDescription = ({ return ( - - - {resource?.description} - + + + {resource?.description || "Set description"} + @@ -76,7 +95,7 @@ export const ResourceDescription = ({ }); setOpen(false); }} - disabled={description !== undefined} + disabled={description === undefined} /> diff --git a/frontend/src/components/resources/deployment/actions.tsx b/frontend/src/components/resources/deployment/actions.tsx index c5a306398..0ceda4dde 100644 --- a/frontend/src/components/resources/deployment/actions.tsx +++ b/frontend/src/components/resources/deployment/actions.tsx @@ -139,12 +139,22 @@ const StopContainer = ({ id }: DeploymentId) => { export const StartOrStopContainer = ({ id }: DeploymentId) => { const deployments = useRead("ListDeployments", {}).data; const deployment = deployments?.find((d) => d.id === id); + const state = deployment?.info.state; - if (deployment?.info.state === Types.DockerContainerState.NotDeployed) + if ( + state === Types.DockerContainerState.NotDeployed || + state === Types.DockerContainerState.Unknown + ) { return null; + } - if (deployment?.info.state === Types.DockerContainerState.Running) + if ( + state === Types.DockerContainerState.Running || + state === Types.DockerContainerState.Restarting + ) { return ; + } + return ; }; diff --git a/frontend/src/components/resources/deployment/dashboard.tsx b/frontend/src/components/resources/deployment/dashboard.tsx index ea3f9b769..35f09941a 100644 --- a/frontend/src/components/resources/deployment/dashboard.tsx +++ b/frontend/src/components/resources/deployment/dashboard.tsx @@ -20,7 +20,7 @@ export const DeploymentsChart = () => { return ( - +
diff --git a/frontend/src/components/resources/procedure/index.tsx b/frontend/src/components/resources/procedure/index.tsx index 9e2113b87..714b50f48 100644 --- a/frontend/src/components/resources/procedure/index.tsx +++ b/frontend/src/components/resources/procedure/index.tsx @@ -106,7 +106,7 @@ export const ProcedureComponents: RequiredResourceComponents = { const procedure_count = useRead("ListProcedures", {}).data?.length; return ( - +
diff --git a/frontend/src/components/resources/repo/index.tsx b/frontend/src/components/resources/repo/index.tsx index 471a5fccd..2b8eb78c6 100644 --- a/frontend/src/components/resources/repo/index.tsx +++ b/frontend/src/components/resources/repo/index.tsx @@ -73,7 +73,7 @@ export const RepoComponents: RequiredResourceComponents = { const repo_count = useRead("ListRepos", {}).data?.length; return ( - +
diff --git a/frontend/src/components/resources/server/dashboard.tsx b/frontend/src/components/resources/server/dashboard.tsx index 4019ca470..529cf1ad4 100644 --- a/frontend/src/components/resources/server/dashboard.tsx +++ b/frontend/src/components/resources/server/dashboard.tsx @@ -19,7 +19,7 @@ export const ServersChart = () => { const { data } = useRead("GetServersSummary", {}); return ( - +
diff --git a/frontend/src/components/util.tsx b/frontend/src/components/util.tsx index 2146abf81..ddfccd4ff 100644 --- a/frontend/src/components/util.tsx +++ b/frontend/src/components/util.tsx @@ -116,7 +116,13 @@ export const ActionWithDialog = ({ const [input, setInput] = useState(""); return ( - + { + setOpen(open); + setInput(""); + }} + > (
- +
diff --git a/frontend/src/pages/resource.tsx b/frontend/src/pages/resource.tsx index 25ba3bdaa..55fe29f0b 100644 --- a/frontend/src/pages/resource.tsx +++ b/frontend/src/pages/resource.tsx @@ -1,5 +1,6 @@ import { Page } from "@components/layouts"; import { ResourceComponents } from "@components/resources"; +import { ResourceDescription } from "@components/resources/common"; import { AddTags, ResourceTags } from "@components/tags"; import { ResourceUpdates } from "@components/updates/resource"; import { usePushRecentlyViewed, useResourceParamType } from "@lib/hooks"; @@ -36,6 +37,7 @@ export const Resource = () => { ))}
+
} actions={