From 1ddc9cc92951e959fea3374d207ba6671877d0b2 Mon Sep 17 00:00:00 2001 From: Joseph Chamish Date: Wed, 20 Jan 2021 18:50:18 -0500 Subject: [PATCH] Structure change (#4220) * Structure change * Remove duplicate folders from previous structure * Cleanup websocket protocol * Updating from based off PR * Fixup - remove wrong files during conflict and get the websocket working * renaming tsx to ts Co-authored-by: Jeremy Letto --- webclient/copy_shared_files.ps1 | 3 + webclient/package-lock.json | 18 ++++ webclient/package.json | 7 +- webclient/src/AppShell/Player/Player.css | 0 .../src/AppShell/common/services/index.ts | 4 - webclient/src/AppShell/common/types/index.tsx | 2 - webclient/src/AppShell/common/types/user.tsx | 3 - webclient/src/WebClient/commands/index.tsx | 2 - .../src/WebClient/events/RoomEvents/index.tsx | 4 - .../src/WebClient/services/RoomService.tsx | 53 ---------- webclient/src/WebClient/services/index.ts | 3 - .../CheckboxField/CheckboxField.css | 0 .../CheckboxField/CheckboxField.tsx | 0 .../{AppShell => components}/Decks/Decks.css | 0 .../{AppShell => components}/Decks/Decks.tsx | 2 +- .../{AppShell => components}/Game/Game.css | 0 .../{AppShell => components}/Game/Game.tsx | 2 +- .../guards => components/Guard}/AuthGuard.tsx | 8 +- .../guards => components/Guard}/ModGuard.tsx | 8 +- .../Header/Header.css | 0 .../Header/Header.tsx | 7 +- .../{AppShell => components}/Header/logo.png | Bin .../components/InputAction/InputAction.css | 0 .../components/InputAction/InputAction.tsx | 2 +- .../components/InputField/InputField.tsx | 0 .../Logs}/LogResults.css | 0 .../Logs}/LogResults.tsx | 0 .../{AppShell => components}/Logs/Logs.css | 0 .../{AppShell => components}/Logs/Logs.tsx | 15 ++- .../Player/Player.tsx | 4 +- .../Room/Games => components/Room}/Games.css | 0 .../Room/Games => components/Room}/Games.tsx | 9 +- .../Messages => components/Room}/Messages.css | 0 .../Messages => components/Room}/Messages.tsx | 0 .../{AppShell => components}/Room/Room.css | 0 .../{AppShell => components}/Room/Room.tsx | 20 ++-- .../Room}/SayMessage.tsx | 2 +- .../ScrollToBottomOnChanges.tsx | 0 .../components/SelectField/SelectField.css | 0 .../components/SelectField/SelectField.tsx | 0 .../Rooms => components/Server}/Rooms.css | 0 .../Rooms => components/Server}/Rooms.tsx | 5 +- .../Server/Server.css | 0 .../Server/Server.tsx | 19 ++-- .../ThreePaneLayout/ThreePaneLayout.css | 0 .../ThreePaneLayout/ThreePaneLayout.tsx | 4 +- .../components/UserDisplay/UserDisplay.css | 0 .../components/UserDisplay/UserDisplay.tsx | 10 +- .../components/VirtualList/VirtualList.css | 0 .../components/VirtualList/VirtualList.tsx | 0 webclient/src/components/index.ts | 25 +++++ .../Account/Account.css | 0 .../Account/Account.tsx | 26 ++--- .../Account}/AddToBuddies.tsx | 2 +- .../Account}/AddToIgnore.tsx | 2 +- .../{AppShell => containers/App}/AppShell.css | 0 .../{AppShell => containers/App}/AppShell.tsx | 6 +- .../App}/AppShellRoutes.tsx | 18 ++-- webclient/src/containers/index.ts | 2 + .../ConnectForm/ConnectForm.css | 0 .../ConnectForm/ConnectForm.tsx | 3 +- .../RegisterForm/RegisterForm.css | 0 .../RegisterForm/RegisterForm.tsx | 2 +- .../Logs => forms}/SearchForm/SearchForm.css | 0 .../Logs => forms}/SearchForm/SearchForm.tsx | 3 +- webclient/src/forms/index.ts | 4 + webclient/src/index.tsx | 2 +- webclient/src/store/common/SortUtil.tsx | 2 +- webclient/src/store/common/index.ts | 2 +- webclient/src/store/index.ts | 21 +++- webclient/src/store/rooms/index.ts | 1 - webclient/src/store/rooms/rooms.dispatch.tsx | 2 +- .../store/{rootReducer.tsx => rootReducer.ts} | 0 webclient/src/store/server/index.ts | 7 +- .../{server.actions.tsx => server.actions.ts} | 0 ...server.dispatch.tsx => server.dispatch.ts} | 2 +- ...er.interfaces.tsx => server.interfaces.ts} | 0 .../{server.reducer.tsx => server.reducer.ts} | 0 ...rver.selectors.tsx => server.selectors.ts} | 0 .../{server.types.tsx => server.types.ts} | 0 webclient/src/store/{store.tsx => store.ts} | 0 webclient/src/translations/en.json | 3 + webclient/src/types/index.ts | 4 +- .../{AppShell/common => }/types/routes.tsx | 0 .../{WebClient => websocket}/ProtoFiles.tsx | 0 .../{WebClient => websocket}/WebClient.tsx | 10 +- .../WebClient/services/RoomService.tsx | 48 +++++++++ .../WebClient/services/SessionService.tsx | 45 ++++----- .../commands/RoomCommands.tsx | 2 +- .../commands/SessionCommands.tsx | 4 +- webclient/src/websocket/commands/index.tsx | 2 + .../events/RoomEvents/JoinRoom.tsx | 0 .../events/RoomEvents/LeaveRoom.tsx | 0 .../events/RoomEvents/ListGames.tsx | 0 .../events/RoomEvents/RoomSay.tsx | 0 .../src/websocket/events/RoomEvents/index.tsx | 4 + .../events/SessionEvents/AddToList.tsx | 0 .../events/SessionEvents/ConnectionClosed.tsx | 0 .../events/SessionEvents/ListRooms.tsx | 0 .../events/SessionEvents/NotifyUser.tsx | 0 .../SessionEvents/PlayerPropertiesChanges.tsx | 0 .../events/SessionEvents/RemoveFromList.tsx | 0 .../SessionEvents/ServerIdentification.tsx | 0 .../events/SessionEvents/ServerMessage.tsx | 0 .../events/SessionEvents/ServerShutdown.tsx | 0 .../events/SessionEvents/UserJoined.tsx | 0 .../events/SessionEvents/UserLeft.tsx | 0 .../events/SessionEvents/UserMessage.tsx | 0 .../events/SessionEvents/index.ts | 0 webclient/src/websocket/index.ts | 11 ++ .../AuthenticationService.tsx | 4 +- .../instanceService}/ModeratorService.tsx | 4 +- .../instanceService}/RoomsService.tsx | 4 +- .../instanceService}/RouterService.tsx | 2 +- .../instanceService}/SessionService.tsx | 4 +- .../src/websocket/instanceService/index.ts | 4 + .../services/NormalizeService.tsx | 2 +- .../src/websocket/services/RoomService.tsx | 50 ++++++++++ .../src/websocket/services/SessionService.tsx | 94 ++++++++++++++++++ webclient/src/websocket/services/index.ts | 3 + .../util => websocket/utils}/guid.util.tsx | 0 .../util => websocket/utils}/index.tsx | 0 .../utils}/sanitizeHtml.util.tsx | 0 123 files changed, 424 insertions(+), 228 deletions(-) create mode 100644 webclient/copy_shared_files.ps1 delete mode 100644 webclient/src/AppShell/Player/Player.css delete mode 100644 webclient/src/AppShell/common/services/index.ts delete mode 100644 webclient/src/AppShell/common/types/index.tsx delete mode 100644 webclient/src/AppShell/common/types/user.tsx delete mode 100644 webclient/src/WebClient/commands/index.tsx delete mode 100644 webclient/src/WebClient/events/RoomEvents/index.tsx delete mode 100644 webclient/src/WebClient/services/RoomService.tsx delete mode 100644 webclient/src/WebClient/services/index.ts rename webclient/src/{AppShell/common => }/components/CheckboxField/CheckboxField.css (100%) rename webclient/src/{AppShell/common => }/components/CheckboxField/CheckboxField.tsx (100%) rename webclient/src/{AppShell => components}/Decks/Decks.css (100%) rename webclient/src/{AppShell => components}/Decks/Decks.tsx (75%) rename webclient/src/{AppShell => components}/Game/Game.css (100%) rename webclient/src/{AppShell => components}/Game/Game.tsx (75%) rename webclient/src/{AppShell/common/guards => components/Guard}/AuthGuard.tsx (62%) rename webclient/src/{AppShell/common/guards => components/Guard}/ModGuard.tsx (64%) rename webclient/src/{AppShell => components}/Header/Header.css (100%) rename webclient/src/{AppShell => components}/Header/Header.tsx (93%) rename webclient/src/{AppShell => components}/Header/logo.png (100%) rename webclient/src/{AppShell/common => }/components/InputAction/InputAction.css (100%) rename webclient/src/{AppShell/common => }/components/InputAction/InputAction.tsx (91%) rename webclient/src/{AppShell/common => }/components/InputField/InputField.tsx (100%) rename webclient/src/{AppShell/Logs/LogResults => components/Logs}/LogResults.css (100%) rename webclient/src/{AppShell/Logs/LogResults => components/Logs}/LogResults.tsx (100%) rename webclient/src/{AppShell => components}/Logs/Logs.css (100%) rename webclient/src/{AppShell => components}/Logs/Logs.tsx (83%) rename webclient/src/{AppShell => components}/Player/Player.tsx (68%) rename webclient/src/{AppShell/Room/Games => components/Room}/Games.css (100%) rename webclient/src/{AppShell/Room/Games => components/Room}/Games.tsx (94%) rename webclient/src/{AppShell/Room/Messages => components/Room}/Messages.css (100%) rename webclient/src/{AppShell/Room/Messages => components/Room}/Messages.tsx (100%) rename webclient/src/{AppShell => components}/Room/Room.css (100%) rename webclient/src/{AppShell => components}/Room/Room.tsx (74%) rename webclient/src/{AppShell/Room/SayMessage => components/Room}/SayMessage.tsx (83%) rename webclient/src/{AppShell/common => }/components/ScrollToBottomOnChanges/ScrollToBottomOnChanges.tsx (100%) rename webclient/src/{AppShell/common => }/components/SelectField/SelectField.css (100%) rename webclient/src/{AppShell/common => }/components/SelectField/SelectField.tsx (100%) rename webclient/src/{AppShell/Server/Rooms => components/Server}/Rooms.css (100%) rename webclient/src/{AppShell/Server/Rooms => components/Server}/Rooms.tsx (94%) rename webclient/src/{AppShell => components}/Server/Server.css (100%) rename webclient/src/{AppShell => components}/Server/Server.tsx (86%) rename webclient/src/{AppShell/common => }/components/ThreePaneLayout/ThreePaneLayout.css (100%) rename webclient/src/{AppShell/common => }/components/ThreePaneLayout/ThreePaneLayout.tsx (96%) rename webclient/src/{AppShell/common => }/components/UserDisplay/UserDisplay.css (100%) rename webclient/src/{AppShell/common => }/components/UserDisplay/UserDisplay.tsx (94%) rename webclient/src/{AppShell/common => }/components/VirtualList/VirtualList.css (100%) rename webclient/src/{AppShell/common => }/components/VirtualList/VirtualList.tsx (100%) create mode 100644 webclient/src/components/index.ts rename webclient/src/{AppShell => containers}/Account/Account.css (100%) rename webclient/src/{AppShell => containers}/Account/Account.tsx (84%) rename webclient/src/{AppShell/Account/AddToBuddies => containers/Account}/AddToBuddies.tsx (84%) rename webclient/src/{AppShell/Account/AddToIgnore => containers/Account}/AddToIgnore.tsx (83%) rename webclient/src/{AppShell => containers/App}/AppShell.css (100%) rename webclient/src/{AppShell => containers/App}/AppShell.tsx (95%) rename webclient/src/{AppShell => containers/App}/AppShellRoutes.tsx (69%) create mode 100644 webclient/src/containers/index.ts rename webclient/src/{AppShell/Server => forms}/ConnectForm/ConnectForm.css (100%) rename webclient/src/{AppShell/Server => forms}/ConnectForm/ConnectForm.tsx (94%) rename webclient/src/{AppShell/Server => forms}/RegisterForm/RegisterForm.css (100%) rename webclient/src/{AppShell/Server => forms}/RegisterForm/RegisterForm.tsx (96%) rename webclient/src/{AppShell/Logs => forms}/SearchForm/SearchForm.css (100%) rename webclient/src/{AppShell/Logs => forms}/SearchForm/SearchForm.tsx (93%) create mode 100644 webclient/src/forms/index.ts rename webclient/src/store/{rootReducer.tsx => rootReducer.ts} (100%) rename webclient/src/store/server/{server.actions.tsx => server.actions.ts} (100%) rename webclient/src/store/server/{server.dispatch.tsx => server.dispatch.ts} (98%) rename webclient/src/store/server/{server.interfaces.tsx => server.interfaces.ts} (100%) rename webclient/src/store/server/{server.reducer.tsx => server.reducer.ts} (100%) rename webclient/src/store/server/{server.selectors.tsx => server.selectors.ts} (100%) rename webclient/src/store/server/{server.types.tsx => server.types.ts} (100%) rename webclient/src/store/{store.tsx => store.ts} (100%) create mode 100644 webclient/src/translations/en.json rename webclient/src/{AppShell/common => }/types/routes.tsx (100%) rename webclient/src/{WebClient => websocket}/ProtoFiles.tsx (100%) rename webclient/src/{WebClient => websocket}/WebClient.tsx (96%) create mode 100644 webclient/src/websocket/WebClient/services/RoomService.tsx rename webclient/src/{ => websocket}/WebClient/services/SessionService.tsx (50%) rename webclient/src/{WebClient => websocket}/commands/RoomCommands.tsx (93%) rename webclient/src/{WebClient => websocket}/commands/SessionCommands.tsx (99%) create mode 100644 webclient/src/websocket/commands/index.tsx rename webclient/src/{WebClient => websocket}/events/RoomEvents/JoinRoom.tsx (100%) rename webclient/src/{WebClient => websocket}/events/RoomEvents/LeaveRoom.tsx (100%) rename webclient/src/{WebClient => websocket}/events/RoomEvents/ListGames.tsx (100%) rename webclient/src/{WebClient => websocket}/events/RoomEvents/RoomSay.tsx (100%) create mode 100644 webclient/src/websocket/events/RoomEvents/index.tsx rename webclient/src/{WebClient => websocket}/events/SessionEvents/AddToList.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/ConnectionClosed.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/ListRooms.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/NotifyUser.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/PlayerPropertiesChanges.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/RemoveFromList.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/ServerIdentification.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/ServerMessage.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/ServerShutdown.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/UserJoined.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/UserLeft.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/UserMessage.tsx (100%) rename webclient/src/{WebClient => websocket}/events/SessionEvents/index.ts (100%) create mode 100644 webclient/src/websocket/index.ts rename webclient/src/{AppShell/common/services => websocket/instanceService}/AuthenticationService.tsx (83%) rename webclient/src/{AppShell/common/services => websocket/instanceService}/ModeratorService.tsx (55%) rename webclient/src/{AppShell/common/services => websocket/instanceService}/RoomsService.tsx (70%) rename webclient/src/{AppShell/common/services => websocket/instanceService}/RouterService.tsx (61%) rename webclient/src/{AppShell/common/services => websocket/instanceService}/SessionService.tsx (84%) create mode 100644 webclient/src/websocket/instanceService/index.ts rename webclient/src/{WebClient => websocket}/services/NormalizeService.tsx (96%) create mode 100644 webclient/src/websocket/services/RoomService.tsx create mode 100644 webclient/src/websocket/services/SessionService.tsx create mode 100644 webclient/src/websocket/services/index.ts rename webclient/src/{WebClient/util => websocket/utils}/guid.util.tsx (100%) rename webclient/src/{WebClient/util => websocket/utils}/index.tsx (100%) rename webclient/src/{WebClient/util => websocket/utils}/sanitizeHtml.util.tsx (100%) diff --git a/webclient/copy_shared_files.ps1 b/webclient/copy_shared_files.ps1 new file mode 100644 index 00000000..1c80b1be --- /dev/null +++ b/webclient/copy_shared_files.ps1 @@ -0,0 +1,3 @@ +#!/bin/bash +robocopy /E ../common/pb/. ./public/pb/ +robocopy /E ../cockatrice/resources/countries/. ./src/images/countries diff --git a/webclient/package-lock.json b/webclient/package-lock.json index 5862024f..526eef08 100644 --- a/webclient/package-lock.json +++ b/webclient/package-lock.json @@ -1612,6 +1612,24 @@ "@types/react": "*" } }, + "@types/react-virtualized-auto-sizer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.0.tgz", + "integrity": "sha512-NMErdIdSnm2j/7IqMteRiRvRulpjoELnXWUwdbucYCz84xG9PHcoOrr7QfXwB/ku7wd6egiKFrzt/+QK4Imeeg==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, + "@types/react-window": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.2.tgz", + "integrity": "sha512-gP1xam68Wc4ZTAee++zx6pTdDAH08rAkQrWm4B4F/y6hhmlT9Mgx2q8lTCXnrPHXsr15XjRN9+K2DLKcz44qEQ==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, "@types/redux": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/@types/redux/-/redux-3.6.0.tgz", diff --git a/webclient/package.json b/webclient/package.json index baa531e3..0f628c3b 100644 --- a/webclient/package.json +++ b/webclient/package.json @@ -37,8 +37,7 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject", - "postinstall": "./copy_shared_files.sh" + "eject": "react-scripts eject" }, "eslintConfig": { "extends": "react-app" @@ -54,5 +53,9 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "@types/react-virtualized-auto-sizer": "^1.0.0", + "@types/react-window": "^1.8.2" } } diff --git a/webclient/src/AppShell/Player/Player.css b/webclient/src/AppShell/Player/Player.css deleted file mode 100644 index e69de29b..00000000 diff --git a/webclient/src/AppShell/common/services/index.ts b/webclient/src/AppShell/common/services/index.ts deleted file mode 100644 index c396ed56..00000000 --- a/webclient/src/AppShell/common/services/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./AuthenticationService"; -export * from "./ModeratorService"; -export * from "./RoomsService"; -export * from "./SessionService"; \ No newline at end of file diff --git a/webclient/src/AppShell/common/types/index.tsx b/webclient/src/AppShell/common/types/index.tsx deleted file mode 100644 index 3369f43e..00000000 --- a/webclient/src/AppShell/common/types/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./routes"; -export * from "./user"; \ No newline at end of file diff --git a/webclient/src/AppShell/common/types/user.tsx b/webclient/src/AppShell/common/types/user.tsx deleted file mode 100644 index 3d5f9a0a..00000000 --- a/webclient/src/AppShell/common/types/user.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export interface User { - name: string; -} \ No newline at end of file diff --git a/webclient/src/WebClient/commands/index.tsx b/webclient/src/WebClient/commands/index.tsx deleted file mode 100644 index 96282909..00000000 --- a/webclient/src/WebClient/commands/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./RoomCommands"; -export * from "./SessionCommands"; \ No newline at end of file diff --git a/webclient/src/WebClient/events/RoomEvents/index.tsx b/webclient/src/WebClient/events/RoomEvents/index.tsx deleted file mode 100644 index ecf21479..00000000 --- a/webclient/src/WebClient/events/RoomEvents/index.tsx +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./JoinRoom"; -export * from "./LeaveRoom"; -export * from "./ListGames"; -export * from "./RoomSay"; diff --git a/webclient/src/WebClient/services/RoomService.tsx b/webclient/src/WebClient/services/RoomService.tsx deleted file mode 100644 index fe45a5bb..00000000 --- a/webclient/src/WebClient/services/RoomService.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { Dispatch, Selectors } from "store/rooms"; -import { store } from "store"; - - -import { WebClient } from "../WebClient"; - -import { NormalizeService } from "./NormalizeService"; - -export class RoomService { - webClient: WebClient; - - constructor(webClient) { - this.webClient = webClient; - } - - clearStore() { - Dispatch.clearStore(); - } - - joinRoom(roomInfo) { - NormalizeService.normalizeRoomInfo(roomInfo); - Dispatch.joinRoom(roomInfo); - } - - updateRooms(rooms) { - Dispatch.updateRooms(rooms); - } - - updateGames(roomId, gameList) { - const game = gameList[0]; - - if (!game.gameType) { - const { gametypeMap } = Selectors.getRoom(store.getState(), roomId); - NormalizeService.normalizeGameObject(game, gametypeMap); - } - - Dispatch.updateGames(roomId, gameList); - } - - addMessage(roomId, message) { - NormalizeService.normalizeUserMessage(message); - - Dispatch.addMessage(roomId, message); - } - - userJoined(roomId, user) { - Dispatch.userJoined(roomId, user); - } - - userLeft(roomId, name) { - Dispatch.userLeft(roomId, name); - } -} diff --git a/webclient/src/WebClient/services/index.ts b/webclient/src/WebClient/services/index.ts deleted file mode 100644 index 8e86f29d..00000000 --- a/webclient/src/WebClient/services/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./NormalizeService"; -export * from "./RoomService"; -export * from "./SessionService"; \ No newline at end of file diff --git a/webclient/src/AppShell/common/components/CheckboxField/CheckboxField.css b/webclient/src/components/CheckboxField/CheckboxField.css similarity index 100% rename from webclient/src/AppShell/common/components/CheckboxField/CheckboxField.css rename to webclient/src/components/CheckboxField/CheckboxField.css diff --git a/webclient/src/AppShell/common/components/CheckboxField/CheckboxField.tsx b/webclient/src/components/CheckboxField/CheckboxField.tsx similarity index 100% rename from webclient/src/AppShell/common/components/CheckboxField/CheckboxField.tsx rename to webclient/src/components/CheckboxField/CheckboxField.tsx diff --git a/webclient/src/AppShell/Decks/Decks.css b/webclient/src/components/Decks/Decks.css similarity index 100% rename from webclient/src/AppShell/Decks/Decks.css rename to webclient/src/components/Decks/Decks.css diff --git a/webclient/src/AppShell/Decks/Decks.tsx b/webclient/src/components/Decks/Decks.tsx similarity index 75% rename from webclient/src/AppShell/Decks/Decks.tsx rename to webclient/src/components/Decks/Decks.tsx index 21235466..83c9d9c5 100644 --- a/webclient/src/AppShell/Decks/Decks.tsx +++ b/webclient/src/components/Decks/Decks.tsx @@ -1,7 +1,7 @@ // eslint-disable-next-line import React, { Component } from "react"; -import AuthGuard from "AppShell/common/guards/AuthGuard"; +import { AuthGuard } from "components/index"; import "./Decks.css"; diff --git a/webclient/src/AppShell/Game/Game.css b/webclient/src/components/Game/Game.css similarity index 100% rename from webclient/src/AppShell/Game/Game.css rename to webclient/src/components/Game/Game.css diff --git a/webclient/src/AppShell/Game/Game.tsx b/webclient/src/components/Game/Game.tsx similarity index 75% rename from webclient/src/AppShell/Game/Game.tsx rename to webclient/src/components/Game/Game.tsx index 566f92a8..dd4f516e 100644 --- a/webclient/src/AppShell/Game/Game.tsx +++ b/webclient/src/components/Game/Game.tsx @@ -1,7 +1,7 @@ // eslint-disable-next-line import React, { Component } from "react"; -import AuthGuard from "AppShell/common/guards/AuthGuard"; +import { AuthGuard } from "../index"; import "./Game.css"; diff --git a/webclient/src/AppShell/common/guards/AuthGuard.tsx b/webclient/src/components/Guard/AuthGuard.tsx similarity index 62% rename from webclient/src/AppShell/common/guards/AuthGuard.tsx rename to webclient/src/components/Guard/AuthGuard.tsx index 922f22f8..07198a5b 100644 --- a/webclient/src/AppShell/common/guards/AuthGuard.tsx +++ b/webclient/src/components/Guard/AuthGuard.tsx @@ -2,10 +2,10 @@ import React, { Component } from "react"; import { connect } from "react-redux"; import { Redirect } from "react-router-dom"; -import { Selectors } from "store/server"; +import { ServerSelectors } from "store"; +import { RouteEnum } from "types"; -import { AuthenticationService } from "AppShell/common/services"; -import { RouteEnum } from "AppShell/common/types"; +import { AuthenticationService } from "websocket"; class AuthGuard extends Component { render() { @@ -20,7 +20,7 @@ interface AuthGuardProps { } const mapStateToProps = state => ({ - state: Selectors.getState(state), + state: ServerSelectors.getState(state), }); export default connect(mapStateToProps)(AuthGuard); \ No newline at end of file diff --git a/webclient/src/AppShell/common/guards/ModGuard.tsx b/webclient/src/components/Guard/ModGuard.tsx similarity index 64% rename from webclient/src/AppShell/common/guards/ModGuard.tsx rename to webclient/src/components/Guard/ModGuard.tsx index 9951d788..e1ea5e3d 100644 --- a/webclient/src/AppShell/common/guards/ModGuard.tsx +++ b/webclient/src/components/Guard/ModGuard.tsx @@ -2,11 +2,11 @@ import React, { Component } from "react"; import { connect } from "react-redux"; import { Redirect } from "react-router-dom"; -import { Selectors } from "store/server"; +import { ServerSelectors } from "store"; import { User } from "types"; -import { AuthenticationService } from "AppShell/common/services"; -import { RouteEnum } from "AppShell/common/types"; +import { AuthenticationService } from "websocket"; +import { RouteEnum } from "types"; class ModGuard extends Component { render() { @@ -21,7 +21,7 @@ interface ModGuardProps { } const mapStateToProps = state => ({ - user: Selectors.getUser(state), + user: ServerSelectors.getUser(state), }); export default connect(mapStateToProps)(ModGuard); \ No newline at end of file diff --git a/webclient/src/AppShell/Header/Header.css b/webclient/src/components/Header/Header.css similarity index 100% rename from webclient/src/AppShell/Header/Header.css rename to webclient/src/components/Header/Header.css diff --git a/webclient/src/AppShell/Header/Header.tsx b/webclient/src/components/Header/Header.tsx similarity index 93% rename from webclient/src/AppShell/Header/Header.tsx rename to webclient/src/components/Header/Header.tsx index 2fef07ad..5bede691 100644 --- a/webclient/src/AppShell/Header/Header.tsx +++ b/webclient/src/components/Header/Header.tsx @@ -6,12 +6,11 @@ import Chip from "@material-ui/core/Chip"; import Toolbar from "@material-ui/core/Toolbar"; import * as _ from "lodash"; -import { Selectors as RoomsSelectors } from "store/rooms"; -import { Selectors as ServerSelectors } from "store/server"; +import { RoomsSelectors, ServerSelectors } from "store"; import { Room, User } from "types"; -import { AuthenticationService } from "AppShell/common/services"; -import { RouteEnum } from "AppShell/common/types"; +import { AuthenticationService } from "../../websocket"; +import { RouteEnum } from "../../types"; import "./Header.css"; import logo from "./logo.png"; diff --git a/webclient/src/AppShell/Header/logo.png b/webclient/src/components/Header/logo.png similarity index 100% rename from webclient/src/AppShell/Header/logo.png rename to webclient/src/components/Header/logo.png diff --git a/webclient/src/AppShell/common/components/InputAction/InputAction.css b/webclient/src/components/InputAction/InputAction.css similarity index 100% rename from webclient/src/AppShell/common/components/InputAction/InputAction.css rename to webclient/src/components/InputAction/InputAction.css diff --git a/webclient/src/AppShell/common/components/InputAction/InputAction.tsx b/webclient/src/components/InputAction/InputAction.tsx similarity index 91% rename from webclient/src/AppShell/common/components/InputAction/InputAction.tsx rename to webclient/src/components/InputAction/InputAction.tsx index 0097e9e9..d20d70ad 100644 --- a/webclient/src/AppShell/common/components/InputAction/InputAction.tsx +++ b/webclient/src/components/InputAction/InputAction.tsx @@ -3,7 +3,7 @@ import React from "react"; import { Field } from "redux-form" import Button from "@material-ui/core/Button"; -import InputField from '../InputField/InputField'; +import { InputField } from 'components'; import "./InputAction.css"; diff --git a/webclient/src/AppShell/common/components/InputField/InputField.tsx b/webclient/src/components/InputField/InputField.tsx similarity index 100% rename from webclient/src/AppShell/common/components/InputField/InputField.tsx rename to webclient/src/components/InputField/InputField.tsx diff --git a/webclient/src/AppShell/Logs/LogResults/LogResults.css b/webclient/src/components/Logs/LogResults.css similarity index 100% rename from webclient/src/AppShell/Logs/LogResults/LogResults.css rename to webclient/src/components/Logs/LogResults.css diff --git a/webclient/src/AppShell/Logs/LogResults/LogResults.tsx b/webclient/src/components/Logs/LogResults.tsx similarity index 100% rename from webclient/src/AppShell/Logs/LogResults/LogResults.tsx rename to webclient/src/components/Logs/LogResults.tsx diff --git a/webclient/src/AppShell/Logs/Logs.css b/webclient/src/components/Logs/Logs.css similarity index 100% rename from webclient/src/AppShell/Logs/Logs.css rename to webclient/src/components/Logs/Logs.css diff --git a/webclient/src/AppShell/Logs/Logs.tsx b/webclient/src/components/Logs/Logs.tsx similarity index 83% rename from webclient/src/AppShell/Logs/Logs.tsx rename to webclient/src/components/Logs/Logs.tsx index ab50a4be..7aa35ce4 100644 --- a/webclient/src/AppShell/Logs/Logs.tsx +++ b/webclient/src/components/Logs/Logs.tsx @@ -4,14 +4,13 @@ import { connect } from "react-redux"; import { withRouter } from "react-router-dom"; import * as _ from "lodash"; -import { Dispatch, Selectors, ServerStateLogs } from "store/server" +import { ServerDispatch, ServerSelectors, ServerStateLogs } from "store"; -import { ModeratorService } from "AppShell/common/services"; -import AuthGuard from "AppShell/common/guards/AuthGuard"; -import ModGuard from "AppShell/common/guards/ModGuard"; +import { ModeratorService } from "websocket"; -import LogResults from "./LogResults/LogResults"; -import SearchForm from "./SearchForm/SearchForm"; +import { AuthGuard, ModGuard} from "components"; +import LogResults from "./LogResults"; +import { SearchForm } from "forms"; import "./Logs.css"; @@ -25,7 +24,7 @@ class Logs extends Component { } componentWillUnmount() { - Dispatch.clearLogs(); + ServerDispatch.clearLogs(); } onSubmit(fields) { @@ -96,7 +95,7 @@ interface LogsTypes { } const mapStateToProps = state => ({ - logs: Selectors.getLogs(state) + logs: ServerSelectors.getLogs(state) }); export default withRouter(connect(mapStateToProps)(Logs)); diff --git a/webclient/src/AppShell/Player/Player.tsx b/webclient/src/components/Player/Player.tsx similarity index 68% rename from webclient/src/AppShell/Player/Player.tsx rename to webclient/src/components/Player/Player.tsx index a814281f..293d2813 100644 --- a/webclient/src/AppShell/Player/Player.tsx +++ b/webclient/src/components/Player/Player.tsx @@ -1,9 +1,7 @@ // eslint-disable-next-line import React, { Component } from "react"; -import AuthGuard from "AppShell/common/guards/AuthGuard"; - -import "./Player.css"; +import { AuthGuard } from "components"; class Player extends Component { render() { diff --git a/webclient/src/AppShell/Room/Games/Games.css b/webclient/src/components/Room/Games.css similarity index 100% rename from webclient/src/AppShell/Room/Games/Games.css rename to webclient/src/components/Room/Games.css diff --git a/webclient/src/AppShell/Room/Games/Games.tsx b/webclient/src/components/Room/Games.tsx similarity index 94% rename from webclient/src/AppShell/Room/Games/Games.tsx rename to webclient/src/components/Room/Games.tsx index adb0e575..7b9f93e3 100644 --- a/webclient/src/AppShell/Room/Games/Games.tsx +++ b/webclient/src/components/Room/Games.tsx @@ -13,9 +13,8 @@ import Tooltip from "@material-ui/core/Tooltip"; // import { RoomsService } from "AppShell/common/services"; -import { SortUtil } from "store/common"; -import { Dispatch, Selectors } from "store/rooms"; -import UserDisplay from "AppShell/common/components/UserDisplay/UserDisplay"; +import { SortUtil, RoomsDispatch, RoomsSelectors } from "store"; +import { UserDisplay } from "components"; import "./Games.css"; @@ -55,7 +54,7 @@ class Games extends Component { handleSort(sortByField) { const { room: { roomId }, sortBy } = this.props; const { field, order } = SortUtil.toggleSortBy(sortByField, sortBy); - Dispatch.sortGames(roomId, field, order); + RoomsDispatch.sortGames(roomId, field, order); } private isUnavailableGame({ started, maxPlayers, playerCount }) { @@ -138,7 +137,7 @@ interface GamesProps { } const mapStateToProps = state => ({ - sortBy: Selectors.getSortGamesBy(state) + sortBy: RoomsSelectors.getSortGamesBy(state) }); export default connect(mapStateToProps)(Games); diff --git a/webclient/src/AppShell/Room/Messages/Messages.css b/webclient/src/components/Room/Messages.css similarity index 100% rename from webclient/src/AppShell/Room/Messages/Messages.css rename to webclient/src/components/Room/Messages.css diff --git a/webclient/src/AppShell/Room/Messages/Messages.tsx b/webclient/src/components/Room/Messages.tsx similarity index 100% rename from webclient/src/AppShell/Room/Messages/Messages.tsx rename to webclient/src/components/Room/Messages.tsx diff --git a/webclient/src/AppShell/Room/Room.css b/webclient/src/components/Room/Room.css similarity index 100% rename from webclient/src/AppShell/Room/Room.css rename to webclient/src/components/Room/Room.css diff --git a/webclient/src/AppShell/Room/Room.tsx b/webclient/src/components/Room/Room.tsx similarity index 74% rename from webclient/src/AppShell/Room/Room.tsx rename to webclient/src/components/Room/Room.tsx index 39d2efb3..074fb3fb 100644 --- a/webclient/src/AppShell/Room/Room.tsx +++ b/webclient/src/components/Room/Room.tsx @@ -5,19 +5,15 @@ import { withRouter /*, RouteComponentProps */ } from "react-router-dom"; import ListItem from "@material-ui/core/ListItem"; import Paper from "@material-ui/core/Paper"; -import { RoomsStateMessages, RoomsStateRooms, Selectors } from "store/rooms"; +import { RoomsStateMessages, RoomsStateRooms, RoomsSelectors } from "store"; +import { RoomsService } from "websocket"; +import { ScrollToBottomOnChanges, ThreePaneLayout, UserDisplay, VirtualList, AuthGuard} from "components"; -import AuthGuard from "AppShell/common/guards/AuthGuard"; -import { RoomsService } from "AppShell/common/services"; -import ScrollToBottomOnChanges from "AppShell/common/components/ScrollToBottomOnChanges/ScrollToBottomOnChanges"; -import ThreePaneLayout from "AppShell/common/components/ThreePaneLayout/ThreePaneLayout"; -import UserDisplay from "AppShell/common/components/UserDisplay/UserDisplay"; -import VirtualList from "AppShell/common/components/VirtualList/VirtualList"; -import Games from "./Games/Games"; -import Messages from "./Messages/Messages"; -import SayMessage from "./SayMessage/SayMessage"; +import Games from "./Games"; +import Messages from "./Messages"; +import SayMessage from "./SayMessage"; import "./Room.css"; @@ -96,8 +92,8 @@ interface RoomProps { } const mapStateToProps = state => ({ - messages: Selectors.getMessages(state), - rooms: Selectors.getRooms(state) + messages: RoomsSelectors.getMessages(state), + rooms: RoomsSelectors.getRooms(state) }); export default withRouter(connect(mapStateToProps)(Room)); \ No newline at end of file diff --git a/webclient/src/AppShell/Room/SayMessage/SayMessage.tsx b/webclient/src/components/Room/SayMessage.tsx similarity index 83% rename from webclient/src/AppShell/Room/SayMessage/SayMessage.tsx rename to webclient/src/components/Room/SayMessage.tsx index d4b2ad25..2c33825c 100644 --- a/webclient/src/AppShell/Room/SayMessage/SayMessage.tsx +++ b/webclient/src/components/Room/SayMessage.tsx @@ -3,7 +3,7 @@ import React from "react"; import { connect } from "react-redux"; import { Form, reduxForm } from "redux-form" -import InputAction from 'AppShell/common/components/InputAction/InputAction'; +import { InputAction } from 'components'; const SayMessage = ({ handleSubmit }) => (
diff --git a/webclient/src/AppShell/common/components/ScrollToBottomOnChanges/ScrollToBottomOnChanges.tsx b/webclient/src/components/ScrollToBottomOnChanges/ScrollToBottomOnChanges.tsx similarity index 100% rename from webclient/src/AppShell/common/components/ScrollToBottomOnChanges/ScrollToBottomOnChanges.tsx rename to webclient/src/components/ScrollToBottomOnChanges/ScrollToBottomOnChanges.tsx diff --git a/webclient/src/AppShell/common/components/SelectField/SelectField.css b/webclient/src/components/SelectField/SelectField.css similarity index 100% rename from webclient/src/AppShell/common/components/SelectField/SelectField.css rename to webclient/src/components/SelectField/SelectField.css diff --git a/webclient/src/AppShell/common/components/SelectField/SelectField.tsx b/webclient/src/components/SelectField/SelectField.tsx similarity index 100% rename from webclient/src/AppShell/common/components/SelectField/SelectField.tsx rename to webclient/src/components/SelectField/SelectField.tsx diff --git a/webclient/src/AppShell/Server/Rooms/Rooms.css b/webclient/src/components/Server/Rooms.css similarity index 100% rename from webclient/src/AppShell/Server/Rooms/Rooms.css rename to webclient/src/components/Server/Rooms.css diff --git a/webclient/src/AppShell/Server/Rooms/Rooms.tsx b/webclient/src/components/Server/Rooms.tsx similarity index 94% rename from webclient/src/AppShell/Server/Rooms/Rooms.tsx rename to webclient/src/components/Server/Rooms.tsx index c9c83612..6f839d73 100644 --- a/webclient/src/AppShell/Server/Rooms/Rooms.tsx +++ b/webclient/src/components/Server/Rooms.tsx @@ -10,8 +10,9 @@ import TableCell from "@material-ui/core/TableCell"; import TableHead from "@material-ui/core/TableHead"; import TableRow from "@material-ui/core/TableRow"; -import { RoomsService } from "AppShell/common/services"; -import { RouteEnum } from "AppShell/common/types"; + +import { RoomsService } from "websocket"; +import { RouteEnum } from "types"; import "./Rooms.css"; diff --git a/webclient/src/AppShell/Server/Server.css b/webclient/src/components/Server/Server.css similarity index 100% rename from webclient/src/AppShell/Server/Server.css rename to webclient/src/components/Server/Server.css diff --git a/webclient/src/AppShell/Server/Server.tsx b/webclient/src/components/Server/Server.tsx similarity index 86% rename from webclient/src/AppShell/Server/Server.tsx rename to webclient/src/components/Server/Server.tsx index 7fc5943c..7516c786 100644 --- a/webclient/src/AppShell/Server/Server.tsx +++ b/webclient/src/components/Server/Server.tsx @@ -7,19 +7,14 @@ import Button from "@material-ui/core/Button"; import ListItem from "@material-ui/core/ListItem"; import Paper from "@material-ui/core/Paper"; -import { Selectors as RoomsSelectors } from "store/rooms"; -import { Selectors as ServerSelectors } from "store/server"; +import { RoomsSelectors, ServerSelectors } from "store"; + +import { AuthenticationService } from "websocket"; + +import { ThreePaneLayout, UserDisplay, VirtualList } from "components"; +import { ConnectForm, RegisterForm } from "forms"; import { Room, StatusEnum, User } from "types"; - -import ThreePaneLayout from "AppShell/common/components/ThreePaneLayout/ThreePaneLayout"; -import UserDisplay from "AppShell/common/components/UserDisplay/UserDisplay"; -import VirtualList from "AppShell/common/components/VirtualList/VirtualList"; - -import { AuthenticationService } from "AppShell/common/services"; - -import ConnectForm from "./ConnectForm/ConnectForm"; -import RegisterForm from "./RegisterForm/RegisterForm"; -import Rooms from "./Rooms/Rooms"; +import Rooms from './Rooms'; import "./Server.css"; diff --git a/webclient/src/AppShell/common/components/ThreePaneLayout/ThreePaneLayout.css b/webclient/src/components/ThreePaneLayout/ThreePaneLayout.css similarity index 100% rename from webclient/src/AppShell/common/components/ThreePaneLayout/ThreePaneLayout.css rename to webclient/src/components/ThreePaneLayout/ThreePaneLayout.css diff --git a/webclient/src/AppShell/common/components/ThreePaneLayout/ThreePaneLayout.tsx b/webclient/src/components/ThreePaneLayout/ThreePaneLayout.tsx similarity index 96% rename from webclient/src/AppShell/common/components/ThreePaneLayout/ThreePaneLayout.tsx rename to webclient/src/components/ThreePaneLayout/ThreePaneLayout.tsx index 1e2a52a4..c24a64fb 100644 --- a/webclient/src/AppShell/common/components/ThreePaneLayout/ThreePaneLayout.tsx +++ b/webclient/src/components/ThreePaneLayout/ThreePaneLayout.tsx @@ -40,8 +40,6 @@ interface ThreePaneLayoutProps { fixedHeight?: boolean, } -const mapStateToProps = state => ({ - -}); +const mapStateToProps = state => ({}); export default connect(mapStateToProps)(ThreePaneLayout); diff --git a/webclient/src/AppShell/common/components/UserDisplay/UserDisplay.css b/webclient/src/components/UserDisplay/UserDisplay.css similarity index 100% rename from webclient/src/AppShell/common/components/UserDisplay/UserDisplay.css rename to webclient/src/components/UserDisplay/UserDisplay.css diff --git a/webclient/src/AppShell/common/components/UserDisplay/UserDisplay.tsx b/webclient/src/components/UserDisplay/UserDisplay.tsx similarity index 94% rename from webclient/src/AppShell/common/components/UserDisplay/UserDisplay.tsx rename to webclient/src/components/UserDisplay/UserDisplay.tsx index 8a839643..5d44bc16 100644 --- a/webclient/src/AppShell/common/components/UserDisplay/UserDisplay.tsx +++ b/webclient/src/components/UserDisplay/UserDisplay.tsx @@ -6,10 +6,10 @@ import { NavLink, generatePath } from "react-router-dom"; import Menu from "@material-ui/core/Menu"; import MenuItem from "@material-ui/core/MenuItem"; -import { SessionService } from "AppShell/common/services"; -import { RouteEnum } from "AppShell/common/types"; +import { SessionService } from "../../websocket"; +import { ServerSelectors } from "../../store"; -import { Selectors } from "store/server"; +import { RouteEnum } from "../../types"; import { User } from "types"; @@ -146,8 +146,8 @@ interface UserDisplayState { } const mapStateToProps = (state) => ({ - buddyList: Selectors.getBuddyList(state), - ignoreList: Selectors.getIgnoreList(state) + buddyList: ServerSelectors.getBuddyList(state), + ignoreList: ServerSelectors.getIgnoreList(state) }); export default connect(mapStateToProps)(UserDisplay); diff --git a/webclient/src/AppShell/common/components/VirtualList/VirtualList.css b/webclient/src/components/VirtualList/VirtualList.css similarity index 100% rename from webclient/src/AppShell/common/components/VirtualList/VirtualList.css rename to webclient/src/components/VirtualList/VirtualList.css diff --git a/webclient/src/AppShell/common/components/VirtualList/VirtualList.tsx b/webclient/src/components/VirtualList/VirtualList.tsx similarity index 100% rename from webclient/src/AppShell/common/components/VirtualList/VirtualList.tsx rename to webclient/src/components/VirtualList/VirtualList.tsx diff --git a/webclient/src/components/index.ts b/webclient/src/components/index.ts new file mode 100644 index 00000000..491d8001 --- /dev/null +++ b/webclient/src/components/index.ts @@ -0,0 +1,25 @@ + + +// Common components +export { default as Header } from './Header/Header'; +export { default as InputField } from './InputField/InputField'; +export { default as InputAction } from './InputAction/InputAction'; +export { default as VirtualList } from './VirtualList/VirtualList'; +export { default as UserDisplay} from './UserDisplay/UserDisplay'; +export { default as ThreePaneLayout } from './ThreePaneLayout/ThreePaneLayout'; +export { default as CheckboxField } from './CheckboxField/CheckboxField'; +export { default as SelectField } from './SelectField/SelectField'; +export { default as ScrollToBottomOnChanges } from './ScrollToBottomOnChanges/ScrollToBottomOnChanges'; + +// Major components +export { default as Game } from './Game/Game'; +export { default as Decks } from './Decks/Decks'; +export { default as Room } from "./Room/Room"; +export { default as Player } from "./Player/Player"; +export { default as Server } from "./Server/Server"; +export { default as Logs } from "./Logs/Logs"; + +// Guards +export { default as AuthGuard } from './Guard/AuthGuard'; +export { default as ModGuard} from './Guard/ModGuard'; + diff --git a/webclient/src/AppShell/Account/Account.css b/webclient/src/containers/Account/Account.css similarity index 100% rename from webclient/src/AppShell/Account/Account.css rename to webclient/src/containers/Account/Account.css diff --git a/webclient/src/AppShell/Account/Account.tsx b/webclient/src/containers/Account/Account.tsx similarity index 84% rename from webclient/src/AppShell/Account/Account.tsx rename to webclient/src/containers/Account/Account.tsx index 64acc520..45fd496b 100644 --- a/webclient/src/AppShell/Account/Account.tsx +++ b/webclient/src/containers/Account/Account.tsx @@ -6,19 +6,13 @@ import Button from "@material-ui/core/Button"; import ListItem from "@material-ui/core/ListItem"; import Paper from "@material-ui/core/Paper"; -import UserDisplay from "AppShell/common/components/UserDisplay/UserDisplay"; -import VirtualList from "AppShell/common/components/VirtualList/VirtualList"; - -import { AuthenticationService, SessionService } from "AppShell/common/services"; - -import AuthGuard from "AppShell/common/guards/AuthGuard"; - -import { Selectors } from "store/server"; - +import { UserDisplay, VirtualList, AuthGuard } from "components"; +import { AuthenticationService, SessionService } from "websocket"; +import { ServerSelectors } from "store"; import { User } from 'types'; -import AddToBuddies from './AddToBuddies/AddToBuddies'; -import AddToIgnore from './AddToIgnore/AddToIgnore'; +import AddToBuddies from './AddToBuddies'; +import AddToIgnore from './AddToIgnore'; import "./Account.css"; @@ -112,11 +106,11 @@ interface AccountProps { } const mapStateToProps = state => ({ - buddyList: Selectors.getBuddyList(state), - ignoreList: Selectors.getIgnoreList(state), - serverName: Selectors.getName(state), - serverVersion: Selectors.getVersion(state), - user: Selectors.getUser(state), + buddyList: ServerSelectors.getBuddyList(state), + ignoreList: ServerSelectors.getIgnoreList(state), + serverName: ServerSelectors.getName(state), + serverVersion: ServerSelectors.getVersion(state), + user: ServerSelectors.getUser(state), }); export default connect(mapStateToProps)(Account); diff --git a/webclient/src/AppShell/Account/AddToBuddies/AddToBuddies.tsx b/webclient/src/containers/Account/AddToBuddies.tsx similarity index 84% rename from webclient/src/AppShell/Account/AddToBuddies/AddToBuddies.tsx rename to webclient/src/containers/Account/AddToBuddies.tsx index 34e721c7..b4432f2d 100644 --- a/webclient/src/AppShell/Account/AddToBuddies/AddToBuddies.tsx +++ b/webclient/src/containers/Account/AddToBuddies.tsx @@ -3,7 +3,7 @@ import React from "react"; import { connect } from "react-redux"; import { Form, reduxForm } from "redux-form" -import InputAction from 'AppShell/common/components/InputAction/InputAction'; +import { InputAction } from 'components'; const AddToBuddies = ({ handleSubmit }) => ( diff --git a/webclient/src/AppShell/Account/AddToIgnore/AddToIgnore.tsx b/webclient/src/containers/Account/AddToIgnore.tsx similarity index 83% rename from webclient/src/AppShell/Account/AddToIgnore/AddToIgnore.tsx rename to webclient/src/containers/Account/AddToIgnore.tsx index df4b47b4..a3cfeba7 100644 --- a/webclient/src/AppShell/Account/AddToIgnore/AddToIgnore.tsx +++ b/webclient/src/containers/Account/AddToIgnore.tsx @@ -3,7 +3,7 @@ import React from "react"; import { connect } from "react-redux"; import { Form, reduxForm } from "redux-form" -import InputAction from 'AppShell/common/components/InputAction/InputAction'; +import { InputAction } from 'components'; const AddToIgnore = ({ handleSubmit }) => ( diff --git a/webclient/src/AppShell/AppShell.css b/webclient/src/containers/App/AppShell.css similarity index 100% rename from webclient/src/AppShell/AppShell.css rename to webclient/src/containers/App/AppShell.css diff --git a/webclient/src/AppShell/AppShell.tsx b/webclient/src/containers/App/AppShell.tsx similarity index 95% rename from webclient/src/AppShell/AppShell.tsx rename to webclient/src/containers/App/AppShell.tsx index 18af2634..bb782383 100644 --- a/webclient/src/AppShell/AppShell.tsx +++ b/webclient/src/containers/App/AppShell.tsx @@ -3,13 +3,11 @@ import React, { Component } from "react"; import { Provider } from "react-redux"; import { MemoryRouter as Router } from "react-router-dom"; import CssBaseline from "@material-ui/core/CssBaseline"; - import { store } from "store"; +import { Header } from 'components'; +import Routes from "./AppShellRoutes"; import "./AppShell.css"; -import Routes from "./AppShellRoutes"; -import Header from "./Header/Header"; - class AppShell extends Component { componentDidMount() { diff --git a/webclient/src/AppShell/AppShellRoutes.tsx b/webclient/src/containers/App/AppShellRoutes.tsx similarity index 69% rename from webclient/src/AppShell/AppShellRoutes.tsx rename to webclient/src/containers/App/AppShellRoutes.tsx index c627dc03..eeeb3375 100644 --- a/webclient/src/AppShell/AppShellRoutes.tsx +++ b/webclient/src/containers/App/AppShellRoutes.tsx @@ -1,15 +1,15 @@ import React from "react"; import { Redirect, Route, Switch } from "react-router-dom"; -import { RouteEnum } from "./common/types"; - -import Account from "./Account/Account"; -import Decks from "./Decks/Decks"; -import Game from "./Game/Game"; -import Logs from "./Logs/Logs"; -import Player from "./Player/Player"; -import Room from "./Room/Room"; -import Server from "./Server/Server"; +import { RouteEnum } from "types"; +import { Account } from "containers"; +import { + Decks, + Game, + Player, + Room, + Server, + Logs } from "components"; const Routes = () => (
diff --git a/webclient/src/containers/index.ts b/webclient/src/containers/index.ts new file mode 100644 index 00000000..49f69ce4 --- /dev/null +++ b/webclient/src/containers/index.ts @@ -0,0 +1,2 @@ +export { default as AppShell } from './App/AppShell'; +export { default as Account } from './Account/Account'; \ No newline at end of file diff --git a/webclient/src/AppShell/Server/ConnectForm/ConnectForm.css b/webclient/src/forms/ConnectForm/ConnectForm.css similarity index 100% rename from webclient/src/AppShell/Server/ConnectForm/ConnectForm.css rename to webclient/src/forms/ConnectForm/ConnectForm.css diff --git a/webclient/src/AppShell/Server/ConnectForm/ConnectForm.tsx b/webclient/src/forms/ConnectForm/ConnectForm.tsx similarity index 94% rename from webclient/src/AppShell/Server/ConnectForm/ConnectForm.tsx rename to webclient/src/forms/ConnectForm/ConnectForm.tsx index 291ca77f..b34c9287 100644 --- a/webclient/src/AppShell/Server/ConnectForm/ConnectForm.tsx +++ b/webclient/src/forms/ConnectForm/ConnectForm.tsx @@ -4,8 +4,7 @@ import { connect } from "react-redux"; import { Form, Field, InjectedFormProps, reduxForm } from "redux-form" import Button from "@material-ui/core/Button"; - -import InputField from "AppShell/common/components/InputField/InputField"; +import { InputField } from "../../components"; import "./ConnectForm.css"; diff --git a/webclient/src/AppShell/Server/RegisterForm/RegisterForm.css b/webclient/src/forms/RegisterForm/RegisterForm.css similarity index 100% rename from webclient/src/AppShell/Server/RegisterForm/RegisterForm.css rename to webclient/src/forms/RegisterForm/RegisterForm.css diff --git a/webclient/src/AppShell/Server/RegisterForm/RegisterForm.tsx b/webclient/src/forms/RegisterForm/RegisterForm.tsx similarity index 96% rename from webclient/src/AppShell/Server/RegisterForm/RegisterForm.tsx rename to webclient/src/forms/RegisterForm/RegisterForm.tsx index 8c9d938e..1140fb20 100644 --- a/webclient/src/AppShell/Server/RegisterForm/RegisterForm.tsx +++ b/webclient/src/forms/RegisterForm/RegisterForm.tsx @@ -5,7 +5,7 @@ import { Form, Field, InjectedFormProps, reduxForm } from 'redux-form' import Button from '@material-ui/core/Button'; -import InputField from 'AppShell/common/components/InputField/InputField'; +import { InputField } from '../../components'; import './RegisterForm.css'; diff --git a/webclient/src/AppShell/Logs/SearchForm/SearchForm.css b/webclient/src/forms/SearchForm/SearchForm.css similarity index 100% rename from webclient/src/AppShell/Logs/SearchForm/SearchForm.css rename to webclient/src/forms/SearchForm/SearchForm.css diff --git a/webclient/src/AppShell/Logs/SearchForm/SearchForm.tsx b/webclient/src/forms/SearchForm/SearchForm.tsx similarity index 93% rename from webclient/src/AppShell/Logs/SearchForm/SearchForm.tsx rename to webclient/src/forms/SearchForm/SearchForm.tsx index abdee2f8..d3913369 100644 --- a/webclient/src/AppShell/Logs/SearchForm/SearchForm.tsx +++ b/webclient/src/forms/SearchForm/SearchForm.tsx @@ -7,8 +7,7 @@ import Button from "@material-ui/core/Button"; import Divider from "@material-ui/core/Divider"; import Paper from "@material-ui/core/Paper"; -import InputField from "AppShell/common/components/InputField/InputField"; -import CheckboxField from "AppShell/common/components/CheckboxField/CheckboxField"; +import { InputField, CheckboxField } from "../../components"; import "./SearchForm.css"; diff --git a/webclient/src/forms/index.ts b/webclient/src/forms/index.ts new file mode 100644 index 00000000..78093a72 --- /dev/null +++ b/webclient/src/forms/index.ts @@ -0,0 +1,4 @@ + +export { default as ConnectForm } from './ConnectForm/ConnectForm'; +export { default as RegisterForm } from './RegisterForm/RegisterForm'; +export { default as SearchForm } from './SearchForm/SearchForm'; diff --git a/webclient/src/index.tsx b/webclient/src/index.tsx index 419ce268..d63d7ebe 100644 --- a/webclient/src/index.tsx +++ b/webclient/src/index.tsx @@ -2,6 +2,6 @@ import React from "react"; import ReactDOM from "react-dom"; import "./index.css"; -import AppShell from "./AppShell/AppShell"; +import { AppShell } from "containers"; ReactDOM.render(, document.getElementById("root")); diff --git a/webclient/src/store/common/SortUtil.tsx b/webclient/src/store/common/SortUtil.tsx index d55a342c..3f9362ec 100644 --- a/webclient/src/store/common/SortUtil.tsx +++ b/webclient/src/store/common/SortUtil.tsx @@ -1,6 +1,6 @@ import { SortBy, SortDirection, User } from "types"; -export class SortUtil { +export default class SortUtil { static sortByField(arr: any[], sortBy: SortBy): void { if (arr.length) { const field = SortUtil.resolveFieldChain(arr[0], sortBy.field); diff --git a/webclient/src/store/common/index.ts b/webclient/src/store/common/index.ts index 2834162c..aebfd91b 100644 --- a/webclient/src/store/common/index.ts +++ b/webclient/src/store/common/index.ts @@ -1 +1 @@ -export * from "./SortUtil"; \ No newline at end of file +export { default as SortUtil} from "./SortUtil"; \ No newline at end of file diff --git a/webclient/src/store/index.ts b/webclient/src/store/index.ts index 82c7bfa5..cd2cea67 100644 --- a/webclient/src/store/index.ts +++ b/webclient/src/store/index.ts @@ -1 +1,20 @@ -export * from "./store"; \ No newline at end of file +export { store } from "./store"; + +// Common +export { SortUtil } from "./common"; + +// Server + +export { + Selectors as ServerSelectors, + Dispatch as ServerDispatch} from './server'; + +export * from "store/server/server.interfaces"; + +export { + Selectors as RoomsSelectors, + Dispatch as RoomsDispatch } from 'store/rooms'; + +export * from "store/rooms/rooms.interfaces"; + + diff --git a/webclient/src/store/rooms/index.ts b/webclient/src/store/rooms/index.ts index 61afb8ea..fecb965d 100644 --- a/webclient/src/store/rooms/index.ts +++ b/webclient/src/store/rooms/index.ts @@ -1,6 +1,5 @@ export * from "./rooms.actions"; export * from "./rooms.dispatch"; -export * from "./rooms.interfaces"; export * from "./rooms.reducer"; export * from "./rooms.selectors"; export * from "./rooms.types"; diff --git a/webclient/src/store/rooms/rooms.dispatch.tsx b/webclient/src/store/rooms/rooms.dispatch.tsx index 0bb0d6fb..b959902b 100644 --- a/webclient/src/store/rooms/rooms.dispatch.tsx +++ b/webclient/src/store/rooms/rooms.dispatch.tsx @@ -1,6 +1,6 @@ import { reset } from 'redux-form'; import { Actions } from "./rooms.actions"; -import { store } from "../store"; +import { store } from "store"; // const history = useHistory(); diff --git a/webclient/src/store/rootReducer.tsx b/webclient/src/store/rootReducer.ts similarity index 100% rename from webclient/src/store/rootReducer.tsx rename to webclient/src/store/rootReducer.ts diff --git a/webclient/src/store/server/index.ts b/webclient/src/store/server/index.ts index 51d9ac73..d59ecb51 100644 --- a/webclient/src/store/server/index.ts +++ b/webclient/src/store/server/index.ts @@ -1,6 +1,5 @@ -export * from "./server.actions"; -export * from "./server.dispatch"; -export * from "./server.interfaces"; +export { Actions } from "./server.actions"; +export { Dispatch } from "./server.dispatch"; export * from "./server.reducer"; -export * from "./server.selectors"; +export { Selectors } from "./server.selectors"; export * from "./server.types"; diff --git a/webclient/src/store/server/server.actions.tsx b/webclient/src/store/server/server.actions.ts similarity index 100% rename from webclient/src/store/server/server.actions.tsx rename to webclient/src/store/server/server.actions.ts diff --git a/webclient/src/store/server/server.dispatch.tsx b/webclient/src/store/server/server.dispatch.ts similarity index 98% rename from webclient/src/store/server/server.dispatch.tsx rename to webclient/src/store/server/server.dispatch.ts index afacb056..51841d31 100644 --- a/webclient/src/store/server/server.dispatch.tsx +++ b/webclient/src/store/server/server.dispatch.ts @@ -1,6 +1,6 @@ import { reset } from 'redux-form'; import { Actions } from "./server.actions"; -import { store } from "../store"; +import { store } from "store"; export const Dispatch = { clearStore: () => { diff --git a/webclient/src/store/server/server.interfaces.tsx b/webclient/src/store/server/server.interfaces.ts similarity index 100% rename from webclient/src/store/server/server.interfaces.tsx rename to webclient/src/store/server/server.interfaces.ts diff --git a/webclient/src/store/server/server.reducer.tsx b/webclient/src/store/server/server.reducer.ts similarity index 100% rename from webclient/src/store/server/server.reducer.tsx rename to webclient/src/store/server/server.reducer.ts diff --git a/webclient/src/store/server/server.selectors.tsx b/webclient/src/store/server/server.selectors.ts similarity index 100% rename from webclient/src/store/server/server.selectors.tsx rename to webclient/src/store/server/server.selectors.ts diff --git a/webclient/src/store/server/server.types.tsx b/webclient/src/store/server/server.types.ts similarity index 100% rename from webclient/src/store/server/server.types.tsx rename to webclient/src/store/server/server.types.ts diff --git a/webclient/src/store/store.tsx b/webclient/src/store/store.ts similarity index 100% rename from webclient/src/store/store.tsx rename to webclient/src/store/store.ts diff --git a/webclient/src/translations/en.json b/webclient/src/translations/en.json new file mode 100644 index 00000000..544b7b4d --- /dev/null +++ b/webclient/src/translations/en.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/webclient/src/types/index.ts b/webclient/src/types/index.ts index e07de8fb..4e858dcf 100644 --- a/webclient/src/types/index.ts +++ b/webclient/src/types/index.ts @@ -2,4 +2,6 @@ export * from "./game"; export * from "./room"; export * from "./server"; export * from "./sort"; -export * from "./user"; \ No newline at end of file +export * from "./user"; +export * from "./routes"; +export * from "./sort"; diff --git a/webclient/src/AppShell/common/types/routes.tsx b/webclient/src/types/routes.tsx similarity index 100% rename from webclient/src/AppShell/common/types/routes.tsx rename to webclient/src/types/routes.tsx diff --git a/webclient/src/WebClient/ProtoFiles.tsx b/webclient/src/websocket/ProtoFiles.tsx similarity index 100% rename from webclient/src/WebClient/ProtoFiles.tsx rename to webclient/src/websocket/ProtoFiles.tsx diff --git a/webclient/src/WebClient/WebClient.tsx b/webclient/src/websocket/WebClient.tsx similarity index 96% rename from webclient/src/WebClient/WebClient.tsx rename to webclient/src/websocket/WebClient.tsx index 82ab513d..13acffd3 100644 --- a/webclient/src/WebClient/WebClient.tsx +++ b/webclient/src/websocket/WebClient.tsx @@ -6,7 +6,7 @@ import * as roomEvents from "./events/RoomEvents"; import * as sessionEvents from "./events/SessionEvents"; import { RoomService, SessionService } from "./services"; -import { RoomCommands, SessionCommands } from "./commands"; +import { RoomCommand, SessionCommands } from "./commands"; import ProtoFiles from "./ProtoFiles"; @@ -14,7 +14,7 @@ const roomEventKeys = Object.keys(roomEvents); const sessionEventKeys = Object.keys(sessionEvents); interface ApplicationCommands { - room: RoomCommands; + room: RoomCommand; session: SessionCommands; } @@ -80,7 +80,7 @@ export class WebClient { // This sucks. I can"t seem to get out of this // circular dependency trap, so this is my current best. this.commands = { - room: new RoomCommands(this), + room: new RoomCommand(this), session: new SessionCommands(this), }; @@ -208,9 +208,8 @@ export class WebClient { this.options = { ...this.options, ...options }; const { host, port } = this.options; - const protocol = port === '443' ? 'wss' : 'ws'; - this.socket = new WebSocket(protocol + "://" + host + ":" + port); + this.socket = new WebSocket("ws://" + host + ":" + port); this.socket.binaryType = "arraybuffer"; // We are talking binary this.socket.onopen = () => { @@ -326,4 +325,5 @@ export class WebClient { } const webClient = new WebClient(); + export default webClient; diff --git a/webclient/src/websocket/WebClient/services/RoomService.tsx b/webclient/src/websocket/WebClient/services/RoomService.tsx new file mode 100644 index 00000000..6fb204aa --- /dev/null +++ b/webclient/src/websocket/WebClient/services/RoomService.tsx @@ -0,0 +1,48 @@ +import { RoomsDispatch, RoomsSelectors, store } from "store"; +import { WebClient } from "../../WebClient"; +import { NormalizeService } from "websocket"; + +export default class RoomService { + webClient: WebClient; + + constructor(webClient) { + this.webClient = webClient; + } + + clearStore() { + RoomsDispatch.clearStore(); + } + + joinRoom(roomInfo) { + NormalizeService.normalizeRoomInfo(roomInfo); + RoomsDispatch.joinRoom(roomInfo); + } + + updateRooms(rooms) { + RoomsDispatch.updateRooms(rooms); + } + + updateGames(roomId, gameList) { + const game = gameList[0]; + + if (!game.gameType) { + const { gametypeMap } = RoomsSelectors.getRoom(store.getState(), roomId); + NormalizeService.normalizeGameObject(game, gametypeMap); + } + + RoomsDispatch.updateGames(roomId, gameList); + } + + addMessage(roomId, message) { + NormalizeService.normalizeUserMessage(message); + RoomsDispatch.addMessage(roomId, message); + } + + userJoined(roomId, user) { + RoomsDispatch.userJoined(roomId, user); + } + + userLeft(roomId, name) { + RoomsDispatch.userLeft(roomId, name); + } +} diff --git a/webclient/src/WebClient/services/SessionService.tsx b/webclient/src/websocket/WebClient/services/SessionService.tsx similarity index 50% rename from webclient/src/WebClient/services/SessionService.tsx rename to webclient/src/websocket/WebClient/services/SessionService.tsx index 6fb98813..8fdc8ba4 100644 --- a/webclient/src/WebClient/services/SessionService.tsx +++ b/webclient/src/websocket/WebClient/services/SessionService.tsx @@ -1,12 +1,11 @@ -import { Dispatch, ServerConnectParams } from "store/server"; +import { ServerDispatch, ServerConnectParams } from "store"; import { StatusEnum } from "types"; -import { sanitizeHtml } from "../util"; -import { WebClient } from "../WebClient"; +import { sanitizeHtml } from "websocket/utils"; +import { WebClient } from "../../WebClient"; +import { NormalizeService } from "websocket"; -import { NormalizeService } from "./NormalizeService"; - -export class SessionService { +export default class SessionService { webClient: WebClient; constructor(webClient) { @@ -14,11 +13,11 @@ export class SessionService { } clearStore() { - Dispatch.clearStore(); + ServerDispatch.clearStore(); } connectServer(options: ServerConnectParams) { - Dispatch.connectServer(); + ServerDispatch.connectServer(); this.webClient.updateStatus(StatusEnum.CONNECTING, "Connecting..."); this.webClient.connect(options); } @@ -29,39 +28,39 @@ export class SessionService { } connectionClosed(reason) { - Dispatch.connectionClosed(reason); + ServerDispatch.connectionClosed(reason); } updateBuddyList(buddyList) { - Dispatch.updateBuddyList(buddyList); + ServerDispatch.updateBuddyList(buddyList); } addToBuddyList(user) { - Dispatch.addToBuddyList(user); + ServerDispatch.addToBuddyList(user); } removeFromBuddyList(userName) { - Dispatch.removeFromBuddyList(userName); + ServerDispatch.removeFromBuddyList(userName); } updateIgnoreList(ignoreList) { - Dispatch.updateIgnoreList(ignoreList); + ServerDispatch.updateIgnoreList(ignoreList); } addToIgnoreList(user) { - Dispatch.addToIgnoreList(user); + ServerDispatch.addToIgnoreList(user); } removeFromIgnoreList(userName) { - Dispatch.removeFromIgnoreList(userName); + ServerDispatch.removeFromIgnoreList(userName); } updateInfo(name, version) { - Dispatch.updateInfo(name, version); + ServerDispatch.updateInfo(name, version); } updateStatus(state, description) { - Dispatch.updateStatus(state, description); + ServerDispatch.updateStatus(state, description); if (state === StatusEnum.DISCONNECTED) { this.connectionClosed({ reason: description }); @@ -69,26 +68,26 @@ export class SessionService { } updateUser(user) { - Dispatch.updateUser(user); + ServerDispatch.updateUser(user); } updateUsers(users) { - Dispatch.updateUsers(users); + ServerDispatch.updateUsers(users); } userJoined(user) { - Dispatch.userJoined(user); + ServerDispatch.userJoined(user); } userLeft(userId) { - Dispatch.userLeft(userId); + ServerDispatch.userLeft(userId); } viewLogs(logs) { - Dispatch.viewLogs(NormalizeService.normalizeLogs(logs)); + ServerDispatch.viewLogs(NormalizeService.normalizeLogs(logs)); } serverMessage(message) { - Dispatch.serverMessage(sanitizeHtml(message)); + ServerDispatch.serverMessage(sanitizeHtml(message)); } } diff --git a/webclient/src/WebClient/commands/RoomCommands.tsx b/webclient/src/websocket/commands/RoomCommands.tsx similarity index 93% rename from webclient/src/WebClient/commands/RoomCommands.tsx rename to webclient/src/websocket/commands/RoomCommands.tsx index f30b9261..109e32f3 100644 --- a/webclient/src/WebClient/commands/RoomCommands.tsx +++ b/webclient/src/websocket/commands/RoomCommands.tsx @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import { WebClient } from "../WebClient"; -export class RoomCommands { +export default class RoomCommands { private webClient: WebClient; constructor(webClient) { diff --git a/webclient/src/WebClient/commands/SessionCommands.tsx b/webclient/src/websocket/commands/SessionCommands.tsx similarity index 99% rename from webclient/src/WebClient/commands/SessionCommands.tsx rename to webclient/src/websocket/commands/SessionCommands.tsx index c54ff1a7..e38630fb 100644 --- a/webclient/src/WebClient/commands/SessionCommands.tsx +++ b/webclient/src/websocket/commands/SessionCommands.tsx @@ -1,9 +1,9 @@ import { StatusEnum } from "types"; import { WebClient } from "../WebClient"; -import { guid } from "../util"; +import { guid } from "../utils"; -export class SessionCommands { +export default class SessionCommands { private webClient: WebClient; constructor(webClient) { diff --git a/webclient/src/websocket/commands/index.tsx b/webclient/src/websocket/commands/index.tsx new file mode 100644 index 00000000..f4d523f7 --- /dev/null +++ b/webclient/src/websocket/commands/index.tsx @@ -0,0 +1,2 @@ +export { default as RoomCommand } from "./RoomCommands"; +export { default as SessionCommands } from "./SessionCommands"; \ No newline at end of file diff --git a/webclient/src/WebClient/events/RoomEvents/JoinRoom.tsx b/webclient/src/websocket/events/RoomEvents/JoinRoom.tsx similarity index 100% rename from webclient/src/WebClient/events/RoomEvents/JoinRoom.tsx rename to webclient/src/websocket/events/RoomEvents/JoinRoom.tsx diff --git a/webclient/src/WebClient/events/RoomEvents/LeaveRoom.tsx b/webclient/src/websocket/events/RoomEvents/LeaveRoom.tsx similarity index 100% rename from webclient/src/WebClient/events/RoomEvents/LeaveRoom.tsx rename to webclient/src/websocket/events/RoomEvents/LeaveRoom.tsx diff --git a/webclient/src/WebClient/events/RoomEvents/ListGames.tsx b/webclient/src/websocket/events/RoomEvents/ListGames.tsx similarity index 100% rename from webclient/src/WebClient/events/RoomEvents/ListGames.tsx rename to webclient/src/websocket/events/RoomEvents/ListGames.tsx diff --git a/webclient/src/WebClient/events/RoomEvents/RoomSay.tsx b/webclient/src/websocket/events/RoomEvents/RoomSay.tsx similarity index 100% rename from webclient/src/WebClient/events/RoomEvents/RoomSay.tsx rename to webclient/src/websocket/events/RoomEvents/RoomSay.tsx diff --git a/webclient/src/websocket/events/RoomEvents/index.tsx b/webclient/src/websocket/events/RoomEvents/index.tsx new file mode 100644 index 00000000..e25aad4f --- /dev/null +++ b/webclient/src/websocket/events/RoomEvents/index.tsx @@ -0,0 +1,4 @@ +export { JoinRoom } from "./JoinRoom"; +export { LeaveRoom } from "./LeaveRoom"; +export { ListGames } from "./ListGames"; +export { RoomSay } from "./RoomSay"; diff --git a/webclient/src/WebClient/events/SessionEvents/AddToList.tsx b/webclient/src/websocket/events/SessionEvents/AddToList.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/AddToList.tsx rename to webclient/src/websocket/events/SessionEvents/AddToList.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/ConnectionClosed.tsx b/webclient/src/websocket/events/SessionEvents/ConnectionClosed.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/ConnectionClosed.tsx rename to webclient/src/websocket/events/SessionEvents/ConnectionClosed.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/ListRooms.tsx b/webclient/src/websocket/events/SessionEvents/ListRooms.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/ListRooms.tsx rename to webclient/src/websocket/events/SessionEvents/ListRooms.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/NotifyUser.tsx b/webclient/src/websocket/events/SessionEvents/NotifyUser.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/NotifyUser.tsx rename to webclient/src/websocket/events/SessionEvents/NotifyUser.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/PlayerPropertiesChanges.tsx b/webclient/src/websocket/events/SessionEvents/PlayerPropertiesChanges.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/PlayerPropertiesChanges.tsx rename to webclient/src/websocket/events/SessionEvents/PlayerPropertiesChanges.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/RemoveFromList.tsx b/webclient/src/websocket/events/SessionEvents/RemoveFromList.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/RemoveFromList.tsx rename to webclient/src/websocket/events/SessionEvents/RemoveFromList.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/ServerIdentification.tsx b/webclient/src/websocket/events/SessionEvents/ServerIdentification.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/ServerIdentification.tsx rename to webclient/src/websocket/events/SessionEvents/ServerIdentification.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/ServerMessage.tsx b/webclient/src/websocket/events/SessionEvents/ServerMessage.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/ServerMessage.tsx rename to webclient/src/websocket/events/SessionEvents/ServerMessage.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/ServerShutdown.tsx b/webclient/src/websocket/events/SessionEvents/ServerShutdown.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/ServerShutdown.tsx rename to webclient/src/websocket/events/SessionEvents/ServerShutdown.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/UserJoined.tsx b/webclient/src/websocket/events/SessionEvents/UserJoined.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/UserJoined.tsx rename to webclient/src/websocket/events/SessionEvents/UserJoined.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/UserLeft.tsx b/webclient/src/websocket/events/SessionEvents/UserLeft.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/UserLeft.tsx rename to webclient/src/websocket/events/SessionEvents/UserLeft.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/UserMessage.tsx b/webclient/src/websocket/events/SessionEvents/UserMessage.tsx similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/UserMessage.tsx rename to webclient/src/websocket/events/SessionEvents/UserMessage.tsx diff --git a/webclient/src/WebClient/events/SessionEvents/index.ts b/webclient/src/websocket/events/SessionEvents/index.ts similarity index 100% rename from webclient/src/WebClient/events/SessionEvents/index.ts rename to webclient/src/websocket/events/SessionEvents/index.ts diff --git a/webclient/src/websocket/index.ts b/webclient/src/websocket/index.ts new file mode 100644 index 00000000..505dd631 --- /dev/null +++ b/webclient/src/websocket/index.ts @@ -0,0 +1,11 @@ +export { default as webClient } from './WebClient'; +export { default as ProtoFiles } from './ProtoFiles'; + + +// Export common used services + +export { NormalizeService, RoomService} from "./services"; + + +// Note: this has to come after webClient +export { AuthenticationService, ModeratorService, RoomsService, SessionService } from "./instanceService"; \ No newline at end of file diff --git a/webclient/src/AppShell/common/services/AuthenticationService.tsx b/webclient/src/websocket/instanceService/AuthenticationService.tsx similarity index 83% rename from webclient/src/AppShell/common/services/AuthenticationService.tsx rename to webclient/src/websocket/instanceService/AuthenticationService.tsx index 4e911708..399b1826 100644 --- a/webclient/src/AppShell/common/services/AuthenticationService.tsx +++ b/webclient/src/websocket/instanceService/AuthenticationService.tsx @@ -1,7 +1,7 @@ import { StatusEnum } from "types"; -import webClient from "WebClient/WebClient"; +import { webClient } from "websocket"; -export class AuthenticationService { +export default class AuthenticationService { static connect(options) { webClient.services.session.connectServer(options); } diff --git a/webclient/src/AppShell/common/services/ModeratorService.tsx b/webclient/src/websocket/instanceService/ModeratorService.tsx similarity index 55% rename from webclient/src/AppShell/common/services/ModeratorService.tsx rename to webclient/src/websocket/instanceService/ModeratorService.tsx index 8d5c150b..046de8c4 100644 --- a/webclient/src/AppShell/common/services/ModeratorService.tsx +++ b/webclient/src/websocket/instanceService/ModeratorService.tsx @@ -1,6 +1,6 @@ -import webClient from "WebClient/WebClient"; +import { webClient } from ".."; -export class ModeratorService { +export default class ModeratorService { static viewLogHistory(filters) { webClient.commands.session.viewLogHistory(filters); } diff --git a/webclient/src/AppShell/common/services/RoomsService.tsx b/webclient/src/websocket/instanceService/RoomsService.tsx similarity index 70% rename from webclient/src/AppShell/common/services/RoomsService.tsx rename to webclient/src/websocket/instanceService/RoomsService.tsx index 92984d86..db883112 100644 --- a/webclient/src/AppShell/common/services/RoomsService.tsx +++ b/webclient/src/websocket/instanceService/RoomsService.tsx @@ -1,6 +1,6 @@ -import webClient from "WebClient/WebClient"; +import { webClient } from ".."; -export class RoomsService { +export default class RoomsService { static joinRoom(roomId) { webClient.commands.session.joinRoom(roomId); } diff --git a/webclient/src/AppShell/common/services/RouterService.tsx b/webclient/src/websocket/instanceService/RouterService.tsx similarity index 61% rename from webclient/src/AppShell/common/services/RouterService.tsx rename to webclient/src/websocket/instanceService/RouterService.tsx index 03bf0070..aac36339 100644 --- a/webclient/src/AppShell/common/services/RouterService.tsx +++ b/webclient/src/websocket/instanceService/RouterService.tsx @@ -1,4 +1,4 @@ -import { RouteEnum } from "../types"; +import { RouteEnum } from "../../types"; export class RouterService { resolveUrl(path, params) { diff --git a/webclient/src/AppShell/common/services/SessionService.tsx b/webclient/src/websocket/instanceService/SessionService.tsx similarity index 84% rename from webclient/src/AppShell/common/services/SessionService.tsx rename to webclient/src/websocket/instanceService/SessionService.tsx index e32f7b63..aef2758c 100644 --- a/webclient/src/AppShell/common/services/SessionService.tsx +++ b/webclient/src/websocket/instanceService/SessionService.tsx @@ -1,6 +1,6 @@ -import webClient from "WebClient/WebClient"; +import { webClient } from ".."; -export class SessionService { +export default class SessionService { static addToBuddyList(userName) { webClient.commands.session.addToBuddyList(userName); } diff --git a/webclient/src/websocket/instanceService/index.ts b/webclient/src/websocket/instanceService/index.ts new file mode 100644 index 00000000..fe3bddb9 --- /dev/null +++ b/webclient/src/websocket/instanceService/index.ts @@ -0,0 +1,4 @@ +export { default as AuthenticationService } from "./AuthenticationService"; +export { default as ModeratorService } from "./ModeratorService"; +export { default as RoomsService } from "./RoomsService"; +export { default as SessionService } from "./SessionService"; \ No newline at end of file diff --git a/webclient/src/WebClient/services/NormalizeService.tsx b/webclient/src/websocket/services/NormalizeService.tsx similarity index 96% rename from webclient/src/WebClient/services/NormalizeService.tsx rename to webclient/src/websocket/services/NormalizeService.tsx index d5301222..f0846be8 100644 --- a/webclient/src/WebClient/services/NormalizeService.tsx +++ b/webclient/src/websocket/services/NormalizeService.tsx @@ -1,4 +1,4 @@ -export class NormalizeService { +export default class NormalizeService { // Flatten room gameTypes into map object static normalizeRoomInfo(roomInfo) { roomInfo.gametypeMap = {}; diff --git a/webclient/src/websocket/services/RoomService.tsx b/webclient/src/websocket/services/RoomService.tsx new file mode 100644 index 00000000..878a196f --- /dev/null +++ b/webclient/src/websocket/services/RoomService.tsx @@ -0,0 +1,50 @@ +import { store, RoomsDispatch, RoomsSelectors } from "store"; +import { WebClient } from "../WebClient"; + +import { NormalizeService } from "websocket"; + +export default class RoomService { + webClient: WebClient; + + constructor(webClient) { + this.webClient = webClient; + } + + clearStore() { + RoomsDispatch.clearStore(); + } + + joinRoom(roomInfo) { + NormalizeService.normalizeRoomInfo(roomInfo); + RoomsDispatch.joinRoom(roomInfo); + } + + updateRooms(rooms) { + RoomsDispatch.updateRooms(rooms); + } + + updateGames(roomId, gameList) { + const game = gameList[0]; + + if (!game.gameType) { + const { gametypeMap } = RoomsSelectors.getRoom(store.getState(), roomId); + NormalizeService.normalizeGameObject(game, gametypeMap); + } + + RoomsDispatch.updateGames(roomId, gameList); + } + + addMessage(roomId, message) { + NormalizeService.normalizeUserMessage(message); + + RoomsDispatch.addMessage(roomId, message); + } + + userJoined(roomId, user) { + RoomsDispatch.userJoined(roomId, user); + } + + userLeft(roomId, name) { + RoomsDispatch.userLeft(roomId, name); + } +} diff --git a/webclient/src/websocket/services/SessionService.tsx b/webclient/src/websocket/services/SessionService.tsx new file mode 100644 index 00000000..0fa7a714 --- /dev/null +++ b/webclient/src/websocket/services/SessionService.tsx @@ -0,0 +1,94 @@ +import { ServerDispatch, ServerConnectParams } from "store"; +import { StatusEnum } from "types"; + +import { sanitizeHtml } from "websocket/utils"; +import { WebClient } from "websocket/WebClient"; + +import { NormalizeService } from "websocket"; + +export default class SessionService { + webClient: WebClient; + + constructor(webClient) { + this.webClient = webClient; + } + + clearStore() { + ServerDispatch.clearStore(); + } + + connectServer(options: ServerConnectParams) { + ServerDispatch.connectServer(); + this.webClient.updateStatus(StatusEnum.CONNECTING, "Connecting..."); + this.webClient.connect(options); + } + + disconnectServer() { + this.webClient.updateStatus(StatusEnum.DISCONNECTING, "Disconnecting..."); + this.webClient.disconnect(); + } + + connectionClosed(reason) { + ServerDispatch.connectionClosed(reason); + } + + updateBuddyList(buddyList) { + ServerDispatch.updateBuddyList(buddyList); + } + + addToBuddyList(user) { + ServerDispatch.addToBuddyList(user); + } + + removeFromBuddyList(userName) { + ServerDispatch.removeFromBuddyList(userName); + } + + updateIgnoreList(ignoreList) { + ServerDispatch.updateIgnoreList(ignoreList); + } + + addToIgnoreList(user) { + ServerDispatch.addToIgnoreList(user); + } + + removeFromIgnoreList(userName) { + ServerDispatch.removeFromIgnoreList(userName); + } + + updateInfo(name, version) { + ServerDispatch.updateInfo(name, version); + } + + updateStatus(state, description) { + ServerDispatch.updateStatus(state, description); + + if (state === StatusEnum.DISCONNECTED) { + this.connectionClosed({ reason: description }); + } + } + + updateUser(user) { + ServerDispatch.updateUser(user); + } + + updateUsers(users) { + ServerDispatch.updateUsers(users); + } + + userJoined(user) { + ServerDispatch.userJoined(user); + } + + userLeft(userId) { + ServerDispatch.userLeft(userId); + } + + viewLogs(logs) { + ServerDispatch.viewLogs(NormalizeService.normalizeLogs(logs)); + } + + serverMessage(message) { + ServerDispatch.serverMessage(sanitizeHtml(message)); + } +} diff --git a/webclient/src/websocket/services/index.ts b/webclient/src/websocket/services/index.ts new file mode 100644 index 00000000..26776f87 --- /dev/null +++ b/webclient/src/websocket/services/index.ts @@ -0,0 +1,3 @@ +export { default as NormalizeService } from "./NormalizeService"; +export { default as RoomService } from "./RoomService"; +export { default as SessionService } from "./SessionService"; \ No newline at end of file diff --git a/webclient/src/WebClient/util/guid.util.tsx b/webclient/src/websocket/utils/guid.util.tsx similarity index 100% rename from webclient/src/WebClient/util/guid.util.tsx rename to webclient/src/websocket/utils/guid.util.tsx diff --git a/webclient/src/WebClient/util/index.tsx b/webclient/src/websocket/utils/index.tsx similarity index 100% rename from webclient/src/WebClient/util/index.tsx rename to webclient/src/websocket/utils/index.tsx diff --git a/webclient/src/WebClient/util/sanitizeHtml.util.tsx b/webclient/src/websocket/utils/sanitizeHtml.util.tsx similarity index 100% rename from webclient/src/WebClient/util/sanitizeHtml.util.tsx rename to webclient/src/websocket/utils/sanitizeHtml.util.tsx