| 1 | import { For, Show } from "solid-js"; |
| 2 | import { Checkbox } from "../components/Checkbox.tsx"; |
| 3 | import type { Access, Catalog, Resources } from "../types/mcp.ts"; |
| 4 | |
| 5 | export function MCPAccess(props: { |
| 6 | catalog: Catalog; |
| 7 | resources: Resources; |
| 8 | value: Access; |
| 9 | onChange: (value: Access) => void; |
| 10 | disabled: boolean; |
| 11 | }) { |
| 12 | return <fieldset class="mcp-access" disabled={props.disabled}> |
| 13 | <legend>{props.catalog === "shale" ? "Repositories" : props.catalog === "agents" ? "Machines" : "Services"}</legend> |
| 14 | <Show when={props.catalog === "shale"}> |
| 15 | <div class="mcp-access-modes"> |
| 16 | <label><input type="radio" name="repository-access" checked={props.value === "all"} onChange={() => props.onChange("all")} /> |
| 17 | <span><strong>All Repositories</strong><span class="muted">Includes repositories you can access now and in the future.</span></span> |
| 18 | </label> |
| 19 | <label><input type="radio" name="repository-access" checked={props.value !== "all"} onChange={() => props.onChange([])} /> |
| 20 | <span><strong>Selected repositories</strong><span class="muted">Limit this connection to the repositories you choose.</span></span> |
| 21 | </label> |
| 22 | </div> |
| 23 | </Show> |
| 24 | <Show when={props.value !== "all"}> |
| 25 | <div class="mcp-resources"><For each={props.resources}>{(resource) => |
| 26 | <Checkbox checked={props.value !== "all" && props.value.includes(resource.id)} disabled={props.disabled} onChange={(checked) => { |
| 27 | const selected = props.value === "all" ? [] : props.value; |
| 28 | props.onChange(checked ? [...selected, resource.id] : selected.filter((id) => id !== resource.id)); |
| 29 | }}><span>{resource.name}<Show when={resource.description}><small class="muted">{resource.description}</small></Show></span></Checkbox> |
| 30 | }</For></div> |
| 31 | <Show when={!props.resources.length}><p class="muted">{props.catalog === "agents" ? "No machines linked. Link a machine in MCP settings before connecting a client." : props.catalog === "shale" ? "No repositories available to select." : "No services available to your account."}</p></Show> |
| 32 | </Show> |
| 33 | </fieldset>; |
| 34 | } |