From ff1dbebe774853753882ac5c4ed8052607c3cf49 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sat, 8 Oct 2022 21:26:48 +0000 Subject: [PATCH] Update to allow using fragment shorthand syntax, switch to standard HTML compliant rendering mode, fix a few things here and there with that switch, use fragments for all components and arcade/admin endpoints. --- bemani/frontend/app.py | 8 +++- .../static/components/events.react.js | 16 ++++---- .../static/components/gamesettings.react.js | 4 +- .../frontend/static/components/nav.react.js | 4 +- .../static/components/slider.react.js | 8 ++-- .../controllers/account/account.react.js | 12 +++--- .../static/controllers/admin/api.react.js | 32 +++++++-------- .../static/controllers/admin/arcades.react.js | 10 ++--- .../static/controllers/admin/cards.react.js | 6 +-- .../controllers/admin/machines.react.js | 40 +++++++++---------- .../static/controllers/admin/news.react.js | 10 ++--- .../static/controllers/admin/user.react.js | 16 ++++---- .../static/controllers/arcade/arcade.react.js | 32 +++++++-------- bemani/frontend/static/themes/dark/form.css | 1 - .../frontend/static/themes/dark/section.css | 5 +-- bemani/frontend/static/themes/dark/site.css | 7 ++-- bemani/frontend/static/themes/dark/table.css | 3 ++ .../static/themes/default/section.css | 3 +- .../frontend/static/themes/default/site.css | 7 ++-- .../frontend/static/themes/default/table.css | 3 ++ bemani/frontend/templates/base.html | 1 + bemani/utils/jsx.py | 4 +- 22 files changed, 122 insertions(+), 110 deletions(-) diff --git a/bemani/frontend/app.py b/bemani/frontend/app.py index 51948ac..b962ee2 100644 --- a/bemani/frontend/app.py +++ b/bemani/frontend/app.py @@ -141,7 +141,7 @@ def jsx(filename: str) -> Response: if jsx is None: with open(jsxfile, 'rb') as f: transformer = JSXTransformer() - jsx = transformer.transform_string(f.read().decode('utf-8')) + jsx = transformer.transform_string(polyfill_fragments(f.read().decode('utf-8'))) # Set the cache to one year, since we namespace on this file's update time g.cache.set(namespace, jsx, timeout=86400 * 365) return Response(jsx, mimetype='application/javascript') @@ -163,6 +163,12 @@ def jsx(filename: str) -> Response: raise +def polyfill_fragments(jsx: str) -> str: + jsx = jsx.replace("<>", "") + jsx = jsx.replace("", "") + return jsx + + def render_react( title: str, controller: str, diff --git a/bemani/frontend/static/components/events.react.js b/bemani/frontend/static/components/events.react.js index db7158b..9158cb8 100644 --- a/bemani/frontend/static/components/events.react.js +++ b/bemani/frontend/static/components/events.react.js @@ -23,44 +23,44 @@ var ExceptionEvent = createReactClass({ if (event.data.service == 'frontend') { location = 'Web UI'; details = ( - + <>
URI:
{event.data.request}
Exception:
{event.data.traceback} -
+ ); } else if(event.data.service == 'xrpc') { location = 'Game Services'; details = ( - + <>
Request:
{event.data.request}
Exception:
{event.data.traceback} -
+ ); } else if(event.data.service == 'scheduler') { location = 'Work Scheduler'; details = ( - + <>
Exception:
{event.data.traceback} -
+ ); } else if (event.data.service == 'api') { location = 'Data Exchange API'; details = ( - + <>
URI:
{event.data.request}
Exception:
{event.data.traceback} -
+ ); } diff --git a/bemani/frontend/static/components/gamesettings.react.js b/bemani/frontend/static/components/gamesettings.react.js index d3d23a6..8226e55 100644 --- a/bemani/frontend/static/components/gamesettings.react.js +++ b/bemani/frontend/static/components/gamesettings.react.js @@ -196,11 +196,11 @@ var GameSettings = createReactClass({ /> { this.state.settings_saving[this.state.current_setting] ? : - null + null } { this.state.settings_saved[this.state.current_setting] ? { "\u2713" } : - null + null } diff --git a/bemani/frontend/static/components/nav.react.js b/bemani/frontend/static/components/nav.react.js index c1b5cad..44678c7 100644 --- a/bemani/frontend/static/components/nav.react.js +++ b/bemani/frontend/static/components/nav.react.js @@ -3,13 +3,13 @@ var Nav = createReactClass({ render: function() { var title = ( - + <> {this.props.title} {this.props.showAlert ? { "\u26a0" } : null } - + ); return (