Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge branch 'development' into 744-stings-i18n-modals
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Sep 29, 2017
2 parents 6b472d3 + b254246 commit 91398da
Show file tree
Hide file tree
Showing 17 changed files with 352 additions and 271 deletions.
9 changes: 7 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@ node('lisk-nano-01'){
}
milestone 1
/* notify of success if previous build failed */
if (currentBuild.getPreviousBuild().result == 'FAILURE') {
slackSend color: 'good', message: "Recovery: build #${env.BUILD_NUMBER} of <${env.BUILD_URL}|${env.JOB_NAME}> was sucessful.", channel: '#lisk-nano-jenkins'
previous_build = currentBuild.getPreviousBuild()
if (previous_build != null && previous_build.result == 'FAILURE') {
def pr_branch = ''
if (env.CHANGE_BRANCH != null) {
pr_branch = " (${env.CHANGE_BRANCH})"
}
slackSend color: 'good', message: "Recovery: build #${env.BUILD_NUMBER} of <${env.BUILD_URL}|${env.JOB_NAME}>${pr_branch} was successful.", channel: '#lisk-nano-jenkins'
}
}
}
Expand Down
183 changes: 53 additions & 130 deletions app/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
const electron = require('electron'); // eslint-disable-line import/no-extraneous-dependencies
const path = require('path');
const buildMenu = require('./menu');

const { app } = electron;
const { BrowserWindow } = electron;
const { Menu } = electron;
const { ipcMain } = electron;
const { app, BrowserWindow, Menu, ipcMain } = electron;

let win;
let isUILoaded = false;
let eventStack = [];

const copyright = `Copyright 漏 2016 - ${new Date().getFullYear()} Lisk Foundation`;
const protocolName = 'lisk';

const sendUrlToRouter = (url) => {
if (isUILoaded && win && win.webContents) {
win.webContents.send('openUrl', url);
} else {
eventStack.push({ event: 'openUrl', value: url });
}
};

function createWindow() {
const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize;
Expand All @@ -25,134 +35,11 @@ function createWindow() {
win.on('blur', () => win.webContents.send('blur'));
win.on('focus', () => win.webContents.send('focus'));

win.webContents.openDevTools();

const template = [
{
label: 'Edit',
submenu: [
{
role: 'undo',
},
{
role: 'redo',
},
{
type: 'separator',
},
{
role: 'cut',
},
{
role: 'copy',
},
{
role: 'paste',
},
{
role: 'selectall',
},
],
},
{
label: 'View',
submenu: [
{
role: 'reload',
},
{
role: 'togglefullscreen',
},
],
},
{
label: 'Window',
submenu: [
{
role: 'minimize',
},
],
},
{
label: 'Help',
submenu: [
{
label: 'Lisk Website',
click() {
electron.shell.openExternal('https://lisk.io');
},
},
{
label: 'Lisk Chat',
click() {
electron.shell.openExternal('https://lisk.chat');
},
},
{
label: 'Lisk Explorer',
click() {
electron.shell.openExternal('https://explorer.lisk.io');
},
},
{
label: 'Lisk Forum',
click() {
electron.shell.openExternal('https://forum.lisk.io');
},
},
{
type: 'separator',
},
{
label: 'Report Issue...',
click() {
electron.shell.openExternal('https://lisk.zendesk.com/hc/en-us/requests/new');
},
},
{
label: 'What\'s New...',
click() {
electron.shell.openExternal('https://github.com/LiskHQ/lisk-nano/releases');
},
},
],
},
];

if (process.platform === 'darwin') {
const name = app.getName();

template.unshift({
label: name,
submenu: [
{
role: 'about',
label: 'About',
},
{
role: 'quit',
label: 'Quit',
},
],
});
} else {
template[template.length - 1].submenu.push({
label: 'About',
click(item, focusedWindow) {
if (focusedWindow) {
const options = {
buttons: ['OK'],
icon: `${__dirname}/assets/lisk.png`,
message: `Lisk Nano\nVersion ${app.getVersion()}\n${copyright}`,
};
electron.dialog.showMessageBox(focusedWindow, options, () => {});
}
},
});
if (process.platform === 'win32') {
sendUrlToRouter(process.argv.slice(1));
}

const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
Menu.setApplicationMenu(buildMenu(app, copyright));

win.loadURL(`file://${__dirname}/dist/index.html`);

Expand Down Expand Up @@ -183,6 +70,15 @@ function createWindow() {
selectionMenu.popup(win);
}
});

// Resolve all events from stack when dom is ready
win.webContents.on('did-finish-load', () => {
isUILoaded = true;
if (eventStack.length > 0) {
eventStack.forEach(({ event, value }) => win.webContents.send(event, value));
eventStack = [];
}
});
}

