From bcc0f9e61d99d693acff6e12d22259949f3af852 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 27 Nov 2024 09:54:12 +0100 Subject: [PATCH 1/6] Cli: fix error description should be appended --- pkgs/clan-cli/clan_cli/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/clan-cli/clan_cli/errors.py b/pkgs/clan-cli/clan_cli/errors.py index 9f86e4ab2..0315ce75f 100644 --- a/pkgs/clan-cli/clan_cli/errors.py +++ b/pkgs/clan-cli/clan_cli/errors.py @@ -163,7 +163,7 @@ class ClanError(Exception): exception_msg += self.msg if self.description: - exception_msg = f" - {self.description}" + exception_msg += f" - {self.description}" super().__init__(exception_msg) From b68cf7a7e50a55f2e2e28680f3cad5fbca8497d6 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 27 Nov 2024 09:56:41 +0100 Subject: [PATCH 2/6] API/serde: fix construction of Enum values --- pkgs/clan-cli/clan_cli/api/serde.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/clan-cli/clan_cli/api/serde.py b/pkgs/clan-cli/clan_cli/api/serde.py index 394f077e2..84328186b 100644 --- a/pkgs/clan-cli/clan_cli/api/serde.py +++ b/pkgs/clan-cli/clan_cli/api/serde.py @@ -230,10 +230,18 @@ def construct_value( raise ClanError(msg, location=f"{loc}") return field_value + # Enums if origin is Enum: if field_value not in origin.__members__: msg = f"Expected one of {', '.join(origin.__members__)}, got {field_value}" raise ClanError(msg, location=f"{loc}") + return origin.__members__[field_value] # type: ignore + + if isinstance(t, type) and issubclass(t, Enum): + if field_value not in t.__members__: + msg = f"Expected one of {', '.join(t.__members__)}, got {field_value}" + raise ClanError(msg, location=f"{loc}") + return t.__members__[field_value] # type: ignore if origin is Annotated: (base_type,) = get_args(t) From f9eaf3e8ec166692b0864e389c7d387043bf4abc Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 27 Nov 2024 09:57:47 +0100 Subject: [PATCH 3/6] Cli: improve targetHost error message --- pkgs/clan-cli/clan_cli/machines/machines.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/machines/machines.py b/pkgs/clan-cli/clan_cli/machines/machines.py index ff06ebf1f..367ad405e 100644 --- a/pkgs/clan-cli/clan_cli/machines/machines.py +++ b/pkgs/clan-cli/clan_cli/machines/machines.py @@ -102,8 +102,11 @@ class Machine: or self.deployment.get("deploymentAddress") ) if val is None: - msg = f"the 'clan.core.networking.targetHost' nixos option is not set for machine '{self.name}'" - raise ClanError(msg) + msg = f"'TargetHost' is not set for machine '{self.name}'" + raise ClanError( + msg, + description="See https://docs.clan.lol/getting-started/deploy/#setting-the-target-host for more information.", + ) return val @property From a0d365a3f9833a894088d5cf0f2fe4fb00b04277 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 27 Nov 2024 09:58:14 +0100 Subject: [PATCH 4/6] UI: remove unsused old sidebar --- pkgs/webview-ui/app/src/Sidebar.tsx | 73 ----------------------------- 1 file changed, 73 deletions(-) delete mode 100644 pkgs/webview-ui/app/src/Sidebar.tsx diff --git a/pkgs/webview-ui/app/src/Sidebar.tsx b/pkgs/webview-ui/app/src/Sidebar.tsx deleted file mode 100644 index 5d62274a7..000000000 --- a/pkgs/webview-ui/app/src/Sidebar.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import { For, Show } from "solid-js"; -import { activeURI } from "./App"; -import { createQuery } from "@tanstack/solid-query"; -import { callApi } from "./api"; -import { A, RouteSectionProps } from "@solidjs/router"; -import { AppRoute, routes } from "./index"; - -export const Sidebar = (props: RouteSectionProps) => { - const clanQuery = createQuery(() => ({ - queryKey: [activeURI(), "meta"], - queryFn: async () => { - const curr = activeURI(); - if (curr) { - const result = await callApi("show_clan_meta", { uri: curr }); - if (result.status === "error") throw new Error("Failed to fetch data"); - return result.data; - } - }, - })); - - return ( - - ); -}; - -const RouteMenu = (props: { - class?: string; - routes: AppRoute[]; - prefix?: string; -}) => ( -
    - !r.hidden)}> - {(route) => ( -
  • - - - - } - > - {(children) => ( -
    - - {route.icon && ( - {route.icon} - )} - {route.label} - - -
    - )} -
    -
  • - )} -
    -
