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

Api Key settings frontend #2403

Merged
merged 16 commits into from
Mar 13, 2024
Merged

Api Key settings frontend #2403

merged 16 commits into from
Mar 13, 2024

Conversation

CDimonaco
Copy link
Member

@CDimonaco CDimonaco commented Mar 11, 2024

Description

This PR adds the Api Key settings frontend.
It includes the generation of new api key with custom expiration

New settings page

image

API Key settings modal

image

How was this tested?

Automated tests

@CDimonaco CDimonaco added enhancement New feature or request javascript Pull requests that update Javascript code labels Mar 11, 2024
@CDimonaco CDimonaco self-assigned this Mar 11, 2024
@CDimonaco CDimonaco changed the title Api Key setting frontend Api Key settings frontend Mar 11, 2024
@CDimonaco CDimonaco marked this pull request as ready for review March 11, 2024 17:32
@CDimonaco CDimonaco added the env Create an ephimeral environment for the pr branch label Mar 11, 2024
@CDimonaco CDimonaco force-pushed the api_settings_modal branch 2 times, most recently from 3f7d17b to 51e2c27 Compare March 11, 2024 20:52
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Hey @CDimonaco ,
Great job.
I have noted many comments, excluding by now the Input/Switch components.
Let me know what do you think

open={open}
onClose={onClose}
>
<div className="flex flex-col my-5">
Copy link
Contributor

Choose a reason for hiding this comment

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

Checking the modal in storybook, I would say that some margins don't follow the mock up.
Can you confirm this with @jagabomb ?
I'm fine, but I want Jurgen's approval there hehe

Copy link
Contributor

Choose a reason for hiding this comment

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

API Key Default State
Hi @CDimonaco, here is my feedback regarding the spacing, and number input for the default state:

  1. Reduce and standardise the spacing between the heading and between line of content (highlighted in red block with pixel height dimensions). Ideally they were 16px in the design.
  2. Remove the margin below the close button. There is already a spacing which is provided by the padding of the modal.
  3. Resolve this UI addition and subtraction indicator for the numeric field since there is a native component (Chrome) which creates a duplication of the same function.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the point 1 and 2, I will standardize the space, for the last point, this is a custom component from the same component library we use for other inputs, if we fallback to the native component, we should design all the style and create a custom component to match all the others input design.

Why this component is bad? We could of course fallback to the native component but we need to create a custom component which I think it's a big effort and out the scope of this pr.

I tested on multiple browser and I cannot reproduce the "dual" indicators on the number component, but again, if we need to write custom logic on top of the custom or native component it's not an easy task and out of the scope of this pr.

cc @dottorblaster maybe my difficulty estimation is wrong, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

@CDimonaco I agree, if the effort is too large for the numeric input to be improved then we can re-look at this in another PR. I just wanted to note the input behaviour since Alberto also raised it too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Point 1 and 2 are perfectly addressable in this PR, when it comes to point 3 I didn't quite get your feedback @jagabomb, my advice is to merge and proceed incrementally to do this kind of work on the design system, which we couldn't foresee.

The alternative is to adopt a text input for the moment, but I would suggest otherwise since with a number input we can ensure nothing strange is submitted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Space standardized, you can check in storybook but this is the screenshot, there are also no more margin under the button, only the modal margins.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

@dottorblaster It is easier to see the issue with the duplicated numeric addition and subtraction (arrow up and arrow down) buttons below. But as I said before, I am happy to defer this to another PR and revisit it when we have time. 😊
Screenshot 2024-03-13 at 09 34 54

assets/js/pages/SettingsPage/SettingsPage.jsx Outdated Show resolved Hide resolved
assets/js/pages/SettingsPage/SettingsPage.jsx Outdated Show resolved Hide resolved
</span>
)}
{generatedApiKey && (
<div className="flex flex-col my-1 mb-4">
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this div could be subcomponent itself, as we use it (or should) the same content here in the modal and in the settings page.
What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, if Jurgen agrees that they should be different, so be it

Copy link
Contributor

Choose a reason for hiding this comment

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

If it helps us have consistency in the layout and implementation then I am happy for it to be a subcomponent.

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's a subcomponent, we will have the same copy button?

@CDimonaco CDimonaco force-pushed the api_settings_modal branch from 8297237 to 718fc0b Compare March 12, 2024 10:53
@CDimonaco CDimonaco force-pushed the api_settings_modal branch from d1d558e to 1f0e400 Compare March 12, 2024 11:22
@CDimonaco CDimonaco requested a review from abravosuse March 12, 2024 13:06
@CDimonaco
Copy link
Member Author

PR ENV
https://2403.prenv.trento.suse.com

Copy link
Contributor

@abravosuse abravosuse left a comment

Choose a reason for hiding this comment

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

Beautiful, Carmine!

Just two questions/remarks:

  1. In the number field in the API Key Settings modal, when you write a number you have two sets of icons to increase/decrease the number. Shouldn't there be only one set, the one of the field itself?
image
  1. Every time you enter the API Key Settings modal, the previous settings are cleared out. This is more a question for @jagabomb . Wouldn't it be better that the last set of settings is displayed instead? For instance, if the user turned on the the non expiration toggle, then, when you open the API Key Settings modal, it is still turned on. Or if the user set 1 year as expiration date then, when you open the modal, it is set to 1 year. Just wondering. The way it works now is also fine.

@CDimonaco
Copy link
Member Author

Beautiful, Carmine!

Just two questions/remarks:

1. In the number field in the API Key Settings modal, when you write a number you have two sets of icons to increase/decrease the number. Shouldn't there be only one set, the one of the field itself?
image
2. Every time you enter the API Key Settings modal, the previous settings are cleared out. This is more a question for @jagabomb . Wouldn't it be better that the last set of settings is displayed instead? For instance, if the user turned on the the non expiration toggle, then, when you open the API Key Settings modal, it is still turned on. Or if the user set 1 year as expiration date then, when you open the modal, it is set to 1 year. Just wondering. The way it works now is also fine.

For the first question is a browser compatibility issues, I tested on some different browser and I did not find the issue, the library we are using is one of the best but these glitch could appear

For the second question, is technically feasible to do, but it's not easy because we should have compatibility with the previous key it's almost impossible to come back to the form with the expiration set, for example we know the date of the expiration but we don't know if you did 1 month or 30 days for example, I think it's better to leave the modal as is, resettinng it's state when the user close the modal

This keep consistency and usability imho

@abravosuse
Copy link
Contributor

For the first question is a browser compatibility issues, I tested on some different browser and I did not find the issue, the library we are using is one of the best but these glitch could appear

OK. But, for the record, I'm not using anything out of ordinary (Chrome Version 122.0.6261.112).

For the second question, is technically feasible to do, but it's not easy because we should have compatibility with the previous key it's almost impossible to come back to the form with the expiration set, for example we know the date of the expiration but we don't know if you did 1 month or 30 days for example, I think it's better to leave the modal as is, resettinng it's state when the user close the modal

This keep consistency and usability imho

OK. I thought the data in the data entered in the modal was persistent. If it adds complexity to the implementation, then forget about it.

@CDimonaco
Copy link
Member Author

For the first question is a browser compatibility issues, I tested on some different browser and I did not find the issue, the library we are using is one of the best but these glitch could appear

OK. But, for the record, I'm not using anything out of ordinary (Chrome Version 122.0.6261.112).

For the second question, is technically feasible to do, but it's not easy because we should have compatibility with the previous key it's almost impossible to come back to the form with the expiration set, for example we know the date of the expiration but we don't know if you did 1 month or 30 days for example, I think it's better to leave the modal as is, resettinng it's state when the user close the modal
This keep consistency and usability imho

OK. I thought the data in the data entered in the modal was persistent. If it adds complexity to the implementation, then forget about it.

The modal data is "persistent" across page reloads, but in the end the modal will generate an expiration timestamp.

We could remove the modal "reset" so the user can see the previous settings if they open and close the modal in the same page, but I think it's not really useful and can lead to some confusion about the usage

@CDimonaco CDimonaco requested a review from jagabomb March 12, 2024 14:36
@jagabomb
Copy link
Contributor

2. Every time you enter the API Key Settings modal, the previous settings are cleared out. This is more a question for @jagabomb . Wouldn't it be better that the last set of settings is displayed instead? For instance, if the user turned on the the non expiration toggle, then, when you open the API Key Settings modal, it is still turned on. Or if the user set 1 year as expiration date then, when you open the modal, it is set to 1 year. Just wondering. The way it works now is also fine.

I agree with you here @abravosuse, although I think this Storybook version doesn't really need to showcase the logic like that. I would say that behaviour should be in the AC so that we implement the logic in the product. Unless the team feels there is value to implement logic like that in the Storybook too?

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Excellent work @CDimonaco
Codewise, ready to merge from my side (with some small nitpicks XD)

@jagabomb
Copy link
Contributor

API Key Generated State

  1. I wonder if we should make this sentence case instead of title case, "Key will expires 12 Mar 2024"? What are you thoughts @abravosuse?
  2. Can we have a hover state for the "Copy to Clipboard" button and after you click it show a tooltip that says "Copied to clipboard". I have included button states for reference.

@CDimonaco CDimonaco force-pushed the api_settings_modal branch from 001d36f to 1e3f251 Compare March 13, 2024 09:44
Copy link
Member

@EMaksy EMaksy left a comment

Choose a reason for hiding this comment

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

Hey man great work, what a big beautiful pr.
I wrote some comments and questions, but the code looks great.
For me LGTM!

@CDimonaco
Copy link
Member Author

Merging as is

Creating 2 tech debts, one for the copy button, the other one for the numeric input.

@CDimonaco CDimonaco merged commit f1beb76 into main Mar 13, 2024
24 checks passed
@CDimonaco CDimonaco deleted the api_settings_modal branch March 13, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request env Create an ephimeral environment for the pr branch javascript Pull requests that update Javascript code
Development

Successfully merging this pull request may close these issues.

6 participants