Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProjectsSettings.tsx

55 lines2.0 KB

1import { EnvironmentId } from "@t3tools/contracts";
2import { LayersIcon } from "lucide-react";
3​
4import { Button } from "../ui/button";
5import { ProjectSettingsPanel } from "./ProjectSettingsPanel";
6import { useSettingsScope } from "./SettingsScopeContext";
7import { SettingsScopeNotice } from "./SettingsScopeNotice";
8import { SettingsPageContainer } from "./settingsLayout";
9import { ALL_ENVIRONMENTS_VALUE, selectEnvironmentAxis } from "./settingsScopeAxis";
10​
11export function ProjectsSettings() {
12 const { search: value, scope, selectScope } = useSettingsScope();
13 const unavailable =
14 scope.kind === "unavailable" ? (
15 <SettingsPageContainer>
16 <div className="flex flex-col items-start gap-3">
17 <p className="text-sm text-muted-foreground">{scope.message}</p>
18 {value.machine || value.checkout ? (
19 <Button
20 variant="outline"
21 size="xs"
22 onClick={() => selectScope(selectEnvironmentAxis(value, ALL_ENVIRONMENTS_VALUE))}
23 >
24 <LayersIcon />
25 Show all environments
26 </Button>
27 ) : null}
28 </div>
29 </SettingsPageContainer>
30 ) : null;
31 // Keep the panel mounted so it can follow members when regrouping changes the project key.
32 const projectScope =
33 scope.kind === "project" ||
34 scope.kind === "checkout" ||
35 (scope.kind === "unavailable" &&
36 (scope.reason === "project-missing" || scope.reason === "checkout-missing"));
37 return (
38 <div className="flex min-h-0 flex-1 flex-col">
39 {value.project && projectScope ? (
40 <ProjectSettingsPanel
41 projectKey={value.project}
42 environmentId={value.machine ? EnvironmentId.make(value.machine) : null}
43 checkoutKey={value.checkout ?? null}
44 unavailable={unavailable}
45 />
46 ) : unavailable ? (
47 unavailable
48 ) : (
49 <SettingsScopeNotice target="project">
50 Choose a project to manage its name, icon, checkouts and actions.
51 </SettingsScopeNotice>
52 )}
53 </div>
54 );