UI - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: единая шапка и OIDC вход launcher
This commit is contained in:
@@ -25,6 +25,11 @@ const appRoles = new Set(["viewer", "member", "admin", "owner"]);
|
||||
const grantStatuses = new Set(["active", "disabled"]);
|
||||
const exceptionTypes = new Set(["deny", "allow"]);
|
||||
const serviceStatuses = new Set(["active", "maintenance", "hidden", "disabled"]);
|
||||
const defaultSettings = {
|
||||
brand: {
|
||||
logoLinkUrl: "/",
|
||||
},
|
||||
};
|
||||
|
||||
export function createControlPlaneStore({ projectRoot }) {
|
||||
const publicStorageRoot = join(projectRoot, "public", "storage");
|
||||
@@ -179,6 +184,32 @@ export function createControlPlaneStore({ projectRoot }) {
|
||||
return { client, data };
|
||||
}
|
||||
|
||||
async function updateSettings(payload, identity) {
|
||||
const data = readData();
|
||||
const actor = resolveActor(data, identity);
|
||||
const patch = typeof payload === "object" && payload !== null ? payload : {};
|
||||
const settings = normalizeSettings({
|
||||
...data.settings,
|
||||
...patch,
|
||||
brand: {
|
||||
...(data.settings?.brand ?? {}),
|
||||
...(patch.brand ?? {}),
|
||||
},
|
||||
});
|
||||
|
||||
data.settings = settings;
|
||||
addAuditEvent(data, actor, {
|
||||
action: "Обновлены системные настройки",
|
||||
objectType: "settings",
|
||||
objectName: "Brand settings",
|
||||
result: "success",
|
||||
details: `Logo link: ${settings.brand.logoLinkUrl}`,
|
||||
});
|
||||
|
||||
await writeData(data);
|
||||
return { settings, data };
|
||||
}
|
||||
|
||||
async function updateUserProfile(userId, payload, identity) {
|
||||
const data = readData();
|
||||
const actor = resolveActor(data, identity);
|
||||
@@ -882,6 +913,7 @@ export function createControlPlaneStore({ projectRoot }) {
|
||||
updateInvite,
|
||||
updateMembership,
|
||||
updateService,
|
||||
updateSettings,
|
||||
updateUserProfile,
|
||||
upsertException,
|
||||
upsertGrant,
|
||||
@@ -898,9 +930,21 @@ function normalizeData(payload) {
|
||||
}
|
||||
}
|
||||
|
||||
data.settings = normalizeSettings(data.settings);
|
||||
return data;
|
||||
}
|
||||
|
||||
function normalizeSettings(payload) {
|
||||
const settings = typeof payload === "object" && payload !== null ? payload : {};
|
||||
const brand = typeof settings.brand === "object" && settings.brand !== null ? settings.brand : {};
|
||||
|
||||
return {
|
||||
brand: {
|
||||
logoLinkUrl: optionalString(brand.logoLinkUrl, defaultSettings.brand.logoLinkUrl),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function resolveActor(data, identity) {
|
||||
const user = data.users.find(
|
||||
(item) =>
|
||||
|
||||
Reference in New Issue
Block a user