forked from github-starred/komodo
init repo config
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user