mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 10:25:58 +00:00
management labelpolicy
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import {
|
||||
management,
|
||||
ZitadelServer,
|
||||
ZitadelServerOptions,
|
||||
getManagement,
|
||||
getServer,
|
||||
getServers,
|
||||
initializeServer,
|
||||
LabelPolicy,
|
||||
} from "@zitadel/server";
|
||||
// import { getAuth } from "@zitadel/server/auth";
|
||||
|
||||
@@ -16,7 +20,17 @@ if (!getServers().length) {
|
||||
}
|
||||
|
||||
const server = getServer();
|
||||
console.log(server);
|
||||
|
||||
export function getBranding(
|
||||
server: ZitadelServer
|
||||
): Promise<LabelPolicy | undefined> {
|
||||
const mgmt = getManagement(server);
|
||||
|
||||
return mgmt.getLabelPolicy({}).then((resp) => resp.policy);
|
||||
}
|
||||
|
||||
export { server };
|
||||
// export async function getMyUser(): Promise<GetMyUserResponse> {
|
||||
// const auth = await getAuth();
|
||||
// const response = await auth.getMyUser({});
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import { getBranding } from "#/lib/zitadel";
|
||||
import { useTheme } from "next-themes";
|
||||
import { server } from "../lib/zitadel";
|
||||
|
||||
const ThemeWrapper = ({ children }: any) => {
|
||||
const ThemeWrapper = async ({ children }: any) => {
|
||||
const { resolvedTheme } = useTheme();
|
||||
|
||||
const isDark = resolvedTheme && resolvedTheme === "dark";
|
||||
|
||||
try {
|
||||
const policy = await getBranding(server);
|
||||
|
||||
const backgroundStyle = {
|
||||
backgroundColor: `${policy?.backgroundColorDark}.`,
|
||||
};
|
||||
|
||||
console.log(policy);
|
||||
|
||||
return (
|
||||
<div className={`${isDark ? "ui-dark" : "ui-light"} `}>
|
||||
<div style={backgroundStyle}>{children}</div>
|
||||
</div>
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
return (
|
||||
<div className={`${isDark ? "ui-dark" : "ui-light"} `}>{children}</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default ThemeWrapper;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from "./server";
|
||||
export * from "./middleware";
|
||||
export * from "./management";
|
||||
|
||||
// export * as auth from "./auth";
|
||||
// export * as management from "./management";
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export * from "./management";
|
||||
export * as management from "../proto/server/zitadel/management";
|
||||
export * from "../proto/server/zitadel/policy";
|
||||
|
||||
@@ -26,10 +26,19 @@ export function getServers(): ZitadelServer[] {
|
||||
return apps;
|
||||
}
|
||||
|
||||
export function getServer(name?: string): ZitadelServer | undefined {
|
||||
return name
|
||||
? apps.find((a) => a.name === name)
|
||||
: apps.length === 1
|
||||
? apps[0]
|
||||
: undefined;
|
||||
export function getServer(name?: string): ZitadelServer {
|
||||
if (name) {
|
||||
const found = apps.find((a) => a.name === name);
|
||||
if (found) {
|
||||
return found;
|
||||
} else {
|
||||
throw new Error("No server found");
|
||||
}
|
||||
} else {
|
||||
if (apps.length) {
|
||||
return apps[0];
|
||||
} else {
|
||||
throw new Error("No server found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user