SDA-4288_main: Allow / Disallow user edit pod url via config

This commit is contained in:
NguyenTranHoangSym 2023-09-11 17:05:53 +07:00
parent 21f183613e
commit be50ab8d5a
7 changed files with 83 additions and 4 deletions

View File

@ -3,6 +3,7 @@
"autoUpdateUrl": "", "autoUpdateUrl": "",
"autoUpdateChannel": "latest", "autoUpdateChannel": "latest",
"isAutoUpdateEnabled": true, "isAutoUpdateEnabled": true,
"isPodUrlEditable": true,
"forceAutoUpdate": false, "forceAutoUpdate": false,
"autoUpdateCheckInterval": "30", "autoUpdateCheckInterval": "30",
"enableBrowserLogin": false, "enableBrowserLogin": false,

View File

@ -50,6 +50,11 @@ force_auto_update=$(sed -n '10p' ${settingsFilePath});
if [ "$force_auto_update" = "" ]; then force_auto_update=false; fi if [ "$force_auto_update" = "" ]; then force_auto_update=false; fi
sed -i "" -E "s#\"forceAutoUpdate\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"forceAutoUpdate\":\ $force_auto_update#g" "${newPath}" sed -i "" -E "s#\"forceAutoUpdate\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"forceAutoUpdate\":\ $force_auto_update#g" "${newPath}"
## Add settings is pod url editable
is_pod_url_editable=$(sed -n '11p' ${settingsFilePath});
if [ "$is_pod_url_editable" = "" ]; then is_pod_url_editable=true; fi
sed -i "" -E "s#\"isPodUrlEditable\" ?: ?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])#\"isPodUrlEditable\":\ $is_pod_url_editable#g" "${newPath}"
## Get Symphony Permissions from the temp file ## ## Get Symphony Permissions from the temp file ##
media=$(sed -n '1p' ${permissionsFilePath}); media=$(sed -n '1p' ${permissionsFilePath});
geo_location=$(sed -n '2p' ${permissionsFilePath}); geo_location=$(sed -n '2p' ${permissionsFilePath});

View File

