fix: display admin and inactive when view

This commit is contained in:
jialin
2025-11-12 16:11:17 +08:00
parent 653ada5f0f
commit 2045bfaf78
7 changed files with 63 additions and 24 deletions
+10
View File
@@ -241,6 +241,15 @@ export default function useOverlayScroller(data?: {
};
};
const getScrollElement = () => {
if (!instanceRef.current || !scrollEventElement.current) {
instanceRef.current = instance?.();
scrollEventElement.current =
instanceRef.current?.elements()?.scrollEventElement;
}
return scrollEventElement;
};
useEffect(() => {
return () => {
instanceRef.current?.destroy?.();
@@ -254,6 +263,7 @@ export default function useOverlayScroller(data?: {
scrollEventElement: scrollEventElement,
initialized: initialized.current,
getScrollElementScrollableHeight,
getScrollElement,
generateInstance,
destroyInstance: destroyInstance,
updateScrollerPosition: throttledUpdateScrollerPosition,
@@ -28,6 +28,7 @@ const ColumnWrapper: React.FC<ColumnWrapperProps> = ({
scrollEventElement,
scrollToBottom,
scrollToTarget,
getScrollElement,
getScrollElementScrollableHeight
} = useOverlayScroller({
options: {
@@ -49,6 +50,7 @@ const ColumnWrapper: React.FC<ColumnWrapperProps> = ({
scroller: scroller,
osInstance: instance,
scrollEventElement,
getScrollElement,
getScrollElementScrollableHeight,
scrollToBottom,
scrollToTarget
@@ -11,6 +11,7 @@ interface WrapperContextProps {
scrollTop: number;
};
scrollToTarget?: (target: any, offset?: number) => void;
getScrollElement?: () => HTMLElement | null;
}
export const WrapperContext = createContext<WrapperContextProps>(
@@ -75,8 +75,10 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
}));
setTotalPages(res.pagination.totalPage);
setUserList(options);
return options;
} catch (error) {
setUserList([]);
return [];
}
};
@@ -110,14 +112,6 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
}
};
const handleFilterChange = (e: any) => {
if (e.target.checked) {
setFilterInUsers(new Set(['admin', 'inactive']));
} else {
setFilterInUsers(new Set());
}
};
useImperativeHandle(ref, () => ({
submit: () => {
form.submit();
@@ -134,20 +128,43 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
}));
useEffect(() => {
if (currentData?.id) {
queryModelAccessUserList(currentData.id).then((res) => {
const keys = res.items.map((item) => item.id);
setTargetKeys(keys);
form.setFieldsValue({
access_policy: currentData.access_policy,
users: res.items.map((item) => ({ id: item.id }))
const init = async () => {
const allusers = await getUserList(queryParams);
const userMap = new Map(allusers.map((u) => [u.key, u]));
if (currentData?.id) {
queryModelAccessUserList(currentData.id).then((res) => {
const keys = res.items.map((item) => item.id);
setTargetKeys(keys);
let hasAdmin = false;
let hasInactive = false;
for (const key of keys) {
const user = userMap.get(key);
if (!user) continue;
if (user.is_admin) hasAdmin = true;
if (!user.is_active) hasInactive = true;
if (hasAdmin && hasInactive) break;
}
const filterSet = new Set<string>();
if (hasAdmin) filterSet.add('admin');
if (hasInactive) filterSet.add('inactive');
setFilterInUsers(filterSet);
form.setFieldsValue({
access_policy: currentData.access_policy,
users: res.items.map((item) => ({ id: item.id }))
});
});
});
} else {
setTargetKeys([]);
form.setFieldsValue({ users: [] });
}
getUserList(queryParams);
} else {
setTargetKeys([]);
form.setFieldsValue({ users: [] });
}
};
init();
}, [currentData?.id]);
const renderFilterDropdown = () => {
@@ -451,7 +451,6 @@ const AddModal: FC<AddModalProps> = (props) => {
]);
if (props.deploymentType === 'modelFiles') {
clearCacheFormValues();
form.current?.form?.setFieldsValue({
...props.initialValues
});
+9 -1
View File
@@ -101,7 +101,12 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
onValuesChange,
onOk
} = props;
const { getScrollElementScrollableHeight } = useWrapperContext();
const {
getScrollElementScrollableHeight,
getScrollElement,
osInstance,
scrollEventElement
} = useWrapperContext();
const { backendOptions, getBackendOptions } = useQueryBackends();
const { getGPUOptionList, gpuOptions, workerLabelOptions } =
useGenerateGPUOptions();
@@ -111,6 +116,8 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
const scheduleType = Form.useWatch('scheduleType', form);
const [target, setTarget] = React.useState<string>(TABKeysMap.BASIC);
console.log('scroller instance in form:', osInstance, scrollEventElement);
const segmentOptions = [
{
value: TABKeysMap.BASIC,
@@ -162,6 +169,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
setActiveKey,
segmentOptions,
segmentedTop: segmentedTop,
getScrollElement,
getScrollElementScrollableHeight: getScrollElementScrollableHeight
});
+3 -1
View File
@@ -15,7 +15,8 @@ export default function useScrollAfterExpand({
segmentOptions,
defaultWait = 300,
segmentedTop = { top: 0, offsetTop: 96 },
getScrollElementScrollableHeight
getScrollElementScrollableHeight,
getScrollElement
}: {
form: any;
activeKey: string[];
@@ -25,6 +26,7 @@ export default function useScrollAfterExpand({
scrollHeight: number;
scrollTop: number;
};
getScrollElement?: () => HTMLElement | null;
defaultWait?: number;
segmentedTop: {
top: number;