mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 20:37:21 +00:00
added easier access points to modify schema + added relation flip in dialog
This commit is contained in:
@@ -33,6 +33,7 @@ export function BkndProvider({
|
||||
useState<Pick<BkndContext, "version" | "schema" | "config" | "permissions">>();
|
||||
const [fetched, setFetched] = useState(false);
|
||||
const errorShown = useRef<boolean>();
|
||||
const [local_version, set_local_version] = useState(0);
|
||||
const api = useApi();
|
||||
|
||||
async function reloadSchema() {
|
||||
@@ -80,6 +81,7 @@ export function BkndProvider({
|
||||
setSchema(schema);
|
||||
setWithSecrets(_includeSecrets);
|
||||
setFetched(true);
|
||||
set_local_version((v) => v + 1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,7 +100,10 @@ export function BkndProvider({
|
||||
const actions = getSchemaActions({ api, setSchema, reloadSchema });
|
||||
|
||||
return (
|
||||
<BkndContext.Provider value={{ ...schema, actions, requireSecrets, app, adminOverride }}>
|
||||
<BkndContext.Provider
|
||||
value={{ ...schema, actions, requireSecrets, app, adminOverride }}
|
||||
key={local_version}
|
||||
>
|
||||
{children}
|
||||
</BkndContext.Provider>
|
||||
);
|
||||
|
||||
@@ -83,6 +83,26 @@ const modals = {
|
||||
bkndModals.open(bkndModals.ids.dataCreate, {
|
||||
initialPath: ["entities", "entity"],
|
||||
initialState: { action: "entity" }
|
||||
}),
|
||||
createRelation: (rel: { source?: string; target?: string; type?: string }) =>
|
||||
bkndModals.open(bkndModals.ids.dataCreate, {
|
||||
initialPath: ["entities", "relation"],
|
||||
initialState: {
|
||||
action: "relation",
|
||||
relations: {
|
||||
create: [rel as any]
|
||||
}
|
||||
}
|
||||
}),
|
||||
createMedia: (entity?: string) =>
|
||||
bkndModals.open(bkndModals.ids.dataCreate, {
|
||||
initialPath: ["entities", "template-media"],
|
||||
initialState: {
|
||||
action: "template-media",
|
||||
initial: {
|
||||
entity
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user