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

Version switch appears even though I only have one version #1613

Closed
dracos opened this issue Oct 8, 2024 · 6 comments · Fixed by readthedocs/readthedocs.org#11727
Closed
Assignees
Labels
Bug A bug Needed: replication Bug replication is required

Comments

@dracos
Copy link

dracos commented Oct 8, 2024

An empty switcher (I don't know if language or version) is now appearing on https://ukcovid19inquiry.dracos.co.uk/ even though I only have one version and one language:

image

The docs at https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html#confval-version_selector say "It only appears when there are more than 1 active version." and "It only appears when there is more than 1 active language."

I presumably can set version_selector and language_selector to False in the config, but the documentation made me think I did not have to do this. (I have already removed display_version as my builds started failing.)

@dracos dracos added Bug A bug Needed: replication Bug replication is required labels Oct 8, 2024
@humitos
Copy link
Member

humitos commented Oct 8, 2024

IIRC, we decided to always show the version selector, even if there was only one version to keep consistency when there were more than one and also to show the name of the current version, but I'm not 100% sure. If that's the case, we should update the documentation. @agjohnson what should be the correct behavior here?

So, it should be showing the current active version in your project, but I saw there may be an error in the API response because .versions.active == [], but .versions.current.active == true. Your project should have at least one active version, otherwise it shouldn't serve that version 🤔

$ curl -s 'https://ukcovid19inquiry.dracos.co.uk/_/addons/?client-version=0.18.0&api-version=1&project-slug=uk-covid19-inquiry-hearings&version-slug=latest' | jq '.versions'
{
  "active": [],
  "current": {
    "active": true,
    "aliases": [],
    "built": true,
    "downloads": {},
    "hidden": false,
    "id": 16390072,
    "identifier": "main",
    "privacy_level": "public",
    "ref": null,
    "slug": "latest",
    "type": "branch",
    "urls": {
      "dashboard": {
        "edit": "https://readthedocs.org/projects/uk-covid19-inquiry-hearings/version/latest/edit/"
      },
      "documentation": "https://ukcovid19inquiry.dracos.co.uk/",
      "vcs": "https://github.com/dracos/uk-covid19-inquiry/tree/main/"
    },
    "verbose_name": "latest"
  }
}

@agjohnson
Copy link
Collaborator

Yeah, I feel we'd always want the version there for consistency. If we do away with anything, it could just be a string without the dropdown icon, but I feel this text should always be there if the feature is enabled on the theme.

We should make sure the documentation communicates how to disable these dropdowns if the project doesn't want them.

@github-project-automation github-project-automation bot moved this to Planned in 📍Roadmap Oct 10, 2024
@humitos humitos self-assigned this Oct 10, 2024
humitos added a commit to readthedocs/readthedocs.org that referenced this issue Oct 30, 2024
We always return all the active versions no matter the versioning scheme of the
project. That's how `versions.active` is expected to work.

However, it seems the conditional was below where these versions are calculated.
I also updated the test case that checks for the active versions on single
versions projects.

Closes readthedocs/sphinx_rtd_theme#1613
@humitos
Copy link
Member

humitos commented Oct 30, 2024

I took a deeper look at this and I was able to find the bug in the API response. I opened a PR to fix this issue at readthedocs/readthedocs.org#11727 and it will be deployed next week.

With that change, your project should look like our own documentation:

Peek 2024-10-30 12-49

@humitos
Copy link
Member

humitos commented Oct 30, 2024

From this issue there are other extra tasks we can work on:

  • update the documentation to mention this selector will be always shown, instead of "It only appears when there are more than 1 active version."
  • decide what's the correct behavior when there is only one active version: show the dropdown or only a fixed/regular string
  • take into account Version not shown anymore for self-hosted documentations #1624 on these updates

humitos added a commit to readthedocs/readthedocs.org that referenced this issue Oct 31, 2024
* Addons: return all active versions on single version project

We always return all the active versions no matter the versioning scheme of the
project. That's how `versions.active` is expected to work.

However, it seems the conditional was below where these versions are calculated.
I also updated the test case that checks for the active versions on single
versions projects.

Closes readthedocs/sphinx_rtd_theme#1613

* Add special case for single version projects
@github-project-automation github-project-automation bot moved this from Needs review to Done in 📍Roadmap Oct 31, 2024
@humitos
Copy link
Member

humitos commented Oct 31, 2024

This is already fixed and it will be deployed in the next week.

@humitos
Copy link
Member

humitos commented Nov 5, 2024

The fix is deployed and it's working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Needed: replication Bug replication is required
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants