feat: 🎸 support external link opening

This commit is contained in:
Randall Morey committed 2021-02-12 13:52:58 -05:00
1 parent 2ac65ba4e5
commit 24fa7e7403
5 files changed
+1049 -803

No files matched your search

+8
View File
@@ -26,6 +26,14 @@ export default function initializeMockIPC (server) {
return this.origin;
}
resetOrigin() {
this.origin = null;
}
openExternal(href) {
window.open(href);
}
cliExists() {
return true;
}
+14
View File
@@ -1,5 +1,6 @@
import Route from '@ember/routing/route';
import Ember from 'ember';
import jQuery from 'jquery';
/* eslint-disable-next-line ember/no-mixins */
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import { inject as service } from '@ember/service';
@@ -16,6 +17,7 @@ export default class ApplicationRoute extends Route.extend(
@service session;
@service origin;
@service ipc;
// =attributes
@@ -33,6 +35,18 @@ export default class ApplicationRoute extends Route.extend(
return this.origin.updateOrigin();
}
/**
* Adds listener on target=_blank links so that they may be opened in an
* external browser.
*/
afterModel() {
const ipc = this.ipc;
/* eslint-disable-next-line ember/no-jquery */
jQuery(document).on('click', 'a[href][target="_blank"]', function () {
ipc.invoke('openExternal', this.href);
});
}
/**
* After becoming authenticated, does nothing. This overrides the default
* behavior of the ApplicationRouteMixin, which is to redirect after auth.
+8
View File
@@ -1,3 +1,4 @@
const { shell } = require('electron');
const handle = require('./ipc-handler');
const boundaryCli = require('./boundary-cli');
const origin = require('./origin.js');
@@ -24,6 +25,13 @@ handle('resetOrigin', async (requestOrigin) => {
origin.resetOrigin();
});
/**
* Opens the specified URL in an external browser.
*/
handle('openExternal', async (href) => {
shell.openExternal(href);
});
/**
* Check for boundary cli existence
*/
+1
View File
@@ -35,6 +35,7 @@
},
"devDependencies": {
"@doyensec/electronegativity": "^1.7.0",
"@ember/jquery": "^1.1.0",
"@ember/optional-features": "^1.3.0",
"@ember/render-modifiers": "^1.0.2",
"@glimmer/component": "^1.0.1",
+1018 -803
View File
File diff suppressed because it is too large. Load diff