From 539ec0d1fa52d83cae2a77fd4fdd1cb561eb6b1d Mon Sep 17 00:00:00 2001 From: John Hatton Date: Sat, 18 Jan 2020 12:24:38 -0700 Subject: [PATCH] Change beta alert message to fix electron focus problem --- app/components/AlertDialog/AlertDialog.scss | 27 ++++++++ app/components/AlertDialog/AlertDialog.tsx | 68 ++++++++++++++++++++ app/containers/HomePage.tsx | 16 ++--- app/package.json | 2 +- assets/Warning.png | Bin 1871 -> 624 bytes 5 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 app/components/AlertDialog/AlertDialog.scss create mode 100644 app/components/AlertDialog/AlertDialog.tsx diff --git a/app/components/AlertDialog/AlertDialog.scss b/app/components/AlertDialog/AlertDialog.scss new file mode 100644 index 00000000..c8224a01 --- /dev/null +++ b/app/components/AlertDialog/AlertDialog.scss @@ -0,0 +1,27 @@ +//@import "../../colors"; +@import "../commonDialog.scss"; + +.alertDialog { + .dialogContent { + padding: 20px; + display: flex; + flex-direction: column; + + .row { + display: flex; + flex-direction: row; + img { + width: auto; + margin-right: 10px; + margin-top: 3px; + } + } + h1 { + font-family: Roboto; + font-size: 12pt; + height: 1em; + font-weight: bold; + margin: 0; + } + } +} diff --git a/app/components/AlertDialog/AlertDialog.tsx b/app/components/AlertDialog/AlertDialog.tsx new file mode 100644 index 00000000..6bbbda04 --- /dev/null +++ b/app/components/AlertDialog/AlertDialog.tsx @@ -0,0 +1,68 @@ +import * as React from "react"; +import ReactModal from "react-modal"; +import "./AlertDialog.scss"; +import CloseOnEscape from "react-close-on-escape"; +import { locate } from "../../crossPlatformUtilities"; +import { Trans } from "@lingui/react"; + +interface IState { + isOpen: boolean; + config: IConfig; +} +interface IConfig { + message: string; + buttonText?: string; +} +export default class AlertDialog extends React.Component<{}, IState> { + private static singleton: AlertDialog; + + constructor() { + super({}); + this.state = { + isOpen: false, + config: { message: "message is not set yet" } + }; + AlertDialog.singleton = this; + } + private handleCloseModal(doDelete: boolean) { + this.setState({ isOpen: false }); + } + + public static async show(config: IConfig) { + AlertDialog.singleton.setState({ + isOpen: true, + config + }); + } + public render() { + return ( + { + this.handleCloseModal(false); + }} + > + this.handleCloseModal(false)} + > +
+
+ +

{this.state.config.message}

+
+
+
+
+ +
+
+
+
+ ); + } +} diff --git a/app/containers/HomePage.tsx b/app/containers/HomePage.tsx index b5e150ab..2191a5c9 100644 --- a/app/containers/HomePage.tsx +++ b/app/containers/HomePage.tsx @@ -21,6 +21,8 @@ import { t } from "@lingui/macro"; import { i18n } from "../localization"; import { analyticsEvent } from "../analytics"; import RegistrationDialog from "../components/registration/RegistrationDialog"; +import AlertDialog from "../components/AlertDialog/AlertDialog"; + const isDev = require("electron-is-dev"); // tslint:disable-next-line:no-empty-interface @@ -93,15 +95,10 @@ export default class HomePage extends React.Component { public componentDidMount() { if (!this.isRunningFromSource()) { - // NB: From code (at least on windows), it is safe to just show windows.alert. But on macos, when run from DMG, - // a blank window comes up, and the alert is hidden behind it. So the timeout here is just to get it in front. - window.setTimeout( - () => - window.alert( - `Thanks for helping to test SayMore X! Warning: this is a "beta", so make sure you have a backup of your work.` - ), - 2000 - ); + AlertDialog.show({ + message: `Warning: this is a beta test version, so make sure you have a backup of your work.`, + buttonText: "I understand" + }); } if (userSettings.HowUsing === "") { @@ -239,6 +236,7 @@ export default class HomePage extends React.Component { "" )} + ); } diff --git a/app/package.json b/app/package.json index 827cb4ac..bb1eef38 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "saymore-x", "productName": "SayMore X", - "version": "0.8.1", + "version": "0.8.2", "description": "File & metadata organization for language documentation projects.", "main": "./main-bundle.js", "author": { diff --git a/assets/Warning.png b/assets/Warning.png index 8df35174c7700b51aec94ccfbd3aee00afac7982..574a54b70c0d67e1abcb1c4ce64c261899ff2c6f 100644 GIT binary patch delta 612 zcmV-q0-OEM4)6q!7k?ZG1^@s60K&Z@00009a7bBm000XU000XU0RWnu7ytkO0drDE zLIAGL9O(c600d`2O+f$vv5yPSKP@e0_!%zt$fF!*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