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

luci-app-ddns: show the URL which will be used. #7559

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

adelton
Copy link
Contributor

@adelton adelton commented Jan 11, 2025

  • This PR is not from my main or master branch 💩, but a separate branch ✅
  • Each commit has a valid ✒️ Signed-off-by: <[email protected]> row (via git commit --signoff)
  • Each commit and PR title has a valid 📝 <package name>: title first line subject for packages
  • Incremented 🆙 any PKG_VERSION in the Makefile
  • Tested on: x86_64 VM with OpenWrt 24.10.0-rc5 (r28304-6dacba30a7)
  • ( Preferred ) Mention: @ the original code author for feedback
  • ( Preferred ) Screenshot or mp4 of changes:
    Screenshot_2025-01-11_14-33-50
  • ( Optional ) Closes luci-app-ddns: Namecheap DDNS setting are misleading #2436
  • ( Optional ) Depends on: e.g. openwrt/packages#pr-number in sister repo
  • Description: When using the DDNS settings, I was always puzzled a bit by the Replaces [DOMAIN] in Update-URL (URL-encoded) comments. It's certainly nice to have that information but I always wondered "what is that Update-URL?" for this service? Then I came across luci-app-ddns: Namecheap DDNS setting are misleading #2436 which basically discusses that this DDNS provider does not use username and expects host (?) instead. We likely cannot finetune the description of the fields in the UI to this case but maybe if we actually showed the admin the Update-URL which will be used, it might be easier for them to figure out which field to use for what.

@adelton
Copy link
Contributor Author

adelton commented Jan 11, 2025

This can also be considered as a fix for #5297.

@adelton
Copy link
Contributor Author

adelton commented Jan 11, 2025

In #3582 folks suggest that LuCI should parse the URL for the [FIELD]s to then determine what UI fields should be mandatory.

If we don't plan to do that (or do that right now) and we start to show the URL in the UI with this PR, could we make all the currently-mandatory fields optional? And basically make it the responsibility of the user to fill in the fields used in the URL, based on the hints in under the fields?

@systemcrash
Copy link
Contributor

I suppose this is a start at being helpful, but it does have exceptions. Some providers have old info that mandates a username+password, but providing a token (i.e. password field) only, works fine. The providers template URLs drive which fields are mandated. Improvements in this area are welcome.

@adelton
Copy link
Contributor Author

adelton commented Jan 13, 2025

Would you prefer this PR to also attempt to do those improvements, or would it make sense to accept the current work to expose the URL, and to subsequent work in a separate PR?

@systemcrash
Copy link
Contributor

We're close to 24 release, so minimal (atomic) changes are the easiest to test and review. But this can be kept minimal if done right (mandating fields based on those in the URL). The field presence in the provider URL is fairly easy to detect. It might require an exhaustive review of providers and their URLs (which are all in another repo anyway). This PR as-is satisfies the issue already, no?

@adelton
Copy link
Contributor Author

adelton commented Jan 13, 2025

If we are talking about the #2436, I believe this PR as-is should significantly alleviate hardship people might experience attempting to fill the form to match the expectations, by showing where each of the values will land.

@@ -674,6 +680,11 @@ return view.extend({
};
}

if (Boolean(s.url)) {
o = s.taboption('basic', form.DummyValue, '_url', _("Update URL"));
o.default = s.url;
Copy link
Contributor

Choose a reason for hiding this comment

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

I find that monospace makes the URL easier to parse:

					o.rawhtml = true;
					o.default = '<div style="font-family: monospace;">' + s.url; + '</div>'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd have to properly escape that s.url as well.

If we want to show this in monospace, I'd much rather add support for .monospace to form.Value and form.DummyValue and configure it more cleanly that way, rather than hacking it with o.rawhtml. (A much bigger change, granted.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I had a thought that perhaps adding a whole .style element might be the way to go. But that's for another day.

The whole point of .rawhtml is so you don't have to escape. That you provide raw HTML.

https://openwrt.github.io/luci/jsapi/LuCI.form.DummyValue.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. And if we are to provide raw HTML, it has to be a valid, properly escaped HTML, doesn't it? And we cannot know that for the URL value.

So I added some .replaces; rebased on master.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we have escape functions scattered all over the place, so having some central function would be useful.

In this case, I think we should also handle at least ' and " also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those only have to be escaped in attributes.

@systemcrash systemcrash merged commit cb8f54a into openwrt:master Jan 22, 2025
5 checks passed
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.

2 participants