added cookie to config + fixed config set endpoint

This commit is contained in:
dswbx
2024-11-25 16:57:12 +01:00
parent 824ff40133
commit 16a6a3315d
14 changed files with 114 additions and 47 deletions

View File

@@ -30,8 +30,12 @@ export function BkndProvider({
const errorShown = useRef<boolean>();
const client = useClient();
async function fetchSchema(_includeSecrets: boolean = false) {
if (withSecrets) return;
async function reloadSchema() {
await fetchSchema(includeSecrets, true);
}
async function fetchSchema(_includeSecrets: boolean = false, force?: boolean) {
if (withSecrets && !force) return;
const { body, res } = await client.api.system.readSchema({
config: true,
secrets: _includeSecrets
@@ -80,7 +84,7 @@ export function BkndProvider({
if (!fetched || !schema) return null;
const app = new AppReduced(schema?.config as any);
const actions = getSchemaActions({ client, setSchema });
const actions = getSchemaActions({ client, setSchema, reloadSchema });
return (
<BkndContext.Provider value={{ ...schema, actions, requireSecrets, app }}>

View File

@@ -6,11 +6,12 @@ import type { AppQueryClient } from "../utils/AppQueryClient";
export type SchemaActionsProps = {
client: AppQueryClient;
setSchema: React.Dispatch<React.SetStateAction<any>>;
reloadSchema: () => Promise<void>;
};
export type TSchemaActions = ReturnType<typeof getSchemaActions>;
export function getSchemaActions({ client, setSchema }: SchemaActionsProps) {
export function getSchemaActions({ client, setSchema, reloadSchema }: SchemaActionsProps) {
const api = client.api;
async function handleConfigUpdate(
@@ -61,6 +62,7 @@ export function getSchemaActions({ client, setSchema }: SchemaActionsProps) {
}
return {
reload: reloadSchema,
set: async <Module extends keyof ModuleConfigs>(
module: keyof ModuleConfigs,
value: ModuleConfigs[Module],