From c68f546be991064b1f21f1e3feb7a2ff60b1499b Mon Sep 17 00:00:00 2001 From: jialin Date: Wed, 29 Apr 2026 11:13:06 +0800 Subject: [PATCH] fix: apikey filters --- .../components/add-apikey-modal/index.tsx | 15 ++++++++++----- src/pages/api-keys/hooks/use-keys-columns.tsx | 6 ++++-- src/pages/api-keys/index.tsx | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) 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 e91b8fe4..14ab4b8e 100644 --- a/src/pages/api-keys/components/add-apikey-modal/index.tsx +++ b/src/pages/api-keys/components/add-apikey-modal/index.tsx @@ -182,15 +182,20 @@ const AddModal: React.FC = ({ } if (action === PageAction.EDIT && currentData && open) { parseExpireValue(currentData as ListItem); + const isLegacyAllScope = currentData.scope?.includes('*'); + const normalizedScope = isLegacyAllScope + ? ['management', 'inference'] + : currentData.scope; + const normalizedAllowedModelNames = isLegacyAllScope + ? [] + : currentData.allowed_model_names || []; form.setFieldsValue({ name: currentData.name, description: currentData.description, - scope: currentData.scope, - allowed_type: currentData.allowed_model_names?.length - ? 'custom' - : 'all', + scope: normalizedScope, + allowed_type: normalizedAllowedModelNames.length ? 'custom' : 'all', expires_in: parseExpireValue(currentData as ListItem), - allowed_model_names: currentData.allowed_model_names || [] + allowed_model_names: normalizedAllowedModelNames }); } diff --git a/src/pages/api-keys/hooks/use-keys-columns.tsx b/src/pages/api-keys/hooks/use-keys-columns.tsx index f73b6f72..0a441465 100644 --- a/src/pages/api-keys/hooks/use-keys-columns.tsx +++ b/src/pages/api-keys/hooks/use-keys-columns.tsx @@ -108,12 +108,14 @@ const useModelsColumns = ({ }, render: (text: string[], record: ListItem) => (
- {record.scope?.includes('management') && ( + {(record.scope?.includes('management') || + record.scope?.includes('*')) && ( {intl.formatMessage({ id: 'apikeys.accessScope.management' })} )} - {record.scope?.includes('inference') && ( + {(record.scope?.includes('inference') || + record.scope?.includes('*')) && (
{ marginTop={30} showSelect={currentUser?.is_admin} selectOptions={userList} - select={{ showSearch: true }} + select={{ showSearch: { optionFilterProp: 'label' } }} selectHolder={intl.formatMessage({ id: 'models.table.filterByName' })} buttonText={intl.formatMessage({ id: 'apikeys.button.create' })} handleSearch={handleSearch}