refactor: 💡 upgrade ui/desktop to Ember 3.24
This commit is contained in:
49 files changed
+329
-662
No files matched your search
@@ -13,6 +13,7 @@
|
||||
# misc
|
||||
/coverage/
|
||||
!.*
|
||||
.eslintcache
|
||||
|
||||
# ember-try
|
||||
/.node_modules.ember-try/
|
||||
|
||||
+21
-15
@@ -7,25 +7,31 @@ module.exports = {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: {
|
||||
legacyDecorators: true
|
||||
}
|
||||
legacyDecorators: true,
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
'ember'
|
||||
],
|
||||
plugins: ['ember'],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:ember/recommended'
|
||||
'plugin:ember/recommended',
|
||||
'plugin:prettier/recommended',
|
||||
],
|
||||
env: {
|
||||
browser: true
|
||||
browser: true,
|
||||
},
|
||||
rules: {
|
||||
'ember/no-get': 'off',
|
||||
'ember/no-get-with-default': 'off',
|
||||
'ember/no-computed-properties-in-native-classes': 'off',
|
||||
'ember/no-assignment-of-untracked-properties-used-in-tracking-contexts':
|
||||
'off',
|
||||
},
|
||||
rules: {},
|
||||
overrides: [
|
||||
// node files
|
||||
{
|
||||
files: [
|
||||
'.eslintrc.js',
|
||||
'.prettierrc.js',
|
||||
'.template-lintrc.js',
|
||||
'ember-cli-build.js',
|
||||
'testem.js',
|
||||
@@ -33,22 +39,22 @@ module.exports = {
|
||||
'blueprints/*/index.js',
|
||||
'config/**/*.js',
|
||||
'lib/*/index.js',
|
||||
'server/**/*.js'
|
||||
'server/**/*.js',
|
||||
],
|
||||
parserOptions: {
|
||||
sourceType: 'script'
|
||||
sourceType: 'script',
|
||||
},
|
||||
env: {
|
||||
browser: false,
|
||||
node: true
|
||||
node: true,
|
||||
},
|
||||
plugins: ['node'],
|
||||
extends: ['plugin:node/recommended'],
|
||||
rules: {
|
||||
// this can be removed once the following is fixed
|
||||
// https://github.com/mysticatea/eslint-plugin-node/issues/77
|
||||
'node/no-unpublished-require': 'off'
|
||||
}
|
||||
}
|
||||
]
|
||||
'node/no-unpublished-require': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
# unconventional js
|
||||
/blueprints/*/files/
|
||||
/vendor/
|
||||
|
||||
# compiled output
|
||||
/dist/
|
||||
/tmp/
|
||||
|
||||
# dependencies
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
|
||||
# misc
|
||||
/coverage/
|
||||
!.*
|
||||
.eslintcache
|
||||
|
||||
# ember-try
|
||||
/.node_modules.ember-try/
|
||||
/bower.json.ember-try
|
||||
/package.json.ember-try
|
||||
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
singleQuote: true,
|
||||
};
|
||||
@@ -5,6 +5,6 @@ module.exports = {
|
||||
rules: {
|
||||
'no-bare-strings': true,
|
||||
'no-curly-component-invocation': { allow: ['app-name'] },
|
||||
'no-implicit-this': { allow: ['app-name', 'is-loading'] }
|
||||
}
|
||||
'no-implicit-this': { allow: ['app-name', 'is-loading'] },
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
language: node_js
|
||||
node_js:
|
||||
- "10"
|
||||
|
||||
dist: xenial
|
||||
|
||||
addons:
|
||||
chrome: stable
|
||||
|
||||
cache:
|
||||
yarn: true
|
||||
|
||||
env:
|
||||
global:
|
||||
# See https://git.io/vdao3 for details.
|
||||
- JOBS=1
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
- export PATH=$HOME/.yarn/bin:$PATH
|
||||
|
||||
script:
|
||||
- yarn test
|
||||
@@ -37,6 +37,7 @@ export default class CopyableComponent extends Component {
|
||||
this.copied = true;
|
||||
yield timeout(1000);
|
||||
this.copied = false;
|
||||
/* eslint-disable-next-line prettier/prettier */
|
||||
}).drop() confirmCopyTimer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@ import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ScopesScopeAuthenticateController extends Controller {
|
||||
|
||||
// =services
|
||||
|
||||
@service origin;
|
||||
|
||||
@@ -2,7 +2,6 @@ import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ScopesScopeProjectsSessionsIndexController extends Controller {
|
||||
|
||||
// =sessions
|
||||
|
||||
@service session;
|
||||
@@ -19,9 +18,10 @@ export default class ScopesScopeProjectsSessionsIndexController extends Controll
|
||||
const sessions = this.model;
|
||||
const sortedSessions = sessions
|
||||
// filter sessions by current user
|
||||
.filter(session => session.user_id === userId)
|
||||
.filter((session) => session.user_id === userId)
|
||||
// sort by created time
|
||||
.sortBy('session.created_time').reverse();
|
||||
.sortBy('session.created_time')
|
||||
.reverse();
|
||||
return [
|
||||
// then move active sessions to the top
|
||||
...sortedSessions.filter((session) => session.isCancelable),
|
||||
@@ -29,5 +29,4 @@ export default class ScopesScopeProjectsSessionsIndexController extends Controll
|
||||
...sortedSessions.filter((session) => !session.isCancelable),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,11 +24,9 @@ export default class ScopesScopeProjectsTargetsTargetSessionsController extends
|
||||
get cancelableUserSessions() {
|
||||
const sessions = this.sessions;
|
||||
const userId = this.session.data.authenticated.user_id;
|
||||
const filteredSessions =
|
||||
sessions.filter(session =>
|
||||
session.isCancelable &&
|
||||
session.user_id === userId
|
||||
);
|
||||
const filteredSessions = sessions.filter(
|
||||
(session) => session.isCancelable && session.user_id === userId
|
||||
);
|
||||
|
||||
// Sort sessions
|
||||
const sortedSessions = A(filteredSessions).sortBy('created_time').reverse();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { getOwner } from '@ember/application';
|
||||
|
||||
export function initialize(registry) {
|
||||
|
||||
// Lookup the application route
|
||||
const ApplicationRoute = registry.resolveRegistration
|
||||
? registry.resolveRegistration('route:application')
|
||||
@@ -13,7 +12,7 @@ export function initialize(registry) {
|
||||
const originalBeforeModel = this.beforeModel;
|
||||
|
||||
// Override the beforeModel hook and initialize the origin
|
||||
this.beforeModel = async function() {
|
||||
this.beforeModel = async function () {
|
||||
const origin = getOwner(this).lookup('service:origin');
|
||||
return origin.updateOrigin().then(
|
||||
() => originalBeforeModel.apply(this, arguments),
|
||||
@@ -26,5 +25,5 @@ export function initialize(registry) {
|
||||
|
||||
export default {
|
||||
after: 'ember-simple-auth',
|
||||
initialize
|
||||
initialize,
|
||||
};
|
||||
@@ -14,12 +14,12 @@ Router.map(function () {
|
||||
});
|
||||
this.route('projects', function () {
|
||||
this.route('targets', function () {
|
||||
this.route('target', { path: ':target_id' }, function() {
|
||||
this.route('target', { path: ':target_id' }, function () {
|
||||
this.route('hosts');
|
||||
this.route('sessions');
|
||||
});
|
||||
});
|
||||
this.route('sessions', function() {});
|
||||
this.route('sessions', function () {});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,12 +37,10 @@ export default class ScopesScopeAuthenticateMethodRoute extends Route {
|
||||
const authMethod = this.modelFor('scopes.scope.authenticate.method');
|
||||
const authenticatorName = `authenticator:${authMethod.type}`;
|
||||
const requestCookies = false;
|
||||
await this.session.authenticate(
|
||||
authenticatorName,
|
||||
creds,
|
||||
requestCookies,
|
||||
{ scope, authMethod }
|
||||
);
|
||||
await this.session.authenticate(authenticatorName, creds, requestCookies, {
|
||||
scope,
|
||||
authMethod,
|
||||
});
|
||||
this.replaceWith('index');
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,4 @@ export default class ScopesScopeProjectsRoute extends Route {
|
||||
.query('scope', { recursive: true, scope_id: 'global' })
|
||||
.filter(({ isProject }) => isProject);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ export default class ScopesScopeProjectsSessionsRoute extends Route {
|
||||
yield timeout(POLL_TIMEOUT_SECONDS * 1000);
|
||||
yield this.refresh();
|
||||
}
|
||||
/* eslint-disable-next-line prettier/prettier */
|
||||
}).drop() poller;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeProjectsSessionsIndexRoute extends Route {
|
||||
}
|
||||
export default class ScopesScopeProjectsSessionsIndexRoute extends Route {}
|
||||
@@ -34,6 +34,7 @@ export default class ScopesScopeProjectsTargetsRoute extends Route {
|
||||
yield timeout(POLL_TIMEOUT_SECONDS * 1000);
|
||||
yield this.refreshSessions();
|
||||
}
|
||||
/* eslint-disable-next-line prettier/prettier */
|
||||
}).drop() poller;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class ScopesScopeProjectsTargetsTargetRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,11 +27,9 @@ export default class ScopesScopeProjectsTargetsTargetHostsRoute extends Route {
|
||||
);
|
||||
|
||||
// Extract host ids from all host sets
|
||||
const hostIds = hostSets.map(({host_ids}) =>
|
||||
host_ids.content.map((hostId) =>
|
||||
hostId.value
|
||||
)
|
||||
)
|
||||
const hostIds = hostSets.map(({ host_ids }) =>
|
||||
host_ids.content.map((hostId) => hostId.value)
|
||||
);
|
||||
|
||||
// Load unique hosts
|
||||
const uniqueHostIds = new Set(hostIds.flat());
|
||||
@@ -42,7 +40,7 @@ export default class ScopesScopeProjectsTargetsTargetHostsRoute extends Route {
|
||||
[...uniqueHostIds].map((hostId) =>
|
||||
this.store.findRecord('host', hostId)
|
||||
)
|
||||
)
|
||||
})
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,4 @@ export default class ScopesScopeProjectsTargetsTargetIndexRoute extends Route {
|
||||
afterModel() {
|
||||
this.transitionTo('scopes.scope.projects.targets.target.sessions');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { action } from '@ember/object';
|
||||
import { notifySuccess, notifyError } from 'core/decorators/notify';
|
||||
|
||||
export default class ScopesScopeProjectsTargetsTargetSessionsRoute extends Route {
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
@@ -16,5 +15,4 @@ export default class ScopesScopeProjectsTargetsTargetSessionsRoute extends Route
|
||||
async cancelSession(session) {
|
||||
await session.cancelSession();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { inject as service } from '@ember/service';
|
||||
import { notifyError } from 'core/decorators/notify';
|
||||
|
||||
export default class OriginService extends Service {
|
||||
|
||||
// =services
|
||||
|
||||
@service ipc;
|
||||
@@ -59,11 +58,14 @@ export default class OriginService extends Service {
|
||||
*/
|
||||
async setOrigin(origin) {
|
||||
const originalHost = this.adapter.host;
|
||||
assert(`setOrigin expects a string, you passed ${origin}`, typeof origin === 'string');
|
||||
assert(
|
||||
`setOrigin expects a string, you passed ${origin}`,
|
||||
typeof origin === 'string'
|
||||
);
|
||||
try {
|
||||
this.adapter.host = origin;
|
||||
this.rendererOrigin = origin;
|
||||
if (origin !== await this.mainOrigin) {
|
||||
if (origin !== (await this.mainOrigin)) {
|
||||
await this.ipc.invoke('setOrigin', origin);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -81,5 +83,4 @@ export default class OriginService extends Service {
|
||||
this.rendererOrigin = null;
|
||||
await this.ipc.invoke('resetOrigin');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@
|
||||
</form.radioGroup>
|
||||
</Rose::Form>
|
||||
</dropdown.section>
|
||||
|
||||
|
||||
</utilities.dropdown>
|
||||
</header.utilities>
|
||||
{{/if}}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"packages": [
|
||||
{
|
||||
"name": "ember-cli",
|
||||
"version": "3.20.2",
|
||||
"version": "3.24.0",
|
||||
"blueprints": [
|
||||
{
|
||||
"name": "app",
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = function (environment) {
|
||||
|
||||
'ember-cli-mirage': {
|
||||
//enabled: ENABLE_MIRAGE,
|
||||
directory: '../../addons/api/mirage'
|
||||
directory: '../../addons/api/mirage',
|
||||
},
|
||||
|
||||
api: {
|
||||
@@ -49,9 +49,9 @@ module.exports = function (environment) {
|
||||
baseURL: 'https://boundaryproject.io/help/desktop',
|
||||
topics: {
|
||||
targets: '/targets',
|
||||
sessions: '/sessions'
|
||||
}
|
||||
}
|
||||
sessions: '/sessions',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (process.env.ENABLE_MIRAGE) {
|
||||
@@ -89,7 +89,7 @@ module.exports = function (environment) {
|
||||
|
||||
// Use in-memory storage
|
||||
ENV.storage = {
|
||||
memory: true
|
||||
memory: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = {
|
||||
const addr = origin.origin;
|
||||
const sanitized = {
|
||||
target_id: escapeAndValidateBase62(target_id),
|
||||
token: escapeAndValidateBase62(token)
|
||||
token: escapeAndValidateBase62(token),
|
||||
};
|
||||
if (host_id) sanitized.host_id = escapeAndValidateBase62(host_id);
|
||||
const command = [
|
||||
@@ -34,15 +34,15 @@ module.exports = {
|
||||
`-token=${sanitized.token}`,
|
||||
`-addr=${addr}`,
|
||||
'-format=json',
|
||||
'--output-json-errors'
|
||||
'--output-json-errors',
|
||||
];
|
||||
|
||||
if (host_id) command.push(`-host-id=${sanitized.host_id}`)
|
||||
if (host_id) command.push(`-host-id=${sanitized.host_id}`);
|
||||
return spawnAsyncJSONPromise(command);
|
||||
},
|
||||
// Returns JSON-formatted version information from the CLI
|
||||
version: () => {
|
||||
const command = [ '-v' ];
|
||||
const command = ['-v'];
|
||||
const rawOutput = spawnSync(command);
|
||||
let gitRevision = /Git Revision:\s*(?<rev>.*)\n/.exec(rawOutput);
|
||||
let versionNumber = /Version Number:\s*(?<ver>.*)\n/.exec(rawOutput);
|
||||
@@ -53,5 +53,5 @@ module.exports = {
|
||||
: `CLI Commit: ${gitRevision}`;
|
||||
return { gitRevision, versionNumber, formatted };
|
||||
return rawOutput;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -20,8 +20,8 @@ const enableDevCSP = () => {
|
||||
csp['style-src'].push("'unsafe-inline'");
|
||||
csp['script-src'].push("'unsafe-eval'");
|
||||
csp['script-src'].push("'unsafe-inline'");
|
||||
csp['script-src'].push("http://localhost:7020");
|
||||
csp['connect-src'].push("ws://localhost:7020");
|
||||
csp['script-src'].push('http://localhost:7020');
|
||||
csp['connect-src'].push('ws://localhost:7020');
|
||||
};
|
||||
|
||||
const generateCSPHeader = () => {
|
||||
@@ -33,14 +33,13 @@ const generateCSPHeader = () => {
|
||||
policy['connect-src'].push(origin.origin);
|
||||
}
|
||||
|
||||
return Object
|
||||
.keys(policy)
|
||||
.map(key => `${key} ${policy[key].join(' ')};`)
|
||||
return Object.keys(policy)
|
||||
.map((key) => `${key} ${policy[key].join(' ')};`)
|
||||
.join(' ');
|
||||
}
|
||||
};
|
||||
|
||||
if (isDev) enableDevCSP();
|
||||
|
||||
module.exports = {
|
||||
generateCSPHeader: generateCSPHeader
|
||||
generateCSPHeader: generateCSPHeader,
|
||||
};
|
||||
@@ -4,7 +4,14 @@ const {
|
||||
default: installExtension,
|
||||
EMBER_INSPECTOR,
|
||||
} = require('electron-devtools-installer');
|
||||
const { session, app, protocol, BrowserWindow, ipcMain, Menu } = require('electron');
|
||||
const {
|
||||
session,
|
||||
app,
|
||||
protocol,
|
||||
BrowserWindow,
|
||||
ipcMain,
|
||||
Menu,
|
||||
} = require('electron');
|
||||
require('./handlers.js');
|
||||
|
||||
const origin = require('./origin.js');
|
||||
@@ -63,7 +70,8 @@ app.on('ready', async () => {
|
||||
// Disallow all permissions requests originating outside of serve://boundary,
|
||||
// per Electronegativity PERMISSION_REQUEST_HANDLER_GLOBAL_CHECK
|
||||
ses.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
if (webContents.getURL().startsWith('serve://boundary')) return callback(false);
|
||||
if (webContents.getURL().startsWith('serve://boundary'))
|
||||
return callback(false);
|
||||
return callback(true);
|
||||
});
|
||||
|
||||
@@ -72,8 +80,8 @@ app.on('ready', async () => {
|
||||
callback({
|
||||
responseHeaders: {
|
||||
...details.responseHeaders,
|
||||
'Content-Security-Policy': [generateCSPHeader()]
|
||||
}
|
||||
'Content-Security-Policy': [generateCSPHeader()],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -91,7 +99,7 @@ app.on('ready', async () => {
|
||||
}
|
||||
|
||||
// Configure menu in prod env
|
||||
if(!isDev) {
|
||||
if (!isDev) {
|
||||
const menuTemplate = Menu.buildFromTemplate(menu.generateMenuTemplate());
|
||||
Menu.setApplicationMenu(menuTemplate);
|
||||
}
|
||||
@@ -109,7 +117,7 @@ app.on('ready', async () => {
|
||||
enableRemoteModule: false,
|
||||
allowRunningInsecureContent: false,
|
||||
preload: preloadPath,
|
||||
disableBlinkFeatures: 'Auxclick'
|
||||
disableBlinkFeatures: 'Auxclick',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
const { ipcMain } = require('electron');
|
||||
const isDev = require('electron-is-dev');
|
||||
|
||||
const log = (method, request='', response='', type='log') => {
|
||||
const requestString = typeof request === 'object'
|
||||
? JSON.stringify(request)
|
||||
: request;
|
||||
const log = (method, request = '', response = '', type = 'log') => {
|
||||
const requestString =
|
||||
typeof request === 'object' ? JSON.stringify(request) : request;
|
||||
// only log in dev mode
|
||||
if (isDev) {
|
||||
console[type](
|
||||
@@ -15,7 +14,7 @@ const log = (method, request='', response='', type='log') => {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function handle (command, handler) {
|
||||
module.exports = function handle(command, handler) {
|
||||
ipcMain.handle(command, async function (event, request) {
|
||||
const requestPayload = request;
|
||||
let result;
|
||||
@@ -26,7 +25,7 @@ module.exports = function handle (command, handler) {
|
||||
// If e is an Error instance, we need to extract the message and wrap
|
||||
// it in a POJO before stringifying it. If not an Error, e is assumed to
|
||||
// be already a POJO.
|
||||
const errorMessage = (e instanceof Error) ? { message: e.message } : e;
|
||||
const errorMessage = e instanceof Error ? { message: e.message } : e;
|
||||
result = new Error(JSON.stringify(errorMessage));
|
||||
log(command, requestPayload, e, 'error');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { shell } = require('electron')
|
||||
const { shell } = require('electron');
|
||||
|
||||
const generateMenuTemplate = () => {
|
||||
return [
|
||||
@@ -14,15 +14,13 @@ const generateMenuTemplate = () => {
|
||||
{ role: 'hideothers' },
|
||||
{ role: 'unhide' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
{ role: 'quit' },
|
||||
],
|
||||
},
|
||||
// { role: 'fileMenu' }
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
{ role: 'close' }
|
||||
]
|
||||
submenu: [{ role: 'close' }],
|
||||
},
|
||||
// { role: 'editMenu' }
|
||||
{
|
||||
@@ -40,12 +38,9 @@ const generateMenuTemplate = () => {
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Speech',
|
||||
submenu: [
|
||||
{ role: 'startSpeaking' },
|
||||
{ role: 'stopSpeaking' }
|
||||
]
|
||||
}
|
||||
]
|
||||
submenu: [{ role: 'startSpeaking' }, { role: 'stopSpeaking' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
// { role: 'viewMenu' }
|
||||
{
|
||||
@@ -57,8 +52,8 @@ const generateMenuTemplate = () => {
|
||||
{ role: 'zoomIn' },
|
||||
{ role: 'zoomOut' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'togglefullscreen' }
|
||||
]
|
||||
{ role: 'togglefullscreen' },
|
||||
],
|
||||
},
|
||||
// { role: 'windowMenu' }
|
||||
{
|
||||
@@ -69,21 +64,21 @@ const generateMenuTemplate = () => {
|
||||
{ type: 'separator' },
|
||||
{ role: 'front' },
|
||||
{ type: 'separator' },
|
||||
{ role: 'window' }
|
||||
]
|
||||
{ role: 'window' },
|
||||
],
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Documentation',
|
||||
click: () => shell.openExternal('https://www.boundaryproject.io')
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
click: () => shell.openExternal('https://www.boundaryproject.io'),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
generateMenuTemplate: generateMenuTemplate
|
||||
generateMenuTemplate: generateMenuTemplate,
|
||||
};
|
||||
@@ -1,27 +1,27 @@
|
||||
const { net } = require('electron')
|
||||
const { net } = require('electron');
|
||||
|
||||
const requestTimeoutSeconds = 10;
|
||||
// Simple promise wrapper around Electron's net.request feature.
|
||||
// https://www.electronjs.org/docs/api/client-request
|
||||
const netRequestPromise = url => new Promise((resolve, reject) => {
|
||||
try {
|
||||
const request = net.request(url);
|
||||
// We don't worry about canceling the request timeout timer once a
|
||||
// request ends because: request.abort() has no effect after a request
|
||||
// ends and the promise will already have been completed, so a rejection
|
||||
// has no effect either.
|
||||
const requestTimeout =
|
||||
setTimeout(() => {
|
||||
const netRequestPromise = (url) =>
|
||||
new Promise((resolve, reject) => {
|
||||
try {
|
||||
const request = net.request(url);
|
||||
// We don't worry about canceling the request timeout timer once a
|
||||
// request ends because: request.abort() has no effect after a request
|
||||
// ends and the promise will already have been completed, so a rejection
|
||||
// has no effect either.
|
||||
const requestTimeout = setTimeout(() => {
|
||||
request.abort();
|
||||
reject(new Error('Request timeout'));
|
||||
}, requestTimeoutSeconds * 1000);
|
||||
request.on('error', reject);
|
||||
request.on('response', resolve);
|
||||
request.end();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
request.on('error', reject);
|
||||
request.on('response', resolve);
|
||||
request.end();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
|
||||
// Provides a singleton class instance to enable a consistent view of
|
||||
// runtime settings across the application.
|
||||
@@ -30,7 +30,6 @@ const netRequestPromise = url => new Promise((resolve, reject) => {
|
||||
// set up at runtime. For example, the Boundary origin is a runtime setting.
|
||||
|
||||
class RuntimeSettings {
|
||||
|
||||
// Internal private origin is exposed via getter/setter below.
|
||||
#origin = undefined;
|
||||
|
||||
@@ -38,7 +37,9 @@ class RuntimeSettings {
|
||||
* The user-specified Boundary origin, which should be allowed by CSP.
|
||||
* @type {?string}
|
||||
*/
|
||||
get origin() { return this.#origin; }
|
||||
get origin() {
|
||||
return this.#origin;
|
||||
}
|
||||
set origin(origin) {
|
||||
if (this.#origin !== origin) {
|
||||
this.#origin = origin;
|
||||
@@ -79,7 +80,7 @@ class RuntimeSettings {
|
||||
}
|
||||
|
||||
triggerOriginChanged() {
|
||||
this.#originWatchers.forEach(fn => fn(this.#origin));
|
||||
this.#originWatchers.forEach((fn) => fn(this.#origin));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ const boundaryPath = path.resolve(__dirname, '..', 'cli', 'boundary');
|
||||
|
||||
// Convert to json
|
||||
const jsonify = (data) => {
|
||||
if(typeof data !== 'string') data = JSON.stringify(data);
|
||||
if (typeof data !== 'string') data = JSON.stringify(data);
|
||||
try {
|
||||
return JSON.parse(data);
|
||||
} catch (e) {
|
||||
// Ignore parse errors
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// You can throw exceptions, or allow them to occur, and this is supported.
|
||||
// Exceptions thrown in this way will be returned to the UI as an
|
||||
@@ -28,7 +28,6 @@ const jsonify = (data) => {
|
||||
// helpful message for users, so it's recommended to craft nice
|
||||
// POJO representation and throw it or promise->reject it.
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* Spawns an asynchronous child process that is expected to output JSON
|
||||
* data on either stdout or stderr. The process is allowed to continue
|
||||
@@ -65,6 +64,5 @@ module.exports = {
|
||||
const childProcess = spawnSync(boundaryPath, command);
|
||||
const rawOutput = childProcess.output.toString();
|
||||
return rawOutput;
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
@@ -5,7 +5,7 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
||||
module.exports = function (defaults) {
|
||||
let app = new EmberApp(defaults, {
|
||||
'ember-cli-babel': {
|
||||
includeExternalHelpers: true
|
||||
includeExternalHelpers: true,
|
||||
},
|
||||
babel: {
|
||||
sourceMaps: 'inline',
|
||||
|
||||
+28
-20
@@ -15,20 +15,23 @@
|
||||
"build:development": "ember build",
|
||||
"prebuild:desktop": "cp -r dist/ electron-app/ember-dist/",
|
||||
"build:desktop": "cd electron-app && yarn make",
|
||||
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
|
||||
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
|
||||
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
|
||||
"lint:hbs": "ember-template-lint .",
|
||||
"lint:hbs:fix": "ember-template-lint . --fix",
|
||||
"lint:js": "eslint .",
|
||||
"lint:sass": "stylelint '**/*.scss'",
|
||||
"lint:electron": "electronegativity -r -i ./electron-app",
|
||||
"format": "npm-run-all format:*",
|
||||
"format:js": "prettier --write '{app,config,stories,tests,electron-app/src}/**/*.js' *.js",
|
||||
"format:sass": "prettier --write app/**/*.scss",
|
||||
"lint:js:fix": "eslint . --fix",
|
||||
"start": "ember serve",
|
||||
"prestart:desktop": "cd electron-app && yarn build:cli",
|
||||
"start:desktop": "ember electron",
|
||||
"clean:coverage": "rm -rf coverage_*",
|
||||
"pretest": "yarn clean:coverage",
|
||||
"test": "npm-run-all test:*",
|
||||
"test": "npm-run-all lint test:*",
|
||||
"test:ember": "COVERAGE=true ember exam --random",
|
||||
"postinstall": "cd electron-app && yarn install",
|
||||
"posttest": "ember coverage-merge && yarn clean:coverage"
|
||||
@@ -36,50 +39,55 @@
|
||||
"devDependencies": {
|
||||
"@doyensec/electronegativity": "^1.7.0",
|
||||
"@ember/jquery": "^1.1.0",
|
||||
"@ember/optional-features": "^1.3.0",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/render-modifiers": "^1.0.2",
|
||||
"@glimmer/component": "^1.0.1",
|
||||
"@glimmer/tracking": "^1.0.0",
|
||||
"@ember/test-helpers": "^2.1.4",
|
||||
"@glimmer/component": "^1.0.3",
|
||||
"@glimmer/tracking": "^1.0.3",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-loader": "^8.1.0",
|
||||
"broccoli-asset-rev": "^3.0.0",
|
||||
"clipboard": "^2.0.6",
|
||||
"core": "*",
|
||||
"doctoc": "^1.4.0",
|
||||
"ember-auto-import": "^1.6.0",
|
||||
"ember-auto-import": "^1.10.1",
|
||||
"ember-autofocus-modifier": "^1.1.0",
|
||||
"ember-cli": "~3.20.2",
|
||||
"ember-cli-app-version": "^3.2.0",
|
||||
"ember-cli-babel": "^7.21.0",
|
||||
"ember-cli": "~3.24.0",
|
||||
"ember-cli-app-version": "^4.0.0",
|
||||
"ember-cli-babel": "^7.23.0",
|
||||
"ember-cli-code-coverage": "^1.0.2",
|
||||
"ember-cli-dependency-checker": "^3.2.0",
|
||||
"ember-cli-htmlbars": "^5.2.0",
|
||||
"ember-cli-htmlbars": "^5.3.1",
|
||||
"ember-cli-inject-live-reload": "^2.0.2",
|
||||
"ember-cli-sass": "^10.0.1",
|
||||
"ember-cli-sri": "^2.1.1",
|
||||
"ember-cli-template-lint": "^2.0.2",
|
||||
"ember-cli-uglify": "^3.0.0",
|
||||
"ember-cli-terser": "^4.0.1",
|
||||
"ember-concurrency": "^1.3.0",
|
||||
"ember-electron": "https://github.com/adopted-ember-addons/ember-electron#v3.0.0-beta.4",
|
||||
"ember-exam": "^6.0.1",
|
||||
"ember-export-application-global": "^2.0.1",
|
||||
"ember-inline-svg": "^1.0.0",
|
||||
"ember-load-initializers": "^2.1.1",
|
||||
"ember-load-initializers": "^2.1.2",
|
||||
"ember-maybe-import-regenerator": "^0.1.6",
|
||||
"ember-modifier": "^2.1.1",
|
||||
"ember-notify": "^6.0.0",
|
||||
"ember-qunit": "^4.6.0",
|
||||
"ember-resolver": "^8.0.0",
|
||||
"ember-source": "~3.20.2",
|
||||
"ember-template-lint": "^2.14.0",
|
||||
"eslint": "^7.5.0",
|
||||
"eslint-plugin-ember": "^8.9.1",
|
||||
"ember-page-title": "^6.0.3",
|
||||
"ember-qunit": "^5.1.1",
|
||||
"ember-resolver": "^8.0.2",
|
||||
"ember-source": "~3.24.0",
|
||||
"ember-template-lint": "^2.15.0",
|
||||
"eslint": "^7.17.0",
|
||||
"eslint-config-prettier": "^7.1.0",
|
||||
"eslint-plugin-ember": "^10.1.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"faker": "^5.1.0",
|
||||
"loader.js": "^4.7.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.1.2",
|
||||
"qunit-dom": "^1.2.0",
|
||||
"prettier": "^2.2.1",
|
||||
"qunit": "^2.13.0",
|
||||
"qunit-dom": "^1.6.0",
|
||||
"rose": "*",
|
||||
"sass": "^1.29.0",
|
||||
"sinon": "^9.2.1",
|
||||
|
||||
@@ -166,7 +166,7 @@ module('Acceptance | authentication', function (hooks) {
|
||||
authenticateSession({
|
||||
scope: {
|
||||
id: instances.scopes.global.id,
|
||||
type: instances.scopes.global.type
|
||||
type: instances.scopes.global.type,
|
||||
},
|
||||
});
|
||||
later(async () => {
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
{{content-for "body"}}
|
||||
{{content-for "test-body"}}
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div id="ember-testing-container">
|
||||
<div id="ember-testing"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/testem.js" integrity=""></script>
|
||||
<script src="{{rootURL}}assets/vendor.js"></script>
|
||||
<script src="{{rootURL}}assets/test-support.js"></script>
|
||||
|
||||
@@ -3,10 +3,10 @@ import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | branded-card', function(hooks) {
|
||||
module('Integration | Component | branded-card', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function(assert) {
|
||||
test('it renders', async function (assert) {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.set('myAction', function(val) { ... });
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import Application from '../app';
|
||||
import config from '../config/environment';
|
||||
import Application from 'desktop/app';
|
||||
import config from 'desktop/config/environment';
|
||||
import * as QUnit from 'qunit';
|
||||
import { setApplication } from '@ember/test-helpers';
|
||||
import { setup } from 'qunit-dom';
|
||||
import { start } from 'ember-qunit';
|
||||
|
||||
setApplication(Application.create(config.APP));
|
||||
|
||||
setup(QUnit.assert);
|
||||
|
||||
start();
|
||||
@@ -1,12 +1,17 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Controller | scopes/scope/projects/sessions/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/projects/sessions/index',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.owner.lookup('controller:scopes/scope/projects/sessions/index');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/projects/sessions/index'
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
}
|
||||
);
|
||||
+13
-8
@@ -1,12 +1,17 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Controller | scopes/scope/projects/targets/target/sessions', function(hooks) {
|
||||
setupTest(hooks);
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/projects/targets/target/sessions',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.owner.lookup('controller:scopes/scope/projects/targets/target/sessions');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/projects/targets/target/sessions'
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/sessions', function(hooks) {
|
||||
module('Unit | Route | scopes/scope/projects/sessions', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/sessions');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/sessions/index', function(hooks) {
|
||||
module('Unit | Route | scopes/scope/projects/sessions/index', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/sessions/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/targets/target', function(hooks) {
|
||||
module('Unit | Route | scopes/scope/projects/targets/target', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/targets/target');
|
||||
assert.ok(route);
|
||||
});
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/targets/target/hosts', function(hooks) {
|
||||
setupTest(hooks);
|
||||
module(
|
||||
'Unit | Route | scopes/scope/projects/targets/target/hosts',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/targets/target/hosts');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:scopes/scope/projects/targets/target/hosts'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -1,11 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/targets/target/index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
module(
|
||||
'Unit | Route | scopes/scope/projects/targets/target/index',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/targets/target/index');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:scopes/scope/projects/targets/target/index'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -1,11 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | scopes/scope/projects/targets/target/sessions', function(hooks) {
|
||||
setupTest(hooks);
|
||||
module(
|
||||
'Unit | Route | scopes/scope/projects/targets/target/sessions',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:scopes/scope/projects/targets/target/sessions');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:scopes/scope/projects/targets/target/sessions'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -58,13 +58,13 @@ module('Unit | Service | ipc', function (hooks) {
|
||||
assert.expect(1);
|
||||
const stringifiedPayload = JSON.stringify({
|
||||
foo: 'bar',
|
||||
test: 42
|
||||
test: 42,
|
||||
});
|
||||
const myWindow = {
|
||||
postMessage(request, origin, [port]) {
|
||||
// Post back an error on the response port
|
||||
port.postMessage(new Error(stringifiedPayload));
|
||||
}
|
||||
},
|
||||
};
|
||||
try {
|
||||
await new IPCRequest('hello', 'world', myWindow);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Service | origin', function(hooks) {
|
||||
module('Unit | Service | origin', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
test('it exists', function (assert) {
|
||||
let service = this.owner.lookup('service:origin');
|
||||
assert.ok(service);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user