diff --git a/src/assets/styles/common.less b/src/assets/styles/common.less index 7f5fc96d..42431697 100644 --- a/src/assets/styles/common.less +++ b/src/assets/styles/common.less @@ -368,3 +368,15 @@ textarea:hover { .line-6 { line-height: 24px; } + +.align-right { + text-align: right; +} + +.align-left { + text-align: left; +} + +.align-center { + text-align: center; +} diff --git a/src/components/editor-wrap/index.tsx b/src/components/editor-wrap/index.tsx index 38926123..06f57d6c 100644 --- a/src/components/editor-wrap/index.tsx +++ b/src/components/editor-wrap/index.tsx @@ -4,7 +4,6 @@ import styled from 'styled-components'; import './index.less'; const HeaderWrapper = styled.div<{ $height?: number }>` - height: ${(props) => (props.$height ? `${props.$height}px` : 'auto')}; display: flex; padding-block: 0; justify-content: space-between; @@ -12,7 +11,7 @@ const HeaderWrapper = styled.div<{ $height?: number }>` `; const Wrapper = styled.div` - border-radius: var(--border-radius-mini); + border-radius: var(--border-radius); overflow: hidden; &.bordered { @@ -57,7 +56,15 @@ const EditorWrap: React.FC = ({ borderless: variant === 'borderless' })} > - {header && {header}} + {header && ( + + {header} + + )}
{children}
); diff --git a/src/locales/en-US/apikeys.ts b/src/locales/en-US/apikeys.ts index d1b10602..c70c703c 100644 --- a/src/locales/en-US/apikeys.ts +++ b/src/locales/en-US/apikeys.ts @@ -17,5 +17,9 @@ export default { 'apikeys.table.bindModels': 'Model Access', 'apikeys.models.all': 'All models', 'apikeys.models.selected': 'Allowed models', - 'apikeys.models.noModelsFound': 'No models found' + 'apikeys.models.noModelsFound': 'No models found', + 'apikeys.accessScope.all': 'All', + 'apikeys.accessScope.management': 'Management APIs', + 'apikeys.accessScope.inference': 'Inference APIs', + 'apikeys.access.permissions': 'Access Permissions' }; diff --git a/src/locales/ja-JP/apikeys.ts b/src/locales/ja-JP/apikeys.ts index 87f5ad8a..76aa923b 100644 --- a/src/locales/ja-JP/apikeys.ts +++ b/src/locales/ja-JP/apikeys.ts @@ -17,12 +17,17 @@ export default { 'apikeys.table.bindModels': 'Model Access', 'apikeys.models.all': 'All models', 'apikeys.models.selected': 'Allowed models', - 'apikeys.models.noModelsFound': 'No models found' + 'apikeys.models.noModelsFound': 'No models found', + 'apikeys.accessScope.all': 'All', + 'apikeys.accessScope.management': 'Management APIs', + 'apikeys.accessScope.inference': 'Inference APIs', + 'apikeys.access.permissions': 'Access Permissions' }; // ========== To-Do: Translate Keys (Remove After Translation) ========== // 1. 'apikeys.table.bindModels': 'Model Access', // 2. 'apikeys.models.all': 'All models', // 3. 'apikeys.models.selected': 'Allowed models', -// 4. 'apikeys.models.noModelsFound': 'No models found' +// 4. 'apikeys.models.noModelsFound': 'No models found', +// 5. 'apikeys.access.permissions': 'Access Permissions' // ========== End of To-Do List ========== diff --git a/src/locales/ru-RU/apikeys.ts b/src/locales/ru-RU/apikeys.ts index c8590369..dcfb78c5 100644 --- a/src/locales/ru-RU/apikeys.ts +++ b/src/locales/ru-RU/apikeys.ts @@ -17,7 +17,11 @@ export default { 'apikeys.table.bindModels': 'Доступ к моделям', 'apikeys.models.all': 'Все модели', 'apikeys.models.selected': 'Разрешенные модели', - 'apikeys.models.noModelsFound': 'Модели не найдены' + 'apikeys.models.noModelsFound': 'Модели не найдены', + 'apikeys.accessScope.all': 'All', + 'apikeys.accessScope.management': 'Management APIs', + 'apikeys.accessScope.inference': 'Inference APIs', + 'apikeys.access.permissions': 'Access Permissions' }; // ========== To-Do: Translate Keys (Remove After Translation) ========== diff --git a/src/locales/tr-TR/apikeys.ts b/src/locales/tr-TR/apikeys.ts index abb8514f..fcdad199 100644 --- a/src/locales/tr-TR/apikeys.ts +++ b/src/locales/tr-TR/apikeys.ts @@ -17,5 +17,9 @@ export default { 'apikeys.table.bindModels': 'Model Erişimi', 'apikeys.models.all': 'Tüm modeller', 'apikeys.models.selected': 'İzin verilen modeller', - 'apikeys.models.noModelsFound': 'Model bulunamadı' + 'apikeys.models.noModelsFound': 'Model bulunamadı', + 'apikeys.accessScope.all': 'All', + 'apikeys.accessScope.management': 'Management APIs', + 'apikeys.accessScope.inference': 'Inference APIs', + 'apikeys.access.permissions': 'Access Permissions' }; diff --git a/src/locales/zh-CN/apikeys.ts b/src/locales/zh-CN/apikeys.ts index 713eb94d..20ed9fee 100644 --- a/src/locales/zh-CN/apikeys.ts +++ b/src/locales/zh-CN/apikeys.ts @@ -16,5 +16,9 @@ export default { 'apikeys.table.bindModels': '模型访问', 'apikeys.models.all': '所有模型', 'apikeys.models.selected': '指定模型', - 'apikeys.models.noModelsFound': '未找到模型' + 'apikeys.models.noModelsFound': '未找到模型', + 'apikeys.accessScope.all': '全部', + 'apikeys.accessScope.management': '管理接口', + 'apikeys.accessScope.inference': '推理接口', + 'apikeys.access.permissions': '访问权限' }; diff --git a/src/pages/_components/yaml-editor/index.tsx b/src/pages/_components/yaml-editor/index.tsx index 78671057..2aabd2a9 100644 --- a/src/pages/_components/yaml-editor/index.tsx +++ b/src/pages/_components/yaml-editor/index.tsx @@ -22,6 +22,7 @@ const Container = styled.div` position: relative; border: 1px solid var(--ant-color-border); border-radius: var(--ant-border-radius); + overflow: hidden; .monaco-editor .scroll-decoration { box-shadow: none; } diff --git a/src/pages/api-keys/components/add-apikey-modal/form.tsx b/src/pages/api-keys/components/add-apikey-modal/form.tsx index 69785114..35702f0d 100644 --- a/src/pages/api-keys/components/add-apikey-modal/form.tsx +++ b/src/pages/api-keys/components/add-apikey-modal/form.tsx @@ -1,3 +1,4 @@ +import Password from '@/components/seal-form/password'; import SealInput from '@/components/seal-form/seal-input'; import SealSelect from '@/components/seal-form/seal-select'; import { PageAction } from '@/config'; @@ -5,7 +6,7 @@ import { PageActionType } from '@/config/types'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; import React from 'react'; -import { expirationOptions } from '../../config'; +import { accessScopeOptions, expirationOptions } from '../../config'; import { FormData, ListItem } from '../../config/types'; import AllowModelsForm from './allow-models'; @@ -16,6 +17,17 @@ const APIKeyForm: React.FC<{ }> = ({ action, currentData, onValuesChange }) => { const intl = useIntl(); + const optionRender = (option: any) => { + return ( + + {option.label} + {option.data.description && ( + [{option.data.description}] + )} + + ); + }; + return ( <> @@ -39,6 +51,28 @@ const APIKeyForm: React.FC<{ required > + {action === PageAction.CREATE && ( + name="custom"> + + + )} + + name="scope" + normalize={(value) => (value ? [value] : [])} + getValueProps={(value) => ({ + value: Array.isArray(value) ? value[0] : value + })} + > + + name="expires_in" rules={[ diff --git a/src/pages/api-keys/components/add-apikey-modal/index.tsx b/src/pages/api-keys/components/add-apikey-modal/index.tsx index 6419b25a..9e0e2883 100644 --- a/src/pages/api-keys/components/add-apikey-modal/index.tsx +++ b/src/pages/api-keys/components/add-apikey-modal/index.tsx @@ -96,6 +96,12 @@ const AddModal: React.FC = ({ expires_in: getExpireValue(data.expires_in) }; const res = await createApisKey({ data: params }); + + // if custom value + if (data.custom) { + return onOk(); + } + setAPIKeyValue(res.value); setShowKey(true); }; @@ -107,6 +113,7 @@ const AddModal: React.FC = ({ const handleOnOk = async (formdata: FormData) => { try { + console.log('formdata=========', formdata); setLoading(true); const data = { ..._.omit(formdata, ['allowed_type']), @@ -261,6 +268,9 @@ const AddModal: React.FC = ({ form={form} onFinish={handleOnOk} preserve={false} + initialValues={{ + scope: ['*'] + }} > {!showKey && ( => { const intl = useIntl(); + const renderAPIs = (record: ListItem) => { + const option = accessScopeOptions.find( + (item) => item.value === record.scope?.[0] + ); + return ( + + {intl.formatMessage({ + id: option?.label || '' + })} + [{option?.description}] + + ); + }; + return useMemo(() => { return [ { @@ -42,9 +58,23 @@ const useModelsColumns = ({ key: 'name', sorter: tableSorter(1), render: (text: string, record: ListItem) => ( - - {text} - + + + {text} + + + {intl.formatMessage({ id: 'playground.params.custom' })} + + ) }, { @@ -73,18 +103,34 @@ const useModelsColumns = ({ ) }, { - title: intl.formatMessage({ id: 'apikeys.table.bindModels' }), + title: intl.formatMessage({ id: 'apikeys.access.permissions' }), dataIndex: 'allowed_model_names', key: 'allowed_model_names', ellipsis: { showTitle: false }, render: (text: string[], record: ListItem) => ( - - {text?.length - ? text?.join(', ') - : intl.formatMessage({ id: 'common.select.option' })} - +
+ APIs: + {renderAPIs(record)} + + {intl.formatMessage({ id: 'models.title' })}: + + + + {text?.length + ? text?.join(', ') + : intl.formatMessage({ id: 'common.select.option' })} + + +
) }, {