diff --git a/.gitignore b/.gitignore index 16acd49d7..e6ab8f66c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules dist +build package-lock.json diff --git a/src/component/app.tsx b/src/component/app.tsx index 79bd59041..c4815eff8 100644 --- a/src/component/app.tsx +++ b/src/component/app.tsx @@ -49,14 +49,6 @@ class App extends React.Component { this.handleMainWindowClick = this.handleMainWindowClick.bind(this); } - public componentDidMount(): void { - const webviewTag: WebviewTag = document.getElementById('preview') as WebviewTag; - webviewTag.addEventListener('did-stop-loading', () => { - store.openStyleguide('../designkit'); - store.openPage('homepage'); - }); - } - private handleMainWindowClick(): void { this.props.store.setElementFocus(false); createMenu(store); diff --git a/src/component/menu.ts b/src/component/menu.ts index a25e8c503..7d65bf70b 100644 --- a/src/component/menu.ts +++ b/src/component/menu.ts @@ -1,13 +1,22 @@ import { BrowserWindow, MenuItem, MenuItemConstructorOptions, remote, WebContents } from 'electron'; import { PageElement } from '../store/page/page_element'; import { Store } from '../store'; -const { Menu, shell, app } = remote; +const { Menu, shell, app, dialog } = remote; export function createMenu(store: Store): void { const template: MenuItemConstructorOptions[] = [ { label: '&File', submenu: [ + { + label: '&Open Project', + click: () => { + dialog.showOpenDialog({ properties: ['openDirectory'] }, filePaths => { + store.openStyleguide(filePaths[0]); + store.openPage('homepage'); + }); + } + }, { label: 'New &Page', accelerator: 'CmdOrCtrl+N' diff --git a/src/electron/index.ts b/src/electron/index.ts index 430c97ca0..9dafa20e5 100644 --- a/src/electron/index.ts +++ b/src/electron/index.ts @@ -19,7 +19,7 @@ function createWindow(): void { // and load the index.html of the app. win.loadURL( url.format({ - pathname: PathUtils.join(__dirname, '..', '..', 'src', 'electron', 'index.html'), + pathname: PathUtils.join(__dirname, '..', 'electron', 'index.html'), protocol: 'file:', slashes: true }) diff --git a/src/store/index.ts b/src/store/index.ts index c9ebe87c8..c2b32ec70 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -102,7 +102,7 @@ export class Store { MobX.transaction(() => { if (!PathUtils.isAbsolute(styleGuidePath)) { // Currently, store is two levels below alva, so go two up - styleGuidePath = PathUtils.join(__dirname, '..', '..', styleGuidePath); + styleGuidePath = PathUtils.join(styleGuidePath); } this.styleGuidePath = styleGuidePath; this.currentPage = undefined;