Skip to content

feat(site): add annotation to display values of type clibase.Duration correctly #10667

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

Merged
merged 3 commits into from
Nov 15, 2023

Conversation

johnstcn
Copy link
Member

  • Adds an annotation format_duration_ns to all deployment values of type clibase.Duration
  • Adds a unit test that complains if you forget to add the above annotation to a clibase.Duration
  • Modifies optionValue() to check for the presence of format_duration_ns when displaying an option.

@johnstcn johnstcn self-assigned this Nov 14, 2023
@johnstcn johnstcn changed the title feat(site): correctly display values of type clibase.Duration feat(site): add annotation to display values of type clibase.Duration correctly Nov 14, 2023
@@ -37,14 +39,16 @@ describe("optionValue", () => {
...defaultOption,
name: "Session Duration",
value: 3600 * 1e9,
annotations: { format_duration_ns: "falsae" },
Copy link
Member Author

Choose a reason for hiding this comment

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

self-review: technically a typo but illustrates behaviour well

@johnstcn johnstcn marked this pull request as ready for review November 14, 2023 12:50
Value: &c.MaxTokenLifetime,
Group: &deploymentGroupNetworkingHTTP,
YAML: "maxTokenLifetime",
Default: ((100 * 365 * time.Hour * 24) + (25 * time.Hour * 24)).String(),
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this value currently does not display correctly (screenshot from dev.coder.com):

image

We can modify this in a separate PR but I would consider it out of scope here.

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

LGTM, but what is the story with _ns? Can't we use _ms or will it be breaking?

@johnstcn
Copy link
Member Author

LGTM, but what is the story with _ns? Can't we use _ms or will it be breaking?

It doesn't really matter what the annotation is called. I chose the _ns suffix because it accepts an integer value that is a number of nanoseconds.

@johnstcn
Copy link
Member Author

LGTM, but what is the story with _ns? Can't we use _ms or will it be breaking?

It doesn't really matter what the annotation is called. I chose the _ns suffix because it accepts an integer value that is a number of nanoseconds.

Updated to format_duration without the _ns suffix.

@johnstcn johnstcn merged commit 6085b92 into main Nov 15, 2023
@johnstcn johnstcn deleted the cj/ui-deployment-values-duration branch November 15, 2023 12:29
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants