Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react"]
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ insert_final_newline = true
# 4 space indentation
[*.js]
indent_style = space
indent_size = 4
indent_size = 2
charset = utf-8

# Matches the exact files either package.json or .travis.yml
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
10 changes: 2 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
module.exports = {
"extends": "airbnb-base",
"globals": {
"document": true,
"fetch": true
},
"extends": "airbnb",
"rules": {
"comma-dangle": ["error", {
"functions": "never",
}],
"indent": [2, 4],
"space-before-function-paren": [
"error",
"never"
],
'import/no-unresolved': 0
]
}
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
release-builds
release-builds
dist
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/main.js",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron"
}
]
}
File renamed without changes.
208 changes: 113 additions & 95 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,148 +9,166 @@ const {
const path = require('path');
const url = require('url');
const AutoLaunch = require('auto-launch');
const setupEvents = require('./src/installers/setupEvents');

setupEvents.handleSquirrelEvent();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow = null;
let tray = null;
let isBrowsing = false;
let dev = false;

const gitEasyAutoLauncher = new AutoLaunch({
name: 'git-easy',
isHidden: true,
mac: {
useLaunchAgent: true
}
name: 'git-easy',
isHidden: true,
mac: {
useLaunchAgent: true
}
});

gitEasyAutoLauncher.isEnabled().then((enabled) => {
if (enabled || process.env.NODE_ENV === 'development') return;
gitEasyAutoLauncher.enable();
if (enabled || process.env.NODE_ENV === 'development') return;
gitEasyAutoLauncher.enable();
});

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow = null;
let tray = null;
let isBrowsing = false;

// TODO: emit a broader hide-window event
const hideWindow = () => {
mainWindow.hide();
mainWindow.webContents.send('clear-filter');
mainWindow.hide();
mainWindow.webContents.send('clear-filter');
};

const showWindow = () => {
if (!isBrowsing) {
mainWindow.show();
}
if (!isBrowsing) {
mainWindow.show();
}
};
// Keep a reference for dev mode
if (process.defaultApp || /[\\/]electron-prebuilt[\\/]/.test(process.execPath) || /[\\/]electron[\\/]/.test(process.execPath)) {
dev = true;
}

const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 350,
height: 450,
show: false,
skipTaskbar: true,
frame: false,
minHeight: 250,
minWidth: 250
});
mainWindow = new BrowserWindow({
width: 350,
height: 450,
show: false,
skipTaskbar: true,
frame: false,
minHeight: 250,
minWidth: 250
});

mainWindow.setMenu(null);

mainWindow.setMenu(null);

// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));

mainWindow.on('blur', () => {
if (!isBrowsing) {
hideWindow();
}
let indexPath;
if (dev && process.argv.indexOf('--noDevServer') === -1) {
indexPath = url.format({
protocol: 'http:',
host: 'localhost:8080',
pathname: 'index.html',
slashes: true
});
} else {
indexPath = url.format({
protocol: 'file:',
pathname: path.join(__dirname, 'dist', 'index.html'),
slashes: true
});
}

// Open the DevTools.
// mainWindow.webContents.openDevTools()
mainWindow.loadURL(indexPath);

// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.on('blur', () => {
if (!isBrowsing) {
hideWindow();
}
});

// Don't show until we are ready and loaded
mainWindow.once('ready-to-show', () => {
// Open the DevTools automatically if developing
if (dev) {
// mainWindow.webContents.openDevTools();
}
});

// Emitted when the window is closed.
mainWindow.on('closed', () => {
mainWindow = null;
});
};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
createWindow();

if (/^darwin/.test(process.platform)) {
app.dock.hide();
createWindow();
// TODO: create proper enum helpers
if (/^darwin/.test(process.platform)) {
app.dock.hide();
}

const contextMenu = Menu.buildFromTemplate([
{
label: 'Show App',
click() {
showWindow();
}
},
{
label: 'Quit',
click() {
app.isQuiting = true;
app.quit();
}
}
]);

tray = new Tray(path.join(__dirname, '/src/assets/images/icon.png'));
tray.setToolTip('Git Easy');

const contextMenu = Menu.buildFromTemplate([
{
label: 'Show App',
click() {
showWindow();
}
},
{
label: 'Quit',
click() {
app.isQuiting = true;
app.quit();
}
}
]);
tray.setContextMenu(contextMenu);

tray.on('click', () => {
showWindow();
});
tray = new Tray(path.join(__dirname, '/src/assets/images/icon.png'));
tray.setToolTip('Git Easy');
tray.setContextMenu(contextMenu);

tray.on('click', () => {
showWindow();
});
});

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
if (mainWindow === null) {
createWindow();
}
});

ipcMain.on('mark-as-browsing', (e, arg) => {
isBrowsing = arg.isBrowsing;
if (isBrowsing) {
hideWindow();
} else {
showWindow();
}
isBrowsing = arg.isBrowsing;
if (isBrowsing) {
hideWindow();
} else {
showWindow();
}
});

ipcMain.on('hide-main-window', () => {
hideWindow();
hideWindow();
});

ipcMain.on('register-shortcut-open', (_, shortcut) => {
/* eslint-disable no-console */
console.log('Global shortcut registered: ', shortcut);
globalShortcut.register(shortcut, () => {
showWindow();
});
console.log('Global shortcut registered: ', shortcut);
globalShortcut.register(shortcut, () => {
showWindow();
});
});
Loading