-
Notifications
You must be signed in to change notification settings - Fork 74
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
THREESCALE-10245: access tokens expiration UI #3943
base: master
Are you sure you want to change the base?
Conversation
058be50
to
54db7d7
Compare
c9d2ba3
to
995530a
Compare
Great job @jlledom ! 🏆
Depending if it's US or not, the date can be interpreted differently. I think the following presentation as it shows on the different screen is better. Also, I think it would be nice to show the expiration date on the table listing all tokens... |
if (fieldDate) { | ||
value = fieldDate.toISOString().replace(msExp, 'Z') | ||
} else if (selectedItem.id === 5 ) { | ||
value = pickedDate.toISOString().replace(msExp, 'Z') | ||
} | ||
|
||
return value |
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.
Removed the suggestion, because noticed that it's not just "if-else", but "if - else if", and value can be empty at the return.
Maybe we can accept both formats on the backend by using DateTime.parse
? It seems to work both with milliseconds and no milliseconds.
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'll explore this possibility, it might work
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 couldn't do it. Basically I though on two approaches:
Both failed. 1 can't be done because the Patternfly react component doesn't accept ant time zone, it will always use the OS timezone.
Done 88badaf |
<span className="pf-c-form-control-expiration-hint">{fieldHint}</span> | ||
</FormGroup> | ||
<input id={id} name={id} type="hidden" value={dateValue} /> | ||
{selectedItem.id === 5 && ( |
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 don't love these synthetic ids on the options list. It's a bit hard to understand why this is checked for equality with 5
.
Some alternative ideas I had:
- use a string instead of the numeric ID for an easier interpretation, e.g.
{ id: '7', name: '7 days', period: 7 },
{ id: '30', name: '30 days', period: 30 },
{ id: 'custom', name: 'Custom...', period: 0 },
{ id: 'no-exp', name: 'No expiration', period: 0 }
or something like that.
Or even remove the id
, and reuse period
, and have for example period: 0
for "no expiration", and period: -1
for custom. This way there are less values that we need to care about.
I also suggest to use label
rather than name
, as it is used for the field label
in FormSelectOption
, so we'll have something like
<FormSelectOption
key={item.period}
label={item.label}
value={item.period}
/>
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.
use a string instead of the numeric ID for an easier interpretation, e.g.
Done fda4ff2
Or even remove the id, and reuse period, and have for example period: 0 for "no expiration", and period: -1 for custom. This way there are less values that we need to care about.
I didn't do this because I find this as confusing as the previous code.
I also suggest to use label rather than name, as it is used for the field label in FormSelectOption, so we'll have something like
Done 14b083d
)} | ||
{dateValue === '' && ( | ||
<> | ||
<br /> |
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 don't like this break here, but I couldn't find an easy way to add some top margin, so that's OK...
I was looking at https://pf4.patternfly.org/utilities/spacing/, and was hoping that adding className="pf-u-mt-md"
would help, but it didn't 😬 I think that probably the CSS containing this class is not being loaded... not sure, but I didn't investigate further.
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.
Also, now I think the parenthesis ()
are not needed, but well, not important.
For simplicity
Also we don't need to extend from `IRecord`
From #3951:
I didn't do this one because I think the current format is clear enough and it's formatted in client's time zone. Not sure if using UTC instead would make things clearer, as UTC time can belong to a different day to the client time zone.
I agree on these two, but I didn't applied them because they make tests much more difficult. Check pickDate on the test suite. |
Ooh, well, that's sad, because I think they are very useful, especially not being able to pick later dates - because it doesn't make sense. |
Hm, well, I think it's confusing... I don't know where the locale setting for I'd prefer at least |
I'd say it comes from the OS.
Which screens? maybe those screens take the locale from the provider settings. |
I correct myself, only the timezone can be configured for the provider, locale is always the same in porta for everybody. However, we don't use a single date format in all screens. I think I'm gonna implement one of your suggestions. |
Add a warning when the time zone differs from the provider's one
Jest complains about wrong syntax ¯\_(ツ)_/¯
@mayorova I updated the date format in the field hint. Also, since I don't think we can, or should, fix the time zone mismatch problem, I added a warning to clarify which time will the token expire at. The tooltip only appears when there's a timezone mismatch between the browser and the provider configuration. |
What this PR does / why we need it:
After we merged #3939 now we want to update the Access Tokens screens to add a new field for the expiration date. For this, I created a new React component based on what Github does:
Which issue(s) this PR fixes
THREESCALE-10245
Verification steps
Just set the an expiration date when creating a token and verify the data is correctly stored in DB and is properly shown in
#index
and#edit
screensScreenshots