From 315d31540d1e5eaf42bb35906a485057fe84451b Mon Sep 17 00:00:00 2001 From: SungChul Hong Date: Thu, 23 Jan 2025 17:53:37 +0900 Subject: [PATCH] fix: show vfolder list based on delegated user --- react/src/components/VFolderTable.tsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/react/src/components/VFolderTable.tsx b/react/src/components/VFolderTable.tsx index 8c7f64bf19..dbb1e14eb6 100644 --- a/react/src/components/VFolderTable.tsx +++ b/react/src/components/VFolderTable.tsx @@ -145,16 +145,34 @@ const VFolderTable: React.FC = ({ } }, [aliasMap, internalForm, aliasBasePath]); + const formInstance = Form.useFormInstance(); + const ownerInfo = formInstance.getFieldValue(['owner']); + // valid when owner is enabled and all fields are not undefined + const isValidOwner = + ownerInfo?.enabled && + (!_.isEmpty(ownerInfo) + ? _.every(_.omit(ownerInfo, 'enabled'), (key, value) => { + return key !== undefined; + }) + : false); + const ownerEmail = isValidOwner ? ownerInfo.email : undefined; + + useEffect(() => { + formInstance.setFieldsValue({ mounts: undefined, vfolderAliasMap: {} }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isValidOwner]); + const { t } = useTranslation(); const baiRequestWithPromise = useBaiSignedRequestWithPromise(); const currentProject = useCurrentProjectValue(); const [fetchKey, updateFetchKey] = useUpdatableState('first'); const [isPendingRefetch, startRefetchTransition] = useTransition(); const { data: allFolderList } = useSuspenseTanQuery({ - queryKey: ['VFolderSelectQuery', fetchKey, currentProject.id], + queryKey: ['VFolderSelectQuery', fetchKey, currentProject.id, ownerEmail], queryFn: () => { const search = new URLSearchParams(); search.set('group_id', currentProject.id); + ownerEmail && search.set('owner_user_email', ownerEmail); return baiRequestWithPromise({ method: 'GET', url: `/folders?${search.toString()}`,