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

Adds query param for version no #4270

Merged
merged 3 commits into from
Jun 23, 2020
Merged

Conversation

aszenz
Copy link
Contributor

@aszenz aszenz commented Jun 20, 2020

Fixes #4260

This adds support for using a query parameter to select the version no.

Note: If the provided version number in the query string cannot be found then the page is shown as blank since the axios get call returns a 404 and isn't being caught. If this is a concern then a proper 404 message can be shown something like No such version number found.

@calebcartwright
Copy link
Member

Note: If the version number is not present the page is shown as blank since the axios get call returns a 404 and isn't being caught

Just to clarify, are you saying that if the query parameter is not provided then the page is blank? If so we'd have to fix that, as that behavior would be highly undesirable (and confusing for users!)

@calebcartwright
Copy link
Member

Or do you mean if someone does something goofy like ?version=fake?

@aszenz
Copy link
Contributor Author

aszenz commented Jun 20, 2020

Note: If the version number is not present the page is shown as blank since the axios get call returns a 404 and isn't being caught

Just to clarify, are you saying that if the query parameter is not provided then the page is blank? If so we'd have to fix that, as that behavior would be highly undesirable (and confusing for users!)

No if the query parameter is blank / not provided then it will just select master as it did before.

Or do you mean if someone does something goofy like ?version=fake?

Yes simply a version number that doesn't exist, doesn't have to be goofy, someone could just make a mistake and write a non existent version number and see a blank screen

@aszenz
Copy link
Contributor Author

aszenz commented Jun 20, 2020

Note: If the version number is not present the page is shown as blank since the axios get call returns a 404 and isn't being caught

Just to clarify, are you saying that if the query parameter is not provided then the page is blank? If so we'd have to fix that, as that behavior would be highly undesirable (and confusing for users!)

I updated the pr description to clarify my point

@calebcartwright
Copy link
Member

Thanks for the clarification! Could you update these changes to account for the invalid version scenario?

@aszenz
Copy link
Contributor Author

aszenz commented Jun 21, 2020

Thanks for the clarification! Could you update these changes to account for the invalid version scenario?

done, added a message in case the request for the configuration fails

docs/index.html Outdated Show resolved Hide resolved
Copy link
Contributor

@ayazhafiz ayazhafiz left a comment

Choose a reason for hiding this comment

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

This won't update the query param in the url when the version changes because of a dropdown selection. It may be nice to have this (maybe in another fix).

if (version.startsWith('v')) return version;
return `v${version}`;
};
const versionNumber = null !== versionParam ? parseVersionParam(versionParam) : 'master';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe checking for falsyness (!versionParam) is better, in case the param looks like ?version=

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, semantically the user has provided a version number, an empty string in this case. so the current way clearly separates version not provided case from provided but invalid case.
If its still necessary will use falsy then

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah but I think it's fair to assume the user didn't intend to specify a particular version since no valid version will be an empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, an empty string may not be a valid version but what about ?version=0.0 or ?version=0n.
do we also interpret them as having no intention to specify a version.

Copy link
Member

Choose a reason for hiding this comment

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

IIRC URLSearchParams will return strictly null in the absence of the query param, so I don't want to bikeshed too much on this one.

If anyone's interested in trying to handle the empty string version case then I'd suggest that be done in a follow up

@aszenz
Copy link
Contributor Author

aszenz commented Jun 22, 2020

This won't update the query param in the url when the version changes because of a drop down selection. It may be nice to have this (maybe in another fix).

Yes good observation, we would need to bind the selected option with the query parameter.

@calebcartwright
Copy link
Member

This won't update the query param in the url when the version changes because of a drop down selection. It may be nice to have this (maybe in another fix).

Yes good observation, we would need to bind the selected option with the query parameter.

Good spot! TBH this is another one I could probably live with deferring to a follow up PR, unless you'd be interested in implementing and would prefer to address that within this PR @aszenz?

aszenz added 3 commits June 24, 2020 01:10
This adds support for using a query parameter for selecting the version no
Catch request exception in case fetching the configuration from the url fails, this can happen either if non existent version number is passed in or because of server issues.
Covers a few common cases in which the version number can be specified.
@aszenz
Copy link
Contributor Author

aszenz commented Jun 23, 2020

Good spot! TBH this is another one I could probably live with deferring to a follow up PR, unless you'd be interested in implementing and would prefer to address that within this PR @aszenz?

Thanks, we have to now link both the search term and version no from the ui to the url, so would prefer to think about it in another pr.
Also rebased this branch on master, to remove conflicts

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

Thanks!

@calebcartwright calebcartwright merged commit 0c337c2 into rust-lang:master Jun 23, 2020
calebcartwright pushed a commit to calebcartwright/rustfmt that referenced this pull request May 18, 2021
* Adds query param for version no

This adds support for using a query parameter for selecting the version no

* Adds error handling to configuration request

Catch request exception in case fetching the configuration from the url fails, this can happen either if non existent version number is passed in or because of server issues.

* Makes version selection better

Covers a few common cases in which the version number can be specified.
calebcartwright pushed a commit that referenced this pull request May 18, 2021
* Adds query param for version no

This adds support for using a query parameter for selecting the version no

* Adds error handling to configuration request

Catch request exception in case fetching the configuration from the url fails, this can happen either if non existent version number is passed in or because of server issues.

* Makes version selection better

Covers a few common cases in which the version number can be specified.
ashvin021 pushed a commit to ashvin021/rustfmt that referenced this pull request Jul 27, 2021
* Adds query param for version no

This adds support for using a query parameter for selecting the version no

* Adds error handling to configuration request

Catch request exception in case fetching the configuration from the url fails, this can happen either if non existent version number is passed in or because of server issues.

* Makes version selection better

Covers a few common cases in which the version number can be specified.
calebcartwright pushed a commit to calebcartwright/rustfmt that referenced this pull request Aug 18, 2021
* Adds query param for version no

This adds support for using a query parameter for selecting the version no

* Adds error handling to configuration request

Catch request exception in case fetching the configuration from the url fails, this can happen either if non existent version number is passed in or because of server issues.

* Makes version selection better

Covers a few common cases in which the version number can be specified.
calebcartwright pushed a commit that referenced this pull request Aug 18, 2021
* Adds query param for version no

This adds support for using a query parameter for selecting the version no

* Adds error handling to configuration request

Catch request exception in case fetching the configuration from the url fails, this can happen either if non existent version number is passed in or because of server issues.

* Makes version selection better

Covers a few common cases in which the version number can be specified.
@karyon
Copy link
Contributor

karyon commented Oct 26, 2021

backported in #4958

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

Successfully merging this pull request may close these issues.

Support version-specific configuration documentation links.
4 participants