MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / FieldSetView

Function FieldSetView

web/pgadmin/static/js/SchemaView/FieldSetView.jsx:25–69  ·  view source on GitHub ↗
({
  field, accessPath, dataDispatch, viewHelperProps, controlClassName,
})

Source from the content-addressed store, hash-verified

23
24
25export default function FieldSetView({
26 field, accessPath, dataDispatch, viewHelperProps, controlClassName,
27}) {
28 const [, setKey] = useState(0);
29 const subscriberManager = useSchemaStateSubscriber(setKey);
30 const schema = field.schema;
31 const schemaState = useContext(SchemaStateContext);
32 const value = useFieldValue(accessPath, schemaState);
33 const options = useFieldSchema(
34 field, accessPath, value, viewHelperProps, schemaState, subscriberManager
35 );
36
37 const label = field.label;
38
39 listenDepChanges(
40 accessPath, field, schemaState, () => subscriberManager.current?.signal()
41 );
42
43 const fieldGroups = useMemo(
44 () => createFieldControls({
45 schema, schemaState, accessPath, viewHelperProps, dataDispatch
46 }),
47 [schema, schemaState, accessPath, viewHelperProps, dataDispatch]
48 );
49
50 // We won't show empty feldset too.
51 if(!options.visible || !fieldGroups.length) {
52 return <></>;
53 }
54
55 return (
56 <FieldSet title={label} className={controlClassName}>
57 {fieldGroups.map(
58 (fieldGroup, gidx) => (
59 <React.Fragment key={`${fieldGroup.id}-${gidx}`}>
60 {fieldGroup.controls.map(
61 (item, idx) => <FieldControl
62 item={item} key={`${item.controlProps.id}-${idx}`} schemaId={schema._id} />
63 )}
64 </React.Fragment>
65 )
66 )}
67 </FieldSet>
68 );
69}
70
71FieldSetView.propTypes = {
72 viewHelperProps: PropTypes.object,

Callers

nothing calls this directly

Calls 6

useSchemaStateSubscriberFunction · 0.90
useFieldValueFunction · 0.90
useFieldSchemaFunction · 0.90
listenDepChangesFunction · 0.90
createFieldControlsFunction · 0.90
signalMethod · 0.80

Tested by

no test coverage detected