diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml index b83fd8448..c6bdca7b8 100644 --- a/.github/workflows/ui.yml +++ b/.github/workflows/ui.yml @@ -37,7 +37,7 @@ jobs: working-directory: telemetry/ui strategy: matrix: - node-version: [16.x] + node-version: [22.x] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 1dd3f62cf..46a86c3ae 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -96,7 +96,7 @@ Not part of the CLI (yet), but running just the UI is simple: .. code-block:: bash - $ cd burr/ui + $ cd telemetry/ui $ npm run start Package data diff --git a/burr/tracking/server/run.py b/burr/tracking/server/run.py index ad253cc6b..9bd6cba93 100644 --- a/burr/tracking/server/run.py +++ b/burr/tracking/server/run.py @@ -363,15 +363,15 @@ async def version() -> dict: if serve_static: base_asset_directory = str(files("burr").joinpath("tracking/server/build")) - static_directory = os.path.join(base_asset_directory, "static") + assets_directory = os.path.join(base_asset_directory, "assets") ui_app.mount( - "/static", - StaticFiles(directory=static_directory), - "/static", + "/assets", + StaticFiles(directory=assets_directory), + "/assets", ) - # public assets in create react app don't get put under build/static, - # we need to route them over + # public assets (favicon, manifest, logo, etc.) are in the build root, + # routed under /public for the UI to reference ui_app.mount("/public", StaticFiles(directory=base_asset_directory, html=True), "/public") # Read index.html once at startup @@ -392,8 +392,8 @@ async def manifest_json(): async def react_app(req: Request, rest_of_path: str): """Serves the React app, rewriting asset paths to respect the mount prefix. - When mounted as a sub-app (e.g. under /burr), the CRA build's hardcoded - absolute paths (/static/js/..., /api/v0/...) need to be prefixed with the + When mounted as a sub-app (e.g. under /burr), the build's hardcoded + absolute paths (/assets/..., /api/v0/...) need to be prefixed with the mount path so the browser fetches them from the correct location. This rewrites both the HTML (href/src attributes) and injects a script that @@ -404,7 +404,7 @@ async def react_app(req: Request, rest_of_path: str): root_path = req.scope.get("root_path", "") if root_path: - # Rewrite CRA's absolute paths to include the mount prefix + # Rewrite absolute paths to include the mount prefix html = _index_html_template.replace('href="/', f'href="{root_path}/') html = html.replace('src="/', f'src="{root_path}/') # Inject a script before that patches the OpenAPI BASE config diff --git a/docs/contributing/contributing.rst b/docs/contributing/contributing.rst index 03c49293e..74035ed2b 100644 --- a/docs/contributing/contributing.rst +++ b/docs/contributing/contributing.rst @@ -92,7 +92,7 @@ Not part of the CLI (yet), but running just the UI is simple: .. code-block:: bash - $ cd burr/ui + $ cd telemetry/ui $ npm run start Package data diff --git a/docs/contributing/iterating.rst b/docs/contributing/iterating.rst index 27a5ae154..ff62db40f 100644 --- a/docs/contributing/iterating.rst +++ b/docs/contributing/iterating.rst @@ -68,8 +68,8 @@ Then, you can run the following commands: $ npm run start This will start the UI on port 3000. You can then navigate to ``http://localhost:3000`` to see the UI. -It currently assumes that the tracking server is running on port 7241. The proxy is set up in the -``package.json`` file. +It currently assumes that the tracking server is running on port 7241. The proxy is configured in +``vite.config.ts``. Note that if you want to just develop off the server you'll first have to build the UI and symlink the ``tracking/server/build`` directory to the ``telemetry/ui/build`` directory. We have this structure to diff --git a/telemetry/ui/.eslintignore b/telemetry/ui/.eslintignore index cdfef6079..90039f2a9 100644 --- a/telemetry/ui/.eslintignore +++ b/telemetry/ui/.eslintignore @@ -17,5 +17,8 @@ build/* tailwind.config.js +postcss.config.js +vite.config.ts +vitest.config.ts .eslintrc.js src/api # generated code diff --git a/telemetry/ui/.prettierignore b/telemetry/ui/.prettierignore index db8314b54..494d76c2b 100644 --- a/telemetry/ui/.prettierignore +++ b/telemetry/ui/.prettierignore @@ -17,4 +17,4 @@ build/* tailwind.config.js -.eslitrc.js +.eslintrc.js diff --git a/telemetry/ui/README.md b/telemetry/ui/README.md index a8a609215..19d1ea4c5 100644 --- a/telemetry/ui/README.md +++ b/telemetry/ui/README.md @@ -6,9 +6,9 @@ to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -17,9 +17,9 @@ under the License. --> -# Getting Started with Create React App +# Burr Tracking UI -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +Burr's telemetry tracking UI, built with React and Vite. ## Available Scripts @@ -27,39 +27,26 @@ In the project directory, you can run: ### `npm start` -Runs the app in the development mode.\ +Runs the app in development mode with hot module replacement.\ Open [http://localhost:3000](http://localhost:3000) to view it in the browser. -The page will reload if you make edits.\ -You will also see any lint errors in the console. - ### `npm test` -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. +Runs the test suite with Vitest in watch mode. ### `npm run build` Builds the app for production to the `build` folder.\ It correctly bundles React in production mode and optimizes the build for the best performance. -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. +### `npm run preview` -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. +Previews the production build locally using Vite's preview server. -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. +### `npm run lint` -## Learn More +Runs ESLint on the project. -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). +### `npm run lint:fix` -To learn React, check out the [React documentation](https://reactjs.org/). +Runs ESLint with auto-fix on the project. diff --git a/telemetry/ui/index.html b/telemetry/ui/index.html new file mode 100644 index 000000000..b44a14216 --- /dev/null +++ b/telemetry/ui/index.html @@ -0,0 +1,36 @@ + + + + +
+ + + + + + +