chore: Refactor custom desktop window actions check
This commit is contained in:
6 files changed
+22
-17
No files matched your search
@@ -129,8 +129,8 @@ export default function initializeMockIPC(server) {
|
||||
/**
|
||||
* Check for OS chrome state
|
||||
*/
|
||||
isWindowChromeless() {
|
||||
return false;
|
||||
showWindowActions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,8 +36,8 @@ export default class ApplicationRoute extends Route {
|
||||
async setupController(controller) {
|
||||
controller.set('hasMacOSChrome', await this.ipc.invoke('hasMacOSChrome'));
|
||||
controller.set(
|
||||
'isWindowChromeless',
|
||||
await this.ipc.invoke('isWindowChromeless')
|
||||
'showWindowActions',
|
||||
await this.ipc.invoke('showWindowActions')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{page-title (app-name)}}
|
||||
|
||||
<Rose::Layout::Global
|
||||
class='{{if this.isWindowChromeless ' layout-scroll'}}'
|
||||
class='{{if this.showWindowActions ' layout-scroll'}}'
|
||||
as |layout|
|
||||
>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{{/if}}
|
||||
|
||||
<header.utilities as |utilities|>
|
||||
{{#if this.isWindowChromeless}}
|
||||
{{#if this.showWindowActions}}
|
||||
<Rose::Button
|
||||
@iconOnly='flight-icons/svg/x-16'
|
||||
@style='warning'
|
||||
|
||||
@@ -69,19 +69,24 @@ handle('connect', ({ target_id, token, host_id }) =>
|
||||
handle('stop', ({ session_id }) => sessionManager.stopById(session_id));
|
||||
|
||||
/**
|
||||
* Check frame/chrome state. Only enabled on non-MacOS.
|
||||
*/
|
||||
handle('isWindowChromeless', () =>
|
||||
process.env.DISABLE_WINDOW_CHROME ? false : !isMac()
|
||||
);
|
||||
|
||||
/**
|
||||
* Check for MacOS chrome
|
||||
* Check for OS window chrome. Enabled on MacOS only.
|
||||
* Window chrome is disabled regardless of platform when
|
||||
* `DISABLE_WINDOW_CHROME` env var is enabled.
|
||||
*/
|
||||
handle('hasMacOSChrome', () =>
|
||||
process.env.DISABLE_WINDOW_CHROME ? false : isMac()
|
||||
);
|
||||
|
||||
/**
|
||||
* Show window actions for non-MacOS platforms.
|
||||
* Window actions are disabled regardless of platform when
|
||||
* `DISABLE_WINDOW_CHROME` env var is enabled.
|
||||
*/
|
||||
handle(
|
||||
'showWindowActions',
|
||||
() => !isMac() || process.env.DISABLE_WINDOW_CHROME
|
||||
);
|
||||
|
||||
/**
|
||||
* Minimize window
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,7 @@ module('Acceptance | origin', function (hooks) {
|
||||
|
||||
test('visiting index with chrome disabled hides custom window actions', async function (assert) {
|
||||
assert.expect(3);
|
||||
stubs.ipcService.withArgs('isWindowChromeless').returns(false);
|
||||
stubs.ipcService.withArgs('showWindowActions').returns(false);
|
||||
await visit(urls.origin);
|
||||
assert.notOk(find('.button-window-close'), 'Window close button');
|
||||
assert.notOk(find('.button-window-minimize'), 'Window minimize button');
|
||||
@@ -58,7 +58,7 @@ module('Acceptance | origin', function (hooks) {
|
||||
|
||||
test('visiting index with chrome enabled shows custom window actions', async function (assert) {
|
||||
assert.expect(3);
|
||||
stubs.ipcService.withArgs('isWindowChromeless').returns(true);
|
||||
stubs.ipcService.withArgs('showWindowActions').returns(true);
|
||||
await visit(urls.origin);
|
||||
assert.ok(find('.button-window-close'), 'Window close button');
|
||||
assert.ok(find('.button-window-minimize'), 'Window minimize button');
|
||||
|
||||
@@ -18,7 +18,7 @@ class MockIPC {
|
||||
|
||||
resetOrigin() {}
|
||||
hasMacOSChrome() {}
|
||||
isWindowChromeless() {}
|
||||
showWindowActions() {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user