Files
t3code/apps/web/src/sourceControlPresentation.ts
T
cad2c93616 feat: multi-provider pull requests page with in-app reviews (#4849)
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: maria <[email protected]>
Co-authored-by: maria-rcks <[email protected]>
Co-authored-by: codex <[email protected]>
2026-08-10 17:47:02 +02:00

70 lines
2.4 KiB
TypeScript

import { GitPullRequestIcon } from "lucide-react";
import type { ElementType } from "react";
import type { SourceControlProviderInfo, SourceControlProviderKind } from "@t3tools/contracts";
export {
DEFAULT_CHANGE_REQUEST_TERMINOLOGY,
formatChangeRequestAction,
formatCreateChangeRequestPhrase,
getChangeRequestTerminology,
resolveChangeRequestPresentation,
type ChangeRequestPresentation,
type ChangeRequestTerminology,
} from "@t3tools/shared/sourceControl";
import {
getChangeRequestTerminology,
resolveChangeRequestPresentation,
type ChangeRequestTerminology,
} from "@t3tools/shared/sourceControl";
import { AzureDevOpsIcon, BitbucketIcon, GitHubIcon, GitLabIcon } from "./components/Icons";
export interface SourceControlPresentation {
readonly providerName: string;
readonly terminology: ChangeRequestTerminology;
readonly Icon: ElementType<{ className?: string }>;
}
export function getSourceControlPresentation(
provider: SourceControlProviderInfo | null | undefined,
): SourceControlPresentation {
const presentation = resolveChangeRequestPresentation(provider);
switch (presentation.icon) {
case "github":
return {
providerName: provider?.name || presentation.providerName,
terminology: getChangeRequestTerminology(provider),
Icon: GitHubIcon,
};
case "gitlab":
return {
providerName: provider?.name || presentation.providerName,
terminology: getChangeRequestTerminology(provider),
Icon: GitLabIcon,
};
case "azure-devops":
return {
providerName: provider?.name || presentation.providerName,
terminology: getChangeRequestTerminology(provider),
Icon: AzureDevOpsIcon,
};
case "bitbucket":
return {
providerName: provider?.name || presentation.providerName,
terminology: getChangeRequestTerminology(provider),
Icon: BitbucketIcon,
};
case "change-request":
return {
providerName: provider?.name || presentation.providerName,
terminology: getChangeRequestTerminology(provider),
Icon: GitPullRequestIcon,
};
}
}
/** For surfaces that know only the host kind, such as a change request row or filter. */
export function getSourceControlPresentationForKind(
kind: SourceControlProviderKind,
): SourceControlPresentation {
return getSourceControlPresentation({ kind, name: "", baseUrl: "" });
}