diff --git a/addons/api/mirage/scenarios/ipc.js b/addons/api/mirage/scenarios/ipc.js index e10ef7508..36846194d 100644 --- a/addons/api/mirage/scenarios/ipc.js +++ b/addons/api/mirage/scenarios/ipc.js @@ -120,17 +120,17 @@ export default function initializeMockIPC(server) { } /** - * Check for browsers running on mac OS + * Check for window chrome on MacOS */ - isMacOS() { - return Boolean(window.navigator.userAgent.match(/(macintosh)/i)); + hasMacOSChrome() { + return false; } /** - * Check for OS frame + * Check for OS chrome state */ - isFrameless() { - return true; + isWindowChromeless() { + return false; } /** diff --git a/ui/desktop/README.md b/ui/desktop/README.md index 2751287f2..d2d754eed 100644 --- a/ui/desktop/README.md +++ b/ui/desktop/README.md @@ -78,7 +78,7 @@ These environment variables may be used to customized the build. | `APP_UPDATER_LATEST_VERSION_TAG` | Next version for comparison with current version. | | `APP_UPDATER_LATEST_VERSION_LOCATION` | Location of app release to use for updating client. Can be a filepath or url. | | `BYPASS_CLI_SETUP` | Disable download and extraction of cli. For development use only. | -| `BYPASS_OS_SHELL` | Disable OS shell with window actions. For internal use only. | +| `DISABLE_WINDOW_CHROME` | Disable window chrome. For internal use only. | ### Building for Production diff --git a/ui/desktop/app/controllers/application.js b/ui/desktop/app/controllers/application.js index 8d9c53da5..0eb5226e0 100644 --- a/ui/desktop/app/controllers/application.js +++ b/ui/desktop/app/controllers/application.js @@ -1,7 +1,6 @@ import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; import config from '../config/environment'; -import { computed } from '@ember/object'; export default class ApplicationController extends Controller { // =services @@ -11,15 +10,4 @@ export default class ApplicationController extends Controller { // =attributes notifyTimeout = config.notifyTimeout; - - // =attributes - - /** - * Check for MacOS frame - * @type {boolean} - */ - @computed('isMacOS', 'isFrameless') - get isFrameMacOS() { - return this.isMacOS && !this.isFrameless; - } } diff --git a/ui/desktop/app/routes/application.js b/ui/desktop/app/routes/application.js index 55bae783d..20719a9d3 100644 --- a/ui/desktop/app/routes/application.js +++ b/ui/desktop/app/routes/application.js @@ -34,8 +34,11 @@ export default class ApplicationRoute extends Route { * Add window frame config on controller. */ async setupController(controller) { - controller.set('isMacOS', await this.ipc.invoke('isMacOS')); - controller.set('isFrameless', await this.ipc.invoke('isFrameless')); + controller.set('hasMacOSChrome', await this.ipc.invoke('hasMacOSChrome')); + controller.set( + 'isWindowChromeless', + await this.ipc.invoke('isWindowChromeless') + ); } // =actions diff --git a/ui/desktop/app/templates/application.hbs b/ui/desktop/app/templates/application.hbs index e4cf86c72..c57622e33 100644 --- a/ui/desktop/app/templates/application.hbs +++ b/ui/desktop/app/templates/application.hbs @@ -1,14 +1,14 @@ {{page-title (app-name)}} @@ -19,7 +19,7 @@ {{/if}} - {{#if this.isFrameless}} + {{#if this.isWindowChromeless}} { Menu.setApplicationMenu(menuTemplate); /** - * Enable electron OS frame for MacOS only. - * Disable frame regardless of OS using `BYPASS_OS_SHELL` + * Enable electron OS window frame/chrome for MacOS only. + * Disable frame/chrome regardless of OS when `DISABLE_WINDOW_CHROME` is set. */ - let showFrame = isMac(); - if (process.env.BYPASS_OS_SHELL) showFrame = false; + let showWindowChrome = isMac(); + if (process.env.DISABLE_WINDOW_CHROME) showWindowChrome = false; const browserWindowOptions = { width: 1280, height: 760, - frame: showFrame, - titleBarStyle: showFrame ? 'hiddenInset' : 'none', + frame: showWindowChrome, + titleBarStyle: showWindowChrome ? 'hiddenInset' : 'none', webPreferences: { partition, sandbox: true, diff --git a/ui/desktop/electron-app/src/ipc/handlers.js b/ui/desktop/electron-app/src/ipc/handlers.js index c5e795e99..02780d834 100644 --- a/ui/desktop/electron-app/src/ipc/handlers.js +++ b/ui/desktop/electron-app/src/ipc/handlers.js @@ -69,16 +69,18 @@ handle('connect', ({ target_id, token, host_id }) => handle('stop', ({ session_id }) => sessionManager.stopById(session_id)); /** - * Check for frameless window state. Only MacOS uses default OS frame. - * Frameless window disables OS window actions (minimize, fullscreen, close). - * Enable `BYPASS_OS_SHELL` to bypass OS verification for frame. + * Check frame/chrome state. Only enabled on non-MacOS. */ -handle('isFrameless', () => !isMac() || process.env.BYPASS_OS_SHELL); +handle('isWindowChromeless', () => + process.env.DISABLE_WINDOW_CHROME ? false : !isMac() +); /** - * Check for MacOS + * Check for MacOS chrome */ -handle('isMacOS', () => isMac()); +handle('hasMacOSChrome', () => + process.env.DISABLE_WINDOW_CHROME ? false : isMac() +); /** * Minimize window diff --git a/ui/desktop/tests/acceptance/application-test.js b/ui/desktop/tests/acceptance/application-test.js index 4f9cabdee..bb0431529 100644 --- a/ui/desktop/tests/acceptance/application-test.js +++ b/ui/desktop/tests/acceptance/application-test.js @@ -47,31 +47,41 @@ module('Acceptance | origin', function (hooks) { sinon.restore(); }); - test('visiting index on MacOS hides custom window actions', async function (assert) { - assert.expect(4); - stubs.ipcService.withArgs('isMacOS').returns(true); - stubs.ipcService.withArgs('isFrameless').returns(false); + test('visiting index with chrome disabled hides custom window actions', async function (assert) { + assert.expect(3); + stubs.ipcService.withArgs('isWindowChromeless').returns(false); await visit(urls.origin); assert.notOk(find('.button-window-close'), 'Window close button'); assert.notOk(find('.button-window-minimize'), 'Window minimize button'); assert.notOk(find('.button-window-fullscreen'), 'Window fullscreen button'); + }); + + test('visiting index with chrome enabled shows custom window actions', async function (assert) { + assert.expect(3); + stubs.ipcService.withArgs('isWindowChromeless').returns(true); + await visit(urls.origin); + assert.ok(find('.button-window-close'), 'Window close button'); + assert.ok(find('.button-window-minimize'), 'Window minimize button'); + assert.ok(find('.button-window-fullscreen'), 'Window fullscreen button'); + }); + + test('visiting index with MacOS chrome enabled', async function (assert) { + assert.expect(1); + stubs.ipcService.withArgs('hasMacOSChrome').returns(true); + await visit(urls.origin); assert.ok( find('.rose-header.header-cushion'), 'Adds header padding around native window actions' ); }); - test('visiting index on non-MacOS shows custom window actions', async function (assert) { - assert.expect(4); - stubs.ipcService.withArgs('isMacOS').returns(false); - stubs.ipcService.withArgs('isFrameless').returns(true); + test('visiting index with MacOS chrome disabled', async function (assert) { + assert.expect(1); + stubs.ipcService.withArgs('hasMacOSChrome').returns(false); await visit(urls.origin); - assert.ok(find('.button-window-close'), 'Window close button'); - assert.ok(find('.button-window-minimize'), 'Window minimize button'); - assert.ok(find('.button-window-fullscreen'), 'Window fullscreen button'); assert.notOk( find('.rose-header.header-cushion'), - 'Disables header padding around native window actions' + 'Does not add header padding around native window actions' ); }); }); diff --git a/ui/desktop/tests/helpers/window-mock-ipc.js b/ui/desktop/tests/helpers/window-mock-ipc.js index bb9214b15..22910f249 100644 --- a/ui/desktop/tests/helpers/window-mock-ipc.js +++ b/ui/desktop/tests/helpers/window-mock-ipc.js @@ -17,8 +17,8 @@ class MockIPC { } resetOrigin() {} - isMacOS() {} - isFrameless() {} + hasMacOSChrome() {} + isWindowChromeless() {} } /**