@ -161,6 +161,7 @@ class Script
new PublicProperty("ENABLE_BROWSER_LOGIN", "false"), new PublicProperty("ENABLE_BROWSER_LOGIN", "false"),
new PublicProperty("BROWSER_LOGIN_AUTOCONNECT", "false"), new PublicProperty("BROWSER_LOGIN_AUTOCONNECT", "false"),
new PublicProperty("FORCE_AUTO_UPDATE","false"), new PublicProperty("FORCE_AUTO_UPDATE","false"),
new PublicProperty("IS_POD_URL_EDITABLE","true"),
new PublicProperty("CHROME_FLAGS", ""), new PublicProperty("CHROME_FLAGS", ""),
new Property("MSIINSTALLPERUSER", "1"), new Property("MSIINSTALLPERUSER", "1"),
new Property("PROGRAMSFOLDER", System.Environment.ExpandEnvironmentVariables(@"%PROGRAMFILES%")) new Property("PROGRAMSFOLDER", System.Environment.ExpandEnvironmentVariables(@"%PROGRAMFILES%"))
@ -189,7 +190,7 @@ class Script
new ElevatedManagedAction(CustomActions.UpdateConfig, Return.check, When.After, Step.InstallFiles, Condition.NOT_BeingRemoved ) new ElevatedManagedAction(CustomActions.UpdateConfig, Return.check, When.After, Step.InstallFiles, Condition.NOT_BeingRemoved )
{ {
// The UpdateConfig action needs the built-in property INSTALLDIR as well as most of the custom properties // The UpdateConfig action needs the built-in property INSTALLDIR as well as most of the custom properties
UsesProperties = "INSTALLDIR,POD_URL,CONTEXT_ORIGIN_URL,MINIMIZE_ON_CLOSE,ALWAYS_ON_TOP,AUTO_START,BRING_TO_FRONT,MEDIA,LOCATION,NOTIFICATIONS,MIDI_SYSEX,POINTER_LOCK,FULL_SCREEN,OPEN_EXTERNAL,CUSTOM_TITLE_BAR,DEV_TOOLS_ENABLED,AUTO_LAUNCH_PATH,USER_DATA_PATH,OVERRIDE_USER_AGENT,CHROME_FLAGS,ENABLE_BROWSER_LOGIN,BROWSER_LOGIN_AUTOCONNECT,FORCE_AUTO_UPDATE" UsesProperties = "INSTALLDIR,POD_URL,CONTEXT_ORIGIN_URL,MINIMIZE_ON_CLOSE,ALWAYS_ON_TOP,AUTO_START,BRING_TO_FRONT,MEDIA,LOCATION,NOTIFICATIONS,MIDI_SYSEX,POINTER_LOCK,FULL_SCREEN,OPEN_EXTERNAL,CUSTOM_TITLE_BAR,DEV_TOOLS_ENABLED,AUTO_LAUNCH_PATH,USER_DATA_PATH,OVERRIDE_USER_AGENT,CHROME_FLAGS,ENABLE_BROWSER_LOGIN,BROWSER_LOGIN_AUTOCONNECT,FORCE_AUTO_UPDATE,IS_POD_URL_EDITABLE"
}, },
// CleanRegistry // CleanRegistry
@ -366,6 +367,7 @@ public class CustomActions
data = ReplaceBooleanProperty(data, "enableBrowserLogin", session.Property("ENABLE_BROWSER_LOGIN")); data = ReplaceBooleanProperty(data, "enableBrowserLogin", session.Property("ENABLE_BROWSER_LOGIN"));
data = ReplaceBooleanProperty(data, "browserLoginAutoConnect", session.Property("BROWSER_LOGIN_AUTOCONNECT")); data = ReplaceBooleanProperty(data, "browserLoginAutoConnect", session.Property("BROWSER_LOGIN_AUTOCONNECT"));
data = ReplaceBooleanProperty(data, "forceAutoUpdate", session.Property("FORCE_AUTO_UPDATE")); data = ReplaceBooleanProperty(data, "forceAutoUpdate", session.Property("FORCE_AUTO_UPDATE"));
data = ReplaceBooleanProperty(data, "isPodUrlEditable", session.Property("IS_POD_URL_EDITABLE"));
// Write the contents back to the file // Write the contents back to the file
System.IO.File.WriteAllText(filename, data); System.IO.File.WriteAllText(filename, data);
} }

View File

@ -579,6 +579,19 @@ Expected values:
* "false" * "false"
Will also consider PMP settings Will also consider PMP settings
-------------------------------------------------------------------
### IS_POD_URL_EDITABLE
Allow user to edit the POD via triple click on url at 'About Us'
By default its value will be 'true'
Expected values:
* "true"
Allow user to edit pod url
* "false"
Prevent user from editing pod url
#### Example, install with browser login autoconnect enabled #### Example, install with browser login autoconnect enabled
msiexec /i Symphony.msi BROWSER_LOGIN_AUTOCONNECT="true" msiexec /i Symphony.msi BROWSER_LOGIN_AUTOCONNECT="true"
@ -597,3 +610,10 @@ or
or or
msiexec /i Symphony.msi msiexec /i Symphony.msi
This equals to msiexec /i Symphony.msi FORCE_AUTO_UPDATE="false" This equals to msiexec /i Symphony.msi FORCE_AUTO_UPDATE="false"
#### Example, install with pod url not editable
msiexec /i Symphony.msi IS_POD_URL_EDITABLE="false"
or
msiexec /i Symphony.msi
This equals to msiexec /i Symphony.msi IS_POD_URL_EDITABLE="true"

View File

