Add date/time format setting in portal#16796
Conversation
Currently, the format used for rendering dates and times is derived from the language/locale selected by the user. The formats used in the en-US locale ("English" in Harbor's GUI) are ambiguous and hard to understand for many users.
For example, is 10/11/21 the 10th of November, 2021, the 11th of October, 2021, or even something else like the 21nd of November, 2010? Even if one does know how to interpret it in theory, such dates are essentially enciphered and must be mentally deciphered by the user every time, incurring unnecessary cognitive load.
Similarly, many users are used to the 24-hour clock rather than the 12-hour clock (AM/PM), and so on.
This PR adds a dropdown next to the existing language selector that lets the user choose between the default format for the current locale and the internationally standardized, unambiguous ISO 8601 format. For example, when viewing a list of resources, the ISO 8601 option makes points in time display as
> 2021-10-11, 13:37
instead of
> 10/11/21, 1:37 PM
thereby improving the user experience considerably for users not familiar with the US date/time format (or, in general, the default format for the locale they have selected).
The localized versions of the "Default" label are copied from `SCANNER.DEFAULT` in each locale.
Signed-off-by: Simon Alling <alling.simon@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #16796 +/- ##
==========================================
- Coverage 71.62% 67.20% -4.42%
==========================================
Files 736 966 +230
Lines 67491 80167 +12676
Branches 0 2550 +2550
==========================================
+ Hits 48342 53879 +5537
- Misses 15769 22616 +6847
- Partials 3380 3672 +292
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Technically, |
Signed-off-by: Simon Alling <alling.simon@gmail.com>
547265d to
457ec17
Compare
|
Why do I have to sign off commits I push to the PR branch after the initial one? The PR should be squash-merged anyway. |
|
@SimonAlling Please rebase your code to resolve conflicts and squash the two commits into one |
Every commit should be signed off. And one PR should only contain one commit |
Signed-off-by: Simon Alling <alling.simon@gmail.com>
2473e30 to
4193fa2
Compare
|
@SimonAlling Please run |
I have resolved the merge conflicts. 👍 I'd rather not rewrite the history of this PR branch though, unless there is a really good reason. Please see #16810.
Squash-merging can be used to create a single commit on the trunk without rewriting the history of the PR branch (details in #16810). Here is my suggested commit message body: Details |
|
@SimonAlling We had a discussion about your PR, we will merge this RP after your rebasing code and squashing commits into one |
Could you please share your conclusions and/or elaborate on why squash-merging doesn't suffice, either here or in #16810? My suggested commit message body can be copied from an earlier comment and, unlike rewriting the history of the PR branch, squash-merging guarantees a single, non-merge commit on the trunk. How are you guys planning on merging the PR anyway, if not by squash-merging? In my opinion, rebasing and force-pushing PR branches left and right goes completely against the spirit of Git, nullifies many of the benefits of using Git and cannot be justified without good reason (e.g. signing off retroactively). I'd be happy to learn about other ways to see things though! |
|
@SimonAlling In my opinion, the In actual development, in order to achieve a certain goal, we may decompose it into many steps, and each step may be a commit, but this does not mean that every commit is what we care about. So we use the |
|
@AllForNothing, it seems like we have the exact same opinion and goal – great! 😃 The easiest and best way to accomplish that goal is to select Squash and merge and then paste my suggested commit message body from earlier in the thread (or edit GitHub's generated body manually). That will create a single, non-merge commit on the trunk, just like if I would squash and rebase this branch and it would then be rebase-merged. However, squash-merging has these advantages:
Unfortunately, GitHub generates a cluttered commit message body by default, so care must be taken when performing the merge. (This is already the case today: maintainers apparently often accidentally merge PRs as merge commits.) (I think this discussion belongs in #16810, but it hasn't seen too much activity.) |
|
@SimonAlling Can you resolve the conflicts, then I will use Squash and merge option to merge this PR |
|
@AllForNothing, cool! I have resolved the conflicts and auto-formatted the code. I noticed when I ran the test suite that hundreds of these warnings are spammed in the output: So I assume the test suite should be tweaked in some way so that there is a valid saved value when running tests. |
|
Will raise a subsequent PR to clear the warnings |
|
Cool! As a piece of advice for future PRs, note that extra care needs to be taken when squash-merging, because GitHub's suggested message surprisingly and annoyingly consists of the messages of all commits on the PR branch (e.g. |
Update it because goharbor#16796 modifies head_admin_xpath. Signed-off-by: Yang Jiao <jiaoya@vmware.com>
Update it because goharbor#16796 modifies head_admin_xpath. Signed-off-by: Yang Jiao <jiaoya@vmware.com>
Update it because goharbor#16796 modifies head_admin_xpath. Signed-off-by: Yang Jiao <jiaoya@vmware.com>
Update it because goharbor#16796 modifies head_admin_xpath. Signed-off-by: Yang Jiao <jiaoya@vmware.com>
Update it because goharbor#16796 modifies header user. Signed-off-by: Yang Jiao <jiaoya@vmware.com>
* Add date/time format setting in portal
Currently, the format used for rendering dates and times is derived from the language/locale selected by the user. The formats used in the en-US locale ("English" in Harbor's GUI) are ambiguous and hard to understand for many users.
For example, is 10/11/21 the 10th of November, 2021, the 11th of October, 2021, or even something else like the 21nd of November, 2010? Even if one does know how to interpret it in theory, such dates are essentially enciphered and must be mentally deciphered by the user every time, incurring unnecessary cognitive load.
Similarly, many users are used to the 24-hour clock rather than the 12-hour clock (AM/PM), and so on.
This PR adds a dropdown next to the existing language selector that lets the user choose between the default format for the current locale and the internationally standardized, unambiguous ISO 8601 format. For example, when viewing a list of resources, the ISO 8601 option makes points in time display as
> 2021-10-11, 13:37
instead of
> 10/11/21, 1:37 PM
thereby improving the user experience considerably for users not familiar with the US date/time format (or, in general, the default format for the locale they have selected).
The localized versions of the "Default" label are copied from `SCANNER.DEFAULT` in each locale.
Signed-off-by: Simon Alling <alling.simon@gmail.com>
* Fix indentation
Signed-off-by: Simon Alling <alling.simon@gmail.com>
* Remove redundant localStorage existence check
Signed-off-by: Simon Alling <alling.simon@gmail.com>
* Run 'npm run lint -- --fix'
Update it because goharbor#16796 modifies header user. Signed-off-by: Yang Jiao <jiaoya@vmware.com>


Currently, the format used for rendering dates and times is derived from the language/locale selected by the user. The formats used in the en-US locale ("English" in Harbor's GUI) are ambiguous and hard to understand for many users.
For example, is 10/11/21 the 10th of November, 2021, the 11th of October, 2021, or even something else like the 21nd of November, 2010? Even if one does know how to interpret it in theory, such dates are essentially enciphered and must be mentally deciphered by the user every time, incurring unnecessary cognitive load.
Similarly, many users are used to the 24-hour clock rather than the 12-hour clock (AM/PM), and so on.
This PR adds a dropdown next to the existing language selector that lets the user choose between the default format for the current locale and the internationally standardized, unambiguous ISO 8601 format. For example, when viewing a list of resources, the ISO 8601 option makes points in time display as
instead of
thereby improving the user experience considerably for users not familiar with the US date/time format (or, in general, the default format for the locale they have selected).
The localized versions of the "Default" label are copied from
SCANNER.DEFAULTin each locale.Fixes #16730.
Signed-off-by: Simon Alling alling.simon@gmail.com
💡 I recommend passing
--color-words='[Ll]ocale|import \{ D|formatTransformer|\);|.'togit difforgit showwhen reviewing this PR.Please indicate you've done the following: