Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Change embed-grid and embed-chart to redirects #1873

Merged
merged 5 commits into from
Apr 3, 2024

Conversation

mattrunyon
Copy link
Collaborator

@mattrunyon mattrunyon commented Mar 15, 2024

Publishing an alpha with the embed-refactor label so we can test with a local DHC build

This changes embed-grid and embed-chart to just be simple redirects to /iframe/widget. This should reduce our footprint in the install size as this is about half of the size we contribute currently.

BREAKING CHANGE: @deephaven/embed-grid does not handle messages to the iframe for filtering or sorting the grid any more

@mattrunyon mattrunyon requested a review from mofojed March 15, 2024 22:58
@mattrunyon mattrunyon self-assigned this Mar 15, 2024
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.23%. Comparing base (f302fb9) to head (8639ac7).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1873      +/-   ##
==========================================
+ Coverage   46.11%   46.23%   +0.12%     
==========================================
  Files         636      645       +9     
  Lines       38070    38241     +171     
  Branches     9627     9672      +45     
==========================================
+ Hits        17556    17682     +126     
- Misses      20461    20506      +45     
  Partials       53       53              
Flag Coverage Δ
unit 46.23% <ø> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

Minor correction with document.baseURI instead of window.location.
I see you published the alpha, you tried it out as well and it worked yeah?

Comment on lines 8 to 9
const url = new URL(window.location);
url.pathname = '/iframe/widget/';
Copy link
Member

Choose a reason for hiding this comment

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

Should be using baseURI, not window.location:

Suggested change
const url = new URL(window.location);
url.pathname = '/iframe/widget/';
const url = new URL('/iframe/widget/', document.baseURI);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ya I think I need to adjust it to a relative path and add a base tag then. In the existing version, we have base=./ so baseURI is actually /iframe/chart or /iframe/table

What this doesn't allow (and neither does our existing base) is specifying a base that isn't ./ or rewriting it with a web server. If our base is ever rewritten, the jsapi and iframes will try to load from paths that likely don't exist

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, if I combine instead of just changing url.pathname after, then the URL params get dropped

Copy link
Member

Choose a reason for hiding this comment

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

Yea true it assumes we're at a path like iframe/table already:

BASE_URL=./
# We assume embed-grid is served at nested path, e.g. '/iframe/grid'
VITE_CORE_API_URL=../../jsapi
VITE_MODULE_PLUGINS_URL=../../js-plugins

Devin has rewriting the base before to have two Deephaven instances running on the same host; but that's beside the point.

Also good point about dropping params.

packages/embed-grid/build/index.html Outdated Show resolved Hide resolved
packages/embed-chart/.gitignore Outdated Show resolved Hide resolved
@mattrunyon mattrunyon requested a review from mofojed March 27, 2024 22:04
@mattrunyon
Copy link
Collaborator Author

Changed this to just use vite to build embed-grid and embed-chart still. All it does is copy the index into the build folder. This way there's no issues of people accidentally committing stale build artifacts since the folder was being un-ignored with the first change.

Will publish an alpha and test everything is working properly

<!doctype html>
<html lang="en">
<head>
<base href="./" />
Copy link
Member

Choose a reason for hiding this comment

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

This should still be BASE_URL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was just trying to make this simple (using Vite default config). I don't see any reason BASE_URL needs to be easily changeable at build time as we don't support anything other than ./

Copy link
Member

Choose a reason for hiding this comment

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

Yea fair


<script>
// Can't be an HTML meta redirect because we need to keep the search params
const url = new URL('../../iframe/widget/', document.baseURI);
Copy link
Member

Choose a reason for hiding this comment

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

May as well just do ../widget ...

Suggested change
const url = new URL('../../iframe/widget/', document.baseURI);
const url = new URL('../widget/', document.baseURI);

We could have env vars that you set when building to reference where the new iframe path should be, but this is fine... if you change the path, you'll need to rewrite the path in this index.html file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ya I figured these were simple enough redirects that adding an env file just adds an unnecessary layer of pass through. Not any gain IMO when we're replacing a single use value with a single use variable instead and we're ultimately trying to remove these separate embed packages

@mattrunyon mattrunyon requested a review from mofojed April 1, 2024 16:18
@mattrunyon
Copy link
Collaborator Author

Just tested again w/ the latest commit alpha and ./gradlew prepareCompose and the redirect works as expected

<!doctype html>
<html lang="en">
<head>
<base href="./" />
Copy link
Member

Choose a reason for hiding this comment

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

Yea fair

@mattrunyon mattrunyon merged commit e17619a into deephaven:main Apr 3, 2024
5 checks passed
@mattrunyon mattrunyon deleted the redirect-embed-apps branch April 3, 2024 20:00
@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants