diff --git a/ui/desktop/app/routes/application.js b/ui/desktop/app/routes/application.js index c80f5873e..66790a728 100644 --- a/ui/desktop/app/routes/application.js +++ b/ui/desktop/app/routes/application.js @@ -46,7 +46,7 @@ export default class ApplicationRoute extends Route { /** * Add OS config on controller */ - async setupController(controller, ...args) { + async setupController(controller) { controller.set('isMacOS', await this.ipc.invoke('isMacOS')); controller.set('isWindowsOS', await this.ipc.invoke('isWindowsOS')); } diff --git a/ui/desktop/app/styles/app.scss b/ui/desktop/app/styles/app.scss index 4cf316805..0e74f0a64 100644 --- a/ui/desktop/app/styles/app.scss +++ b/ui/desktop/app/styles/app.scss @@ -141,11 +141,12 @@ .rose-header { -webkit-app-region: drag; - -webkit-user-select: none; min-height: sizing.rems(l) * 2; position: relative; + -webkit-user-select: none; - .rose-header-brand, .rose-header-nav, + .rose-header-brand, + .rose-header-nav, .rose-header-utilities .rose-dropdown, .rose-header-utilities button { -webkit-app-region: no-drag; diff --git a/ui/desktop/app/templates/application.hbs b/ui/desktop/app/templates/application.hbs index c57d7a85f..2bdaa0da2 100644 --- a/ui/desktop/app/templates/application.hbs +++ b/ui/desktop/app/templates/application.hbs @@ -1,9 +1,16 @@ {{page-title (app-name)}} - + - + {{#if this.session.isAuthenticated}} @@ -14,13 +21,19 @@ {{#if this.isWindowsOS}} - - - diff --git a/ui/desktop/electron-app/src/index.js b/ui/desktop/electron-app/src/index.js index 3e84acb11..1c9c7f6e2 100644 --- a/ui/desktop/electron-app/src/index.js +++ b/ui/desktop/electron-app/src/index.js @@ -199,17 +199,6 @@ app.on('before-quit', (event) => { const buttonId = dialog.showMessageBoxSync(null, dialogOpts); buttonId === 0 ? sessionManager.stopAll() : event.preventDefault(); - - // console.log(returnValue.response); - // switch (returnValue.response) { - // case 0: - // sessionManager.stopAll(); - // break; - // default: - // event.preventDefault(); - // break; - // } - // }); } }); diff --git a/ui/desktop/tests/acceptance/authentication-test.js b/ui/desktop/tests/acceptance/authentication-test.js index 514d1d2b7..c030a22c3 100644 --- a/ui/desktop/tests/acceptance/authentication-test.js +++ b/ui/desktop/tests/acceptance/authentication-test.js @@ -19,14 +19,12 @@ import { authenticateSession, invalidateSession, } from 'ember-simple-auth/test-support'; +import WindowMockIPC from '../helpers/window-mock-ipc'; module('Acceptance | authentication', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - let mockIPC; - let messageHandler; - const instances = { scopes: { global: null, @@ -102,41 +100,11 @@ module('Acceptance | authentication', function (hooks) { urls.targets = `${urls.projects}/targets`; urls.sessions = `${urls.projects}/sessions`; - class MockIPC { - origin = null; - - invoke(method, payload) { - return this[method](payload); - } - - getOrigin() { - return this.origin; - } - - setOrigin(origin) { - this.origin = origin; - return this.origin; - } - } - - mockIPC = new MockIPC(); - messageHandler = async function (event) { - if (event.origin !== window.location.origin) return; - const { method, payload } = event.data; - if (method) { - const response = await mockIPC.invoke(method, payload); - event.ports[0].postMessage(response); - } - }; - - window.addEventListener('message', messageHandler); + // Mock the postMessage interface used by IPC. + this.owner.register('service:browser/window', WindowMockIPC); setDefaultOrigin(this); }); - hooks.afterEach(function () { - window.removeEventListener('message', messageHandler); - }); - test('visiting index while unauthenticated redirects to global authenticate method', async function (assert) { assert.expect(2); await visit(urls.index); diff --git a/ui/desktop/tests/acceptance/projects-test.js b/ui/desktop/tests/acceptance/projects-test.js index d7978c12f..38d54b480 100644 --- a/ui/desktop/tests/acceptance/projects-test.js +++ b/ui/desktop/tests/acceptance/projects-test.js @@ -18,14 +18,12 @@ import { authenticateSession, invalidateSession, } from 'ember-simple-auth/test-support'; +import WindowMockIPC from '../helpers/window-mock-ipc'; module('Acceptance | projects', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - let mockIPC; - let messageHandler; - const instances = { scopes: { global: null, @@ -103,41 +101,11 @@ module('Acceptance | projects', function (hooks) { urls.authenticate.methods.global = `${urls.authenticate.global}/${instances.authMethods.global.id}`; urls.projects = `${urls.scopes.org}/projects`; - class MockIPC { - origin = null; - - invoke(method, payload) { - return this[method](payload); - } - - getOrigin() { - return this.origin; - } - - setOrigin(origin) { - this.origin = origin; - return this.origin; - } - } - - mockIPC = new MockIPC(); - messageHandler = async function (event) { - if (event.origin !== window.location.origin) return; - const { method, payload } = event.data; - if (method) { - const response = await mockIPC.invoke(method, payload); - event.ports[0].postMessage(response); - } - }; - - window.addEventListener('message', messageHandler); + // Mock the postMessage interface used by IPC. + this.owner.register('service:browser/window', WindowMockIPC); setDefaultOrigin(this); }); - hooks.afterEach(function () { - window.removeEventListener('message', messageHandler); - }); - test('visiting index while unauthenticated redirects to global authenticate method', async function (assert) { invalidateSession(); assert.expect(2); diff --git a/ui/desktop/tests/acceptance/targets-test.js b/ui/desktop/tests/acceptance/targets-test.js index 9d735dbb1..85881b7ec 100644 --- a/ui/desktop/tests/acceptance/targets-test.js +++ b/ui/desktop/tests/acceptance/targets-test.js @@ -19,14 +19,12 @@ import { authenticateSession, invalidateSession, } from 'ember-simple-auth/test-support'; +import WindowMockIPC from '../helpers/window-mock-ipc'; module('Acceptance | targets', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - let mockIPC; - let messageHandler; - const instances = { scopes: { global: null, @@ -106,41 +104,11 @@ module('Acceptance | targets', function (hooks) { urls.projects = `${urls.scopes.org}/projects`; urls.targets = `${urls.projects}/targets`; - class MockIPC { - origin = null; - - invoke(method, payload) { - return this[method](payload); - } - - getOrigin() { - return this.origin; - } - - setOrigin(origin) { - this.origin = origin; - return this.origin; - } - } - - mockIPC = new MockIPC(); - messageHandler = async function (event) { - if (event.origin !== window.location.origin) return; - const { method, payload } = event.data; - if (method) { - const response = await mockIPC.invoke(method, payload); - event.ports[0].postMessage(response); - } - }; - - window.addEventListener('message', messageHandler); + // Mock the postMessage interface used by IPC. + this.owner.register('service:browser/window', WindowMockIPC); setDefaultOrigin(this); }); - hooks.afterEach(function () { - window.removeEventListener('message', messageHandler); - }); - test('visiting index while unauthenticated redirects to global authenticate method', async function (assert) { invalidateSession(); assert.expect(2); diff --git a/ui/desktop/tests/helpers/window-mock-ipc.js b/ui/desktop/tests/helpers/window-mock-ipc.js index 9d191d87a..18195accb 100644 --- a/ui/desktop/tests/helpers/window-mock-ipc.js +++ b/ui/desktop/tests/helpers/window-mock-ipc.js @@ -17,6 +17,8 @@ class MockIPC { } resetOrigin() {} + isMacOS() {} + isWindowsOS() {} } /**