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

User Profile translations - value put in correct field after search #28047

Merged
merged 6 commits into from Mar 21, 2024

Conversation

agagancarczyk
Copy link
Contributor

@agagancarczyk agagancarczyk commented Mar 19, 2024

Closes #27838 and closes #28103

@agagancarczyk agagancarczyk self-assigned this Mar 19, 2024
@agagancarczyk agagancarczyk requested a review from a team as a code owner March 19, 2024 11:52
@agagancarczyk agagancarczyk force-pushed the issue-27838 branch 2 times, most recently from c80da6e to c97e615 Compare March 20, 2024 16:01
Comment on lines 89 to 90
(attribute: UserProfileAttribute) =>
attribute.name === attributeToDelete,
Copy link
Contributor

Choose a reason for hiding this comment

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

This type is already inferrable, let's not add any additional type information if it's not needed.

Suggested change
(attribute: UserProfileAttribute) =>
attribute.name === attributeToDelete,
(attribute) => attribute.name === attributeToDelete,

)?.displayName;

const formattedTranslationsToDelete = translationsToDelete?.substring(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment here with some explanation as to why we need to slice this string like this?

Comment on lines 129 to 130
(attribute: UserProfileAttribute) =>
attribute.name !== attributeToDelete,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, type can be inferred.

Suggested change
(attribute: UserProfileAttribute) =>
attribute.name !== attributeToDelete,
(attribute) => attribute.name !== attributeToDelete,

@@ -116,11 +116,32 @@ export const AddTranslationsDialog = ({
}, [combinedLocales, translationKey, setValue]);

const handleOk = () => {
const formData = getValues();
onTranslationsAdded(formData);
const formData = getValues() as Translations;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this compiles the same without a type-cast, so let's remove it.

Suggested change
const formData = getValues() as Translations;
const formData = getValues();

whoAmI.getLocale(),
)}
{filteredLocales.map((locale) => {
const rowIndex = combinedLocales.findIndex(
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure rowIndex is always unique? It's being used as a key here, which can lead to issues if not unique in this loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @jonkoops I have added the index provided by the map(), and I'm using it as a fallback to ensure the uniqueness of the key.

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
@agagancarczyk agagancarczyk merged commit 1ca8d4f into keycloak:main Mar 21, 2024
52 checks passed
ahus1 pushed a commit to ahus1/keycloak that referenced this pull request Mar 22, 2024
…eycloak#28047)

* fixed the issue of adding translation for searched locale

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

* fixed the issue of adding translation for searched locale

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

* small fix

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

* renamed

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

* fixed translation deleting on attribute deletion

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

* feedback

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

---------

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants