Skip to content

Conversation

emlun
Copy link
Member

@emlun emlun commented Sep 21, 2024

Purpose

Since #8757, the Syncthing GUI now has an unauthenticated state. One consequence of this is that $scope.versionBase() is not initialized while unauthenticated, which causes the docsURL function to truncate links to just https://docs.syncthing.net/, discarding the section path. This currently affects at least the "Help > Introduction" link reachable both while logged in and not. The issue is exacerbated in #9175 where we sometimes want to show additional contextual help links from the login page to particular sections of the docs.

I don't think it's any worse to try to preserve the section path even without an explicit version tag, than to fall back to just the host and lose all context the link was attempting to provide.

Testing

Screenshots

This is a GUI change, but affecting only URLs in the markup with no visual changes.

Drawbacks

If a docsURL call generates a versionless link to a docs page that doesn't exist on https://docs.syncthing.net - presumably because Syncthing is not the latest version and links to a deleted page? - then this will lead to GitHub's generic 404 page with no link to the Syncthing docs root. Before, any versionless link would also be a pathless link, leading to the Syncthing docs root instead of a 404 page.

In syncthing#9175 we will sometimes want to
show links to the documentation on the login page. These links currently get
truncated to just `https://docs.syncthing.net`, discarding the section path,
because the server version is not yet known while on the login page.

I don't think it's any worse to try to preserve the section path even without an
explicit version tag, than to fall back to just the host and lose all context
the link was attempting to provide.
@emlun emlun added the ui Issues related to the graphical user interface label Sep 21, 2024
@emlun emlun changed the title Don't require versionBase in docsURL gui: Don't require versionBase in docsURL Sep 21, 2024
@calmh
Copy link
Member

calmh commented Sep 21, 2024

I didn't look at the details yet, but gut feeling says Syncthing should be able to know what version it is even without being logged in...

@emlun
Copy link
Member Author

emlun commented Sep 21, 2024

The data is retrieved via an API call to /rest/system/version, which is not under the /rest/noauth/ prefix, and thus requires authentication if auth is configured...

...but on the other hand you're very much right that the information exists elsewhere! Looks like every successful HTTP response from the backend, authenticated or not, includes a X-Syncthing-Version header with the same value as the version attribute returned from /rest/system/version. 😄

I'll see what I can do with that.

@emlun
Copy link
Member Author

emlun commented Sep 21, 2024

Ok, as you can see in the commit log (I assume this is no problem since you'll squash it anyway?) I experimented with a couple of solutions for this but settled on making a (most likely already cached) simple GET request to / to fetch the header when not authenticated. Let me know if you prefer the $http interceptor solution, or something else entirely.

@emlun emlun requested a review from calmh September 21, 2024 21:05
@emlun emlun changed the title gui: Don't require versionBase in docsURL gui: Get version from header when not authenticated Sep 21, 2024
@calmh
Copy link
Member

calmh commented Sep 22, 2024

Looks good to me.

@calmh calmh changed the title gui: Get version from header when not authenticated fix(gui): get version from header when not authenticated Sep 22, 2024
@calmh calmh merged commit 8ff670c into syncthing:main Sep 22, 2024
22 checks passed
@emlun emlun deleted the docsurl-version branch September 22, 2024 08:14
@calmh calmh added this to the v1.28.0 milestone Sep 24, 2024
leoon-ding pushed a commit to leoon-ding/syncthing that referenced this pull request Mar 19, 2025
)

### Purpose

Since syncthing#8757, the Syncthing GUI now has an unauthenticated state. One
consequence of this is that `$scope.versionBase()` is not initialized
while unauthenticated, which causes the `docsURL` function to truncate
links to just `https://docs.syncthing.net`/, discarding the section
path. This currently affects at least the "Help > Introduction" link
reachable both while logged in and not. The issue is exacerbated in
syncthing#9175 where we sometimes want
to show additional contextual help links from the login page to
particular sections of the docs.

I don't think it's any worse to try to preserve the section path even
without an explicit version tag, than to fall back to just the host and
lose all context the link was attempting to provide.

### Testing

- On commit b1ed280 (before):
  - Open the GUI, set a username and log out.
- Open the "Help" drop-down. The "Introduction" item links to:
https://docs.syncthing.net/
  - Log in.
- Open the "Help" drop-down. The "Introduction" item links to:
https://docs.syncthing.net/v1.27.10/intro/gui
- On commit 44fef31 (after):
  - Open the GUI, set a username and log out.
- Open the "Help" drop-down. The "Introduction" item links to:
https://docs.syncthing.net/intro/gui
  - Log in.
- Open the "Help" drop-down. The "Introduction" item links to:
https://docs.syncthing.net/v1.27.10/intro/gui

### Screenshots

This is a GUI change, but affecting only URLs in the markup with no
visual changes.


### Drawbacks

If a `docsURL` call generates a versionless link to a docs page that
doesn't exist on https://docs.syncthing.net - presumably because
Syncthing is not the latest version and links to a deleted page? - then
this will lead to GitHub's generic 404 page with no link to the
Syncthing docs root. Before, any versionless link would also be a
pathless link, leading to the Syncthing docs root instead of a 404 page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui Issues related to the graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants