* refactor(forge): forge-neutral foundation (GitHub-only) Decouple git-hosting from GitHub behind a neutral abstraction (issue #1616), GitHub-only for now; existing GitHub behaviour is unchanged. - Forge manifest, neutral ForgeService contract, forge registry + resolver, and a client forge-module registry. - GitHub code renamed to the neutral shape; PR/Issue attachment wording preserved. - forge.search.response enums parse tolerantly (unknown kind/auth state degrade instead of breaking the client). - createPullRequest reports typed CLI/auth errors instead of a generic message. - forge-resolver host/remote caches are LRU-bounded. - Forge host trust is explicit: only a known cloud host or a CLI-authenticated host is ever talked to; an unauthenticated GitHub Enterprise host fails resolution instead of routing to github.com. - Docs: forge-providers guide, glossary and i18n forge-copy conventions, architecture and rpc-namespacing terminology. - Vitest React Native mocks (unistyles, svg, linking, lucide) consolidated into shared aliased test-stubs. * feat(forge): GitLab adapter, forge-aware UI, pipelines and approvals GitLab adapter over the glab CLI on the neutral contracts: MR status, forge-aware UI, pipeline tree, and N-of-M approvals. - threadIsResolved is part of the neutral timeline item. - Pipeline load failures show an error instead of an empty section. - Manual pipeline jobs render as pending. - Fork/detached MR head pipelines are fetched by MR iid (glab ci get --merge-request). * feat(forge): Gitea family adapter (Gitea, Forgejo, Codeberg) One adapter over the tea CLI serving Gitea, Forgejo, and Codeberg on the neutral contracts. - CI status aggregates commit statuses and Actions runs together. - Gitea's terminal "warning" state maps to failure on server and client. - Gitea Actions check details are reachable from the PR pane by workflowRunId. * refactor(forge): localize compatibility handling * test(forge): expect normalized GitLab facts --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
/**
|
|
* Brand marks are SVG React components, so they cannot travel over the wire as
|
|
* a string. This file derives icon and brand-color lookup tables from
|
|
* CLIENT_FORGE_VIEW_MODULES; a new forge ships an icon component in the client
|
|
* bundle and references it from its view module. Unknown icon kinds fall back to
|
|
* a generic pull-request glyph.
|
|
*/
|
|
import { withUnistyles } from "react-native-unistyles";
|
|
import { GitPullRequest } from "lucide-react-native";
|
|
import {
|
|
type ForgeBrandColor,
|
|
type ForgeIconColorMapping,
|
|
type ForgeIconComponent,
|
|
} from "@/git/client-forge-module";
|
|
import { CLIENT_FORGE_VIEW_MODULES } from "@/git/forges/view";
|
|
|
|
const FORGE_ICON_BY_KIND = new Map(
|
|
CLIENT_FORGE_VIEW_MODULES.map((module) => [module.id, module.icon]),
|
|
);
|
|
|
|
/**
|
|
* Raw brand icon component for an `iconKind`, for call sites that style with a
|
|
* plain `color` prop. Falls back to a generic pull-request glyph.
|
|
*/
|
|
export function getForgeIconComponent(iconKind: string): ForgeIconComponent {
|
|
return FORGE_ICON_BY_KIND.get(iconKind) ?? GitPullRequest;
|
|
}
|
|
|
|
const THEMED_ICON_BY_KIND = Object.fromEntries(
|
|
CLIENT_FORGE_VIEW_MODULES.map((module) => [module.id, withUnistyles(module.icon)]),
|
|
);
|
|
const ThemedGitPullRequest = withUnistyles(GitPullRequest);
|
|
|
|
/** Theme-driven color mapping, e.g. `(theme) => ({ color: theme.colors.foregroundMuted })`. */
|
|
export type { ForgeIconColorMapping };
|
|
|
|
function brandColorMapping(colors: ForgeBrandColor): ForgeIconColorMapping {
|
|
return (theme) => ({ color: theme.colorScheme === "light" ? colors.light : colors.dark });
|
|
}
|
|
|
|
const BRAND_COLOR_MAPPING_BY_KIND = new Map(
|
|
CLIENT_FORGE_VIEW_MODULES.flatMap((module) =>
|
|
module.brandColor ? [[module.id, brandColorMapping(module.brandColor)] as const] : [],
|
|
),
|
|
);
|
|
|
|
/**
|
|
* The forge's brand color mapping, or null for forges with no dedicated brand
|
|
* color (github renders in a neutral tone; an unknown forge has none). Call
|
|
* sites pair this with {@link ForgeBrandIcon}: use it to tint the icon, or to
|
|
* decide whether to show a brand badge at all.
|
|
*/
|
|
export function getForgeBrandColorMapping(iconKind: string): ForgeIconColorMapping | null {
|
|
return BRAND_COLOR_MAPPING_BY_KIND.get(iconKind) ?? null;
|
|
}
|
|
|
|
/**
|
|
* Themed brand icon for an `iconKind`, for call sites that color via a unistyles
|
|
* mapping. Falls back to a generic pull-request glyph for unknown forges.
|
|
*/
|
|
export function ForgeBrandIcon({
|
|
iconKind,
|
|
size,
|
|
uniProps,
|
|
}: {
|
|
iconKind: string;
|
|
size: number;
|
|
uniProps: ForgeIconColorMapping;
|
|
}) {
|
|
const ThemedIcon = THEMED_ICON_BY_KIND[iconKind] ?? ThemedGitPullRequest;
|
|
return <ThemedIcon size={size} uniProps={uniProps} />;
|
|
}
|