shared-lib-web 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -528
- package/dist/components/app-brand.d.ts.map +1 -1
- package/dist/components/app-brand.js +9 -5
- package/dist/components/app-brand.js.map +1 -1
- package/dist/components/coming-soon.d.ts.map +1 -1
- package/dist/components/coming-soon.js +3 -2
- package/dist/components/coming-soon.js.map +1 -1
- package/dist/components/language-switcher.d.ts +5 -1
- package/dist/components/language-switcher.d.ts.map +1 -1
- package/dist/components/language-switcher.js +20 -7
- package/dist/components/language-switcher.js.map +1 -1
- package/dist/components/otp-modal.d.ts +5 -0
- package/dist/components/otp-modal.d.ts.map +1 -0
- package/dist/components/otp-modal.js +77 -0
- package/dist/components/otp-modal.js.map +1 -0
- package/dist/components/settings-menu.d.ts +4 -0
- package/dist/components/settings-menu.d.ts.map +1 -1
- package/dist/components/settings-menu.js +15 -2
- package/dist/components/settings-menu.js.map +1 -1
- package/dist/context/use-ui.d.ts.map +1 -1
- package/dist/context/use-ui.js +4 -3
- package/dist/context/use-ui.js.map +1 -1
- package/dist/i18n/browser-language.d.ts +9 -0
- package/dist/i18n/browser-language.d.ts.map +1 -0
- package/dist/i18n/browser-language.js +89 -0
- package/dist/i18n/browser-language.js.map +1 -0
- package/dist/i18n/default-messages.d.ts.map +1 -1
- package/dist/i18n/default-messages.js +15 -0
- package/dist/i18n/default-messages.js.map +1 -1
- package/dist/i18n/locale-groups.d.ts +18 -0
- package/dist/i18n/locale-groups.d.ts.map +1 -0
- package/dist/i18n/locale-groups.js +74 -0
- package/dist/i18n/locale-groups.js.map +1 -0
- package/dist/i18n/locale-service.d.ts +22 -4
- package/dist/i18n/locale-service.d.ts.map +1 -1
- package/dist/i18n/locale-service.js +95 -27
- package/dist/i18n/locale-service.js.map +1 -1
- package/dist/i18n/locale-signal.d.ts +18 -0
- package/dist/i18n/locale-signal.d.ts.map +1 -0
- package/dist/i18n/locale-signal.js +142 -0
- package/dist/i18n/locale-signal.js.map +1 -0
- package/dist/i18n/translator.d.ts +8 -1
- package/dist/i18n/translator.d.ts.map +1 -1
- package/dist/i18n/translator.js +36 -12
- package/dist/i18n/translator.js.map +1 -1
- package/dist/index.d.ts +24 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/dist/interfaces/app-types.d.ts +6 -0
- package/dist/interfaces/app-types.d.ts.map +1 -1
- package/dist/interfaces/ui-config.d.ts +184 -15
- package/dist/interfaces/ui-config.d.ts.map +1 -1
- package/dist/interfaces/ui-context.d.ts +1 -1
- package/dist/interfaces/ui-context.d.ts.map +1 -1
- package/dist/layouts/auth-layout.js +1 -1
- package/dist/layouts/auth-layout.js.map +1 -1
- package/dist/providers/provider-effects.d.ts +2 -2
- package/dist/providers/provider-effects.d.ts.map +1 -1
- package/dist/providers/provider-effects.js +4 -1
- package/dist/providers/provider-effects.js.map +1 -1
- package/dist/providers/register-config.d.ts.map +1 -1
- package/dist/providers/register-config.js +2 -0
- package/dist/providers/register-config.js.map +1 -1
- package/dist/providers/shared-web-ui-provider.d.ts +7 -19
- package/dist/providers/shared-web-ui-provider.d.ts.map +1 -1
- package/dist/providers/shared-web-ui-provider.js +21 -22
- package/dist/providers/shared-web-ui-provider.js.map +1 -1
- package/dist/query/query-param.d.ts +4 -1
- package/dist/query/query-param.d.ts.map +1 -1
- package/dist/query/query-param.js +6 -3
- package/dist/query/query-param.js.map +1 -1
- package/dist/state/api-loader.d.ts +19 -0
- package/dist/state/api-loader.d.ts.map +1 -0
- package/dist/state/api-loader.js +187 -0
- package/dist/state/api-loader.js.map +1 -0
- package/dist/state/auth-service.d.ts +9 -0
- package/dist/state/auth-service.d.ts.map +1 -1
- package/dist/state/auth-service.js +70 -3
- package/dist/state/auth-service.js.map +1 -1
- package/dist/state/branch-service.d.ts +1 -1
- package/dist/state/branch-service.js +3 -3
- package/dist/state/branch-service.js.map +1 -1
- package/dist/state/company-service.d.ts +16 -0
- package/dist/state/company-service.d.ts.map +1 -0
- package/dist/state/company-service.js +97 -0
- package/dist/state/company-service.js.map +1 -0
- package/dist/state/language-service.d.ts +5 -2
- package/dist/state/language-service.d.ts.map +1 -1
- package/dist/state/language-service.js +12 -7
- package/dist/state/language-service.js.map +1 -1
- package/dist/state/layout-choice-service.d.ts +10 -0
- package/dist/state/layout-choice-service.d.ts.map +1 -0
- package/dist/state/layout-choice-service.js +34 -0
- package/dist/state/layout-choice-service.js.map +1 -0
- package/dist/state/menu-service.d.ts +1 -1
- package/dist/state/menu-service.js +2 -2
- package/dist/state/menu-service.js.map +1 -1
- package/dist/state/otp-service.d.ts +69 -0
- package/dist/state/otp-service.d.ts.map +1 -0
- package/dist/state/otp-service.js +212 -0
- package/dist/state/otp-service.js.map +1 -0
- package/dist/state/preference-sync.d.ts +1 -1
- package/dist/state/preference-sync.d.ts.map +1 -1
- package/dist/state/preference-sync.js +11 -3
- package/dist/state/preference-sync.js.map +1 -1
- package/dist/state/signals.d.ts +9 -1
- package/dist/state/signals.d.ts.map +1 -1
- package/dist/state/signals.js +28 -4
- package/dist/state/signals.js.map +1 -1
- package/dist/theme/custom-themes.d.ts +28 -0
- package/dist/theme/custom-themes.d.ts.map +1 -0
- package/dist/theme/custom-themes.js +218 -0
- package/dist/theme/custom-themes.js.map +1 -0
- package/dist/theme/dark-themes.d.ts +9 -1
- package/dist/theme/dark-themes.d.ts.map +1 -1
- package/dist/theme/dark-themes.js +74 -2
- package/dist/theme/dark-themes.js.map +1 -1
- package/dist/theme/logo.d.ts +6 -3
- package/dist/theme/logo.d.ts.map +1 -1
- package/dist/theme/logo.js +17 -3
- package/dist/theme/logo.js.map +1 -1
- package/dist/theme/theme-service.d.ts +14 -3
- package/dist/theme/theme-service.d.ts.map +1 -1
- package/dist/theme/theme-service.js +64 -10
- package/dist/theme/theme-service.js.map +1 -1
- package/dist/types/field-wrapper.d.ts +2 -0
- package/dist/types/field-wrapper.d.ts.map +1 -1
- package/dist/types/field-wrapper.js +3 -2
- package/dist/types/field-wrapper.js.map +1 -1
- package/dist/types/type.otp.d.ts +2 -0
- package/dist/types/type.otp.d.ts.map +1 -1
- package/dist/types/type.otp.js +2 -2
- package/dist/types/type.otp.js.map +1 -1
- package/dist/utils/app-http.d.ts +41 -1
- package/dist/utils/app-http.d.ts.map +1 -1
- package/dist/utils/app-http.js +188 -12
- package/dist/utils/app-http.js.map +1 -1
- package/dist/utils/content-util.d.ts +6 -0
- package/dist/utils/content-util.d.ts.map +1 -0
- package/dist/utils/content-util.js +45 -0
- package/dist/utils/content-util.js.map +1 -0
- package/dist/utils/error-util.d.ts +3 -0
- package/dist/utils/error-util.d.ts.map +1 -0
- package/dist/utils/error-util.js +58 -0
- package/dist/utils/error-util.js.map +1 -0
- package/dist/utils/language-util.d.ts +3 -3
- package/dist/utils/language-util.d.ts.map +1 -1
- package/dist/utils/language-util.js +7 -7
- package/dist/utils/language-util.js.map +1 -1
- package/dist/utils/menu-util.js +1 -1
- package/dist/utils/menu-util.js.map +1 -1
- package/dist/utils/signal-source.d.ts +4 -0
- package/dist/utils/signal-source.d.ts.map +1 -0
- package/dist/utils/signal-source.js +13 -0
- package/dist/utils/signal-source.js.map +1 -0
- package/dist/utils/storage-keys.d.ts +5 -0
- package/dist/utils/storage-keys.d.ts.map +1 -1
- package/dist/utils/storage-keys.js +5 -0
- package/dist/utils/storage-keys.js.map +1 -1
- package/package.json +3 -3
- package/src/components/app-brand.tsx +9 -5
- package/src/components/coming-soon.tsx +3 -2
- package/src/components/language-switcher.tsx +26 -7
- package/src/components/otp-modal.tsx +154 -0
- package/src/components/settings-menu.tsx +28 -2
- package/src/context/use-ui.ts +4 -3
- package/src/i18n/browser-language.ts +98 -0
- package/src/i18n/default-messages.ts +15 -0
- package/src/i18n/locale-groups.ts +87 -0
- package/src/i18n/locale-service.ts +99 -27
- package/src/i18n/locale-signal.ts +173 -0
- package/src/i18n/translator.ts +38 -12
- package/src/index.ts +102 -4
- package/src/interfaces/app-types.ts +6 -0
- package/src/interfaces/ui-config.ts +191 -15
- package/src/interfaces/ui-context.ts +1 -1
- package/src/layouts/auth-layout.tsx +1 -1
- package/src/providers/provider-effects.ts +5 -2
- package/src/providers/register-config.ts +2 -0
- package/src/providers/shared-web-ui-provider.tsx +26 -43
- package/src/query/query-param.ts +6 -2
- package/src/state/api-loader.ts +205 -0
- package/src/state/auth-service.ts +84 -3
- package/src/state/branch-service.ts +3 -3
- package/src/state/company-service.ts +107 -0
- package/src/state/language-service.ts +12 -7
- package/src/state/layout-choice-service.ts +40 -0
- package/src/state/menu-service.ts +2 -2
- package/src/state/otp-service.ts +283 -0
- package/src/state/preference-sync.ts +11 -3
- package/src/state/signals.ts +36 -4
- package/src/theme/custom-themes.ts +236 -0
- package/src/theme/dark-themes.ts +80 -3
- package/src/theme/logo.ts +19 -4
- package/src/theme/org-themes.json +70 -0
- package/src/theme/theme-service.ts +70 -10
- package/src/types/field-wrapper.tsx +5 -2
- package/src/types/type.otp.tsx +11 -2
- package/src/utils/app-http.ts +205 -12
- package/src/utils/content-util.ts +49 -0
- package/src/utils/error-util.ts +64 -0
- package/src/utils/language-util.ts +7 -7
- package/src/utils/menu-util.ts +1 -1
- package/src/utils/signal-source.ts +15 -0
- package/src/utils/storage-keys.ts +6 -0
package/src/query/query-param.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
openMegaMenuIdSignal,
|
|
20
20
|
queryParamsSignal,
|
|
21
21
|
railFlyoutSignal,
|
|
22
|
+
readIsPathPageMode,
|
|
22
23
|
uiConfigSignal,
|
|
23
24
|
} from "../state/signals.ts";
|
|
24
25
|
import { toPagePath, toPageParamValue } from "./page-path.ts";
|
|
@@ -151,10 +152,13 @@ export function readCurrentPage(): string {
|
|
|
151
152
|
return currentPageSignal.value;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* true when pages live in the path (/profiles) instead of ?page: config.layout.pageMode "path",
|
|
157
|
+
* or no pageMode and the app type "shell".
|
|
158
|
+
*/
|
|
155
159
|
export function isPathPageMode(): boolean {
|
|
156
160
|
const config = uiConfigSignal.peek();
|
|
157
|
-
return config
|
|
161
|
+
return readIsPathPageMode(config);
|
|
158
162
|
}
|
|
159
163
|
|
|
160
164
|
/**
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// api-loader.ts
|
|
2
|
+
// The backend sources of the config, used by the provider itself (like loadThemes):
|
|
3
|
+
//
|
|
4
|
+
// loadSupportLanguages once, when the provider mounts -> setLanguages(reply)
|
|
5
|
+
// loadCompanyDetails once, when the provider mounts (an "mfe" only when it sets it) -> setCompanyDetails(reply)
|
|
6
|
+
// loadBranches when a user is signed in (sign in, or restored session) -> setBranches(reply)
|
|
7
|
+
// (before the menu: the menu request already sends x-branch-id)
|
|
8
|
+
// loadMenuNavigation when a user is signed in -> skeleton, then setMenu(reply)
|
|
9
|
+
// sign out -> branches and menu are removed
|
|
10
|
+
//
|
|
11
|
+
// A source is your function, a URL / path (AppHttp.Get), or a SIGNAL you fill yourself:
|
|
12
|
+
// loadMenuNavigation: navSignal // null = skeleton, a reply = the menu; every new value is shown at once
|
|
13
|
+
// A signal is followed as it is (no call, no sign-in rule): your code decides when it changes.
|
|
14
|
+
// Type "mfe" uses only loadSupportLanguages and, when set, loadCompanyDetails (the shell owns the rest); no menu.
|
|
15
|
+
|
|
16
|
+
import { effect } from "@preact/signals-react";
|
|
17
|
+
import type { BranchSource, LangSource, MenuSource } from "../interfaces/app-types.ts";
|
|
18
|
+
import type { ApiSource, UiConfig, ValueSignal } from "../interfaces/ui-config.ts";
|
|
19
|
+
import { AppHttp, readJwtToken } from "../utils/app-http.ts";
|
|
20
|
+
import { isSignalSource } from "../utils/signal-source.ts";
|
|
21
|
+
import { isAuthenticatedSignal } from "./auth-service.ts";
|
|
22
|
+
import { registerBranches, setBranches } from "./branch-service.ts";
|
|
23
|
+
import { setCompanyDetails } from "./company-service.ts";
|
|
24
|
+
import { registerLanguages, setLanguages } from "./language-service.ts";
|
|
25
|
+
import { registerMenu, setMenu, setMenuLoading } from "./menu-service.ts";
|
|
26
|
+
import { appTypeSignal, uiConfigSignal } from "./signals.ts";
|
|
27
|
+
|
|
28
|
+
/** Configs whose loadSupportLanguages already ran (StrictMode mounts twice). */
|
|
29
|
+
const languageLoadedConfigs = new WeakSet<UiConfig>();
|
|
30
|
+
|
|
31
|
+
/** Configs whose loadCompanyDetails already ran (StrictMode mounts twice). */
|
|
32
|
+
const companyLoadedConfigs = new WeakSet<UiConfig>();
|
|
33
|
+
|
|
34
|
+
/** The token whose branches and menu were loaded last ("" = signed out), so a second mount does not load again. */
|
|
35
|
+
let loadedSessionToken: string | undefined = undefined;
|
|
36
|
+
|
|
37
|
+
/** Applies one value of a source signal (menu, languages or branches). */
|
|
38
|
+
type SignalValueApplier = (value: never) => void;
|
|
39
|
+
|
|
40
|
+
/** A source the provider calls (a function or a URL), not a signal. */
|
|
41
|
+
function isCallableSource(source: ApiSource | undefined): source is string | (() => Promise<unknown>) {
|
|
42
|
+
return typeof source === "function" || typeof source === "string";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Calls one loader: your function, or AppHttp.Get(url). A signal answers with its current value. */
|
|
46
|
+
export function callApiSource(source: ApiSource): Promise<unknown> {
|
|
47
|
+
if (typeof source === "function") {
|
|
48
|
+
return source();
|
|
49
|
+
}
|
|
50
|
+
if (isSignalSource(source)) {
|
|
51
|
+
const currentValue = source.peek();
|
|
52
|
+
return Promise.resolve(currentValue);
|
|
53
|
+
}
|
|
54
|
+
return AppHttp.Get(source);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** loadSupportLanguages -> setLanguages. Once per config. On an error the default language stays. */
|
|
58
|
+
export async function loadConfigLanguages(config: UiConfig): Promise<void> {
|
|
59
|
+
const langSource = config.loadSupportLanguages;
|
|
60
|
+
const isLoaded = languageLoadedConfigs.has(config);
|
|
61
|
+
if (!isCallableSource(langSource) || isLoaded) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
languageLoadedConfigs.add(config);
|
|
65
|
+
try {
|
|
66
|
+
const reply = await callApiSource(langSource);
|
|
67
|
+
setLanguages(reply as LangSource);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("shared-lib-web: config.loadSupportLanguages failed; the default language stays.", error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** loadCompanyDetails -> setCompanyDetails. Once per config. On an error the config values (appName, logos) stay. */
|
|
74
|
+
export async function loadConfigCompany(config: UiConfig): Promise<void> {
|
|
75
|
+
const companySource = config.loadCompanyDetails;
|
|
76
|
+
const isLoaded = companyLoadedConfigs.has(config);
|
|
77
|
+
if (!isCallableSource(companySource) || isLoaded) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
companyLoadedConfigs.add(config);
|
|
81
|
+
try {
|
|
82
|
+
const reply = await callApiSource(companySource);
|
|
83
|
+
setCompanyDetails(reply);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error("shared-lib-web: config.loadCompanyDetails failed; the config app name and logos stay.", error);
|
|
86
|
+
setCompanyDetails({});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** loadBranches -> setBranches (no switcher on an error). */
|
|
91
|
+
async function fetchBranchList(branchSource: ApiSource): Promise<void> {
|
|
92
|
+
try {
|
|
93
|
+
const reply = await callApiSource(branchSource);
|
|
94
|
+
setBranches(reply as BranchSource);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error("shared-lib-web: config.loadBranches failed; no branch switcher.", error);
|
|
97
|
+
setBranches(null);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** loadMenuNavigation -> menu skeleton, then setMenu (an empty menu on an error). */
|
|
102
|
+
async function fetchMenuNavigation(navSource: ApiSource): Promise<void> {
|
|
103
|
+
setMenuLoading();
|
|
104
|
+
try {
|
|
105
|
+
const reply = await callApiSource(navSource);
|
|
106
|
+
setMenu(reply as MenuSource);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error("shared-lib-web: config.loadMenuNavigation failed; the menu is empty.", error);
|
|
109
|
+
setMenu([]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** After sign in: branches first, then the menu (only sources the provider calls; signals follow themselves). */
|
|
114
|
+
export async function loadSessionData(config: UiConfig): Promise<void> {
|
|
115
|
+
const branchSource = config.loadBranches;
|
|
116
|
+
const navSource = config.loadMenuNavigation;
|
|
117
|
+
if (isCallableSource(branchSource)) {
|
|
118
|
+
await fetchBranchList(branchSource);
|
|
119
|
+
}
|
|
120
|
+
if (isCallableSource(navSource)) {
|
|
121
|
+
await fetchMenuNavigation(navSource);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** After sign out: no branches, and the menu waits (skeleton) for the next user. Signal sources are left alone. */
|
|
126
|
+
export function clearSessionData(config: UiConfig): void {
|
|
127
|
+
if (isCallableSource(config.loadBranches)) {
|
|
128
|
+
setBranches(null);
|
|
129
|
+
}
|
|
130
|
+
if (isCallableSource(config.loadMenuNavigation)) {
|
|
131
|
+
setMenuLoading();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Runs on every sign in / sign out (a signals effect). */
|
|
136
|
+
function followSession(): void {
|
|
137
|
+
const isSignedIn = isAuthenticatedSignal.value;
|
|
138
|
+
const config = uiConfigSignal.peek();
|
|
139
|
+
if (!config) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const token = isSignedIn ? readJwtToken() : "";
|
|
143
|
+
if (token === loadedSessionToken) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
loadedSessionToken = token;
|
|
147
|
+
if (isSignedIn) {
|
|
148
|
+
void loadSessionData(config);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
clearSessionData(config);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Forgets what was loaded (a new config, or tests). */
|
|
155
|
+
export function forgetApiSession(): void {
|
|
156
|
+
loadedSessionToken = undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Reads a source signal (so the effect follows it) and applies its value. */
|
|
160
|
+
function applySignalValue(sourceSignal: ValueSignal<unknown>, applyValue: SignalValueApplier): void {
|
|
161
|
+
const value = sourceSignal.value;
|
|
162
|
+
applyValue(value as never);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Follows a signal source; returns the stop function (or undefined when the source is not a signal). */
|
|
166
|
+
function followSignalSource(source: ApiSource | undefined, applyValue: SignalValueApplier): (() => void) | undefined {
|
|
167
|
+
if (!isSignalSource(source)) {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
const applySource = applySignalValue.bind(null, source, applyValue);
|
|
171
|
+
return effect(applySource);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Stops every running follower. */
|
|
175
|
+
function stopAll(stoppers: Array<(() => void) | undefined>): void {
|
|
176
|
+
for (const stop of stoppers) {
|
|
177
|
+
stop?.();
|
|
178
|
+
}
|
|
179
|
+
forgetApiSession();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Starts the config sources. Called once by SharedWebUiProvider (layout effect); returns the cleanup.
|
|
184
|
+
* Type "mfe": only loadSupportLanguages (+ loadCompanyDetails when set), and an empty menu (no skeleton; the shell shows the menu).
|
|
185
|
+
*/
|
|
186
|
+
export function startApiLoading(): () => void {
|
|
187
|
+
const config = uiConfigSignal.peek();
|
|
188
|
+
if (!config) {
|
|
189
|
+
return forgetApiSession;
|
|
190
|
+
}
|
|
191
|
+
void loadConfigLanguages(config);
|
|
192
|
+
const stopLanguages = followSignalSource(config.loadSupportLanguages, registerLanguages);
|
|
193
|
+
// Company details also for an MFE that sets loadCompanyDetails (for example an auth MFE with the brand on its login).
|
|
194
|
+
void loadConfigCompany(config);
|
|
195
|
+
const stopCompany = followSignalSource(config.loadCompanyDetails, setCompanyDetails);
|
|
196
|
+
const appType = appTypeSignal.peek();
|
|
197
|
+
if (appType === "mfe") {
|
|
198
|
+
setMenu([]);
|
|
199
|
+
return stopAll.bind(null, [stopLanguages, stopCompany]);
|
|
200
|
+
}
|
|
201
|
+
const stopBranches = followSignalSource(config.loadBranches, registerBranches);
|
|
202
|
+
const stopMenu = followSignalSource(config.loadMenuNavigation, registerMenu);
|
|
203
|
+
const stopSession = effect(followSession);
|
|
204
|
+
return stopAll.bind(null, [stopLanguages, stopCompany, stopBranches, stopMenu, stopSession]);
|
|
205
|
+
}
|
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
// isAuthenticatedSignal.value // true / false
|
|
7
7
|
// endSession(); // log out (LANG, THEME ... are kept)
|
|
8
8
|
// endSession([BRANCH_ID]); // log out, also keeps the listed AppStorage keys
|
|
9
|
+
// refreshSessionToken(newToken); // new token after a JWT regenerate (user stays; AppHttp calls it itself)
|
|
10
|
+
//
|
|
11
|
+
// Microfrontends: each one bundles its own copy of the library. startSession / endSession fire SESSION_EVENT, and
|
|
12
|
+
// every other copy (startSessionSync, started by the provider) applies it: an auth MFE signs in -> the shell is signed in.
|
|
9
13
|
|
|
10
14
|
import { computed, signal } from "@preact/signals-react";
|
|
11
15
|
import { ConstValue } from "dff-util";
|
|
12
16
|
import type { AuthUser } from "../interfaces/app-types.ts";
|
|
13
17
|
import { AppStorage } from "../utils/app-storage.ts";
|
|
14
18
|
import { resetSessionId } from "../utils/session-id.ts";
|
|
15
|
-
import { AUTH_USER, BRANCH_ID, REMEMBER_ME, TOKEN } from "../utils/storage-keys.ts";
|
|
19
|
+
import { AUTH_USER, BRANCH_ID, REMEMBER_ME, SESSION_EVENT, TOKEN } from "../utils/storage-keys.ts";
|
|
16
20
|
import { clearBranch, forgetAppliedBranches, restoreBranch } from "./branch-service.ts";
|
|
17
21
|
import { uiConfigSignal } from "./signals.ts";
|
|
18
22
|
|
|
@@ -33,6 +37,30 @@ function readIsAuthenticated(): boolean {
|
|
|
33
37
|
/** true when a token is present. */
|
|
34
38
|
export const isAuthenticatedSignal = computed(readIsAuthenticated);
|
|
35
39
|
|
|
40
|
+
/** Id of this copy of the library: its own session events are not applied again. */
|
|
41
|
+
const randomNumber = Math.random();
|
|
42
|
+
const LIBRARY_COPY_ID = String(randomNumber);
|
|
43
|
+
|
|
44
|
+
/** What SESSION_EVENT carries. */
|
|
45
|
+
interface SessionEventDetail {
|
|
46
|
+
isSignedIn?: boolean;
|
|
47
|
+
isTokenRefresh?: boolean;
|
|
48
|
+
copyId?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let isSessionSyncStarted = false;
|
|
52
|
+
|
|
53
|
+
/** Tells every other library copy on the page that the session started or ended. */
|
|
54
|
+
function notifySessionChanged(isSignedIn: boolean, isTokenRefresh: boolean = false): void {
|
|
55
|
+
if (typeof window === "undefined") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const detail: SessionEventDetail = { isSignedIn: isSignedIn, isTokenRefresh: isTokenRefresh, copyId: LIBRARY_COPY_ID };
|
|
59
|
+
const eventInit = { detail: detail };
|
|
60
|
+
const sessionEvent = new CustomEvent(SESSION_EVENT, eventInit);
|
|
61
|
+
window.dispatchEvent(sessionEvent);
|
|
62
|
+
}
|
|
63
|
+
|
|
36
64
|
/** AppStorage key of the token (config.http.tokenKey, default "TOKEN"). */
|
|
37
65
|
export function readTokenKey(): string {
|
|
38
66
|
const config = uiConfigSignal.value;
|
|
@@ -55,8 +83,30 @@ export function startSession(token: string, user: AuthUser | null, isRemembered:
|
|
|
55
83
|
AppStorage.setData(tokenKey, token);
|
|
56
84
|
AppStorage.setData(AUTH_USER_KEY, user);
|
|
57
85
|
AppStorage.setData(REMEMBER_ME, isRemembered);
|
|
58
|
-
|
|
86
|
+
// The user first: whatever runs on sign in (branches, menu) already reads the user.
|
|
59
87
|
authUserSignal.value = user;
|
|
88
|
+
sessionTokenSignal.value = token;
|
|
89
|
+
notifySessionChanged(true);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Replaces the token after a JWT regenerate: user, branch and REMEMBER_ME stay, no menu / branch reload.
|
|
94
|
+
* Every other library copy on the page takes the new token too.
|
|
95
|
+
*/
|
|
96
|
+
export function refreshSessionToken(token: string): void {
|
|
97
|
+
const tokenKey = readTokenKey();
|
|
98
|
+
AppStorage.setData(tokenKey, token);
|
|
99
|
+
sessionTokenSignal.value = token;
|
|
100
|
+
notifySessionChanged(true, true);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Another library copy refreshed the token: read it from AppStorage. */
|
|
104
|
+
function applyRefreshedToken(): void {
|
|
105
|
+
const tokenKey = readTokenKey();
|
|
106
|
+
const token = AppStorage.getData(tokenKey);
|
|
107
|
+
if (typeof token === "string" && token.length > 0) {
|
|
108
|
+
sessionTokenSignal.value = token;
|
|
109
|
+
}
|
|
60
110
|
}
|
|
61
111
|
|
|
62
112
|
/** Reads a saved session (sessionStorage). Called by SharedWebUiProvider. */
|
|
@@ -68,8 +118,8 @@ export function restoreSession(): void {
|
|
|
68
118
|
return;
|
|
69
119
|
}
|
|
70
120
|
const storedUser = AppStorage.getData(AUTH_USER_KEY);
|
|
71
|
-
sessionTokenSignal.value = token;
|
|
72
121
|
authUserSignal.value = storedUser && typeof storedUser === "object" ? (storedUser as AuthUser) : null;
|
|
122
|
+
sessionTokenSignal.value = token;
|
|
73
123
|
}
|
|
74
124
|
|
|
75
125
|
/** Sends the browser to config.http.logoutUrl (replace: Back does not return to the signed-in page). */
|
|
@@ -98,7 +148,38 @@ export function endSession(keepKeys: string[] = [], isRedirect: boolean = true):
|
|
|
98
148
|
sessionTokenSignal.value = ConstValue.EMPTY;
|
|
99
149
|
authUserSignal.value = null;
|
|
100
150
|
resetSessionId();
|
|
151
|
+
notifySessionChanged(false);
|
|
101
152
|
if (isRedirect) {
|
|
102
153
|
redirectToLogoutUrl();
|
|
103
154
|
}
|
|
104
155
|
}
|
|
156
|
+
|
|
157
|
+
/** Another library copy started or ended the session: read it from AppStorage (sign in) or clear it here (sign out). */
|
|
158
|
+
export function handleSessionEvent(event: Event): void {
|
|
159
|
+
const detail = (event as CustomEvent<SessionEventDetail>).detail;
|
|
160
|
+
const isOwnEvent = detail?.copyId === LIBRARY_COPY_ID;
|
|
161
|
+
if (!detail || isOwnEvent) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (detail.isTokenRefresh) {
|
|
165
|
+
applyRefreshedToken();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (detail.isSignedIn) {
|
|
169
|
+
restoreSession();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
forgetAppliedBranches();
|
|
173
|
+
sessionTokenSignal.value = ConstValue.EMPTY;
|
|
174
|
+
authUserSignal.value = null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Starts following the session events of the other library copies (once; called by SharedWebUiProvider). */
|
|
178
|
+
export function startSessionSync(): void {
|
|
179
|
+
const hasWindow = typeof window !== "undefined";
|
|
180
|
+
if (!hasWindow || isSessionSyncStarted) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
isSessionSyncStarted = true;
|
|
184
|
+
window.addEventListener(SESSION_EVENT, handleSessionEvent);
|
|
185
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// setBranch(branch.id, branch.name); // after the user picks a branch (saved in AppStorage BRANCH_ID / BRANCH_NAME)
|
|
5
5
|
// branchIdSignal.value // current id, "" when none (re-renders components)
|
|
6
6
|
// clearBranch(); // no branch (endSession() clears it too)
|
|
7
|
-
//
|
|
7
|
+
// config.loadBranches: "/app-api/branches" // the provider calls it after sign in
|
|
8
8
|
|
|
9
9
|
import { signal } from "@preact/signals-react";
|
|
10
10
|
import { ConstValue } from "dff-util";
|
|
@@ -49,7 +49,7 @@ export function restoreBranch(): void {
|
|
|
49
49
|
|
|
50
50
|
// ---- Branch list (the switcher) ----
|
|
51
51
|
//
|
|
52
|
-
//
|
|
52
|
+
// config.loadBranches (the provider calls it after sign in)
|
|
53
53
|
// setBranches(branchReply); // the same without the provider (for example before the menu request)
|
|
54
54
|
//
|
|
55
55
|
// Which branch is selected when the list arrives (disabled branches are never selected):
|
|
@@ -187,7 +187,7 @@ export function setBranches(source: BranchSource | null | undefined): void {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
|
-
* Used by
|
|
190
|
+
* Used by the config loaders (and tests). Applies the value only when it changed.
|
|
191
191
|
* undefined leaves the branches alone; null or [] hides the switcher.
|
|
192
192
|
*/
|
|
193
193
|
export function registerBranches(source: BranchSource | null | undefined): void {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// company-service.ts
|
|
2
|
+
// Company / brand details from the backend (config.loadCompanyDetails, or setCompanyDetails by hand):
|
|
3
|
+
//
|
|
4
|
+
// { "appName": "YourAppName", "companyName": "YourBrandName",
|
|
5
|
+
// "faviconUrl": "https://www.w3.org/favicon.ico", "logoUrl": "https://www.w3.org/Icons/w3c_home.png",
|
|
6
|
+
// "logoDarkUrl": "https://www.w3.org/Icons/w3c_home.png" }
|
|
7
|
+
//
|
|
8
|
+
// appName header / sidebar / login label and the browser tab title (wins over config.appName)
|
|
9
|
+
// companyName alt text of the logo; read companyDetailsSignal to show it anywhere (a footer, the login page)
|
|
10
|
+
// faviconUrl <link rel="icon" href="...">
|
|
11
|
+
// logoUrl the logo on light themes, and on dark themes without logoDarkUrl (wins over config.logoUrl / logoDarkUrl)
|
|
12
|
+
// logoDarkUrl the logo on dark themes (wins over config.logoDarkUrl)
|
|
13
|
+
// A reply may also be { data: {...} }. A missing field keeps the config value.
|
|
14
|
+
|
|
15
|
+
import type { CompanyDetails, CompanySource, UiConfig } from "../interfaces/ui-config.ts";
|
|
16
|
+
import { companyDetailsSignal } from "./signals.ts";
|
|
17
|
+
|
|
18
|
+
/** The fields of CompanyDetails (only text values are kept). */
|
|
19
|
+
const COMPANY_FIELDS: Array<keyof CompanyDetails> = ["appName", "companyName", "faviconUrl", "logoUrl", "logoDarkUrl"];
|
|
20
|
+
|
|
21
|
+
/** true for a plain object (not null, not a list). */
|
|
22
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
23
|
+
const isObject = typeof value === "object" && value !== null;
|
|
24
|
+
return isObject && !Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The details inside a reply: the object itself, or its "data" object. */
|
|
28
|
+
function unwrapCompanyReply(reply: unknown): Record<string, unknown> | null {
|
|
29
|
+
if (!isPlainObject(reply)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const data = reply.data;
|
|
33
|
+
return isPlainObject(data) ? data : reply;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Reads the company details from a reply ({...} or { data: {...} }); empty or unknown values are left out. */
|
|
37
|
+
export function readCompanyDetails(reply: unknown): CompanyDetails | null {
|
|
38
|
+
const source = unwrapCompanyReply(reply);
|
|
39
|
+
if (!source) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const details: CompanyDetails = {};
|
|
43
|
+
for (const field of COMPANY_FIELDS) {
|
|
44
|
+
const value = source[field];
|
|
45
|
+
const isText = typeof value === "string" && value !== "";
|
|
46
|
+
if (isText) {
|
|
47
|
+
details[field] = value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return details;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Points <link rel="icon"> at the favicon URL (created when the page has none). */
|
|
54
|
+
function writeFavicon(faviconUrl: string): void {
|
|
55
|
+
let iconElement = document.querySelector<HTMLLinkElement>('link[rel~="icon"]');
|
|
56
|
+
if (!iconElement) {
|
|
57
|
+
iconElement = document.createElement("link");
|
|
58
|
+
iconElement.rel = "icon";
|
|
59
|
+
document.head.append(iconElement);
|
|
60
|
+
}
|
|
61
|
+
iconElement.href = faviconUrl;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Writes the favicon and the tab title of the company details (fields that are missing are left alone). */
|
|
65
|
+
function applyCompanyToDocument(details: CompanyDetails | null): void {
|
|
66
|
+
const hasDocument = typeof document !== "undefined";
|
|
67
|
+
if (!hasDocument || !details) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (details.faviconUrl) {
|
|
71
|
+
writeFavicon(details.faviconUrl);
|
|
72
|
+
}
|
|
73
|
+
if (details.appName) {
|
|
74
|
+
document.title = details.appName;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sets the company details (the backend reply as it is: {...} or { data: {...} }); null = none (config values).
|
|
80
|
+
* The brand (logo, app name) updates at once; faviconUrl and appName also go to the browser tab.
|
|
81
|
+
*/
|
|
82
|
+
export function setCompanyDetails(reply: CompanySource | unknown): void {
|
|
83
|
+
const details = readCompanyDetails(reply);
|
|
84
|
+
companyDetailsSignal.value = details;
|
|
85
|
+
applyCompanyToDocument(details);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** true while config.loadCompanyDetails has not answered yet (no reply, and no config.appName to show meanwhile). */
|
|
89
|
+
export function isCompanyPending(config: UiConfig, details: CompanyDetails | null): boolean {
|
|
90
|
+
const hasCompanySource = Boolean(config.loadCompanyDetails);
|
|
91
|
+
return hasCompanySource && !details && !config.appName;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The app label: company appName, else config.appName, else config.appNameKey (shown with t()).
|
|
96
|
+
* "" while the company details are still loading (so the app key does not flash before the real name).
|
|
97
|
+
*/
|
|
98
|
+
export function readAppNameLabel(config: UiConfig, details: CompanyDetails | null): string {
|
|
99
|
+
if (details?.appName) {
|
|
100
|
+
return details.appName;
|
|
101
|
+
}
|
|
102
|
+
const isPending = isCompanyPending(config, details);
|
|
103
|
+
if (isPending) {
|
|
104
|
+
return "";
|
|
105
|
+
}
|
|
106
|
+
return config.appName ?? config.appNameKey;
|
|
107
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// language-service.ts
|
|
2
2
|
// Languages that come from the backend at runtime, separate from config.ts (like the menu: nav).
|
|
3
3
|
//
|
|
4
|
-
//
|
|
4
|
+
// config.loadSupportLanguages: "/app-api/languages" // the provider calls it on start
|
|
5
5
|
// setLanguages(langResponse); // or call it yourself
|
|
6
6
|
//
|
|
7
7
|
// langResponse is the backend reply { data: [...], meta } or only the list.
|
|
8
8
|
// Texts load from config.loadLocale(code): locales/en-US.json, locales/ar-SA.json ...
|
|
9
9
|
// When the reply arrives: the current language stays if it is in the list (and the user picked it),
|
|
10
|
-
// otherwise the language marked isDefault
|
|
10
|
+
// otherwise: the language marked isDefault, else config.defaultLanguage, else the browser / system language,
|
|
11
|
+
// else "en-US" (when listed), else the first one.
|
|
11
12
|
|
|
12
|
-
import { applyLanguage,
|
|
13
|
+
import { applyLanguage, readBrowserLanguage, readFallbackLanguage, readIsLanguageChosen } from "../i18n/locale-service.ts";
|
|
13
14
|
import type { LangSource } from "../interfaces/app-types.ts";
|
|
14
15
|
import { findLanguageOption } from "../i18n/direction.ts";
|
|
15
16
|
import { readDefaultLanguageCode, toLanguageOptions } from "../utils/language-util.ts";
|
|
@@ -28,7 +29,10 @@ export function isLanguageListed(languageCode: string | undefined): boolean {
|
|
|
28
29
|
return Boolean(language);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The language to switch to after a new list (when the user did not pick one): the backend isDefault,
|
|
34
|
+
* config.defaultLanguage, the browser / system language, "en-US", or the first one.
|
|
35
|
+
*/
|
|
32
36
|
export function readLanguageAfterUpdate(source: LangSource): string | undefined {
|
|
33
37
|
const languages = languagesSignal.peek();
|
|
34
38
|
const currentCode = localeSignal.peek();
|
|
@@ -39,9 +43,10 @@ export function readLanguageAfterUpdate(source: LangSource): string | undefined
|
|
|
39
43
|
}
|
|
40
44
|
const backendDefault = readDefaultLanguageCode(source);
|
|
41
45
|
const config = uiConfigSignal.peek();
|
|
42
|
-
const
|
|
46
|
+
const browserLanguage = readBrowserLanguage();
|
|
47
|
+
const fallbackLanguage = readFallbackLanguage(config);
|
|
43
48
|
const firstLanguage = languages[0];
|
|
44
|
-
const candidates = [backendDefault,
|
|
49
|
+
const candidates = [backendDefault, config?.defaultLanguage, browserLanguage, fallbackLanguage, firstLanguage?.code];
|
|
45
50
|
for (const candidate of candidates) {
|
|
46
51
|
const isListed = isLanguageListed(candidate);
|
|
47
52
|
if (isListed) {
|
|
@@ -63,7 +68,7 @@ export function setLanguages(source: LangSource): void {
|
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
/**
|
|
66
|
-
* Used by
|
|
71
|
+
* Used by the config loaders (and tests). Applies the value only when it changed.
|
|
67
72
|
* undefined / null -> keep config.languages (or no list yet); texts of config.defaultLanguage still load
|
|
68
73
|
* reply / list -> show it (a new reply replaces the list)
|
|
69
74
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// layout-choice-service.ts
|
|
2
|
+
// Which app layout the user picked — for a shell with microfrontends, where the settings MFE offers the choice and
|
|
3
|
+
// the shell renders the layout:
|
|
4
|
+
// "app" AppLayout: header + menu (sidebar or mega menu)
|
|
5
|
+
// "aside" AsideLayout: menu only, no header, no mega menu
|
|
6
|
+
//
|
|
7
|
+
// changeLayoutChoice("aside"); // saves ORG-LAYOUT_CHOICE (localStorage) and fires PREFERENCE_EVENT
|
|
8
|
+
// layoutChoiceSignal.value // "app" | "aside" — every copy of the library on the page follows at once
|
|
9
|
+
//
|
|
10
|
+
// The provider reads the saved choice on mount; preference-sync.ts follows later changes (same tab and other tabs).
|
|
11
|
+
// An MFE has no layout of its own: it reads layoutChoiceSignal to know whether the shell shows a header.
|
|
12
|
+
|
|
13
|
+
import { signal } from "@preact/signals-react";
|
|
14
|
+
import { AppStorage } from "../utils/app-storage.ts";
|
|
15
|
+
import { LAYOUT_CHOICE } from "../utils/storage-keys.ts";
|
|
16
|
+
|
|
17
|
+
export type LayoutChoice = "app" | "aside";
|
|
18
|
+
|
|
19
|
+
/** The current layout choice ("app" until a saved one is read). */
|
|
20
|
+
export const layoutChoiceSignal = signal<LayoutChoice>("app");
|
|
21
|
+
|
|
22
|
+
/** "aside" stays "aside"; anything else (nothing saved, an old value) is "app". */
|
|
23
|
+
export function toLayoutChoice(value: string | null | undefined): LayoutChoice {
|
|
24
|
+
return value === "aside" ? "aside" : "app";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Reads the saved choice into layoutChoiceSignal (not saved again). */
|
|
28
|
+
export function applySavedLayoutChoice(): void {
|
|
29
|
+
const savedValue = AppStorage.getText(LAYOUT_CHOICE);
|
|
30
|
+
const choice = toLayoutChoice(savedValue);
|
|
31
|
+
if (choice !== layoutChoiceSignal.peek()) {
|
|
32
|
+
layoutChoiceSignal.value = choice;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Picks a layout: saved as LAYOUT_CHOICE; the shell and every MFE on the page follow at once. */
|
|
37
|
+
export function changeLayoutChoice(choice: LayoutChoice): void {
|
|
38
|
+
layoutChoiceSignal.value = choice;
|
|
39
|
+
AppStorage.setData(LAYOUT_CHOICE, choice);
|
|
40
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// menu-service.ts
|
|
2
2
|
// Menus that come from the backend at runtime, separate from config.ts.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
4
|
+
// config.loadMenuNavigation: "/app-api/menu-access" // the provider calls it after sign in
|
|
5
5
|
// setMenu(menuResponse); // or call it yourself, for example after login
|
|
6
6
|
// setMenuLoading(); // sidebar shows a skeleton until setMenu()
|
|
7
7
|
//
|
|
@@ -44,7 +44,7 @@ export function clearMenu(): void {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Used by
|
|
47
|
+
* Used by the config loaders (and tests). Applies the value only when it changed.
|
|
48
48
|
* undefined -> use config.navigation
|
|
49
49
|
* null -> still loading: menu skeleton (typical first value before the API answers)
|
|
50
50
|
* reply / list -> show it (a new reply object later replaces the menu)
|