diff --git a/src/components/seal-form/simple-select.tsx b/src/components/seal-form/simple-select.tsx index c3b2f0ec..89c38978 100644 --- a/src/components/seal-form/simple-select.tsx +++ b/src/components/seal-form/simple-select.tsx @@ -54,7 +54,13 @@ const SimpleSelect: React.FC< } > = forwardRef((props, ref) => { const intl = useIntl(); - const { options = [], showTags, styles = {}, ...restProps } = props; + const { + options = [], + showTags: tagsVisible, + styles = {}, + maxTagCount: tagCount, + ...restProps + } = props; const [allSelection, setAllSelection] = React.useState<{ checked: boolean; @@ -67,6 +73,10 @@ const SimpleSelect: React.FC< const selectRef = React.useRef(null); const selectorRef = React.useRef(null); + const showTags = Array.isArray(props.value) && props.value.length === 1; + const maxTagCount = + Array.isArray(props.value) && props.value.length === 1 ? 1 : 0; + useEffect(() => { setOptionsList(options || []); }, [options]); @@ -268,8 +278,9 @@ const SimpleSelect: React.FC< ...styles.select }} ref={selectorRef} + maxTagTextLength={restProps.maxTagTextLength ?? 15} options={optionsList} - maxTagCount={restProps.maxTagCount || 0} + maxTagCount={maxTagCount} defaultActiveFirstOption={false} popupRender={dropdownRender} optionRender={optionRender} diff --git a/src/pages/usage/components/breakdown-tabs.tsx b/src/pages/usage/components/breakdown-tabs.tsx index ba147798..914e907e 100644 --- a/src/pages/usage/components/breakdown-tabs.tsx +++ b/src/pages/usage/components/breakdown-tabs.tsx @@ -36,7 +36,13 @@ const BreakdownTabs: React.FC<{ key: 'users', label: 'Users', forceRender: true, - children: + children: ( + + ) }, { key: 'api_keys', diff --git a/src/pages/usage/components/filter-bar.tsx b/src/pages/usage/components/filter-bar.tsx index 7ed55c54..601abfd8 100644 --- a/src/pages/usage/components/filter-bar.tsx +++ b/src/pages/usage/components/filter-bar.tsx @@ -1,4 +1,3 @@ -import BaseSelect from '@/components/seal-form/base/select'; import SimpleSelect from '@/components/seal-form/simple-select'; import useRangePickerPreset from '@/pages/dashboard/hooks/use-rangepicker-preset'; import { useModel } from '@@/plugin-model'; @@ -7,7 +6,6 @@ import { useIntl } from '@umijs/max'; import { Button, DatePicker, Dropdown, MenuProps } from 'antd'; import dayjs from 'dayjs'; import React from 'react'; -import { scopeOptions } from '../config'; import { UsageFilterItem } from '../config/types'; import FilterBarCss from '../styles/filter-bar.less'; @@ -109,14 +107,14 @@ const FilterBar: React.FC = (props) => { return (
- {initialState?.currentUser?.is_admin && ( + {/* {initialState?.currentUser?.is_admin && ( - )} + )} */} = (props) => { value={selectedModels} onChange={onModelsChange} /> - + {initialState?.currentUser?.is_admin && ( + + )} { />
diff --git a/src/pages/usage/tables/users-table.tsx b/src/pages/usage/tables/users-table.tsx index 4c9a15f2..63b40f67 100644 --- a/src/pages/usage/tables/users-table.tsx +++ b/src/pages/usage/tables/users-table.tsx @@ -13,7 +13,8 @@ import useQueryBreakdownList from '../services/use-query-breakdown-list'; const Users: React.FC<{ users: FilterOptionType[]; dateRange: { start_date: string; end_date: string }; -}> = ({ users, dateRange }) => { + scope: string; +}> = ({ users, dateRange, scope }) => { const intl = useIntl(); const { loading, dataSource, fetchData } = useQueryBreakdownList({ @@ -54,16 +55,18 @@ const Users: React.FC<{ }; useEffect(() => { - fetchData({ - ...queryParams, - group_by: 'user', - filters: { - users: users || [] - }, - scope: 'all', - ...dateRange - }); - }, [dateRange, users, queryParams]); + if (scope === 'all') { + fetchData({ + ...queryParams, + group_by: 'user', + filters: { + users: users || [] + }, + scope: scope, + ...dateRange + }); + } + }, [dateRange, users, queryParams, scope]); return ( <>