SDA-1859 - Hide menu items instead of disabling it

This commit is contained in:
Kiran Niranjan 2020-03-11 14:40:17 +05:30
parent 07a978c2da
commit 3e9b5ca49d
3 changed files with 8 additions and 51 deletions

View File

@ -304,8 +304,7 @@ export class AppMenu {
},
label: i18n.t('Auto Launch On Startup')(),
type: 'checkbox',
visible: !isLinux,
enabled: !launchOnStartupCC || launchOnStartupCC === CloudConfigDataTypes.NOT_SET,
visible: !isLinux && (!launchOnStartupCC || launchOnStartupCC === CloudConfigDataTypes.NOT_SET),
},
{
checked: isAlwaysOnTop === CloudConfigDataTypes.ENABLED,
@ -316,8 +315,7 @@ export class AppMenu {
},
label: i18n.t('Always on Top')(),
type: 'checkbox',
visible: !isLinux,
enabled: !isAlwaysOnTopCC || isAlwaysOnTopCC === CloudConfigDataTypes.NOT_SET,
visible: !isLinux && (!isAlwaysOnTopCC || isAlwaysOnTopCC === CloudConfigDataTypes.NOT_SET),
},
{
checked: minimizeOnClose === CloudConfigDataTypes.ENABLED,
@ -328,7 +326,7 @@ export class AppMenu {
},
label: i18n.t('Minimize on Close')(),
type: 'checkbox',
enabled: !minimizeOnCloseCC || minimizeOnCloseCC === CloudConfigDataTypes.NOT_SET,
visible: !minimizeOnCloseCC || minimizeOnCloseCC === CloudConfigDataTypes.NOT_SET,
},
{
checked: bringToFront === CloudConfigDataTypes.ENABLED,
@ -341,19 +339,18 @@ export class AppMenu {
? i18n.t('Flash Notification in Taskbar')()
: i18n.t('Bring to Front on Notifications')(),
type: 'checkbox',
enabled: !bringToFrontCC || bringToFrontCC === CloudConfigDataTypes.NOT_SET,
visible: !bringToFrontCC || bringToFrontCC === CloudConfigDataTypes.NOT_SET,
},
this.buildSeparator(),
{
label: (isCustomTitleBar === CloudConfigDataTypes.DISABLED || isCustomTitleBar === CloudConfigDataTypes.NOT_SET)
? i18n.t('Enable Hamburger menu')()
: i18n.t('Disable Hamburger menu')(),
visible: isWindowsOS,
click: () => {
titleBarChangeDialog(isCustomTitleBar === CloudConfigDataTypes.DISABLED ? CloudConfigDataTypes.ENABLED : CloudConfigDataTypes.DISABLED);
this.sendAnalytics(AnalyticsElements.MENU, MenuActionTypes.HAMBURGER_MENU, isCustomTitleBar === CloudConfigDataTypes.ENABLED);
},
enabled: !isCustomTitleBarCC || isCustomTitleBarCC === CloudConfigDataTypes.NOT_SET,
visible: isWindowsOS && (!isCustomTitleBarCC || isCustomTitleBarCC === CloudConfigDataTypes.NOT_SET),
},
{
checked: memoryRefresh === CloudConfigDataTypes.ENABLED,
@ -364,7 +361,7 @@ export class AppMenu {
},
label: i18n.t('Refresh app when idle')(),
type: 'checkbox',
enabled: !memoryRefreshCC || memoryRefreshCC === CloudConfigDataTypes.NOT_SET,
visible: !memoryRefreshCC || memoryRefreshCC === CloudConfigDataTypes.NOT_SET,
},
{
click: async (_item, focusedWindow) => {

View File

@ -7,7 +7,6 @@ import { buildNumber } from '../../package.json';
import { isDevEnv, isElectronQA, isLinux, isMac } from '../common/env';
import { logger } from '../common/logger';
import { filterOutSelectedValues, pick } from '../common/utils';
import { getDefaultUserConfig } from './config-utils';
const writeFile = util.promisify(fs.writeFile);
@ -307,8 +306,9 @@ class Config {
if (!fs.existsSync(this.userConfigPath)) {
// Need to wait until app ready event to access user data
await app.whenReady();
await this.readGlobalConfig();
logger.info(`config-handler: user config doesn't exist! will create new one and update config`);
await this.updateUserConfig({ configVersion: app.getVersion().toString(), buildNumber, ...getDefaultUserConfig() } as IConfig);
await this.updateUserConfig({ configVersion: app.getVersion().toString(), buildNumber, ...this.globalConfig } as IConfig);
}
this.userConfig = this.parseConfigData(fs.readFileSync(this.userConfigPath, 'utf8'));
logger.info(`config-handler: User configuration: `, this.userConfig);

View File

@ -1,40 +0,0 @@
/**
* Returns the default user config data
*/
import { CloudConfigDataTypes, IConfig } from './config-handler';
export const getDefaultUserConfig = (): IConfig => {
return {
minimizeOnClose: CloudConfigDataTypes.ENABLED,
launchOnStartup: CloudConfigDataTypes.ENABLED,
alwaysOnTop: CloudConfigDataTypes.DISABLED,
bringToFront: CloudConfigDataTypes.DISABLED,
whitelistUrl: '*',
isCustomTitleBar: CloudConfigDataTypes.ENABLED,
memoryRefresh: CloudConfigDataTypes.ENABLED,
memoryThreshold: '800',
disableGpu: false,
devToolsEnabled: true,
ctWhitelist: [],
podWhitelist: [],
notificationSettings: {
position: 'upper-right',
display: '',
},
customFlags: {
authServerWhitelist: '',
authNegotiateDelegateWhitelist: '',
disableThrottling: false,
},
permissions: {
media: true,
geolocation: true,
notifications: true,
midiSysex: true,
pointerLock: true,
fullscreen: true,
openExternal: true,
},
autoLaunchPath: '',
};
};