app.on('ready', createWindow);
Expand All @@ -207,6 +103,32 @@ app.on('activate', () => {
}
});

// Set app protocol
app.setAsDefaultProtocolClient(protocolName);

// Force single instance application
const isSecondInstance = app.makeSingleInstance((argv) => {
if (process.platform === 'win32') {
sendUrlToRouter(argv.slice(1));
}
if (win) {
if (win.isMinimized()) win.restore();
win.focus();
}
});

if (isSecondInstance) {
app.quit();
}

app.on('will-finish-launching', () => {
// Protocol handler for MacOS
app.on('open-url', (event, url) => {
event.preventDefault();
sendUrlToRouter(url);
});
});

app.on('login', (event, webContents, request, authInfo, callback) => {
global.myTempFunction = callback;
event.preventDefault();
Expand All @@ -216,3 +138,4 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
ipcMain.on('proxyCredentialsEntered', (event, username, password) => {
global.myTempFunction(username, password);
});

129 changes: 129 additions & 0 deletions app/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
const electron = require('electron'); // eslint-disable-line import/no-extraneous-dependencies

const { Menu } = electron;

const template = [
{
label: 'Edit',
submenu: [
{
role: 'undo',
},
{
role: 'redo',
},
{
type: 'separator',
},
{
role: 'cut',
},
{
role: 'copy',
},
{
role: 'paste',
},
{
role: 'selectall',
},
],
},
{
label: 'View',
submenu: [
{
role: 'reload',
},
{
role: 'togglefullscreen',
},
],
},
{
label: 'Window',
submenu: [
{
role: 'minimize',
},
],
},
{
label: 'Help',
submenu: [
{
label: 'Lisk Website',
click() {
electron.shell.openExternal('https://lisk.io');
},
},
{
label: 'Lisk Chat',
click() {
electron.shell.openExternal('https://lisk.chat');
},
},
{
label: 'Lisk Explorer',
click() {
electron.shell.openExternal('https://explorer.lisk.io');
},
},
{
label: 'Lisk Forum',
click() {
electron.shell.openExternal('https://forum.lisk.io');
},
},
{
type: 'separator',
},
{
label: 'Report Issue...',
click() {
electron.shell.openExternal('https://lisk.zendesk.com/hc/en-us/requests/new');
},
},
{
label: 'What\'s New...',
click() {
electron.shell.openExternal('https://github.com/LiskHQ/lisk-nano/releases');
},
},
],
},
];

module.exports = (app, copyright) => {
if (process.platform === 'darwin') {
const name = app.getName();
template.unshift({
label: name,
submenu: [
{
role: 'about',
label: 'About',
},
{
role: 'quit',
label: 'Quit',
},
],
});
} else {
template[template.length - 1].submenu.push({
label: 'About',
click(item, focusedWindow) {
if (focusedWindow) {
const options = {
buttons: ['OK'],
icon: `${__dirname}/assets/lisk.png`,
message: `Lisk Nano\nVersion ${app.getVersion()}\n${copyright}`,
};
electron.dialog.showMessageBox(focusedWindow, options, () => {});
}
},
});
}
return Menu.buildFromTemplate(template);
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@
"build": {
"appId": "io.lisk.nano",
"productName": "Lisk Nano",
"protocols": {
"name": "lisk-nano",
"schemes": ["lisk"]
},
"artifactName": "lisk-nano-${os}-${arch}-${version}.${ext}",
"linux": {
"target": [
Expand Down
4 changes: 3 additions & 1 deletion src/components/actionBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const ActionBarRaw = ({
<Button
label={secondaryButton.label || t('Cancel')}
className={secondaryButton.className || 'cancel-button'}
onClick={secondaryButton.onClick} />
onClick={secondaryButton.onClick}
type={secondaryButton.type || 'button'} />

<PricedButton
t={t}
Expand All @@ -23,6 +24,7 @@ export const ActionBarRaw = ({
balance={account ? account.balance : 0}
customClassName={primaryButton.className || 'submit-button'}
disabled={primaryButton.disabled}
type={primaryButton.type}
onClick={primaryButton.onClick} />
</section>
);
Expand Down

0 comments on commit 91398da

Please sign in to comment.