-
Notifications
You must be signed in to change notification settings - Fork 5.6k
feat(web): pick settings environment and project as two selects #10636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 7 commits into
codex/hierarchical-settings/backend
from
codex/hierarchical-settings/targets
Sep 11, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6bf24b1
feat(web): select settings targets in one hierarchy
juliusmarminge 175dc99
fix(web): clarify unavailable settings targets and duplicate checkouts
juliusmarminge e74aea6
fix(settings): preserve checkout recovery during regrouping
juliusmarminge b804970
fix(settings): preserve removed checkout scope
juliusmarminge dc154ad
fix(web): pass the project record to ProjectFavicon in the scope picker
juliusmarminge bd45db4
feat(web): pick settings environment and project as two selects
juliusmarminge 013f32b
fix(settings): show a checkout link's environment in the environment …
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,168 +1,53 @@ | ||
| import { resolveEnvironmentMachineKind } from "@t3tools/contracts"; | ||
| import { ChevronDownIcon, FolderIcon } from "lucide-react"; | ||
| import { type ReactNode, useState } from "react"; | ||
| import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon"; | ||
| import { ProjectFavicon } from "../ProjectFavicon"; | ||
| import { WorkspacePageContainer } from "../WorkspacePageContainer"; | ||
| import { useEnvironments } from "../../state/environments"; | ||
| import { Toggle, ToggleGroup } from "../ui/toggle-group"; | ||
| import { | ||
| Combobox, | ||
| ComboboxEmpty, | ||
| ComboboxSearchInput, | ||
| ComboboxItem, | ||
| ComboboxList, | ||
| ComboboxPopup, | ||
| ComboboxTrigger, | ||
| } from "../ui/combobox"; | ||
| import { selectTriggerVariants } from "../ui/select"; | ||
| import { cn } from "../../lib/utils"; | ||
| import { ProjectSettingsPanel, useSettingsProjectGroups } from "./ProjectSettingsPanel"; | ||
| import { ProjectSettingsPanel } from "./ProjectSettingsPanel"; | ||
| import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings"; | ||
|
|
||
| function ScopePicker({ | ||
| label, | ||
| value, | ||
| options, | ||
| onChange, | ||
| }: { | ||
| label: "project" | "machine"; | ||
| value: string | null; | ||
| options: ReadonlyArray<{ value: string; label: string; icon?: ReactNode }>; | ||
| onChange: (value: string | null) => void; | ||
| }) { | ||
| const [query, setQuery] = useState(""); | ||
| const selected = options.find((option) => option.value === value); | ||
| const allIcon = | ||
| label === "project" ? <FolderIcon aria-hidden className="size-3.5 shrink-0" /> : null; | ||
| const items = [{ value: "all", label: `All ${label}s`, icon: allIcon }, ...options]; | ||
| return ( | ||
| <Combobox | ||
| items={items} | ||
| value={items.find((item) => item.value === (value ?? "all")) ?? null} | ||
| inputValue={query} | ||
| onInputValueChange={setQuery} | ||
| onOpenChange={() => setQuery("")} | ||
| onValueChange={(next) => { | ||
| if (next) onChange(next.value === "all" ? null : next.value); | ||
| }} | ||
| > | ||
| <ComboboxTrigger | ||
| aria-label={`${label === "project" ? "Project" : "Machine"} scope`} | ||
| className={cn(selectTriggerVariants({ size: "compact" }), "w-auto min-w-0 max-w-52")} | ||
| > | ||
| <span className="flex min-w-0 items-center gap-1.5"> | ||
| {value === null ? allIcon : selected?.icon} | ||
| <span className="truncate"> | ||
| {value === null ? `All ${label}s` : (selected?.label ?? `Unavailable ${label}`)} | ||
| </span> | ||
| </span> | ||
| <ChevronDownIcon aria-hidden className="-me-1 size-3 opacity-50" /> | ||
| </ComboboxTrigger> | ||
| <ComboboxPopup align="start" className="w-64"> | ||
| <ComboboxSearchInput aria-label={`Search ${label}s`} placeholder={`Search ${label}s...`} /> | ||
| <ComboboxEmpty>No matching {label}s.</ComboboxEmpty> | ||
| <ComboboxList> | ||
| {(item: (typeof items)[number]) => ( | ||
| <ComboboxItem | ||
| key={item.value} | ||
| value={item} | ||
| contentClassName="flex min-w-0 items-center gap-2" | ||
| > | ||
| {item.icon} | ||
| <span className="truncate">{item.label}</span> | ||
| </ComboboxItem> | ||
| )} | ||
| </ComboboxList> | ||
| </ComboboxPopup> | ||
| </Combobox> | ||
| ); | ||
| } | ||
| import { SettingsScopeSelects } from "./SettingsScopeSelects"; | ||
| import { resolveSettingsScope, type SettingsScopeSearch } from "./settingsScope"; | ||
| import { useSettingsProjectGroups } from "./useSettingsProjectGroups"; | ||
|
|
||
| export function ProjectsSettings({ | ||
| projectKey, | ||
| machineId, | ||
| value, | ||
| onScopeChange, | ||
| }: { | ||
| projectKey: string | null; | ||
| machineId: string | null; | ||
| onScopeChange: (project: string | null, machine: string | null) => void; | ||
| value: SettingsScopeSearch; | ||
| onScopeChange: (scope: SettingsScopeSearch) => void; | ||
| }) { | ||
| const groups = useSettingsProjectGroups(); | ||
| const { environments } = useEnvironments(); | ||
| const machine = environments.find((environment) => environment.environmentId === machineId); | ||
| const machineOptions = environments.map((environment) => ({ | ||
| value: environment.environmentId, | ||
| label: environment.label, | ||
| icon: ( | ||
| <EnvironmentMachineIcon | ||
| aria-hidden | ||
| kind={resolveEnvironmentMachineKind(environment.serverConfig)} | ||
| className="size-3.5 shrink-0" | ||
| /> | ||
| ), | ||
| })); | ||
| const scope = resolveSettingsScope(value, groups, environments); | ||
| // The panel follows remembered members when grouping replaces a project key. | ||
| const projectScope = | ||
| scope.kind === "project" || | ||
| scope.kind === "checkout" || | ||
| (scope.kind === "unavailable" && | ||
| (scope.reason === "project-missing" || scope.reason === "checkout-missing")); | ||
| return ( | ||
| <div className="flex min-h-0 flex-1 flex-col"> | ||
| <div className="scrollbar-gutter-both shrink-0 overflow-y-auto"> | ||
| <WorkspacePageContainer className="pb-0"> | ||
| <div | ||
| className="flex flex-wrap items-center gap-2" | ||
| role="group" | ||
| aria-label="Settings scope" | ||
| > | ||
| {environments.length > 3 ? ( | ||
| <ScopePicker | ||
| label="machine" | ||
| value={machineId} | ||
| options={machineOptions} | ||
| onChange={(value) => onScopeChange(projectKey, value)} | ||
| /> | ||
| ) : ( | ||
| <ToggleGroup | ||
| aria-label="Machine scope" | ||
| variant="segmented" | ||
| className="max-w-full flex-wrap" | ||
| value={[machineId ?? "all"]} | ||
| onValueChange={(next) => { | ||
| const value = next[0]; | ||
| if (value) onScopeChange(projectKey, value === "all" ? null : value); | ||
| }} | ||
| > | ||
| <Toggle value="all">All machines</Toggle> | ||
| {machineOptions.map((option) => ( | ||
| <Toggle key={option.value} value={option.value} title={option.label}> | ||
| {option.icon} | ||
| <span className="max-w-36 truncate">{option.label}</span> | ||
| </Toggle> | ||
| ))} | ||
| </ToggleGroup> | ||
| )} | ||
| <div className="ms-auto"> | ||
| <ScopePicker | ||
| label="project" | ||
| value={projectKey} | ||
| options={groups.map((group) => ({ | ||
| value: group.projectKey, | ||
| label: group.displayName, | ||
| icon: <ProjectFavicon project={group} className="size-3.5" />, | ||
| }))} | ||
| onChange={(value) => onScopeChange(value, machineId)} | ||
| /> | ||
| </div> | ||
| </div> | ||
| <WorkspacePageContainer className="items-end pb-0"> | ||
| <SettingsScopeSelects | ||
| value={value} | ||
| groups={groups} | ||
| environments={environments} | ||
| onChange={onScopeChange} | ||
| /> | ||
| </WorkspacePageContainer> | ||
| </div> | ||
| {machineId !== null && !machine ? ( | ||
| <p className="p-8 text-sm text-muted-foreground">This machine is no longer available.</p> | ||
| ) : projectKey === null ? ( | ||
| <ProjectDefaultsSettings environmentId={machine?.environmentId ?? null} /> | ||
| ) : ( | ||
| {value.project && projectScope ? ( | ||
| <ProjectSettingsPanel | ||
| projectKey={projectKey} | ||
| environmentId={machine?.environmentId ?? null} | ||
| projectKey={value.project} | ||
| environmentId={value.machine ? EnvironmentId.make(value.machine) : null} | ||
| checkoutKey={value.checkout ?? null} | ||
| /> | ||
| ) : scope.kind === "unavailable" ? ( | ||
| <p className="p-8 text-sm text-muted-foreground">{scope.message}</p> | ||
| ) : ( | ||
| <ProjectDefaultsSettings | ||
| environmentId={scope.kind === "environment" ? scope.environmentId : null} | ||
| /> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
| import { EnvironmentId } from "@t3tools/contracts"; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.