Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -490,40 +490,56 @@ export function ObjectEditorSelector({ currentUid, setCurrentUid, style }: any)

const [currentInputUid, setCurrentInputUid] = React.useState(currentUid || '');

useEffectOnce(() => {
React.useEffect(() => {
window.unigraph.getReferenceables().then((refs: any) => setReferenceables(refs));
});
}, []);
React.useEffect(() => {
console.log('Object Editor', { currentInputUid, currentSchema, currentSchemaSHName });
}, [currentInputUid]);

return (
<Box sx={{ display: 'inline-flex', flexDirection: 'row', alignItems: 'center' }}>
<TextField
onChange={(e) => {
setCurrentInputUid(e.target.value);
}}
value={currentInputUid}
/>
<Button onClick={() => setCurrentUid(currentInputUid)}>Load object</Button>
Schema name:{' '}
<ReferenceableSelectorControlled
referenceables={referenceables}
onChange={(schema: string) =>
window.unigraph.getSchemas().then((schemas: Record<string, SchemaDgraph>) => {
setCurrentSchema(schemas[schema]);
setCurrentSchemaSHName(schema);
})
}
value={currentSchema?._definition?.type['unigraph.id']}
sx={{ width: '300px' }}
/>
<Button
onClick={async () => {
const returnUid = await window.unigraph.addObject({}, currentSchemaSHName);
setCurrentUid(returnUid);
}}
>
Create with schema
</Button>
</Box>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
{/* <div style={{ display: 'flex', flexDirection: 'column' }}>
Create a new object
<Box sx={{ display: 'inline-flex', flexDirection: 'row', alignItems: 'center' }}>
<ReferenceableSelectorControlled
referenceables={referenceables}
onChange={(schema: string) =>
window.unigraph.getSchemas().then((schemas: Record<string, SchemaDgraph>) => {
setCurrentSchema(schemas[schema]);
setCurrentSchemaSHName(schema);
})
}
value={currentSchema?._definition?.type['unigraph.id']}
sx={{ width: '300px' }}
/>
<Button
onClick={async () => {
const returnUid = await window.unigraph.addObject({}, currentSchemaSHName);
console.log('Obj Editor: Added new obj', { returnUid });

setCurrentUid(returnUid);
}}
>
Create
</Button>
</Box>
</div>
or */}
<div style={{ display: 'flex', flexDirection: 'column' }}>
Load an existing object
<Box sx={{ display: 'inline-flex', flexDirection: 'row', alignItems: 'center' }}>
<TextField
onChange={(e) => {
setCurrentInputUid(e.target.value);
}}
value={currentInputUid}
label="Object UID"
/>
<Button onClick={() => setCurrentUid(currentInputUid)}>Load</Button>
</Box>
</div>
</div>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function ReferenceableSelectorControlled({ referenceables, value, onChang
renderInput={(params) => (
<TextField
{...params}
label="Type"
label="Object Schema"
variant="filled"
value={value || ''}
sx={{
Expand Down