feat: resource-group-management
This commit is contained in:
1 parent
c5a020c65c
commit
5d30306ad7
8 files changed
+60
-17
No files matched your search
@@ -18,6 +18,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { sanitizeMCPServerName } from "@/shared/utils/mcp";
|
||||
import { useNavigationItems } from "@/shared/providers/ConfigProvider";
|
||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||
import { useSharedStore } from "@/shared/store/share";
|
||||
|
||||
interface ProductDetailThemeSelectorProps {
|
||||
product: ServiceData;
|
||||
@@ -37,6 +38,7 @@ const BasicProductDetailThemeSelector: React.FC<
|
||||
const [url, setUrl] = useState<string>("");
|
||||
const [mcpName, setMcpName] = useState<string>("");
|
||||
const [can_invoke, setCanInvoke] = useState<boolean>(false);
|
||||
const [visitor, setVisitor] = useState<boolean>(false);
|
||||
const { t } = useTranslation();
|
||||
const configNavigation = useNavigationItems() || NavigationItems;
|
||||
|
||||
@@ -58,8 +60,24 @@ const BasicProductDetailThemeSelector: React.FC<
|
||||
setMcpName(sanitizeMCPServerName(product.name));
|
||||
}, [product.name]);
|
||||
useEffect(() => {
|
||||
setCanInvoke(product.can_invoke || false);
|
||||
}, [product.can_invoke]);
|
||||
const user = useSharedStore?.getState?.().user;
|
||||
if (user) {
|
||||
if (user?.allow_all) {
|
||||
setCanInvoke(true)
|
||||
} else {
|
||||
const serviceId = product.id
|
||||
const allowIds = user.service_ids
|
||||
if (!allowIds?.includes(serviceId)) {
|
||||
setCanInvoke(false)
|
||||
} else {
|
||||
setCanInvoke(true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setCanInvoke(true);
|
||||
setVisitor(true);
|
||||
}
|
||||
}, [useSharedStore?.getState?.().user]);
|
||||
const getCodeContent = () => {
|
||||
return `{
|
||||
"mcpServers": {
|
||||
@@ -87,6 +105,7 @@ const BasicProductDetailThemeSelector: React.FC<
|
||||
return (
|
||||
<ModernDetail
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
@@ -99,6 +118,7 @@ const BasicProductDetailThemeSelector: React.FC<
|
||||
return (
|
||||
<ClassicDetail
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
@@ -111,6 +131,7 @@ const BasicProductDetailThemeSelector: React.FC<
|
||||
return (
|
||||
<CreativeDetail
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
@@ -123,6 +144,7 @@ const BasicProductDetailThemeSelector: React.FC<
|
||||
return (
|
||||
<TemuDetail
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
@@ -140,6 +162,7 @@ const BasicProductDetailThemeSelector: React.FC<
|
||||
<ProductDetailClient
|
||||
product={product}
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
mcpName={mcpName}
|
||||
url={url}
|
||||
/>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||
|
||||
interface DetailProps {
|
||||
can_invoke?: boolean;
|
||||
visitor?: boolean;
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
@@ -32,6 +33,7 @@ interface DetailProps {
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
can_invoke,
|
||||
visitor,
|
||||
product,
|
||||
url,
|
||||
mcpName,
|
||||
@@ -219,6 +221,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
{/* Code Snippet */}
|
||||
<ServerConfig
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
mcpName={mcpName}
|
||||
url={url}
|
||||
className="w-full max-w-2xl"
|
||||
|
||||
@@ -16,6 +16,7 @@ import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||
|
||||
interface DetailProps {
|
||||
can_invoke?: boolean;
|
||||
visitor?: boolean;
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
@@ -31,6 +32,7 @@ interface DetailProps {
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
can_invoke,
|
||||
visitor,
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
@@ -179,6 +181,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
{/* Code Snippet */}
|
||||
<ServerConfig
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
mcpName={mcpName}
|
||||
url={url}
|
||||
className="w-full max-w-2xl"
|
||||
|
||||
@@ -17,6 +17,7 @@ import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||
|
||||
interface DetailProps {
|
||||
can_invoke?: boolean;
|
||||
visitor?: boolean;
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
@@ -32,6 +33,7 @@ interface DetailProps {
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
can_invoke,
|
||||
visitor,
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
@@ -147,6 +149,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<ServerConfig
|
||||
mcpName={mcpName}
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
url={url}
|
||||
className="w-full max-w-2xl"
|
||||
/>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||
|
||||
interface DetailProps {
|
||||
can_invoke?: boolean;
|
||||
visitor?: boolean;
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
@@ -31,6 +32,7 @@ interface DetailProps {
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
can_invoke,
|
||||
visitor,
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
@@ -166,6 +168,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
{/* Code Snippet */}
|
||||
<ServerConfig
|
||||
can_invoke={can_invoke}
|
||||
visitor={visitor}
|
||||
mcpName={mcpName}
|
||||
url={url}
|
||||
className="w-full max-w-2xl"
|
||||
|
||||
@@ -12,6 +12,7 @@ import { ServiceData } from "@/shared/types/marketplace";
|
||||
|
||||
interface ProductDetailClientProps {
|
||||
product: ServiceData;
|
||||
visitor?: boolean;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
name: string;
|
||||
@@ -24,6 +25,7 @@ interface ProductDetailClientProps {
|
||||
|
||||
export const ProductDetailClient: React.FC<ProductDetailClientProps> = ({
|
||||
product,
|
||||
visitor,
|
||||
breadcrumbs,
|
||||
mcpName,
|
||||
url,
|
||||
@@ -71,7 +73,7 @@ export const ProductDetailClient: React.FC<ProductDetailClientProps> = ({
|
||||
</div>
|
||||
|
||||
{/* Right side - Server Config */}
|
||||
<ServerConfig mcpName={mcpName} url={url} can_invoke={can_invoke} />
|
||||
<ServerConfig mcpName={mcpName} url={url} can_invoke={can_invoke} visitor={visitor} />
|
||||
</div>
|
||||
|
||||
{/* SEO-friendly: Simple text content for search engines */}
|
||||
|
||||
@@ -15,6 +15,7 @@ interface ServerConfigProps {
|
||||
url?: string;
|
||||
className?: string;
|
||||
can_invoke?: boolean;
|
||||
visitor?: boolean;
|
||||
}
|
||||
|
||||
type McpType = "sse" | "streamable-http";
|
||||
@@ -24,6 +25,7 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({
|
||||
url = process.env.NEXT_PUBLIC_MCP_URL,
|
||||
className = "md:min-w-[40%] w-[40%] max-w-100 mt-12",
|
||||
can_invoke,
|
||||
visitor,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { handleLogin } = useAuth();
|
||||
@@ -64,11 +66,22 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({
|
||||
return (
|
||||
<div className={`min-w-full ${className} flex-shrink-0`}>
|
||||
<div className="mb-2 mt-1">
|
||||
<FlipButton
|
||||
className="w-full rounded-md"
|
||||
text={t("Sign up to get the auth key")}
|
||||
onPress={handleLogin}
|
||||
/>
|
||||
{
|
||||
visitor || can_invoke ? <>
|
||||
<FlipButton
|
||||
className="w-full rounded-md"
|
||||
text={t("Sign up to get the auth key")}
|
||||
onPress={handleLogin}
|
||||
/>
|
||||
</> : <>
|
||||
<div className="w-full rounded-lg bg-[#F3126033] md:pr-2 h-[40px] md:h-[50px] shadow-lg flex items-center justify-center">
|
||||
<p className="text-[#C20E4D] text-center font-bold text-lg leading-none">
|
||||
{t("You don't have permission to access this MCP server.")}
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
{/* MCP Type Selection */}
|
||||
@@ -135,15 +148,6 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
{/* Permission Overlay */}
|
||||
{can_invoke === false && (
|
||||
<div className="absolute inset-0 bg-gray-300/70 backdrop-blur-sm rounded-lg flex items-center justify-center z-20">
|
||||
<p className="text-black text-center font-semibold text-lg px-8">
|
||||
{t("You don't have permission to access this MCP server.")}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -14,6 +14,8 @@ export interface User {
|
||||
user_email: string;
|
||||
user_name: string;
|
||||
avatar?: string;
|
||||
allow_all?: boolean;
|
||||
service_ids?: string[];
|
||||
nick_name?: string;
|
||||
language: NavigatorLanguage | "en" | "zh-CN";
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user