mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-25 12:05:06 +02:00
Expose self-host daemon setup URLs from /api/config at runtime so the Add computer dialog renders the operator's own server/app domains, while Multica Cloud defaults stay unchanged. Fixes #3013.
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { createStore } from "zustand/vanilla";
|
|
import { useStore } from "zustand";
|
|
|
|
interface ConfigState {
|
|
cdnDomain: string;
|
|
allowSignup: boolean;
|
|
googleClientId: string;
|
|
daemonServerUrl: string;
|
|
daemonAppUrl: string;
|
|
// Self-host gate (#3433): when true, every "Create workspace" affordance
|
|
// must be hidden. Defaults to false so unknown / older servers behave like
|
|
// the managed-cloud case.
|
|
workspaceCreationDisabled: boolean;
|
|
setCdnDomain: (domain: string) => void;
|
|
setAuthConfig: (config: {
|
|
allowSignup: boolean;
|
|
googleClientId?: string;
|
|
workspaceCreationDisabled?: boolean;
|
|
}) => void;
|
|
setDaemonConfig: (config: {
|
|
daemonServerUrl?: string;
|
|
daemonAppUrl?: string;
|
|
}) => void;
|
|
}
|
|
|
|
export const configStore = createStore<ConfigState>((set) => ({
|
|
cdnDomain: "",
|
|
allowSignup: true,
|
|
googleClientId: "",
|
|
daemonServerUrl: "",
|
|
daemonAppUrl: "",
|
|
workspaceCreationDisabled: false,
|
|
setCdnDomain: (domain) => set({ cdnDomain: domain }),
|
|
setAuthConfig: ({ allowSignup, googleClientId = "", workspaceCreationDisabled = false }) =>
|
|
set({ allowSignup, googleClientId, workspaceCreationDisabled }),
|
|
setDaemonConfig: ({ daemonServerUrl = "", daemonAppUrl = "" }) =>
|
|
set({ daemonServerUrl, daemonAppUrl }),
|
|
}));
|
|
|
|
export function useConfigStore(): ConfigState;
|
|
export function useConfigStore<T>(selector: (state: ConfigState) => T): T;
|
|
export function useConfigStore<T>(selector?: (state: ConfigState) => T) {
|
|
return useStore(configStore, selector as (state: ConfigState) => T);
|
|
}
|