-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI: updates info table row jsdoc #20697
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is so much better! 💖 thanks for updating it to use format-duration
@@ -6,23 +6,17 @@ | |||
import { helper } from '@ember/component/helper'; | |||
import { formatDuration, intervalToDuration } from 'date-fns'; | |||
|
|||
export function duration([time], { nullable = false }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullable = false was only used by transit, which is removed now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes the API returns Duration strings (like 10m
) and sometimes it turns a number, which is the duration value in seconds. I think if we want to update the TTL values to the full unit we should do it consistently for durations like 10m
as well.
In the TTL picker component we use the library @icholy/duration
to parse the given duration if it exists. This might be a good moment to pull some of that parsing into a util that can be shared between the display helper and the component for choosing the TTL
return Duration.parse(duration).seconds(); | ||
} catch (e) { | ||
// return false so parent can decide how to handle parsing error | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parent should probably check ===
some value rather than falsey (!returnedSeconds
) since the valid duration 0
would be falsey. So I would return null instead but that's just me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth between having null here and couldn't decide since they're both false. But that's a good point! Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
TTL duration values will now universally read with their expanded unit, instead of the letter abbreviation. For example,
30 seconds
instead of30s