add model button in settings page

This commit is contained in:
Nate 2025-08-12 20:43:04 -04:00
parent d0cb1221d9
commit 37b33fda81
2 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,35 @@
import { ComponentType, SVGProps } from "react";
import { GhostButton } from "../../..";
import { fontSize } from "../../../../util";
interface BaseIconButtonProps {
icon: ComponentType<SVGProps<SVGSVGElement>>;
text: string;
onClick: (e: React.MouseEvent) => void;
className?: string;
style?: React.CSSProperties;
}
export function BaseIconButton({
icon: Icon,
text,
onClick,
className = "w-full cursor-pointer rounded px-2 py-0.5 text-center",
style = { fontSize: fontSize(-3) },
}: BaseIconButtonProps) {
return (
<GhostButton
className={className}
style={style}
onClick={(e) => {
e.preventDefault();
onClick(e);
}}
>
<div className="flex items-center justify-center gap-1">
<Icon className="h-3 w-3 pr-1" />
<span className="text-[11px]">{text}</span>
</div>
</GhostButton>
);
}

View file

@ -0,0 +1,47 @@
import { BlockType } from "@continuedev/config-yaml";
import {
ArrowTopRightOnSquareIcon,
PlusIcon,
} from "@heroicons/react/24/outline";
import { ComponentType, SVGProps } from "react";
export interface ExploreBlocksConfig {
icon: ComponentType<SVGProps<SVGSVGElement>>;
text: string;
action: () => void;
}
export function getExploreBlocksConfig(
blockType: string,
isLocal: boolean,
onLocalAdd: (blockType: BlockType) => void,
onExplore: (blockType: string) => void
): ExploreBlocksConfig {
const Icon = isLocal ? PlusIcon : ArrowTopRightOnSquareIcon;
const text = `${isLocal ? "Add" : "Explore"} ${
blockType === "mcpServers"
? "MCP Servers"
: blockType.charAt(0).toUpperCase() + blockType.slice(1)
}`;
const action = () => {
if (isLocal) {
onLocalAdd(blockType as BlockType);
} else {
onExplore(blockType);
}
};
return {
icon: Icon,
text,
action,
};
}
export function formatBlockTypeName(blockType: string): string {
return blockType === "mcpServers"
? "MCP Servers"
: blockType.charAt(0).toUpperCase() + blockType.slice(1);
}