Merge branch 'main' into chore-update-electron-minor-version

This commit is contained in:
Carlos Alcaide Corvo authored and GitHub committed 2021-09-28 16:51:45 +02:00
commit 9db7b4d88b
13 files changed
+85 -75

No files matched your search

+6 -6
View File
@@ -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 browsers running on windows OS
* Check for OS chrome state
*/
isWindowsOS() {
return Boolean(window.navigator.userAgent.match(/(windows)/i));
showWindowActions() {
return true;
}
/**
+2 -1
View File
@@ -80,7 +80,8 @@
"path-parse": "^1.0.7",
"nth-check": "^2.0.1",
"tmpl": "^1.0.5",
"set-value": "^4.0.1"
"set-value": "^4.0.1",
"ansi-regex": "^5.0.1"
},
"config": {
"commitizen": {
+1
View File
@@ -89,6 +89,7 @@ These environment variables may be used to customized the build.
| `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_APP_UPDATER` | Disable app updater feature. For development use only. |
| `DISABLE_WINDOW_CHROME` | Disable window chrome. For internal use only. |
### Building for Production
-14
View File
@@ -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,17 +10,4 @@ export default class ApplicationController extends Controller {
// =attributes
notifyTimeout = config.notifyTimeout;
// =attributes
/**
* Display OS window actions (minimize, fullscreen, close) for
* Windows and Linux as OS frame/shell is disable.
* Does not apply to MacOS.
* @type {boolean}
*/
@computed('isMacOS')
get isFrameless() {
return !this.isMacOS;
}
}
+6 -2
View File
@@ -31,10 +31,14 @@ export default class ApplicationRoute extends Route {
}
/**
* Add OS config on controller.
* Add window frame config on controller.
*/
async setupController(controller) {
controller.set('isMacOS', await this.ipc.invoke('isMacOS'));
controller.set('hasMacOSChrome', await this.ipc.invoke('hasMacOSChrome'));
controller.set(
'showWindowActions',
await this.ipc.invoke('showWindowActions')
);
}
// =actions
+3 -3
View File
@@ -1,14 +1,14 @@
{{page-title (app-name)}}
<Rose::Layout::Global
class='{{if this.isFrameless ' layout-scroll'}}'
class='{{if this.showWindowActions ' layout-scroll'}}'
as |layout|
>
<layout.header>
<Rose::Header
class='{{if (is-loading) ' loading'}}
{{if this.isMacOS ' header-cushion'}}'
{{if this.hasMacOSChrome ' header-cushion'}}'
as |header|
>
<header.brand @logo='logo-app' @text={{app-name}} />
@@ -19,7 +19,7 @@
{{/if}}
<header.utilities as |utilities|>
{{#if this.isFrameless}}
{{#if this.showWindowActions}}
<Rose::Button
@iconOnly='flight-icons/svg/x-16'
@style='warning'
+2 -1
View File
@@ -48,6 +48,7 @@
"normalize-url": "^4.5.1",
"jszip": "^3.7.0",
"path-parse": "^1.0.7",
"tar": "^6.1.9"
"tar": "^6.1.9",
"ansi-regex": "^5.0.1"
}
}
+10 -2
View File
@@ -113,11 +113,19 @@ app.on('ready', async () => {
}
Menu.setApplicationMenu(menuTemplate);
/**
* Enable electron OS window frame/chrome for MacOS only.
* Disable frame/chrome regardless of OS when
* `DISABLE_WINDOW_CHROME=true`.
*/
let showWindowChrome = isMac();
if (process.env.DISABLE_WINDOW_CHROME) showWindowChrome = false;
const browserWindowOptions = {
width: 1280,
height: 760,
titleBarStyle: 'hiddenInset',
frame: isMac(),
frame: showWindowChrome,
titleBarStyle: showWindowChrome ? 'hiddenInset' : 'none',
webPreferences: {
partition,
sandbox: true,
+15 -2
View File
@@ -69,9 +69,22 @@ handle('connect', ({ target_id, token, host_id }) =>
handle('stop', ({ session_id }) => sessionManager.stopById(session_id));
/**
* Check for MacOS OS
* Check for OS window chrome. Enabled on MacOS only.
* Window chrome is disabled regardless of platform for
* `DISABLE_WINDOW_CHROME=true`.
*/
handle('isMacOS', () => isMac());
handle('hasMacOSChrome', () =>
process.env.DISABLE_WINDOW_CHROME ? false : isMac()
);
/**
* Show window actions for non-MacOS platforms.
* Window actions are disabled regardless of platform for
* `DISABLE_WINDOW_CHROME=true`.
*/
handle('showWindowActions', () =>
process.env.DISABLE_WINDOW_CHROME ? false : !isMac()
);
/**
* Minimize window
+4 -14
View File
@@ -416,20 +416,10 @@ ansi-escapes@^4.2.1:
dependencies:
type-fest "^0.21.3"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8=
ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=
ansi-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
ansi-regex@^2.0.0, ansi-regex@^3.0.0, ansi-regex@^5.0.0, ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.3.0"
+30 -10
View File
@@ -47,21 +47,41 @@ module('Acceptance | origin', function (hooks) {
sinon.restore();
});
test('visiting index on MacOS hides custom window actions', async function (assert) {
test('visiting index with chrome disabled hides custom window actions', async function (assert) {
assert.expect(3);
stubs.ipcService.withArgs('isMacOS').returns(true);
stubs.ipcService.withArgs('showWindowActions').returns(false);
await visit(urls.origin);
assert.notOk(find('.button-window-close'));
assert.notOk(find('.button-window-minimize'));
assert.notOk(find('.button-window-fullscreen'));
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 on non-MacOS shows custom window actions', async function (assert) {
test('visiting index with chrome enabled shows custom window actions', async function (assert) {
assert.expect(3);
stubs.ipcService.withArgs('isMacOS').returns(false);
stubs.ipcService.withArgs('showWindowActions').returns(true);
await visit(urls.origin);
assert.ok(find('.button-window-close'));
assert.ok(find('.button-window-minimize'));
assert.ok(find('.button-window-fullscreen'));
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 with MacOS chrome disabled', async function (assert) {
assert.expect(1);
stubs.ipcService.withArgs('hasMacOSChrome').returns(false);
await visit(urls.origin);
assert.notOk(
find('.rose-header.header-cushion'),
'Does not add header padding around native window actions'
);
});
});
+2 -1
View File
@@ -17,7 +17,8 @@ class MockIPC {
}
resetOrigin() {}
isMacOS() {}
hasMacOSChrome() {}
showWindowActions() {}
}
/**
+4 -19
View File
@@ -4179,25 +4179,10 @@ ansi-html@0.0.7, ansi-html@^0.0.7:
resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
integrity sha1-gTWEAhliqenm/QOflA0S9WynhZ4=
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8=
ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=
ansi-regex@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
ansi-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
ansi-regex@^2.0.0, ansi-regex@^3.0.0, ansi-regex@^4.1.0, ansi-regex@^5.0.0, ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
ansi-styles@^2.2.1:
version "2.2.1"