Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Mar 30, 2023

Scope & Purpose

This PR updates the frontend dependencies and replaces the ejected version of create-react-app with react-app-rewired.

This should get rid of the GitHub/npm audit nag spam.

It also replaces the yarn lockfile with the npm lockfile so frontend scripts should be invoked using npm run instead of yarn from now on. Note that npm install requires the --legacy-peer-deps argument at the moment.

This should also fix the weird behavior we were seeing when working with the devel version like nested frontends.

  • 💩 Bugfix

Checklist

  • 📖 CHANGELOG entry made

Related Information

  • GitHub issue / Jira ticket: FE-218

@ghost ghost added 1 Bug 3 UI ArangoDB Web Interface (frontend/Aardvark) 9 Waiting for Jenkins 9 Review Required dependencies Pull requests that update a dependency file labels Mar 30, 2023
@ghost ghost added this to the 3.11 milestone Mar 30, 2023
@ghost ghost requested review from ajurdak and palashkaria March 30, 2023 21:48
@ghost ghost self-assigned this Mar 30, 2023
@cla-bot cla-bot bot added the cla-signed label Mar 30, 2023
@ghost ghost force-pushed the bug-fix/fe-218 branch from 38b25a2 to b180ac1 Compare March 30, 2023 22:04
@ghost
Copy link
Author

ghost commented Mar 30, 2023

Jenkins: https://jenkins01.arangodb.biz/view/PR/job/arangodb-matrix-pr/28706/

EDIT: This Jenkins run seems to have killed itself during jslint.

var url = 'cluster/amICoordinator';
if (frontendConfig.react) {
url = arangoHelper.databaseUrl('/_admin/aardvark/cluster/amICoordinator');
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are no longer necessary because they were workarounds for the buggy dev proxy. I've fixed the proxy, see below.

// react unmounting
ReactDOM.unmountComponentAtNode(document.getElementById('content-react'));
const reactRoot = document.getElementById('content-react');
if (reactRoot) ReactDOM.unmountComponentAtNode(reactRoot);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DOM node isn't initially loaded in dev mode and unmountComponentAtNode no longer likes that. This is probably redundant in prod, but here we are.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pluma4345 there's another ReactDOM.unmount below this, maybe that needs the same check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that one is fine, apparently. I don't know what exactly causes the first one to sometimes error out but it's only the first one. I'll leave it as is for now.

@@ -0,0 +1 @@
REACT_APP_ARANGODB_CONFIG_PATH="config.js" No newline at end of file
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still needed although this value is the same in devel and prod now because CRA otherwise tries to resolve the path if we use it in index.html verbatim. If someone has a good workaround to avoid this, I'm all ears.

app.use(
routes,
proxy({
createProxyMiddleware(["/_db/**", "!/_db/*/_admin/aardvark/index.html"], {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now allows us to proxy all requests on port 3000 instead of having to deal with cross-origin request. All ArangoDB routes start with /_db but we need a special case to make sure the index.html is served by CRA. This also means a lot of weird bugs in the devel version of the frontend are now fixed because we no longer have CRA intercepting API calls or CORS causing issues.

@ghost ghost requested a review from palashkaria March 31, 2023 09:24
Copy link
Contributor

@ajurdak ajurdak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@KVS85
Copy link
Contributor

KVS85 commented Apr 3, 2023

Only unrelated errors in CI.

@KVS85 KVS85 merged commit e0b2b4b into devel Apr 3, 2023
@KVS85 KVS85 deleted the bug-fix/fe-218 branch April 3, 2023 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 Bug 3 UI ArangoDB Web Interface (frontend/Aardvark) 9 Ready to Merge cla-signed dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants