Skip to content

New UI: Use URL from window.location #4281

Open
renatoh wants to merge 4 commits intoapache:mainfrom
renatoh:use-url-from-window.location
Open

New UI: Use URL from window.location #4281
renatoh wants to merge 4 commits intoapache:mainfrom
renatoh:use-url-from-window.location

Conversation

@renatoh
Copy link
Copy Markdown
Contributor

@renatoh renatoh commented Apr 13, 2026

At different places, e.g. on the placeholder of the welcome screen, 127.0.0.1:8983 was hard coded, that causes issues when Solr was opened using a different URL, e.g. localhost or any other URL.
Now the URL is taken from window.location.origin. Doing so the todo in Main.kt could be removed.
Additionally the right URL is now pre-populated to solr_url_input on the welcome screen, rather than having hard coded 127.0.0.1:8983 as place-holder in it.

renatoh added 2 commits April 13, 2026 14:45
…rather than a hard coded, and potentially wrong, placeHolder URL
@renatoh renatoh changed the title Use url from window.location New UI: Use URL from window.location Apr 13, 2026
Copy link
Copy Markdown
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

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

I tested this with "http://localhost:8983" and "http://127.0.0.1:8983" and it worked as expected.... I am not a kotlin expert, so hesitant to approve and merge. Hopefully @malliaridis can approve!

@epugh epugh requested a review from malliaridis April 13, 2026 15:36
@epugh
Copy link
Copy Markdown
Contributor

epugh commented Apr 13, 2026

Tests are running.

@renatoh
Copy link
Copy Markdown
Contributor Author

renatoh commented Apr 13, 2026

@epugh Thanks a lot for testing:) Despite of having used Kotlin in the past, I have no experience with Kotlin's Multiplatform, so definitely a must to get it checked by someone who actually understands it.

Copy link
Copy Markdown
Contributor

@malliaridis malliaridis left a comment

Choose a reason for hiding this comment

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

Thanks a lot for addressing this issue, it was bothering me a lot during development, but I didn't took the time to address it myself.

Your implementation looks clean and makes proper use of the expect / actual pattern of Kotlin Multiplatform. I have added a note about the reason for the previous implementation with the placeholder, so that you have a bit more context.

I have only one concern about the platform-specific file namings, that normally are suffixed with [File].[platform].kt, for example PlatformUtils.wasmJs.kt. I have faced some build issues when the implementation was merged together for individual targets. You don't have to change anything yet. If that happens in a release, we will address it separately (I am also investigating the cases when this issue happens).

@renatoh Feel free to add me for any kotlin-specific changes as reviewer, and if you are interested I can provide a few more details about Kotlin stuff. I would also be very grateful if you have the time to review some of my changes or give the implementation of new features a shot. :)

value = model.url,
singleLine = true,
onValueChange = component::onSolrUrlChange,
placeholder = { Text(text = DEFAULT_SOLR_URL) },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The idea of using the default Solr URL as placeholder and not as state directly was so that users can type in a different URL without having to first delete the current content of the input field, hence the placeholder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah ok, I did not realize that you actually don't have to type the URL anymore using placeholder since it was broken for me using Solr on localhost.
Is the idea behind this connect feature so that you don't need to run the UI on all Solr-nodes and you can connect to them from a node running the UI?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, the placeholder is not part of thr state, and therefore ignored. What is stored in thr state is actually the empty string, whichwiththe logic you updated, was previously just using the default solr url which was falling back to the same value). So only in combination it was working. ofcourse, as You correctly noticed, because it was haedcoded to 127.0.9.1:8983, it was not working with other window locations.

What would be sufficient probably is to replace the state fallback as mentioned below with the function you inteoduced with your changes, sothat the fallback and placeholder use the current window.location by default, instead of the hardcoded URL.

I hope that makes sense?

FYI only the value in the input field is relevant to us, and it was by default an empty string. The placeholder, like the label too, are judt hints for the user what to fill in.

If you are new in Ui development or Material components, you can find more information about these parameters in the text field documention

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you like I can also explain everything in more detail in a call, and try to answer any other questions you have too. just let me know. :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And about your question, because I realized I did not answer it. The idea of the connect feature is to allow the desktop client to connect to any dolr instance. In browser that would also be possible, but it would require the correct CORS header to be provided by each individual Solr instance, therefore it is not the goal (yet) to support it in browser.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@malliaridis
ok, with my latest commit placeholder and the using the default if state().url is blank is back. have a look

Comment on lines +85 to +84
var urlValue = state().url
if (urlValue == "") urlValue = DEFAULT_SOLR_URL // use placeholder value if empty

val urlValue = state().url
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we consider not using the default URL as fallback on empty strings, we should disable the connect button when the field is empty for better user experience.

In my opinion it may be better to keep the placeholder logic like before, and simply replace

if (urlValue == "") urlValue = DEFAULT_SOLR_URL

with

if (urlValue == "") urlValue = getDefaultUrl()

But feel free to choose whatever resolution you prefer, your changes are also fine by me the way they are. :)

@malliaridis
Copy link
Copy Markdown
Contributor

@renatoh I leave the decision of how to resolve my feedback topics to you, and once resolved we can merge this PR. :)

…rather than a hard coded, and potentially wrong, placeHolder URL
@renatoh
Copy link
Copy Markdown
Contributor Author

renatoh commented Apr 14, 2026

@renatoh Feel free to add me for any kotlin-specific changes as reviewer, and if you are interested I can provide a few more details about Kotlin stuff. I would also be very grateful if you have the time to review some of my changes or give the implementation of new features a shot. :)

Are there also ticket which require mainly backend work? If so, I am happy to give it the shot. I am not good with front-end stuff and have never enjoyed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants