feat(config): show / hide info on load

This commit is contained in:
Florent Chehab 2020-05-11 15:28:14 +02:00
parent ce16a9d999
commit dbc7e8c2f9
No known key found for this signature in database
GPG Key ID: 9A0CE018889EA246
5 changed files with 39 additions and 18 deletions

View File

@ -9,9 +9,12 @@ backend:
whiteboardInfoBroadcastFreq: 1 whiteboardInfoBroadcastFreq: 1
frontend: frontend:
# When an editable whiteboard is loading in a client, # When a whiteboard is loading in a client
# should it be started in read-only mode. onWhiteboardLoad:
readOnlyOnWhiteboardLoad: false # should an (editable) whiteboard be started in read-only mode by default
setReadOnly: false
# should the whiteboard info be displayed by default
displayInfo: false
# Show smallest screen indicator # Show smallest screen indicator
showSmallestScreenIndicator: true showSmallestScreenIndicator: true
performance: performance:

View File

@ -30,10 +30,20 @@
"frontend": { "frontend": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"required": ["readOnlyOnWhiteboardLoad", "showSmallestScreenIndicator", "performance"], "required": ["onWhiteboardLoad", "showSmallestScreenIndicator", "performance"],
"properties": { "properties": {
"readOnlyOnWhiteboardLoad": { "onWhiteboardLoad": {
"type": "boolean" "type": "object",
"additionalProperties": false,
"required": ["displayInfo", "setReadOnly"],
"properties": {
"setReadOnly": {
"type": "boolean"
},
"displayInfo": {
"type": "boolean"
}
}
}, },
"showSmallestScreenIndicator": { "showSmallestScreenIndicator": {
"type": "boolean" "type": "boolean"

View File

@ -31,11 +31,11 @@ test("Complex object config override", () => {
test("Override default config", () => { test("Override default config", () => {
const defaultConfig = getDefaultConfig(); const defaultConfig = getDefaultConfig();
const overrideConfig1 = { frontend: { readOnlyOnWhiteboardLoad: true } }; const overrideConfig1 = { frontend: { onWhiteboardLoad: { setReadOnly: true } } };
expect(deepMergeConfigs(defaultConfig, overrideConfig1).frontend.readOnlyOnWhiteboardLoad).toBe( expect(
true deepMergeConfigs(defaultConfig, overrideConfig1).frontend.onWhiteboardLoad.setReadOnly
); ).toBe(true);
}); });
test("Dumb config is not valid", () => { test("Dumb config is not valid", () => {

View File

@ -603,10 +603,14 @@ function initWhiteboard() {
// fix bug cursor not showing up // fix bug cursor not showing up
whiteboard.refreshCursorAppearance(); whiteboard.refreshCursorAppearance();
if (process.env.NODE_ENV === "production" && ConfigService.readOnlyOnWhiteboardLoad) { if (process.env.NODE_ENV === "production") {
ReadOnlyService.activateReadOnlyMode(); if (ConfigService.readOnlyOnWhiteboardLoad) ReadOnlyService.activateReadOnlyMode();
InfoService.hideInfo(); else ReadOnlyService.deactivateReadOnlyMode();
if (ConfigService.displayInfoOnWhiteboardLoad) InfoService.displayInfo();
else InfoService.hideInfo();
} else { } else {
// in dev
ReadOnlyService.deactivateReadOnlyMode(); ReadOnlyService.deactivateReadOnlyMode();
InfoService.displayInfo(); InfoService.displayInfo();
} }

View File

@ -10,11 +10,15 @@ class ConfigService {
} }
/** /**
* @type {boolean} * @type {{displayInfo: boolean, setReadOnly: boolean}}
* @readonly
*/ */
#readOnlyOnWhiteboardLoad = false; #onWhiteboardLoad = { setReadOnly: false, displayInfo: false };
get readOnlyOnWhiteboardLoad() { get readOnlyOnWhiteboardLoad() {
return this.#readOnlyOnWhiteboardLoad; return this.#onWhiteboardLoad.setReadOnly;
}
get displayInfoOnWhiteboardLoad() {
return this.#onWhiteboardLoad.displayInfo;
} }
/** /**
@ -50,9 +54,9 @@ class ConfigService {
this.#configFromServer = configFromServer; this.#configFromServer = configFromServer;
const { common } = configFromServer; const { common } = configFromServer;
const { readOnlyOnWhiteboardLoad, showSmallestScreenIndicator, performance } = common; const { onWhiteboardLoad, showSmallestScreenIndicator, performance } = common;
this.#readOnlyOnWhiteboardLoad = readOnlyOnWhiteboardLoad; this.#onWhiteboardLoad = onWhiteboardLoad;
this.#showSmallestScreenIndicator = showSmallestScreenIndicator; this.#showSmallestScreenIndicator = showSmallestScreenIndicator;
this.#refreshInfoInterval = 1000 / performance.refreshInfoFreq; this.#refreshInfoInterval = 1000 / performance.refreshInfoFreq;