feature/ui:1.0 feature,like mcp price method support use token and set more config about home page
This commit is contained in:
1 parent
2262a7f49a
commit
8946be619d
69 files changed
+4189
-1021
No files matched your search
@@ -66,9 +66,9 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
||||
onInputChange('auth_token', '');
|
||||
}}
|
||||
>
|
||||
<SelectItem key="none" value={AuthMethod.None}>{t('None')}</SelectItem>
|
||||
<SelectItem key="apikey" value={AuthMethod.APIKey}>{t('API Key')}</SelectItem>
|
||||
<SelectItem key="token" value={AuthMethod.BearerToken}>{t('Bearer Token')}</SelectItem>
|
||||
<SelectItem key="none" value="none">{t('None')}</SelectItem>
|
||||
<SelectItem key="apikey" value="apikey">{t('API Key')}</SelectItem>
|
||||
<SelectItem key="token" value="token">{t('Bearer Token')}</SelectItem>
|
||||
</Select>
|
||||
|
||||
{/* auth config input fields */}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { MCPServiceFormData } from '@/types/mcp-service';
|
||||
import dynamic from 'next/dynamic';
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { MCPServiceFormData } from "@/types/mcp-service";
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
// dynamic import MDEditor to avoid SSR problem
|
||||
const MDEditor = dynamic(
|
||||
() => import('@uiw/react-md-editor').then((mod) => mod.default),
|
||||
() => import("@uiw/react-md-editor").then((mod) => mod.default),
|
||||
{ ssr: false }
|
||||
);
|
||||
|
||||
@@ -18,29 +18,30 @@ interface DescriptionTabProps {
|
||||
|
||||
export const DescriptionTab: React.FC<DescriptionTabProps> = ({
|
||||
formData,
|
||||
onInputChange
|
||||
onInputChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleMarkdownChange = (value?: string) => {
|
||||
onInputChange('long_description', value || '');
|
||||
onInputChange("long_description", value || "");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4 h-full">
|
||||
<div className="w-full h-full">
|
||||
<MDEditor
|
||||
value={formData.long_description || ''}
|
||||
value={formData.long_description || ""}
|
||||
onChange={handleMarkdownChange}
|
||||
preview="live"
|
||||
hideToolbar={false}
|
||||
visibleDragbar={true}
|
||||
textareaProps={{
|
||||
placeholder: t('Detailed description of the service (supports Markdown)'),
|
||||
placeholder: t("Detailed description of the service"),
|
||||
style: {
|
||||
fontSize: 14,
|
||||
lineHeight: 1.5,
|
||||
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
||||
fontFamily:
|
||||
'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
||||
},
|
||||
}}
|
||||
height="100%"
|
||||
@@ -49,4 +50,4 @@ export const DescriptionTab: React.FC<DescriptionTabProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,15 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Input,
|
||||
Select,
|
||||
SelectItem,
|
||||
} from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { MCPServiceFormData } from '@/types/mcp-service';
|
||||
import { getCurrencySymbol } from '@/shared/utils/currency';
|
||||
import { ChargeType } from '@/shared/types/marketplace';
|
||||
import React from "react";
|
||||
import { Input, Select, SelectItem } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { MCPServiceFormData } from "@/types/mcp-service";
|
||||
import { getCurrencySymbol } from "@/shared/utils/currency";
|
||||
import { ChargeType } from "@/shared/types/marketplace";
|
||||
|
||||
interface PricingTabProps {
|
||||
formData: MCPServiceFormData;
|
||||
@@ -18,52 +14,111 @@ interface PricingTabProps {
|
||||
|
||||
export const PricingTab: React.FC<PricingTabProps> = ({
|
||||
formData,
|
||||
onInputChange
|
||||
onInputChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Select
|
||||
label={t('Charge Type')}
|
||||
label={t("Charge Type")}
|
||||
selectedKeys={formData.charge_type ? [formData.charge_type] : []}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedKey = Array.from(keys)[0] as string;
|
||||
onInputChange('charge_type', selectedKey);
|
||||
onInputChange("charge_type", selectedKey);
|
||||
}}
|
||||
renderValue={() => {
|
||||
const selectedKey = formData.charge_type || ChargeType.PerCall;
|
||||
if (selectedKey === ChargeType.Free) return t('Free');
|
||||
return t(selectedKey === ChargeType.PerCall ? 'Per Call' : 'Per Token');
|
||||
if (selectedKey === ChargeType.Free) return t("Free");
|
||||
return t(
|
||||
selectedKey === ChargeType.PerCall
|
||||
? "Per Call"
|
||||
: "Per Million Tokens"
|
||||
);
|
||||
}}
|
||||
>
|
||||
<SelectItem key="free" value={ChargeType.Free}>
|
||||
<div className="flex flex-col">
|
||||
<span>{t('Free')}</span>
|
||||
<span className="text-xs text-gray-500">{t('No charge for API calls')}</span>
|
||||
<span>{t("Free")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("No charge for API calls")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
<SelectItem key="per_call" value={ChargeType.PerCall}>
|
||||
<div className="flex flex-col">
|
||||
<span>{t('Per Call')}</span>
|
||||
<span className="text-xs text-gray-500">{t('Fixed price per API call')}</span>
|
||||
<span>{t("Per Call")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Fixed price per API call")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
|
||||
<SelectItem key="per_token" value={ChargeType.PerToken}>
|
||||
<div className="flex flex-col">
|
||||
<span>{t("Per Million Tokens")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Price per million tokens consumed")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
</Select>
|
||||
|
||||
{formData.charge_type !== ChargeType.Free && (
|
||||
<Input
|
||||
label={t('Price')}
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={formData.price || ''}
|
||||
onChange={(e) => onInputChange('price', e.target.value)}
|
||||
description={t('Price per unit (call or token)')}
|
||||
startContent={<span className="text-gray-500 leading-[20px]">{getCurrencySymbol()}</span>}
|
||||
/>
|
||||
<>
|
||||
{formData.charge_type === ChargeType.PerToken ? (
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
label={t("Input Token Price")}
|
||||
value={formData.input_token_price || ""}
|
||||
onChange={(e) =>
|
||||
onInputChange("input_token_price", e.target.value)
|
||||
}
|
||||
placeholder={t("Price per million input tokens")}
|
||||
startContent={
|
||||
<span className="text-gray-500 leading-[20px]">
|
||||
{getCurrencySymbol()}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<Input
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
label={t("Output Token Price")}
|
||||
value={formData.output_token_price || ""}
|
||||
onChange={(e) =>
|
||||
onInputChange("output_token_price", e.target.value)
|
||||
}
|
||||
placeholder={t("Price per million output tokens")}
|
||||
startContent={
|
||||
<span className="text-gray-500 leading-[20px]">
|
||||
{getCurrencySymbol()}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Input
|
||||
label={t("Price")}
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={formData.price || ""}
|
||||
onChange={(e) => onInputChange("price", e.target.value)}
|
||||
description={t("Price per API call")}
|
||||
startContent={
|
||||
<span className="text-gray-500 leading-[20px]">
|
||||
{getCurrencySymbol()}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import { Input, Select, SelectItem, Button } from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { ServiceFilters } from '@/types/mcp-service';
|
||||
import { Search, Plus } from 'lucide-react';
|
||||
import React from "react";
|
||||
import { Input, Select, SelectItem, Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { ServiceFilters } from "@/types/mcp-service";
|
||||
import { Search, Plus } from "lucide-react";
|
||||
|
||||
interface ServiceFiltersBarProps {
|
||||
filters: ServiceFilters;
|
||||
@@ -16,7 +16,7 @@ interface ServiceFiltersBarProps {
|
||||
export const ServiceFiltersBar: React.FC<ServiceFiltersBarProps> = ({
|
||||
filters,
|
||||
onFiltersChange,
|
||||
onImportOpenAPI
|
||||
onImportOpenAPI,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -24,20 +24,20 @@ export const ServiceFiltersBar: React.FC<ServiceFiltersBarProps> = ({
|
||||
onFiltersChange({ ...filters, search: value });
|
||||
};
|
||||
|
||||
|
||||
const handleStatusChange = (value: string) => {
|
||||
onFiltersChange({ ...filters, status: value });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col sm:flex-row gap-4 mb-6">
|
||||
<div className="flex flex-col sm:flex-row gap-4">
|
||||
<div className="flex-1">
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={onImportOpenAPI}
|
||||
startContent={<Plus size={16} />}
|
||||
size="sm"
|
||||
>
|
||||
{t('Add Service')}
|
||||
{t("Add Service")}
|
||||
</Button>
|
||||
{/* <Input
|
||||
placeholder={t('Search services...')}
|
||||
@@ -74,10 +74,7 @@ export const ServiceFiltersBar: React.FC<ServiceFiltersBarProps> = ({
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select> */}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
@@ -12,19 +12,19 @@ import {
|
||||
Button,
|
||||
Tooltip,
|
||||
Pagination,
|
||||
Spinner
|
||||
} from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { EnabledEnum, MCPService } from '@/types/mcp-service';
|
||||
Spinner,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { EnabledEnum, MCPService } from "@/types/mcp-service";
|
||||
import {
|
||||
Trash2,
|
||||
Zap,
|
||||
PencilIcon,
|
||||
CircleCheckIcon,
|
||||
BanIcon,
|
||||
} from 'lucide-react';
|
||||
import { ChargeType } from '@/shared/types/marketplace';
|
||||
import { Price } from '@/shared/components/marketplace/Price';
|
||||
} from "lucide-react";
|
||||
import { ChargeType } from "@/shared/types/marketplace";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
|
||||
interface ServiceTableProps {
|
||||
services: MCPService[];
|
||||
@@ -58,22 +58,29 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
const items = services;
|
||||
|
||||
const getStatusColor = (enabled: number) => {
|
||||
return enabled === EnabledEnum.Online ? 'success' : 'danger';
|
||||
return enabled === EnabledEnum.Online ? "success" : "danger";
|
||||
};
|
||||
|
||||
const handleEdit = React.useCallback(
|
||||
(service: MCPService) => {
|
||||
onEdit(service);
|
||||
},
|
||||
[onEdit]
|
||||
);
|
||||
|
||||
const handleEdit = React.useCallback((service: MCPService) => {
|
||||
onEdit(service);
|
||||
}, [onEdit]);
|
||||
|
||||
const handleDelete = React.useCallback((service: MCPService) => {
|
||||
onDelete(service);
|
||||
}, [onDelete]);
|
||||
|
||||
const handleToggleStatus = React.useCallback((service: MCPService) => {
|
||||
onToggleStatus(service);
|
||||
}, [onToggleStatus]);
|
||||
const handleDelete = React.useCallback(
|
||||
(service: MCPService) => {
|
||||
onDelete(service);
|
||||
},
|
||||
[onDelete]
|
||||
);
|
||||
|
||||
const handleToggleStatus = React.useCallback(
|
||||
(service: MCPService) => {
|
||||
onToggleStatus(service);
|
||||
},
|
||||
[onToggleStatus]
|
||||
);
|
||||
|
||||
if (loading && services.length === 0) {
|
||||
return (
|
||||
@@ -96,7 +103,7 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
<div className="flex w-full justify-center">
|
||||
<Pagination
|
||||
showControls
|
||||
variant='light'
|
||||
variant="light"
|
||||
color="primary"
|
||||
page={currentPage}
|
||||
total={pages}
|
||||
@@ -107,17 +114,17 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
}
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn>{t('Service Name')}</TableColumn>
|
||||
<TableColumn>{t('API Endpoint')}</TableColumn>
|
||||
<TableColumn>{t('Status')}</TableColumn>
|
||||
<TableColumn>{t('Pricing')}</TableColumn>
|
||||
<TableColumn className='w-20'>{t('Actions')}</TableColumn>
|
||||
<TableColumn>{t("Service Name")}</TableColumn>
|
||||
<TableColumn>{t("API Endpoint")}</TableColumn>
|
||||
<TableColumn>{t("Status")}</TableColumn>
|
||||
<TableColumn>{t("Pricing")}</TableColumn>
|
||||
<TableColumn className="w-20">{t("Actions")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody
|
||||
items={items}
|
||||
isLoading={loading}
|
||||
loadingContent={<Spinner />}
|
||||
emptyContent={t('No services found')}
|
||||
emptyContent={t("No services found")}
|
||||
>
|
||||
{(service) => (
|
||||
<TableRow key={service.id}>
|
||||
@@ -134,17 +141,22 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
size="sm"
|
||||
variant="flat"
|
||||
>
|
||||
{t(service.enabled === 1 ? 'Online' : 'Offline')}
|
||||
{t(service.enabled === 1 ? "Online" : "Offline")}
|
||||
</Chip>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Price price={service.price} charge_type={service.charge_type} />
|
||||
<Price
|
||||
price={service.price}
|
||||
charge_type={service.charge_type}
|
||||
input_token_price={service.input_token_price}
|
||||
output_token_price={service.output_token_price}
|
||||
/>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="relative flex items-center gap-2">
|
||||
<Tooltip content={t('Edit')} closeDelay={0}>
|
||||
<Tooltip content={t("Edit")} closeDelay={0} disableAnimation>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
@@ -155,22 +167,40 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip content={service.enabled === EnabledEnum.Online ? t('Take Offline') : t('Bring Online')} closeDelay={0} >
|
||||
<Tooltip
|
||||
content={
|
||||
service.enabled === EnabledEnum.Online
|
||||
? t("Take Offline")
|
||||
: t("Bring Online")
|
||||
}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
color={service.enabled === EnabledEnum.Online ? 'danger' : 'success'}
|
||||
color={
|
||||
service.enabled === EnabledEnum.Online
|
||||
? "danger"
|
||||
: "success"
|
||||
}
|
||||
onPress={() => handleToggleStatus(service)}
|
||||
>
|
||||
{service.enabled === EnabledEnum.Online ?
|
||||
<BanIcon className="w-4 h-4" /> :
|
||||
{service.enabled === EnabledEnum.Online ? (
|
||||
<BanIcon className="w-4 h-4" />
|
||||
) : (
|
||||
<CircleCheckIcon className="w-4 h-4" />
|
||||
}
|
||||
)}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip content={t('Delete Service')} color="danger" closeDelay={0}>
|
||||
<Tooltip
|
||||
content={t("Delete Service")}
|
||||
color="danger"
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
@@ -189,4 +219,4 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -38,7 +38,8 @@ export const ToolsTab: React.FC<ToolsTabProps> = ({
|
||||
removeWrapper
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn className='w-1/3'>{t('Tool Name')}</TableColumn>
|
||||
<TableColumn className='w-1/4'>{t('Tool Name')}</TableColumn>
|
||||
<TableColumn className='w-1/4'>{t('Tool URL')}</TableColumn>
|
||||
<TableColumn>{t('Description')}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody emptyContent={t('No tools added yet. Add your first tool using the input above.')}>
|
||||
@@ -49,7 +50,13 @@ export const ToolsTab: React.FC<ToolsTabProps> = ({
|
||||
<TableCell>
|
||||
<Input
|
||||
value={tool.name}
|
||||
// onChange={(e) => handleToolChange(index, 'name', e.target.value)}
|
||||
size="sm"
|
||||
isDisabled
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={tool.url}
|
||||
size="sm"
|
||||
isDisabled
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user