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

Refactor ClientCreateContainer #22

Merged
merged 43 commits into from
Mar 24, 2023
Merged

Refactor ClientCreateContainer #22

merged 43 commits into from
Mar 24, 2023

Conversation

aringocode
Copy link
Collaborator

@aringocode aringocode commented Mar 8, 2023

Changes

  • Refactor ClientCreate component, replace inputs to new cards
  • Add new input authorize_uri and redirect_uri_validation_method
  • Add locales for new cards and input
  • Add grid styles for ClientCreate component
  • Move the rows in ClietnDetail container to new sections

image
image
image

clientCreate2.mp4

@aringocode aringocode self-assigned this Mar 8, 2023
@aringocode aringocode requested a review from Pe5h4 March 21, 2023 07:59
Copy link
Collaborator

@Pe5h4 Pe5h4 left a comment

Choose a reason for hiding this comment

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

I miss broader description of the implemented parts

try {
let response = await SeaCatAuthAPI.post(`/client`, body);
if (response.statusText != 'OK') {
throw new Error("Unable to create client");
}
setDisabled(false);
if (response.data?.client_id) {
Copy link
Collaborator

@Pe5h4 Pe5h4 Mar 22, 2023

Choose a reason for hiding this comment

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

@Aringoaway Is client_id always present in response of this call? If so, then this condition is redundant (and so as setting the disable to false on line 104). I suppose client_id will be always present in the successful response (please validate with @byewokko )

<Row>
<Col md={5} title="client_secret">{t("ClientDetailContainer|Client secret")}</Col>
<Col>
<code>{client?.client_secret}</code>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway <code> tag is very sensitive on undefined values, so please test and eventually do the fix, when value will be undefined. It can cause crash of the application

</Card>
</div>
</Form>
{(advmode && ((client != undefined) && (editClient == true))) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway Why it is possible to turn on adv mode only when you are in editing mode? Cant figure out your thinking here. Btw you are missing a lot of // Descriptions of the code. Its more difficult to find out what your code is doing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I only display this card when the user wants to edit the client. Therefore, this is the condition here. I do not show this card when the client is created.

advmode.mp4

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright, then please add a description

color="danger"
outline
size="sm"
disabled={(fields.length === 1) && ((fields[0].key === ""))}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway What are you checking with this condition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Pe5h4 This condition checks if the number of inputs is 1 and nothing has been added to the input, then the button will be disabled. If text is added to the input, the disabled button becomes a normal, or if will be added next input, the disabled button also becomes a normal.

customcomponent.mp4

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, add the description then please

@Pe5h4
Copy link
Collaborator

Pe5h4 commented Mar 22, 2023

@Aringoaway Can you please provide some actual printscreens / videos?

@aringocode
Copy link
Collaborator Author

@Pe5h4 I have added video to the MR description

@aringocode aringocode requested a review from Pe5h4 March 23, 2023 09:08
@aringocode
Copy link
Collaborator Author

@Pe5h4 can you review pls

Copy link
Contributor

@byewokko byewokko left a comment

Choose a reason for hiding this comment

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

the UI looks good to me. i only propose a few grammar and translation changes

Comment on lines 103 to 104
"Multidomain": "Multidoména",
"Access control": "Přístupová oprávnění",
Copy link
Contributor

Choose a reason for hiding this comment

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

"Multidomain support": "Podpora více domén",
"Access control": "Řízení přístupů",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@byewokko I got feedback from Alesh on the review and he said to use "Multidomain"

Copy link
Contributor

@byewokko byewokko Mar 23, 2023

Choose a reason for hiding this comment

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

ah okay ✨
i guess i understand his view, but still the czech word sounds super weird to me. i'll ask him when i get the chance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@byewokko I'm not sure about the Czech version

"Create client": "Vytvořit klienta",
"Unknown item": "Neznámá položka",
"Code challenge methods": "Metody ověření kódu",
"Code challenge method (PKCE)": "Metod ověření kódu (PKCE)",
Copy link
Contributor

Choose a reason for hiding this comment

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

"Metoda ověření kódu (PKCE)"

"Login URI": "URI přihlašovací stránky",
"Authorize URI": "Autorizace URI",
Copy link
Contributor

Choose a reason for hiding this comment

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

"Autorizační URI"

"Login URI": "URI přihlašovací stránky",
"Authorize URI": "Autorizace URI",
"Authorize anonymous users": "Autorizace anonymních uživatelů",
"URI can't be empty": "URI nemůže být prázdný",
Copy link
Contributor

Choose a reason for hiding this comment

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

"URI nemůže být prázdné"

"URI can't be empty": "URI nemůže být prázdný",
"URI have to start with https": "URI musí začínat https",
"URL hash have to be empty": "URL hash musí být prázdný"
Copy link
Contributor

Choose a reason for hiding this comment

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

"URL hash has to be empty"

@@ -280,143 +188,224 @@ const ClientCreateContainer = (props) => {
if (body?.login_uri == "") {
delete body.login_uri;
}
if (body?.authorize_uri == "") {
delete body?.authorize_uri;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway You are overusing the conditional operators. Here it should be just delete body.authorize_uri;

Please check if there is not any other in the "older" code and eventually update as well

reg={regRedirectUrisMain}
labelName={`${t("ClientCreateContainer|Redirect URIs")}*`}
/>
{metaData["properties"] && Object.entries(metaData["properties"]).map(([key, value]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway I think you can do that more effectively with find method

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Pe5h4 I don't quite understand how I can use the find method here. I need to return an input, but the find method won't do that

Copy link
Collaborator

@Pe5h4 Pe5h4 Mar 23, 2023

Choose a reason for hiding this comment

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

@Aringoaway Oh, I see, but I still dont understand, why you need to use iteration (it can be expensive), when trying to find one specific key and return its content

Can be the content of the redirect_uri_validation_method obtained as:

{metaData["properties"] && metaData["properties"]["redirect_uri_validation_method"] &&
<RadioInput
	key={key}
	name={key}
	register={register}
	valueList={metaData["properties"]["redirect_uri_validation_method"]["enum"]}
	disabled={disabled}
	labelName={t('ClientCreateContainer|Redirect URI validation method')}
	editing={(client != undefined)}
/>}

??

Or maybe its just my overthinking of it...

</div>
</CardHeader>
<CardBody>
{metaData["properties"] && Object.entries(metaData["properties"]).map(([key, value]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway find would be more effective here

<Col md={4} title="client_id">{t("ClientDetailContainer|Client ID")}</Col>
<Col><code>{client?.client_id}</code></Col>
<Col md={5} title="client_id">{t("ClientDetailContainer|Client ID")}</Col>
<Col><code>{(client?.client_id != undefined) && client?.client_id}</code></Col>
Copy link
Collaborator

@Pe5h4 Pe5h4 Mar 23, 2023

Choose a reason for hiding this comment

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

@Aringoaway Ok, this is not correct. the <code> will still be undefined when client_id wont be present.

This is bit better for example:

<code>{client?.client_id ? client.client_id : "N/A"}</code>

Or something similar, dont stick with N/A but rather check how you display cases when value is undefined or empty within clients to have it unified (I have seen "N/A" in your code, so that is why I added this value

<Row>
<Col md={5} title="client_secret">{t("ClientDetailContainer|Client secret")}</Col>
<Col>
<code>{(client?.client_secret != undefined) && client?.client_secret}</code>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway Not correct, see my comment above

{checkboxText}
</Label>
</FormGroup>

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway Remove redundant empty line here

</Button>
</FormGroup>
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Aringoaway Add empty line at the end of the file

reg={regRedirectUrisMain}
labelName={`${t("ClientCreateContainer|Redirect URIs")}*`}
/>
{metaData["properties"] && Object.entries(metaData["properties"]).map(([key, value]) => {
Copy link
Collaborator

@Pe5h4 Pe5h4 Mar 23, 2023

Choose a reason for hiding this comment

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

@Aringoaway Oh, I see, but I still dont understand, why you need to use iteration (it can be expensive), when trying to find one specific key and return its content

Can be the content of the redirect_uri_validation_method obtained as:

{metaData["properties"] && metaData["properties"]["redirect_uri_validation_method"] &&
<RadioInput
	key={key}
	name={key}
	register={register}
	valueList={metaData["properties"]["redirect_uri_validation_method"]["enum"]}
	disabled={disabled}
	labelName={t('ClientCreateContainer|Redirect URI validation method')}
	editing={(client != undefined)}
/>}

??

Or maybe its just my overthinking of it...

@aringocode aringocode requested a review from Pe5h4 March 24, 2023 07:37
Copy link
Collaborator

@Pe5h4 Pe5h4 left a comment

Choose a reason for hiding this comment

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

@Aringoaway Ok, it looks good. Was this

{metaData["properties"] && metaData["properties"]["redirect_uri_validation_method"] &&
tested also when metadata are {} or when metadata["properties"] are undefined? If so, then it can be merged

@aringocode
Copy link
Collaborator Author

@Pe5h4 Thanks for the tip, added one condition metaData != undefined

@aringocode aringocode marked this pull request as ready for review March 24, 2023 14:16
@aringocode aringocode merged commit e196c16 into main Mar 24, 2023
@aringocode aringocode deleted the refactor/update-clietns branch March 24, 2023 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants