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

[ZEPPELIN-6085] Add configuration option for setting the default UI #4824

Merged
merged 16 commits into from
Oct 9, 2024

Conversation

tbonelee
Copy link
Contributor

What is this PR for?

This PR introduces a new configuration option zeppelin.default.ui to set the default UI for Zeppelin.
The available options for this setting are new and classic.
By default, the value is set to new, meaning the new UI will be served at the root path ("/"), while the classic UI will be available at "/classic".
If the configuration is set to classic, the classic UI will be served at "/", and the new UI at "/new".

What type of PR is it?

Improvement

Todos

  • - Task

What is the Jira issue?

How should this be tested?

  • Testing the new option :
    • Set the zeppelin.default.ui config to new (the default).
    • Verify that the new UI is served at the root ("/") and the classic UI is available at "/classic".
    • Verify that navigating between pages works without any issue.
    • Verify that the UI switching button works properly in both UIs.
  • Testing classic option :
    • Similar steps as the above, except the new UI is served at "/classic" and the classic UI is available at the root ("/")

Screenshots (if appropriate)

Questions:

  • Does the license files need to update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? Yes, documentation for the new configuration option has been added.

Copy link
Contributor

@Reamer Reamer left a comment

Choose a reason for hiding this comment

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

I have made some comments on the Java class. I don't know if the changes are possible in the Java script frontends. Aren't the URLs to other elements (images, CSS etc.) fixed during the building of the frontends?

@tbonelee
Copy link
Contributor Author

@Reamer
It seems like it could depend on the situation.
In my opinion, if the resource URLs are set as fixed absolute paths, there could be an issue, but if they are relative paths, there shouldn't be a problem.

In the initial code I wrote, I added code on the server side to insert a base tag into the index.html at runtime.
Howver, when I ran the app and checked the network tab, resources were being fetched from the correct paths even without the base tag, so I removed it.

From reviewing the frontend code, my assumption is that most of the resources are set with relative paths, or they dynamically generate absolute paths based on each app's path, so there didn't seem to be an issue.

However, upon reconsideration, I thought explicitly specifying the base tag would be a more reliable soltuion, so I added the code back in.

@tbonelee
Copy link
Contributor Author

Additionally, I missed this part earlier, but for the MathJax library, the library root path for resolving the module loading URL needs to be changed.
However, it was set to always fetch from the root regardless of the app's path. (In fact, this caused the new UI app, which was served from the /next path, to fetch the MathJax code from the classic UI app's resource path.)

So, I made additional modifications to ensure this part changes according to the app's path.

@jongyoul
Copy link
Member

It includes various types of code :-) Thank you for your work. I'll test it sooner than later.

@tbonelee
Copy link
Contributor Author

tbonelee commented Sep 22, 2024

@Reamer @jongyoul Just pinging to review :)

@tbonelee
Copy link
Contributor Author

I've rebased this branch and added documentation for configuring the default Ui on the explore_ui page.

@pan3793 pan3793 requested a review from Reamer September 29, 2024 14:20
@@ -905,6 +910,10 @@ public boolean isPrometheusMetricEnabled() {
return getBoolean(ConfVars.ZEPPELIN_METRIC_ENABLE_PROMETHEUS);
}

