init repo config

This commit is contained in:
kv
2023-09-12 14:24:38 -07:00
parent 21401c544d
commit 2a3f223a2b
2 changed files with 48 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>Monitor</title>
</head>
<body class="min-h-screen">
<div id="root"></div>

View File

@@ -1,6 +1,10 @@
import { useRead } from "@lib/hooks";
import { ConfigInner } from "@components/config";
import { AccountSelector, ResourceSelector } from "@components/config/util";
import { useRead, useWrite } from "@lib/hooks";
import { Types } from "@monitor/client";
import { RequiredResourceComponents } from "@types";
import { GitBranch } from "lucide-react";
import { useState } from "react";
const useRepo = (id?: string) =>
useRead("ListRepos", {}).data?.find((d) => d.id === id);
@@ -10,7 +14,48 @@ export const Repo: RequiredResourceComponents = {
Description: ({ id }) => <>{id}</>,
Info: ({ id }) => <>{id}</>,
Icon: () => <GitBranch className="w-4 h-4" />,
Page: {},
Page: {
Config: ({ id }) => {
const config = useRead("GetRepo", { id }).data?.config;
const [update, set] = useState<Partial<Types.RepoConfig>>({});
const mutate = useWrite("UpdateRepo");
if (!config) return null;
return (
<ConfigInner
config={config}
update={update}
set={set}
onSave={() => mutate}
components={{
general: {
general: {
server_id: (selected, set) => (
<ResourceSelector
type="Server"
selected={selected}
onSelect={(server_id) => set({ server_id })}
/>
),
github_account: (value, set) => (
<AccountSelector
type="Server"
account_type="github"
id={update.server_id ?? config.server_id}
selected={value}
onSelect={(github_account) => set({ github_account })}
/>
),
repo: true,
branch: true,
on_pull: true,
on_clone: true,
},
},
}}
/>
);
},
},
Actions: () => null,
New: () => null,
};