Skip to content

Commit

Permalink
Add menus for all windows and refine styles
Browse files Browse the repository at this point in the history
  • Loading branch information
HR committed Jun 30, 2019
1 parent 5dee590 commit f64bb05
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 51 deletions.
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

7 changes: 3 additions & 4 deletions app/config.js
Expand Up @@ -3,9 +3,8 @@
* config.js
* Provides all essential config constants
******************************/
// const {app} = require('electron')

// Fixed constants
const ICONS_BASE_PATH = `${__dirname}/static/images/icons`
const VIEWS_BASE_URI = `file://${__dirname}/static`

module.exports = {
Expand Down Expand Up @@ -65,10 +64,10 @@ module.exports = {
correct: 'CORRECT MASTERPASS',
incorrect: 'INCORRECT MASTERPASS',
setSuccess: 'MASTERPASS SUCCESSFULLY SET',
empty: 'PLEASE ENTER A MASTERPASS',
empty: 'PLEASE ENTER THE MASTERPASS',
resetSuccess: 'You have successfully reset your MasterPass. You\'ll be redirected to verify it shortly.',
exportSuccess: 'Successfully exported the credentials',
importSuccess: 'Successfully imported the credentials. You will need to verify the MasterPass for the credentials imported so Crypter will relaunch shortly.'
importSuccess: 'Successfully imported the credentials. You will need to verify the MasterPass for the credentials imported after Crypter relaunches.'
},
ERRORS: {
INVALID_MP_CREDS_FILE: 'Not a valid or corrupted Crypter credentials file!',
Expand Down
8 changes: 3 additions & 5 deletions app/src/crypter.js
@@ -1,7 +1,7 @@
const { app, ipcMain, Menu, BrowserWindow } = require('electron')
const { VIEWS, ERRORS, WINDOW_OPTS } = require('../config')
const crypto = require('../core/crypto')
const menuTemplate = require('./menu')
const menuTemplate = require('./mainMenu')
const { isCryptoFile } = require('../utils/utils')
const logger = require('electron-log')

Expand All @@ -12,10 +12,8 @@ exports.window = function (global, fileToCrypt, callback) {
height: 460,
...WINDOW_OPTS
})
// create menu from menuTemplate
const menu = Menu.buildFromTemplate(menuTemplate)
// set menu
Menu.setApplicationMenu(menu)
// create menu from menuTemplate and set
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate))
// loads crypt.html view into the BrowserWindow
win.loadURL(VIEWS.CRYPTER)

Expand Down
19 changes: 19 additions & 0 deletions app/src/mainMenu.js
@@ -0,0 +1,19 @@
const {app, shell} = require('electron')
const menu = require('./menu')

if (process.platform === 'darwin') {
menu.unshift({
label: 'Crypter',
submenu: [
{ label: 'About Crypter', role: 'about' },
{ label: `Version ${app.getVersion()}`, enabled: false },
{ label: 'Check for Update', click() { app.emit('app:check-update') } },
{ type: 'separator' },
{ label: 'Preferences…', click() { app.emit('app:open-settings') } },
{ type: 'separator' },
{ label: 'Quit', click() { app.emit('app:quit') } }
]
})
}

module.exports = menu
9 changes: 6 additions & 3 deletions app/src/masterPassPrompt.js
@@ -1,8 +1,9 @@
const {app, ipcMain, BrowserWindow} = require('electron')
const {app, ipcMain, Menu, BrowserWindow} = require('electron')
const {VIEWS, WINDOW_OPTS} = require('../config')
const MasterPass = require('../core/MasterPass')
const MasterPassKey = require('../core/MasterPassKey')
const logger = require('electron-log')
const menuTemplate = require('./menu')


exports.window = function (global, callback) {
Expand All @@ -15,11 +16,13 @@ exports.window = function (global, callback) {
height: 460,
...WINDOW_OPTS
})
let webContents = win.webContents

// create menu from menuTemplate and set
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate))
// loads masterpassprompt.html view into the BrowserWindow
win.loadURL(VIEWS.MASTERPASSPROMPT)

