Merge pull request #143 from filecoin-project/colin/electron-updates

Colin/electron updates
This commit is contained in:
CAKE 2020-08-02 21:39:11 -07:00 committed by GitHub
commit b05f521d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 23 deletions

View File

@ -48,6 +48,7 @@ export default class ApplicationPage extends React.Component {
data: null,
sidebar: null,
sidebarLoading: false,
online: null,
};
async componentDidMount() {
@ -55,6 +56,9 @@ export default class ApplicationPage extends React.Component {
window.addEventListener("dragleave", this._handleDragLeave);
window.addEventListener("dragover", this._handleDragOver);
window.addEventListener("drop", this._handleDrop);
window.addEventListener("online", this._handleOnlineStatus);
window.addEventListener("offline", this._handleOnlineStatus);
}
componentWillUnmount() {
@ -64,6 +68,11 @@ export default class ApplicationPage extends React.Component {
window.removeEventListener("drop", this._handleDrop);
}
_handleOnlineStatus = async () => {
window.alert(navigator.onLine ? "online" : "offline");
this.setState({ online: navigator.onLine });
};
_handleSetFile = async ({ file, slate }) => {
this.setState({ fileLoading: true });
@ -241,7 +250,8 @@ export default class ApplicationPage extends React.Component {
_handleDeleteYourself = async () => {
// TODO(jim):
// Put this somewhere better for messages.
const message = "Do you really want to delete your account? It will be permanently removed";
const message =
"Do you really want to delete your account? It will be permanently removed";
if (!window.confirm(message)) {
return false;
}
@ -441,8 +451,12 @@ export default class ApplicationPage extends React.Component {
<WebsitePrototypeWrapper
title="Slate: sign in"
description="Sign in to your Slate account to manage your assets."
url="https://slate.host/application">
<SceneSignIn onAuthenticate={this._handleAuthenticate} onNavigateTo={this._handleNavigateTo} />
url="https://slate.host/application"
>
<SceneSignIn
onAuthenticate={this._handleAuthenticate}
onNavigateTo={this._handleNavigateTo}
/>
</WebsitePrototypeWrapper>
);
}
@ -515,12 +529,17 @@ export default class ApplicationPage extends React.Component {
return (
<React.Fragment>
<WebsitePrototypeWrapper title={title} description={description} url={url}>
<WebsitePrototypeWrapper
title={title}
description={description}
url={url}
>
<ApplicationLayout
navigation={navigationElement}
header={headerElement}
sidebar={sidebarElement}
onDismissSidebar={this._handleDismissSidebar}>
onDismissSidebar={this._handleDismissSidebar}
>
{scene}
</ApplicationLayout>
</WebsitePrototypeWrapper>

View File

@ -3,12 +3,18 @@ const { app, BrowserWindow } = require("electron");
const path = require("path");
const fs = require("fs-extra");
// NOTE(colin): use NEXTJS Production build
if (process.env.NODE_ENV == undefined) process.env.NODE_ENV = "production";
// NOTE(colin): allow API connection
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED == undefined)
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
function bootServer() {
// TODO(colin): Spin up server on a child process
// const { fork } = require('child_process');
// const ps = fork(path.join(__dirname, '../', 'index.js'));
require(path.join(__dirname, "../", "index.js"));
console.log("server running");
// console.log("server running");
}
function fileOverrides() {
@ -39,7 +45,7 @@ function createWindow() {
// and load the index.html of the app.
// TODO(jim):
// We shouldn't hardcode this port.
mainWindow.loadURL("http://localhost:1337");
mainWindow.loadURL("http://localhost:1337/application");
console.log("window created");
}
@ -51,7 +57,7 @@ app.whenReady().then(() => {
bootServer();
createWindow();
app.on("activate", function() {
app.on("activate", function () {
// 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 (BrowserWindow.getAllWindows().length === 0) createWindow();
@ -61,7 +67,7 @@ app.whenReady().then(() => {
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on("window-all-closed", function() {
app.on("window-all-closed", function () {
if (process.platform !== "darwin") app.quit();
});

View File

@ -1,18 +1,30 @@
require('@babel/register')({
const path = require("path");
const dirPath = path.join(__dirname);
require("@babel/register")({
presets: [
[require.resolve('@babel/preset-env')],
[require.resolve("@babel/preset-env")],
[
require.resolve('next/babel'),
require.resolve("next/babel"),
{
'preset-env': {},
'transform-runtime': {},
'styled-jsx': {},
'class-properties': {},
"preset-env": {},
"transform-runtime": {},
"styled-jsx": {},
"class-properties": {},
},
],
],
plugins: [[require.resolve('@babel/plugin-transform-runtime')]],
ignore: ['node_modules', '.next'],
plugins: [
[require.resolve("@babel/plugin-transform-runtime")],
[
require.resolve("babel-plugin-module-resolver"),
{
alias: {
"~": dirPath,
},
},
],
],
ignore: ["node_modules", ".next"],
});
module.exports = require('./server.js');
module.exports = require("./server.js");

View File

@ -8,11 +8,9 @@
"start": "NODE_ENV=production node . --unhandled-rejections=strict",
"build-delete": "rm -rf .next && rm -rf dist/mac",
"build": "NODE_ENV=production next build",
"build-electron": "NODE_ENV=production next build",
"build-system": "rollup -c",
"electron": "electron ./electron/main.js ",
"electron-pack": "electron-builder --dir",
"electron-dist": "electron-builder",
"electron-dev": "NODE_ENV=development electron ./electron/main.js ",
"electron-prod": "NODE_ENV=production next build && electron-builder --dir",
"scripts": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts",
"www-setup-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts setup-database",
"www-seed-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts seed-database",