mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
added bknd admin config override to make it easier to include <Admin />
This commit is contained in:
@@ -234,7 +234,7 @@ export function Setting<Schema extends TObject = any>({
|
||||
<Breadcrumbs path={path} />
|
||||
</AppShell.SectionHeader>
|
||||
<AppShell.Scrollable key={path.join("-")}>
|
||||
{typeof showAlert === "string" && <Alert.Warning message={showAlert} />}
|
||||
{typeof showAlert !== "undefined" && <Alert.Warning message={showAlert} />}
|
||||
|
||||
<div className="flex flex-col flex-grow p-3 gap-3">
|
||||
<JsonSchemaForm
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Setting } from "./components/Setting";
|
||||
import { AuthSettings } from "./routes/auth.settings";
|
||||
import { DataSettings } from "./routes/data.settings";
|
||||
import { FlowsSettings } from "./routes/flows.settings";
|
||||
import { ServerSettings } from "./routes/server.settings";
|
||||
|
||||
function SettingsSidebar() {
|
||||
const { version, schema } = useBknd();
|
||||
@@ -39,36 +40,6 @@ function SettingsSidebar() {
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
{/*<button
|
||||
onClick={() =>
|
||||
modals.openContextModal({
|
||||
modal: "test",
|
||||
title: "Test Modal",
|
||||
innerProps: { modalBody: "This is a test modal" }
|
||||
})
|
||||
}
|
||||
>
|
||||
modal
|
||||
</button>
|
||||
<button
|
||||
onClick={() =>
|
||||
bkndModals.open(bkndModals.ids.test, { modalBody: "test" }, { title: "what" })
|
||||
}
|
||||
>
|
||||
modal2
|
||||
</button>
|
||||
<button onClick={() => bkndModals.open("test", { modalBody: "test" })}>modal</button>
|
||||
<button
|
||||
onClick={() =>
|
||||
bkndModals.open("debug", {
|
||||
data: {
|
||||
one: { what: 1 }
|
||||
}
|
||||
})
|
||||
}
|
||||
>
|
||||
debug
|
||||
</button>*/}
|
||||
</AppShell.Scrollable>
|
||||
</AppShell.Sidebar>
|
||||
);
|
||||
@@ -145,12 +116,7 @@ const SettingRoutesRoutes = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<FallbackRoutes
|
||||
module="server"
|
||||
schema={schema}
|
||||
config={config}
|
||||
uiSchema={uiSchema.server}
|
||||
/>
|
||||
<ServerSettings schema={schema.server} config={config.server} />
|
||||
<DataSettings schema={schema.data} config={config.data} />
|
||||
<AuthSettings schema={schema.auth} config={config.auth} />
|
||||
<FallbackRoutes module="media" schema={schema} config={config} uiSchema={uiSchema.media} />
|
||||
|
||||
55
app/src/ui/routes/settings/routes/server.settings.tsx
Normal file
55
app/src/ui/routes/settings/routes/server.settings.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import { cloneDeep } from "lodash-es";
|
||||
import { useBknd } from "ui";
|
||||
import { Setting } from "ui/routes/settings/components/Setting";
|
||||
import { Route } from "wouter";
|
||||
|
||||
const uiSchema = {
|
||||
cors: {
|
||||
allow_methods: {
|
||||
"ui:widget": "checkboxes"
|
||||
},
|
||||
allow_headers: {
|
||||
"ui:options": {
|
||||
orderable: false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const ServerSettings = ({ schema: _unsafe_copy, config }) => {
|
||||
const { app, adminOverride } = useBknd();
|
||||
const { basepath } = app.getAdminConfig();
|
||||
const _schema = cloneDeep(_unsafe_copy);
|
||||
const prefix = `~/${basepath}/settings`.replace(/\/+/g, "/");
|
||||
|
||||
const schema = _schema;
|
||||
if (adminOverride) {
|
||||
schema.properties.admin.readOnly = true;
|
||||
}
|
||||
|
||||
return (
|
||||
<Route path="/server" nest>
|
||||
<Route
|
||||
path="/"
|
||||
component={() => (
|
||||
<Setting
|
||||
options={{
|
||||
showAlert: () => {
|
||||
if (adminOverride) {
|
||||
return "The admin settings are read-only as they are overriden. Remaining server configuration can be edited.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
}}
|
||||
schema={schema}
|
||||
uiSchema={uiSchema}
|
||||
config={config}
|
||||
prefix={`${prefix}/server`}
|
||||
path={["server"]}
|
||||
/>
|
||||
)}
|
||||
nest
|
||||
/>
|
||||
</Route>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user