From 6a6306f7f0a6a489f6cec90519c6aff855b0a3f8 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 22 Nov 2024 13:58:20 +0100 Subject: [PATCH 1/6] Clan-cli/api: init dynamic get module interface --- pkgs/clan-cli/clan_cli/api/modules.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkgs/clan-cli/clan_cli/api/modules.py b/pkgs/clan-cli/clan_cli/api/modules.py index d09da67c5..88048bc66 100644 --- a/pkgs/clan-cli/clan_cli/api/modules.py +++ b/pkgs/clan-cli/clan_cli/api/modules.py @@ -163,6 +163,28 @@ def get_modules(base_path: str) -> dict[str, str]: return modules +@API.register +def get_module_interface(base_path: str, module_name: str) -> dict[str, Any]: + """ + Check if a module exists and returns the interface schema + Returns an error if the module does not exist or has an incorrect interface + """ + cmd = nix_eval([f"{base_path}#clanInternals.moduleSchemas.{module_name}", "--json"]) + try: + proc = run_no_stdout(cmd) + res = proc.stdout.strip() + except ClanCmdError as e: + msg = "clanInternals might not have moduleSchemas attributes" + raise ClanError( + msg, + location=f"list_modules {base_path}", + description="Evaluation failed on clanInternals.moduleSchemas attribute", + ) from e + modules_schema: dict[str, Any] = json.loads(res) + + return modules_schema + + @API.register def list_modules(base_path: str) -> dict[str, ModuleInfo]: """ From 2b202c879aff96adc8d603bc705879da5d5f09d3 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 22 Nov 2024 14:01:03 +0100 Subject: [PATCH 2/6] UI/components/button: forward classnames --- pkgs/webview-ui/app/src/components/button/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/webview-ui/app/src/components/button/index.tsx b/pkgs/webview-ui/app/src/components/button/index.tsx index 9d179f11a..f3ec97486 100644 --- a/pkgs/webview-ui/app/src/components/button/index.tsx +++ b/pkgs/webview-ui/app/src/components/button/index.tsx @@ -42,6 +42,7 @@ interface ButtonProps extends JSX.ButtonHTMLAttributes { children: JSX.Element; startIcon?: JSX.Element; endIcon?: JSX.Element; + class?: string; } export const Button = (props: ButtonProps) => { const { @@ -50,11 +51,13 @@ export const Button = (props: ButtonProps) => { size = "default", startIcon, endIcon, + class: extraClass = "", ...buttonProps } = props; return ( ); }; From b969c51cd0ab5a6ecc7eb71e9f22af984ee8540a Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 22 Nov 2024 14:36:11 +0100 Subject: [PATCH 5/6] UI/components/sidebar: fix missing top-level keys --- pkgs/webview-ui/app/src/components/Sidebar/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/webview-ui/app/src/components/Sidebar/index.tsx b/pkgs/webview-ui/app/src/components/Sidebar/index.tsx index 8ba262499..896f2de55 100644 --- a/pkgs/webview-ui/app/src/components/Sidebar/index.tsx +++ b/pkgs/webview-ui/app/src/components/Sidebar/index.tsx @@ -69,7 +69,12 @@ export const Sidebar = (props: RouteSectionProps) => {