-); From cc84a53b6daaaa0f1b47c29485ccd9eac310634a Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 27 Nov 2024 09:58:52 +0100 Subject: [PATCH 5/6] UI:_ convert sidebar.css into tailwind notation --- pkgs/webview-ui/app/src/components/Sidebar/css/sidebar.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/webview-ui/app/src/components/Sidebar/css/sidebar.css b/pkgs/webview-ui/app/src/components/Sidebar/css/sidebar.css index 73b7b647b..bc4396831 100644 --- a/pkgs/webview-ui/app/src/components/Sidebar/css/sidebar.css +++ b/pkgs/webview-ui/app/src/components/Sidebar/css/sidebar.css @@ -8,11 +8,7 @@ /* Sidebar Structure */ .sidebar { - min-width: theme(width.72); - height: 100%; - background-color: var(--clr-bg-inv-2); - border: 1px solid var(--clr-border-inv-2); - border-radius: theme(borderRadius.xl); + @apply bg-inv-2 h-full border border-solid border-inv-2 min-w-72 rounded-xl; } .sidebar__body { From e7a934466558b168c9c77da4b4657bcee421215c Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 27 Nov 2024 10:05:54 +0100 Subject: [PATCH 6/6] UI/treewide: replace all {button,icon} component --- pkgs/webview-ui/app/src/Form/form/index.tsx | 49 ++++++--- .../app/src/components/BackButton.tsx | 2 +- .../app/src/components/MachineListItem.tsx | 3 +- pkgs/webview-ui/app/src/components/Menu.tsx | 6 +- .../Sidebar/SidebarFlyout/index.tsx | 2 +- .../src/components/Sidebar/SidebarHeader.tsx | 2 +- .../app/src/components/button/index.tsx | 1 + .../app/src/components/icon/index.tsx | 14 ++- pkgs/webview-ui/app/src/index.tsx | 3 +- pkgs/webview-ui/app/src/layout/header.tsx | 43 ++------ pkgs/webview-ui/app/src/layout/layout.tsx | 4 +- .../app/src/routes/blockdevices/view.tsx | 9 +- .../app/src/routes/clans/create.tsx | 8 +- .../app/src/routes/clans/details.tsx | 44 +++----- pkgs/webview-ui/app/src/routes/clans/list.tsx | 62 ++++++----- pkgs/webview-ui/app/src/routes/flash/view.tsx | 68 ++++++------ pkgs/webview-ui/app/src/routes/hosts/view.tsx | 11 +- .../app/src/routes/machines/create.tsx | 31 +++--- .../app/src/routes/machines/details.tsx | 101 ++++++++++-------- .../app/src/routes/machines/list.tsx | 25 +++-- .../app/src/routes/modules/details.tsx | 9 +- .../app/src/routes/welcome/index.tsx | 15 ++- 22 files changed, 272 insertions(+), 240 deletions(-) diff --git a/pkgs/webview-ui/app/src/Form/form/index.tsx b/pkgs/webview-ui/app/src/Form/form/index.tsx index 3f0df30e3..aad823a6f 100644 --- a/pkgs/webview-ui/app/src/Form/form/index.tsx +++ b/pkgs/webview-ui/app/src/Form/form/index.tsx @@ -35,6 +35,8 @@ import { import cx from "classnames"; import { Label } from "../base/label"; import { SelectInput } from "../fields/Select"; +import { Button } from "@/src/components/button"; +import Icon from "@/src/components/icon"; function generateDefaults(schema: JSONSchema7): unknown { switch (schema.type) { @@ -385,15 +387,25 @@ export function ListValueDisplay(
{props.children}
- - - + + +
@@ -641,7 +653,14 @@ export function ArrayFields( }} // Button for adding new items components={{ - before: , + before: ( + + ), }} // Add the new item to the FieldArray handleSubmit={(values, event) => { @@ -827,8 +846,10 @@ export function ObjectFields( {key} - + + ), }} diff --git a/pkgs/webview-ui/app/src/components/BackButton.tsx b/pkgs/webview-ui/app/src/components/BackButton.tsx index 97acfed46..5db02fb5f 100644 --- a/pkgs/webview-ui/app/src/components/BackButton.tsx +++ b/pkgs/webview-ui/app/src/components/BackButton.tsx @@ -9,7 +9,7 @@ export const BackButton = () => { variant="light" class="w-fit" onClick={() => navigate(-1)} - startIcon={} + startIcon={} > ); }; diff --git a/pkgs/webview-ui/app/src/components/MachineListItem.tsx b/pkgs/webview-ui/app/src/components/MachineListItem.tsx index ba8f31e8a..0b60f7cfc 100644 --- a/pkgs/webview-ui/app/src/components/MachineListItem.tsx +++ b/pkgs/webview-ui/app/src/components/MachineListItem.tsx @@ -5,6 +5,7 @@ import { activeURI } from "../App"; import toast from "solid-toast"; import { A, useNavigate } from "@solidjs/router"; import { RndThumbnail } from "./noiseThumbnail"; +import Icon from "./icon"; type MachineDetails = SuccessQuery<"list_inventory_machines">["data"][string]; @@ -138,7 +139,7 @@ export const MachineListItem = (props: MachineListItemProps) => {
more_vert} + label={} >
@@ -761,41 +775,38 @@ function WifiModule(props: MachineWifiProps) { /> )} - + )} - + {
- +
} diff --git a/pkgs/webview-ui/app/src/routes/machines/list.tsx b/pkgs/webview-ui/app/src/routes/machines/list.tsx index e7c849f41..d4a5f706a 100644 --- a/pkgs/webview-ui/app/src/routes/machines/list.tsx +++ b/pkgs/webview-ui/app/src/routes/machines/list.tsx @@ -9,6 +9,8 @@ import { useQueryClient, } from "@tanstack/solid-query"; import { useNavigate } from "@solidjs/router"; +import { Button } from "@/src/components/button"; +import Icon from "@/src/components/icon"; type MachinesModel = Extract< OperationResponse<"list_inventory_machines">, @@ -80,14 +82,18 @@ export const MachineListView: Component = () => {
- +
- +
@@ -117,12 +123,13 @@ export const MachineListView: Component = () => { No machines defined yet. Click below to define one. - +
diff --git a/pkgs/webview-ui/app/src/routes/modules/details.tsx b/pkgs/webview-ui/app/src/routes/modules/details.tsx index 7db0cc290..b814aab21 100644 --- a/pkgs/webview-ui/app/src/routes/modules/details.tsx +++ b/pkgs/webview-ui/app/src/routes/modules/details.tsx @@ -25,6 +25,8 @@ import { SubmitHandler, } from "@modular-forms/solid"; import { DynForm } from "@/src/Form/form"; +import { Button } from "@/src/components/button"; +import Icon from "@/src/components/icon"; export const ModuleDetails = () => { const params = useParams(); @@ -116,10 +118,9 @@ const Details = (props: DetailsProps) => { {props.data.readme}
- + {/* Add -> Select (required) roles, assign Machine */}
@@ -192,7 +193,7 @@ export const ModuleForm = (props: { id: string }) => { handleSubmit={handleSubmit} schema={schema} components={{ - after: , + after: , }} /> diff --git a/pkgs/webview-ui/app/src/routes/welcome/index.tsx b/pkgs/webview-ui/app/src/routes/welcome/index.tsx index 9e7ed6213..0c4474f0f 100644 --- a/pkgs/webview-ui/app/src/routes/welcome/index.tsx +++ b/pkgs/webview-ui/app/src/routes/welcome/index.tsx @@ -1,4 +1,5 @@ import { setActiveURI } from "@/src/App"; +import { Button } from "@/src/components/button"; import { registerClan } from "@/src/hooks"; import { useNavigate } from "@solidjs/router"; @@ -11,14 +12,12 @@ export const Welcome = () => {

Welcome to Clan

Own the services you use.

- - +