@ -9,7 +9,7 @@ describe('about app', () => {
const aboutDataMock = { const aboutDataMock = {
sbeVersion: '1', sbeVersion: '1',
userConfig: {}, userConfig: {},
globalConfig: {}, globalConfig: { isPodUrlEditable: true },
cloudConfig: {}, cloudConfig: {},
finalConfig: {}, finalConfig: {},
appName: 'Symphony', appName: 'Symphony',
@ -88,4 +88,52 @@ describe('about app', () => {
const podInput = wrapper.find('.AboutApp-pod-input'); const podInput = wrapper.find('.AboutApp-pod-input');
expect(podInput.exists()).toEqual(true); expect(podInput.exists()).toEqual(true);
}); });
it('should not display input when triple clicked on pod', () => {
const cloneAboutDataMock = aboutDataMock;
cloneAboutDataMock.globalConfig = { isPodUrlEditable: false };
cloneAboutDataMock.userConfig = { isPodUrlEditable: true };
const wrapper = shallow(React.createElement(AboutApp));
ipcRenderer.send('about-app-data', cloneAboutDataMock);
const pod = wrapper.find(`[data-testid="POD_INFO"]`);
pod.simulate('click', { detail: 1 });
pod.simulate('click', { detail: 2 });
pod.simulate('click', { detail: 3 });
const podInput = wrapper.find('.AboutApp-pod-input');
expect(podInput.exists()).toEqual(false);
});
it('should not display config based on global config only', () => {
const cloneAboutDataMock = aboutDataMock;
cloneAboutDataMock.globalConfig = { isPodUrlEditable: false };
cloneAboutDataMock.userConfig = { isPodUrlEditable: false };
const wrapper = shallow(React.createElement(AboutApp));
ipcRenderer.send('about-app-data', cloneAboutDataMock);
const pod = wrapper.find(`[data-testid="POD_INFO"]`);
pod.simulate('click', { detail: 1 });
pod.simulate('click', { detail: 2 });
pod.simulate('click', { detail: 3 });
const podInput = wrapper.find('.AboutApp-pod-input');
expect(podInput.exists()).toEqual(false);
});
it('should display config based on global config only', () => {
const cloneAboutDataMock = aboutDataMock;
cloneAboutDataMock.globalConfig = { isPodUrlEditable: true };
cloneAboutDataMock.userConfig = { isPodUrlEditable: false };
const wrapper = shallow(React.createElement(AboutApp));
ipcRenderer.send('about-app-data', cloneAboutDataMock);
const pod = wrapper.find(`[data-testid="POD_INFO"]`);
pod.simulate('click', { detail: 1 });
pod.simulate('click', { detail: 2 });
pod.simulate('click', { detail: 3 });
const podInput = wrapper.find('.AboutApp-pod-input');
expect(podInput.exists()).toEqual(true);
});
}); });

View File

@ -62,6 +62,7 @@ export interface IConfig {
browserLoginAutoConnect?: boolean; browserLoginAutoConnect?: boolean;
betaAutoUpdateChannelEnabled?: boolean; betaAutoUpdateChannelEnabled?: boolean;
forceAutoUpdate?: boolean; forceAutoUpdate?: boolean;
isPodUrlEditable?: boolean;
} }
export interface IGlobalConfig { export interface IGlobalConfig {

View File

@ -2,6 +2,7 @@ import classNames from 'classnames';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import * as React from 'react'; import * as React from 'react';
import { productName } from '../../../package.json'; import { productName } from '../../../package.json';
import { IConfig } from '../../app/config-handler';
import { apiCmds, apiName } from '../../common/api-interface'; import { apiCmds, apiName } from '../../common/api-interface';
import { i18n } from '../../common/i18n-preload'; import { i18n } from '../../common/i18n-preload';
import * as CopyIcon from '../../renderer/assets/copy-icon.svg'; import * as CopyIcon from '../../renderer/assets/copy-icon.svg';
@ -250,8 +251,9 @@ export default class AboutApp extends React.Component<{}, IState> {
public onPodClick(e): void { public onPodClick(e): void {
if (e.detail === 3) { if (e.detail === 3) {
this.setState({ this.setState({
isPodEditing: true, isPodEditing: !!(this.state.globalConfig as IConfig)?.isPodUrlEditable,
didUpdateHostname: true, didUpdateHostname: !!(this.state.globalConfig as IConfig)
?.isPodUrlEditable,
}); });
} }
} }