Skip to content

Commit

Permalink
fix: show vfolder list based on delegated user
Browse files Browse the repository at this point in the history
  • Loading branch information
ironAiken2 committed Jan 23, 2025
1 parent 49288d1 commit 315d315
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion react/src/components/VFolderTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,34 @@ const VFolderTable: React.FC<VFolderTableProps> = ({
}
}, [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()}`,
Expand Down

0 comments on commit 315d315

Please sign in to comment.