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
frontend:
# When an editable whiteboard is loading in a client,
# should it be started in read-only mode.
readOnlyOnWhiteboardLoad: false
# When a whiteboard is loading in a client
onWhiteboardLoad:
# 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
showSmallestScreenIndicator: true
performance:

View File

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

View File

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

View File

@ -603,10 +603,14 @@ function initWhiteboard() {
// fix bug cursor not showing up
whiteboard.refreshCursorAppearance();
if (process.env.NODE_ENV === "production" && ConfigService.readOnlyOnWhiteboardLoad) {
ReadOnlyService.activateReadOnlyMode();
InfoService.hideInfo();
if (process.env.NODE_ENV === "production") {
if (ConfigService.readOnlyOnWhiteboardLoad) ReadOnlyService.activateReadOnlyMode();
else ReadOnlyService.deactivateReadOnlyMode();
if (ConfigService.displayInfoOnWhiteboardLoad) InfoService.displayInfo();
else InfoService.hideInfo();
} else {
// in dev
ReadOnlyService.deactivateReadOnlyMode();
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() {
return this.#readOnlyOnWhiteboardLoad;
return this.#onWhiteboardLoad.setReadOnly;
}
get displayInfoOnWhiteboardLoad() {
return this.#onWhiteboardLoad.displayInfo;
}
/**
@ -50,9 +54,9 @@ class ConfigService {
this.#configFromServer = configFromServer;
const { common } = configFromServer;
const { readOnlyOnWhiteboardLoad, showSmallestScreenIndicator, performance } = common;
const { onWhiteboardLoad, showSmallestScreenIndicator, performance } = common;
this.#readOnlyOnWhiteboardLoad = readOnlyOnWhiteboardLoad;
this.#onWhiteboardLoad = onWhiteboardLoad;
this.#showSmallestScreenIndicator = showSmallestScreenIndicator;
this.#refreshInfoInterval = 1000 / performance.refreshInfoFreq;