import type { GlobalSettings } from "@fusion/core"; import { useTranslation } from "react-i18next"; import { TrackingRepoSelect, type TrackingRepoOption } from "../../TrackingRepoSelect"; import { SettingsSelectRow } from "../SettingsSelectRow"; import { SettingsToggleRow } from "../SettingsToggleRow"; import { SettingsTextRow } from "../SettingsTextRow"; import { SettingsHelpTip } from "../SettingsHelpTip"; import type { SectionBaseProps } from "./context"; type GlobalSourceControlSettings = Pick; export interface SourceControlGlobalSectionProps extends SectionBaseProps { globalSettings: GlobalSourceControlSettings | null; onGlobalSourceControlSettingsChange: (patch: Partial) => void; globalTrackingRepoOptions: TrackingRepoOption[]; globalTrackingRepoLoading: boolean; globalTrackingRepoError: string | null; } /* FNXC:SourceControl 2026-07-15-20:30: The global GitLab fallbacks and the global default tracking repo moved out of "General · Global" into their own section, adjacent to "Source Control · Project" under the Integrations nav group. They are integrations with GitHub/GitLab, not general app preferences, and pairing the two scopes is what lets an operator see a global fallback and its project override without hunting across unrelated sections. NOTE for future edits: `splitSettingsSave` (save-split.ts) gates these nine dual-scope keys on the ACTIVE SECTION ID — they route to the global patch only while this section is open, and to the project patch everywhere else. That guard names `source-control-global` literally. Renaming this section id without updating save-split.ts would silently write these global fallbacks into project settings. FNXC:SettingsScope 2026-07-15-20:30: No scope badge on any row here: all nine keys (`gitlabEnabled`, `gitlabInstanceUrl`, `gitlabApiBaseUrl`, `gitlabAuthTokenType`, `gitlabAuthToken`, `githubTrackingDefaultRepo`, `reportRoadmapDedupeEnabled`, `reportRoadmapLabel`, `reportRoadmapRepo`) are declared in BOTH `DEFAULT_GLOBAL_SETTINGS` and `DEFAULT_PROJECT_SETTINGS`, so no badge can state their scope honestly. The section name ("Source Control · Global") carries it, as does each label's "Global …" prefix. FNXC:SettingsStyling 2026-07-15-20:30: Plain label+control+help rows use the shared primitives; `gitlabAuthToken` uses the primitive's `type: "password"` (defaulting `autocomplete="off"`). The tracking-repo select and the disclosure chrome stay bespoke — they are custom widgets, not label+control+help rows. */ export function SourceControlGlobalSection({ form, setForm, globalSettings, onGlobalSourceControlSettingsChange, globalTrackingRepoOptions, globalTrackingRepoLoading, globalTrackingRepoError, }: SourceControlGlobalSectionProps) { const { t } = useTranslation("app"); /* FNXC:GitLabEnablement 2026-07-04-00:00: The GitLab rows read from the SCOPED global values (`globalSettings`), not the merged `form`, so a project override never renders as the global fallback's value. `form` is only the fallback while the scoped fetch is in flight. */ const globalSourceControl = globalSettings ?? form; const globalGitlab = globalSourceControl; return (<> {/* FNXC:SettingsHelp 2026-07-16-12:45: Inline help moved behind the shared "?" affordance beside the label — operator requirement: no inline description paragraphs in Settings. The bespoke TrackingRepoSelect widget is no obstacle: the tip belongs to the label line, not the control. */}
{t("settings.globalGeneral.projectsInheritThisValueWhenTheyDoNot", "Projects inherit this value when they do not set a project default tracking repo. No default — unset.")}
setForm((f) => ({ ...f, githubTrackingDefaultRepo: nextValue || undefined }))}/>
{/* FNXC:ReportPipeline 2026-07-18-20:45: FR-30 exposes global fallback values beside the global tracking repository so operators can configure a machine-wide public-roadmap policy without creating a project override. */} onGlobalSourceControlSettingsChange({ reportRoadmapDedupeEnabled: value ?? undefined })} /> onGlobalSourceControlSettingsChange({ reportRoadmapLabel: value || undefined })} /> onGlobalSourceControlSettingsChange({ reportRoadmapRepo: value || undefined })} /> {/* FNXC:GitLabEnablement 2026-07-02-00:00: FN-7453 adds a global GitLab enable fallback that can disable outbound GitLab HTTP API operations without deleting saved self-managed URL or token settings. Projects can override the enabled state when they need GitLab active while the global fallback is off. */}
{t("settings.globalGeneral.gitLabConfiguration", "GitLab Configuration")} {/* FNXC:SettingsHelp 2026-07-16-12:45: Inline disclosure hint moved behind the shared "?" affordance beside the summary title — operator requirement: no inline description paragraphs in Settings. The copy stays conditional on `gitlabEnabled` inside the tip. The wrapping span stops propagation, same as the summary's checkbox label, so opening the tip never toggles the disclosure. */} event.stopPropagation()}> {globalGitlab.gitlabEnabled === false ? t("settings.globalGeneral.gitLabDisabledHint", "GitLab API operations are disabled by global default. Saved URL and token fallbacks remain stored for re-enable.") : t("settings.globalGeneral.gitLabEnabledHint", "Global GitLab URL and token fallbacks apply to projects that do not set their own values. No default — unset (unset behaves as enabled until explicitly disabled).")}
onGlobalSourceControlSettingsChange({ gitlabInstanceUrl: v || undefined })} /> /api/v4. Override only for self-managed GitLab API gateways that use a different absolute http:// or https:// URL. No default — unset."), type: "url", placeholder: "https://gitlab.com/api/v4", disabled: globalGitlab.gitlabEnabled === false, }} value={globalGitlab.gitlabApiBaseUrl ?? ""} onChange={(v) => onGlobalSourceControlSettingsChange({ gitlabApiBaseUrl: v || undefined })} /> onGlobalSourceControlSettingsChange({ gitlabAuthTokenType: v as "personal" | "project" | "group" })} /> onGlobalSourceControlSettingsChange({ gitlabAuthToken: v || undefined })} />
); } export default SourceControlGlobalSection;