mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:45:18 +00:00
refactor: code improve
This commit is contained in:
parent
1f62857a9a
commit
515e730048
@ -7,18 +7,26 @@ import { InternalSubTable } from './InternalSubTable';
|
||||
import { FileManageReadPretty } from './FileManager';
|
||||
import { useAssociationFieldContext } from './hooks';
|
||||
|
||||
export const ReadPretty = observer((props: any) => {
|
||||
const ReadPrettyAssociationField = observer((props: any) => {
|
||||
const { isFileCollection } = useAssociationFieldContext();
|
||||
const [currentMode, setCurrentMode] = useState(props.mode || (isFileCollection ? 'FileManager' : 'Select'));
|
||||
useEffect(() => {
|
||||
props.mode && setCurrentMode(props.mode);
|
||||
}, [props.mode]);
|
||||
return (
|
||||
<AssociationFieldProvider>
|
||||
<>
|
||||
{['Select', 'Picker'].includes(currentMode) && <ReadPrettyInternalViewer {...props} />}
|
||||
{currentMode === 'Nester' && <InternalNester {...props} />}
|
||||
{currentMode === 'SubTable' && <InternalSubTable {...props} />}
|
||||
{currentMode === 'FileManager' && <FileManageReadPretty {...props} />}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
export const ReadPretty = observer((props) => {
|
||||
return (
|
||||
<AssociationFieldProvider>
|
||||
<ReadPrettyAssociationField {...props} />
|
||||
</AssociationFieldProvider>
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user