From d6abda063a2cdccf8027b45241a944c685b0db30 Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Fri, 7 Mar 2025 00:09:33 -0800 Subject: [PATCH] stack edits on localstorage and show last deployed config --- .../src/components/resources/stack/info.tsx | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/resources/stack/info.tsx b/frontend/src/components/resources/stack/info.tsx index 85c0cbcd6..0c8e9a07c 100644 --- a/frontend/src/components/resources/stack/info.tsx +++ b/frontend/src/components/resources/stack/info.tsx @@ -1,17 +1,24 @@ import { Section } from "@components/layouts"; import { ReactNode, useState } from "react"; -import { Card, CardContent, CardHeader } from "@ui/card"; -import { useFullStack } from "."; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@ui/card"; +import { useFullStack, useStack } from "."; import { cn, updateLogToHtml } from "@lib/utils"; import { MonacoEditor } from "@components/monaco"; import { useEditPermissions } from "@pages/resource"; import { ConfirmUpdate } from "@components/config/util"; -import { useWrite } from "@lib/hooks"; +import { useLocalStorage, useWrite } from "@lib/hooks"; import { Button } from "@ui/button"; import { FilePlus, History } from "lucide-react"; import { useToast } from "@ui/use-toast"; import { ConfirmButton, ShowHideButton } from "@components/util"; import { DEFAULT_STACK_FILE_CONTENTS } from "./config"; +import { Types } from "komodo_client"; export const StackInfo = ({ id, @@ -20,7 +27,10 @@ export const StackInfo = ({ id: string; titleOther: ReactNode; }) => { - const [edits, setEdits] = useState>({}); + const [edits, setEdits] = useLocalStorage>( + `stack-${id}-edits`, + {} + ); const [show, setShow] = useState>({}); const { canWrite } = useEditPermissions({ type: "Stack", id }); const { toast } = useToast(); @@ -33,6 +43,7 @@ export const StackInfo = ({ }, }); + const not_down = useStack(id)?.info.state !== Types.StackState.Down; const stack = useFullStack(id); // const state = useStack(id)?.info.state ?? Types.StackState.Unknown; // const is_down = [Types.StackState.Down, Types.StackState.Unknown].includes( @@ -199,13 +210,13 @@ export const StackInfo = ({ -
+
File:
{content.path} -
+
{canEdit && ( <> @@ -259,6 +270,26 @@ export const StackInfo = ({ ); })} + + {stack?.info?.deployed_config && not_down && ( + + + Deployed config: + + Output of 'docker compose config' when Stack was last + deployed. + + + + + + + + )} ); };