let webContents = win.webContents

ipcMain.on('checkMasterPass', function (event, masterpass) {
logger.verbose('IPCMAIN: checkMasterPass emitted. Checking MasterPass...')
// Check user submitted MasterPass
Expand Down
21 changes: 2 additions & 19 deletions app/src/menu.js
@@ -1,7 +1,7 @@
const {app, Menu, shell} = require('electron')
const {app, shell} = require('electron')
const {REPO} = require('../config')

const menu = [
module.exports = [
{
label: 'Edit',
submenu: [
Expand Down Expand Up @@ -46,20 +46,3 @@ const menu = [
]
}
]

if (process.platform === 'darwin') {
menu.unshift({
label: 'Crypter',
submenu: [
{ label: 'About Crypter', role: 'about' },
{ label: `Version ${app.getVersion()}`, enabled: false },
{ label: 'Check for Update', click() { app.emit('app:check-update') } },
{ type: 'separator' },
{ label: 'Preferences…', click() { app.emit('app:open-settings') } },
{ type: 'separator' },
{ label: 'Quit', click() { app.emit('app:quit') } }
]
})
}

module.exports = menu
5 changes: 4 additions & 1 deletion app/src/settings.js
@@ -1,4 +1,5 @@
const {app, ipcMain, BrowserWindow} = require('electron')
const {app, ipcMain, Menu, BrowserWindow} = require('electron')
const menuTemplate = require('./menu')
const {CRYPTO, VIEWS, SETTINGS, ERRORS, WINDOW_OPTS} = require('../config')
const logger = require('electron-log')
const fs = require('fs-extra')
Expand All @@ -11,6 +12,8 @@ exports.window = function (global, callback) {
height: 460,
...WINDOW_OPTS
})
// create menu from menuTemplate and set
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate))

let webContents = win.webContents
// loads settings.html view into the BrowserWindow
Expand Down
6 changes: 5 additions & 1 deletion app/src/setup.js
@@ -1,8 +1,9 @@
const {app, ipcMain, BrowserWindow} = require('electron')
const {app, ipcMain, Menu, BrowserWindow} = require('electron')
const {VIEWS, WINDOW_OPTS} = require('../config')
const MasterPass = require('../core/MasterPass')
const MasterPassKey = require('../core/MasterPassKey')
const logger = require('electron-log')
const menuTemplate = require('./menu')

exports.window = function (global, callback) {
// setup view controller
Expand All @@ -14,6 +15,9 @@ exports.window = function (global, callback) {
...WINDOW_OPTS
})

// create menu from menuTemplate and set
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate))

let webContents = win.webContents
let error
// loads setup.html view into the SetupWindow
Expand Down
11 changes: 6 additions & 5 deletions app/static/crypter.html
Expand Up @@ -30,10 +30,11 @@ <h1 class="title">Crypter</h1>
</div>
<div id="panel-crypted">
<div id="crypted-container">
<!-- Dynamically load file info here -->
<!-- Crypted panel dynamically loaded here -->
</div>
<p class="intrfo">
Note these details down!<br/>They may be erased when you navigate back
Note these details down<br/>
(for use with third-party apps)
</p>
<footer>
<a class="back navigationLink" data-panel="crypt">
Expand All @@ -48,16 +49,16 @@ <h1 class="title">Crypter</h1>
<img src="images/icons/{{op}}.svg" class="header"/>
</header>
<div id="finfo">
<h3><div title="{{name}}">{{op}} {{name}}</div></h3>
<h3><div title="{{cryptPath}}">{{op}} {{name}}</div></h3>
<table>
<tr>
<td>Path</td>
<td>Original file</td>
<td>
<input type="text" readonly="readonly" value="{{path}}" title="{{path}}"/>
</td>
</tr>
<tr>
<td>Crypted to</td>
<td>{{op}} file</td>
<td>
<input type="text" readonly="readonly" value="{{cryptPath}}" title="{{cryptPath}}"/>
</td>
Expand Down

0 comments on commit f64bb05

Please sign in to comment.