public DEFAULT_UI getDefaultUi() {
return DEFAULT_UI.valueOf(getString(ConfVars.ZEPPELIN_DEFAULT_UI).toUpperCase());
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if I pass neither new nor classic as a configuration value at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If neither new nor classic is provided as a configuration value, the valueOf() method will throw an IllegalArgumentException during server startup.
I based this behavior on the getRunMode() method, which similarly doesn't handle exceptions for invalid input.

Should we add more graceful error handling here?

Copy link
Member

Choose a reason for hiding this comment

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

Does it mean that we set the configuration as an empty value? It would be proper to throw an exception for the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jongyoul If the value is empty, getString() will return default value (new) and if an invalid value (neither new nor classic) is provided, it will throw an exception.

Do you think it is not appropriate to provide a default value for an empty value in this configuration?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my opinion, the exception and the termination of the start in the event of incorrect configuration is acceptable.

@@ -44,6 +43,14 @@ <h1 class="brand-title" style="display: none">Zeppelin</h1>
"HTML-CSS": { availableFonts: ["TeX"] },
messageStyle: "none"
}
const origin = window.location.origin;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MathJax resolves its dependency URLs based on its configuration.
Previously, it was loading its dependency files from the root URL (the default UI app URL), regardless of whether it was being served from the default UI or the /next UI.
Since both apps included MathJax as a dependency, this didn't cause any issues, but I felt it was more appropriate for MathJax to load its dependencies from the correct app-specific paths.

So, I updated th MathJax configurations to ensure it resolves URLs relative to the correct app.

@@ -17,7 +17,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="./assets/images/zeppelin.png" type="image/x-icon">
<title>Zeppelin</title>
<base href="/">
Copy link
Contributor

Choose a reason for hiding this comment

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

You take this out in the new UI, which I understand. Where is the place in the old UI?

Copy link
Contributor Author

@tbonelee tbonelee Oct 1, 2024

Choose a reason for hiding this comment

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

@Reamer Both the old and new UIs are served from their respective sub-paths (depending on the configuration, either /, /new, or /classic), and as I understand it, the trailing part of the URL after #/... is treated as an anchor and ignored.
Therefore, without the base tag, static resources should be correctly fetched from the appropriate web app serving path, since the src attributes for those resources are set using relative paths.
I verified this in the browser, and everything worked as expected.

Given this, I believe neither app requires a base tag. In fact the old UI didn't have one to begin with.

I understand your question as asking where the base tag is in the old UI, so I've responded accordingly.
However, if I misunderstood your point, please feel free to clarify.

Copy link
Contributor

@Reamer Reamer left a comment

Choose a reason for hiding this comment

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

I looked at the code and it might work. Tests would of course be nice, but are difficult to implement at such a high level to test this small feature.
I have not tested manually myself and take your word for it.

@jongyoul jongyoul merged commit 00b7c55 into apache:master Oct 9, 2024
28 checks passed
jongyoul pushed a commit that referenced this pull request Oct 9, 2024
### What is this PR for?

This PR introduces a new configuration option `zeppelin.default.ui` to set the default UI for Zeppelin.
The available options for this setting are `new` and `classic`.
By default, the value is set to `new`, meaning the new UI will be served at the root path (`"/"`), while the classic UI will be available at `"/classic"`.
If the configuration is set to `classic`, the classic UI will be served at `"/"`, and the new UI at `"/new"`.

### What type of PR is it?

Improvement

### Todos
* [ ] - Task

### What is the Jira issue?
* Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/6085
* Put link here, and add [ZEPPELIN-*Jira number*] in PR title, eg. [ZEPPELIN-533]

### How should this be tested?
- Testing the `new` option :
  - Set the `zeppelin.default.ui` config to `new` (the default).
  - Verify that the new UI is served at the root (`"/"`) and the classic UI is available at `"/classic"`.
  - Verify that navigating between pages works without any issue.
  - Verify that the UI switching button works properly in both UIs.
- Testing `classic` option :
  - Similar steps as the above, except the new UI is served at `"/classic"` and the classic UI is available at the root (`"/"`)

### Screenshots (if appropriate)

### Questions:
* Does the license files need to update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? Yes, documentation for the new configuration option has been added.

Closes #4824 from tbonelee/add-default-ui-config.

Signed-off-by: Jongyoul Lee <[email protected]>
(cherry picked from commit 00b7c55)
Signed-off-by: Jongyoul Lee <[email protected]>
@tbonelee tbonelee deleted the add-default-ui-config branch October 9, 2024 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants