From 574b362d128b412ae45bdf5d1a48441a00a0b784 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Mon, 31 Aug 2020 20:31:50 -0400 Subject: [PATCH] Server select overlay working. --- package-lock.json | 53 ++++++++--- package.json | 6 +- .../distribution/DistributionFactory.ts | 31 +++++-- src/renderer/components/Application.tsx | 50 ++++++----- src/renderer/components/overlay/Overlay.tsx | 2 + .../server-select/ServerSelectOverlay.tsx | 89 +++++++++++++++++-- .../overlay/shared-select/SharedSelect.css | 2 +- src/renderer/index.tsx | 1 + 8 files changed, 185 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index d9b0bff..a0e3059 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1361,6 +1361,38 @@ } } }, + "@eslint/eslintrc": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.0.tgz", + "integrity": "sha512-bfL5365QSCmH6cPeFT7Ywclj8C7LiF7sO6mUGzZhtAMV7iID1Euq6740u/SRi4C80NOnVz/CEfK8/HO+nCAPJg==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "import-fresh": "^3.2.1", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "ajv": { + "version": "6.12.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", + "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + } + } + }, "@sindresorhus/is": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-3.1.2.tgz", @@ -1527,9 +1559,9 @@ } }, "@types/lodash": { - "version": "4.14.160", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.160.tgz", - "integrity": "sha512-aP03BShJoO+WVndoVj/WNcB/YBPt+CIU1mvaao2GRAHy2yg4pT/XS4XnVHEQBjPJGycWf/9seKEO9vopTJGkvA==", + "version": "4.14.161", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.161.tgz", + "integrity": "sha512-EP6O3Jkr7bXvZZSZYlsgt5DIjiGr0dXP1/jVEwVLTFgg0d+3lWVQkRavYVQszV7dYUwvg0B8R0MBDpcmXg7XIA==", "dev": true }, "@types/minimatch": { @@ -1556,9 +1588,9 @@ "dev": true }, "@types/react": { - "version": "16.9.48", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.48.tgz", - "integrity": "sha512-4ykBVswgYitPGMXFRxJCHkxJDU2rjfU3/zw67f8+dB7sNdVJXsrwqoYxz/stkAucymnEEbRPFmX7Ce5Mc/kJCw==", + "version": "16.9.49", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.49.tgz", + "integrity": "sha512-DtLFjSj0OYAdVLBbyjhuV9CdGVHCkHn2R+xr3XkBvK2rS1Y1tkc14XSGjYgm5Fjjr90AxH9tiSzc1pCFMGO06g==", "dev": true, "requires": { "@types/prop-types": "*", @@ -4690,12 +4722,13 @@ "dev": true }, "eslint": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.7.0.tgz", - "integrity": "sha512-1KUxLzos0ZVsyL81PnRN335nDtQ8/vZUD6uMtWbF+5zDtjKcsklIi78XoE0MVL93QvWTu+E5y44VyyCsOMBrIg==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.8.0.tgz", + "integrity": "sha512-qgtVyLZqKd2ZXWnLQA4NtVbOyH56zivOAdBFWE54RFkSZjokzNrcP4Z0eVWsZ+84ByXv+jL9k/wE1ENYe8xRFw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", + "@eslint/eslintrc": "^0.1.0", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -4705,7 +4738,7 @@ "eslint-scope": "^5.1.0", "eslint-utils": "^2.1.0", "eslint-visitor-keys": "^1.3.0", - "espree": "^7.2.0", + "espree": "^7.3.0", "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", diff --git a/package.json b/package.json index faa388a..614abf5 100644 --- a/package.json +++ b/package.json @@ -56,10 +56,10 @@ "@types/electron-devtools-installer": "^2.2.0", "@types/fs-extra": "^9.0.1", "@types/jquery": "^3.5.1", - "@types/lodash": "^4.14.160", + "@types/lodash": "^4.14.161", "@types/mocha": "^8.0.3", "@types/node": "^12.12.54", - "@types/react": "^16.9.48", + "@types/react": "^16.9.49", "@types/react-dom": "^16.9.8", "@types/react-redux": "^7.1.9", "@types/react-transition-group": "^4.4.0", @@ -77,7 +77,7 @@ "electron-devtools-installer": "^3.1.1", "electron-webpack": "^2.8.2", "electron-webpack-ts": "^4.0.1", - "eslint": "^7.7.0", + "eslint": "^7.8.0", "eslint-plugin-react": "^7.20.6", "helios-distribution-types": "1.0.0-pre.1", "mocha": "^8.1.3", diff --git a/src/common/distribution/DistributionFactory.ts b/src/common/distribution/DistributionFactory.ts index b5a230d..0e69d62 100644 --- a/src/common/distribution/DistributionFactory.ts +++ b/src/common/distribution/DistributionFactory.ts @@ -1,28 +1,43 @@ import { Distribution, Server, Module, Type, Required as HeliosRequired } from 'helios-distribution-types' import { MavenComponents, MavenUtil } from 'common/util/MavenUtil' import { join } from 'path' +import { LoggerUtil } from 'common/logging/loggerutil' + +const logger = LoggerUtil.getLogger('DistributionFactory') export class HeliosDistribution { - private mainServerIndex: number + private mainServerIndex!: number public readonly servers: HeliosServer[] constructor( public readonly rawDistribution: Distribution ) { - + this.resolveMainServerIndex() this.servers = this.rawDistribution.servers.map(s => new HeliosServer(s)) - this.mainServerIndex = this.indexOfMainServer() } - private indexOfMainServer(): number { - for(let i=0; i 0) { + for(let i=0; i[] + distribution: HeliosDistribution } interface ApplicationState { @@ -49,7 +51,8 @@ interface ApplicationState { const mapState = (state: StoreType): Partial => { return { currentView: state.currentView, - overlayQueue: state.overlayQueue + overlayQueue: state.overlayQueue, + distribution: state.app.distribution! } } const mapDispatch = { @@ -60,6 +63,8 @@ const mapDispatch = { class Application extends React.Component { + private readonly logger = LoggerUtil.getLogger('Application') + private bkid!: number constructor(props: ApplicationProps & typeof mapDispatch) { @@ -185,26 +190,31 @@ class Application extends React.Component this.logger.info('Server Selection Change:', serverId) }) - this.props.pushGenericOverlay({ - title: 'Test Title 3', - description: 'Test Description', - dismissible: true - }) - this.props.pushGenericOverlay({ - title: 'Test Title 4', - description: 'Test Description', - dismissible: true - }) - this.props.pushGenericOverlay({ - title: 'Test Title IMPORTANT', - description: 'Test Description', - dismissible: true - }, true) + // this.props.pushGenericOverlay({ + // title: 'Test Title 2', + // description: 'Test Description', + // dismissible: true + // }) + // this.props.pushGenericOverlay({ + // title: 'Test Title 3', + // description: 'Test Description', + // dismissible: true + // }) + // this.props.pushGenericOverlay({ + // title: 'Test Title 4', + // description: 'Test Description', + // dismissible: true + // }) + // this.props.pushGenericOverlay({ + // title: 'Test Title IMPORTANT', + // description: 'Test Description', + // dismissible: true + // }, true) }, 5000) } const diff = Date.now() - start diff --git a/src/renderer/components/overlay/Overlay.tsx b/src/renderer/components/overlay/Overlay.tsx index e777324..c443895 100644 --- a/src/renderer/components/overlay/Overlay.tsx +++ b/src/renderer/components/overlay/Overlay.tsx @@ -42,6 +42,8 @@ class Overlay extends React.Component { <> ) diff --git a/src/renderer/components/overlay/server-select/ServerSelectOverlay.tsx b/src/renderer/components/overlay/server-select/ServerSelectOverlay.tsx index 68f54e8..ce7e16c 100644 --- a/src/renderer/components/overlay/server-select/ServerSelectOverlay.tsx +++ b/src/renderer/components/overlay/server-select/ServerSelectOverlay.tsx @@ -1,13 +1,86 @@ import * as React from 'react' +import { connect } from 'react-redux' + +import { HeliosServer } from 'common/distribution/DistributionFactory' +import { LoggerUtil } from 'common/logging/loggerutil' +import { OverlayActionDispatch } from '../../../redux/actions/overlayActions' import '../shared-select/SharedSelect.css' -import { Server } from 'helios-distribution-types' export interface ServerSelectOverlayProps { - servers: Server[] + servers: HeliosServer[] + selectedId: string + onSelection: (serverId: string) => void } -export default class ServerSelectOverlay extends React.Component { +interface ServerSelectOverlayState { + selectedId: string +} + +const mapDispatch = { + ...OverlayActionDispatch +} + +type InternalServerSelectOverlayProps = ServerSelectOverlayProps & typeof mapDispatch + +class ServerSelectOverlay extends React.Component { + + private readonly logger = LoggerUtil.getLogger('ServerSelectOverlay') + + constructor(props: InternalServerSelectOverlayProps) { + super(props) + this.state = { + selectedId: props.selectedId + } + } + + private onSelectClick = async (): Promise => { + try { + this.props.onSelection(this.state.selectedId) + } catch(err) { + this.logger.error('Uncaught error in server select confirmation.', err) + } + this.props.popOverlayContent() + } + + private onCancelClick = async (): Promise => { + this.props.popOverlayContent() + } + + getMainServerStar(): JSX.Element { + return ( +
+ + + + + Main Server +
+ ) + } + + getServers(): JSX.Element[] { + const servers: JSX.Element[] = [] + + for(const { rawServer: raw } of this.props.servers) { + servers.push( + + ) + } + + return servers + } render(): JSX.Element { return ( @@ -16,13 +89,13 @@ export default class ServerSelectOverlay extends React.ComponentAvailable Servers
- {/* Server listings populated here. */} + {this.getServers()}
- +
- +
@@ -30,4 +103,6 @@ export default class ServerSelectOverlay extends React.Component(undefined, mapDispatch)(ServerSelectOverlay) \ No newline at end of file diff --git a/src/renderer/components/overlay/shared-select/SharedSelect.css b/src/renderer/components/overlay/shared-select/SharedSelect.css index 0d00791..98aa8d7 100644 --- a/src/renderer/components/overlay/shared-select/SharedSelect.css +++ b/src/renderer/components/overlay/shared-select/SharedSelect.css @@ -68,7 +68,7 @@ position: relative; background: rgba(131, 131, 131, 0.25); } -.serverListing[selected] { +.serverListing[selectedserver] { cursor: default; opacity: 1.0; } diff --git a/src/renderer/index.tsx b/src/renderer/index.tsx index 568bbef..1be4142 100644 --- a/src/renderer/index.tsx +++ b/src/renderer/index.tsx @@ -28,6 +28,7 @@ ReactDOM.render( ,