Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions studio/src/components/layout/ui/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface DataTableProps<TData, TValue> {
toolbar?: React.ReactNode
className?: string
onRowClick?: (row: TData) => void
paginationPageInfoLabel?: (currentPage: number, totalPages: number) => string
paginationTotalRecordsLabel?: (totalRecords: number) => string
}

export function DataTable<TData, TValue>({
Expand All @@ -67,6 +69,9 @@ export function DataTable<TData, TValue>({
toolbar,
className,
onRowClick,
paginationPageInfoLabel = (currentPage, totalPages) =>
`Page ${currentPage} of ${totalPages}`,
paginationTotalRecordsLabel = (totalRecords) => `${totalRecords} records`,
}: DataTableProps<TData, TValue>) {
const [sorting, setSorting] = React.useState<SortingState>([])
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
Expand Down Expand Up @@ -237,11 +242,17 @@ export function DataTable<TData, TValue>({
<div className="flex items-center justify-between px-4 py-3 border-t">
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<span>
第 {table.getState().pagination.pageIndex + 1} 页,共{" "}
{table.getPageCount()} 页
{paginationPageInfoLabel(
table.getState().pagination.pageIndex + 1,
table.getPageCount()
)}
</span>
<span>•</span>
<span>共 {table.getFilteredRowModel().rows.length} 条记录</span>
<span>
{paginationTotalRecordsLabel(
table.getFilteredRowModel().rows.length
)}
</span>
</div>
<div className="flex items-center gap-2">
<Button
Expand Down
12 changes: 12 additions & 0 deletions studio/src/i18n/locales/en/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,14 @@
"static": "Static",
"dynamic": "Dynamic"
},
"table": {
"status": "Status",
"name": "Module Name",
"description": "Description",
"actions": "Actions",
"pageInfo": "Page {{current}} of {{total}}",
"totalRecords": "{{count}} records"
},
"actions": {
"enable": "Enable",
"disable": "Disable",
Expand Down Expand Up @@ -465,6 +473,10 @@
"maxPagesPerAgent": "Max Pages Per Agent",
"maxPageContentLength": "Max Page Content Length",
"configJson": "Config (JSON)",
"selectPlaceholder": "Please select...",
"addOptionPlaceholder": "Add option...",
"addItem": "Add item",
"unsupportedFieldType": "Unsupported field type",
"noSchema": {
"title": "No Configuration Schema",
"description": "This mod has not defined a configuration schema. The schema will be defined in the mod's manifest.json file."
Expand Down
1 change: 1 addition & 0 deletions studio/src/i18n/locales/en/network.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"refresh": "Refresh",
"total": "Total Agents",
"online": "Online Agents",
"searchPlaceholder": "Search agents...",
"empty": "No agents connected",
"you": "(You)",
"kick": "Kick",
Expand Down
20 changes: 16 additions & 4 deletions studio/src/pages/mod-management/ConfigFieldRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { ConfigField } from '@/types/modConfig';
import { Input } from '@/components/layout/ui/input';
import { Label } from '@/components/layout/ui/label';
Expand Down Expand Up @@ -29,6 +30,7 @@ const ConfigFieldRenderer: React.FC<ConfigFieldRendererProps> = ({
errors = {},
path = '',
}) => {
const { t } = useTranslation('admin');
const fieldPath = path ? `${path}.${field.key}` : field.key;
const error = errors[fieldPath];
const displayValue = value !== undefined && value !== null ? value : field.default;
Expand Down Expand Up @@ -100,7 +102,12 @@ const ConfigFieldRenderer: React.FC<ConfigFieldRendererProps> = ({
}}
>
<SelectTrigger size="lg" className={error ? 'border-red-500' : ''}>
<SelectValue placeholder={field.placeholder || '请选择...'} />
<SelectValue
placeholder={
field.placeholder ||
t('modManagement.settings.selectPlaceholder', '请选择...')
}
/>
</SelectTrigger>
<SelectContent>
{field.options?.map((option) => (
Expand All @@ -126,7 +133,12 @@ const ConfigFieldRenderer: React.FC<ConfigFieldRendererProps> = ({
}}
>
<SelectTrigger size="lg" className={error ? 'border-red-500' : ''}>
<SelectValue placeholder={field.placeholder || '添加选项...'} />
<SelectValue
placeholder={
field.placeholder ||
t('modManagement.settings.addOptionPlaceholder', '添加选项...')
}
/>
</SelectTrigger>
<SelectContent>
{field.options?.map((option) => (
Expand Down Expand Up @@ -248,7 +260,7 @@ const ConfigFieldRenderer: React.FC<ConfigFieldRendererProps> = ({
className="text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-800 hover:bg-blue-50 dark:hover:bg-blue-900/20"
>
<Plus className="w-4 h-4 mr-2" />
添加项
{t('modManagement.settings.addItem', '添加项')}
</Button>
</div>
);
Expand Down Expand Up @@ -277,7 +289,7 @@ const ConfigFieldRenderer: React.FC<ConfigFieldRendererProps> = ({
default:
return (
<div className="text-sm text-gray-500 dark:text-gray-400">
不支持的字段类型: {field.type}
{t('modManagement.settings.unsupportedFieldType', '不支持的字段类型')}: {field.type}
</div>
);
}
Expand Down
11 changes: 11 additions & 0 deletions studio/src/pages/mod-management/ModManagementPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,17 @@ const ModManagementPage: React.FC = () => {
searchColumn={["id", "name", "displayName", "description"]}
pagination={true}
pageSize={10}
paginationPageInfoLabel={(currentPage, totalPages) =>
t("modManagement.table.pageInfo", "第 {{current}} 页,共 {{total}} 页", {
current: currentPage,
total: totalPages,
})
}
paginationTotalRecordsLabel={(totalRecords) =>
t("modManagement.table.totalRecords", "共 {{count}} 条记录", {
count: totalRecords,
})
}
emptyMessage={t(
"modManagement.enabledMods.empty",
"No mods configured"
Expand Down
Loading