chore: update locales

This commit is contained in:
jialin
2025-10-13 15:21:17 +08:00
parent bb7c8e9c85
commit f42f159785
15 changed files with 196 additions and 33 deletions
+12 -2
View File
@@ -1,4 +1,5 @@
import { SearchOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Checkbox, Empty, Input } from 'antd';
import React, { useEffect, useMemo, useState } from 'react';
import styled from 'styled-components';
@@ -34,6 +35,7 @@ interface SelectPanelProps {
leftWidth?: number;
options: Array<{ key: string; title: string }>;
selectedKeys: string[];
notFoundContent?: React.ReactNode;
onSelectChange: (selectedKeys: string[]) => void;
}
@@ -43,8 +45,10 @@ const SelectPanel: React.FC<SelectPanelProps> = ({
options,
selectedKeys,
searchPlaceholder,
notFoundContent,
onSelectChange
}) => {
const intl = useIntl();
const [indeterminate, setIndeterminate] = React.useState(false);
const [checkAll, setCheckAll] = React.useState(false);
const [searchText, setSearchText] = useState('');
@@ -162,7 +166,12 @@ const SelectPanel: React.FC<SelectPanelProps> = ({
indeterminate={indeterminate}
onChange={handleCheckAllChange}
></Checkbox>
<span> {selectedKeys.length} selected</span>
<span>
{intl.formatMessage(
{ id: 'common.select.count' },
{ count: selectedKeys.length }
)}
</span>
</span>
<Input
prefix={
@@ -172,6 +181,7 @@ const SelectPanel: React.FC<SelectPanelProps> = ({
}
size="small"
allowClear
status={'null' as any}
placeholder={searchPlaceholder}
style={{
width: 300,
@@ -192,7 +202,7 @@ const SelectPanel: React.FC<SelectPanelProps> = ({
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="No models found"
description={notFoundContent}
></Empty>
)}
</Left>
+7 -1
View File
@@ -1,4 +1,5 @@
import { MoreOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Transfer, TransferProps } from 'antd';
import styled from 'styled-components';
@@ -72,6 +73,8 @@ interface TransferInnerProps extends TransferProps {
}
const TransferInner: React.FC<TransferInnerProps> = (props) => {
const intl = useIntl();
const renderAllLabels = (info: {
selectedCount: number;
totalCount: number;
@@ -79,7 +82,10 @@ const TransferInner: React.FC<TransferInnerProps> = (props) => {
if (info.selectedCount) {
return (
<span style={{ color: 'var(--ant-color-text-secondary)' }}>
{info.selectedCount} selected
{intl.formatMessage(
{ id: 'common.select.count' },
{ count: info.selectedCount }
)}
</span>
);
}
@@ -1,7 +1,9 @@
import { PageAction } from '@/config';
import { PageActionType } from '@/config/types';
import useAppUtils from '@/hooks/use-app-utils';
import SelectPanel from '@/pages/_components/select-panel';
import { queryModelsList } from '@/pages/llmodels/apis';
import { useIntl } from '@umijs/max';
import { Divider, Form, Radio } from 'antd';
import { useEffect, useState } from 'react';
import styled from 'styled-components';
@@ -18,6 +20,8 @@ const AllowModelsForm: React.FC<{
currentData?: Partial<ListItem> | null;
action: PageActionType;
}> = ({ currentData, action }) => {
const intl = useIntl();
const { getRuleMessage } = useAppUtils();
const form = Form.useFormInstance();
const allowedModelNames = Form.useWatch(
'allowed_model_names',
@@ -57,7 +61,7 @@ const AllowModelsForm: React.FC<{
return (
<div>
<Divider></Divider>
<Label>Model Access</Label>
<Label>{intl.formatMessage({ id: 'apikeys.table.bindModels' })}</Label>
<Form.Item
name="allowed_type"
initialValue="all"
@@ -65,17 +69,38 @@ const AllowModelsForm: React.FC<{
>
<Radio.Group
options={[
{ label: 'All models', value: 'all' },
{ label: 'Selected models', value: 'custom' }
{
label: intl.formatMessage({ id: 'apikeys.models.all' }),
value: 'all'
},
{
label: intl.formatMessage({ id: 'apikeys.models.selected' }),
value: 'custom'
}
]}
></Radio.Group>
</Form.Item>
<Form.Item name="allowed_model_names" hidden={allowedType === 'all'}>
<Form.Item
name="allowed_model_names"
hidden={allowedType === 'all'}
rules={[
{
required: allowedType === 'custom',
message: getRuleMessage(
'select',
intl.formatMessage({ id: 'models.table.models' })
)
}
]}
>
<SelectPanel
height={300}
searchPlaceholder="Search by model name"
searchPlaceholder={intl.formatMessage({ id: 'common.filter.name' })}
options={modelList}
selectedKeys={allowedModelNames || []}
notFoundContent={intl.formatMessage({
id: 'apikeys.models.noModelsFound'
})}
onSelectChange={(selectedKeys) => {
form.setFieldsValue({ allowed_model_names: selectedKeys });
}}
@@ -68,7 +68,11 @@ const useModelsColumns = ({
showTitle: false
},
render: (text: string[], record: ListItem) => (
<AutoTooltip ghost>{text?.join(', ')}</AutoTooltip>
<AutoTooltip ghost>
{text?.length
? text?.join(', ')
: intl.formatMessage({ id: 'common.select.option' })}
</AutoTooltip>
)
},
{
@@ -1,5 +1,6 @@
import TransferInner from '@/pages/_components/transfer';
import { queryUsersList } from '@/pages/users/apis';
import { useIntl } from '@umijs/max';
import { Empty, Form, Radio } from 'antd';
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import styled from 'styled-components';
@@ -22,6 +23,7 @@ interface AccessControlFormProps {
const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
const { currentData, onFinish } = props;
const intl = useIntl();
const [form] = Form.useForm();
const setPublic = Form.useWatch('set_public', form);
const [targetKeys, setTargetKeys] = useState<TransferKey[]>([]);
@@ -42,7 +44,6 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
key: item.id,
is_admin: item.is_admin
}));
console.log('options', options);
setTotalPages(res.pagination.totalPage);
setUserList(options);
} catch (error) {
@@ -56,7 +57,6 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
removeKeys: TransferKey[]
) => {
setTargetKeys(nextTargetKeys);
console.log('nextTargetKeys', nextTargetKeys);
const users = nextTargetKeys.map((key) => ({ id: key }));
form.setFieldsValue({ users });
};
@@ -108,41 +108,62 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
set_public: true
}}
>
<Label>Access Scope</Label>
<Label>{intl.formatMessage({ id: 'models.table.accessScope' })}</Label>
<Form.Item<AccessControlFormData> name="set_public" noStyle>
<Radio.Group
style={{ marginBottom: 12 }}
options={[
{ label: 'All users', value: true },
{ label: 'Selected users', value: false }
{
label: intl.formatMessage({ id: 'models.table.accessScope.all' }),
value: true
},
{
label: intl.formatMessage({
id: 'models.table.accessScope.selected'
}),
value: false
}
]}
></Radio.Group>
</Form.Item>
{!setPublic && (
<>
<Label>User Selection</Label>
<Label>
{intl.formatMessage({ id: 'models.table.userSelection' })}
</Label>
<Form.Item<AccessControlFormData> name="users">
<TransferInner
dataSource={userList}
targetKeys={targetKeys}
pagination={false}
titles={['All Users', 'Selected Users']}
titles={[
intl.formatMessage({ id: 'models.table.users.all' }),
intl.formatMessage({
id: 'models.table.users.selected'
})
]}
locale={{
notFoundContent: [
<Empty
key="all"
description="No users found"
description={intl.formatMessage({
id: 'models.table.nouserFound'
})}
image={Empty.PRESENTED_IMAGE_SIMPLE}
/>,
<Empty
key="selected"
description="No users selected"
description={intl.formatMessage({
id: 'models.table.noselected'
})}
image={Empty.PRESENTED_IMAGE_SIMPLE}
/>
]
}}
showSearch={{
placeholder: 'Filter by username'
placeholder: intl.formatMessage({
id: 'common.filter.name'
})
}}
filterOption={(inputValue, item) =>
item.title.toLowerCase().includes(inputValue.toLowerCase())
@@ -151,7 +172,9 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
<span className="flex-center gap-8">
<span>{item.title}</span>
<span className="text-tertiary">
{item.is_admin ? '(Admin)' : ''}
{item.is_admin
? `(${intl.formatMessage({ id: 'models.table.admin' })})`
: ''}
</span>
</span>
)}
+1 -1
View File
@@ -467,7 +467,7 @@ const Models: React.FC<ModelsProps> = ({
if (val === 'accessControl') {
setOpenAccessControlModal({
title: 'Access Settings',
title: intl.formatMessage({ id: 'models.button.accessSettings' }),
action: PageAction.EDIT,
currentData: row,
open: true
+1 -1
View File
@@ -62,7 +62,7 @@ export const ActionList: ActionItem[] = [
icon: icons.ApiOutlined
},
{
label: 'Access Settings',
label: 'models.button.accessSettings',
key: 'accessControl',
icon: icons.Private
},