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

Fix/661/additional attributes #729

Merged
merged 12 commits into from Dec 18, 2023
Merged

Fix/661/additional attributes #729

merged 12 commits into from Dec 18, 2023

Conversation

nc-fkl
Copy link
Contributor

@nc-fkl nc-fkl commented Dec 7, 2023

  • Added multiple attributes
  • Aligned mapping
  • Aligned frontend layout a littlebit so that its more categorized
  • Setting newly added properties of account via IAccountManager instead of IUser

Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

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

Nice!
Unit and integration tests don't pass.
I'll make real life tests when they do.

$event = new AttributeMappedEvent(ProviderService::SETTING_MAPPING_UID, $idTokenPayload, $tokenUserId);
$this->eventDispatcher->dispatchTyped($event);

$backendUser = $this->userMapper->getOrCreate($providerId, $event->getValue());
$backendUser = $this->userMapper->getOrCreate($providerId, (string)$event->getValue());
Copy link
Member

Choose a reason for hiding this comment

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

Do you cast to get an empty string if the value is null? If so, it would require a comment and do it like:

Suggested change
$backendUser = $this->userMapper->getOrCreate($providerId, (string)$event->getValue());
$backendUser = $this->userMapper->getOrCreate($providerId, $event->getValue() ?? '');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actualy my ide marked it as error that's not casted, that was the only reason for that :) took your solution now

Comment on lines 218 to 223
// filter out empty values
$addressParts = array_filter($addressParts, function($value) {
return !empty($value);
});
// concatenate them back together into a string and remove unsused ', '
$address = preg_replace('/^, |, $/', '', str_replace(' ', ' ', implode(', ', $addressParts)));
Copy link
Member

Choose a reason for hiding this comment

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

I think if you have empty parts and you remove them, the result string will be in the wrong format. If the street is missing, then the postal code will be seen as the street. I think we need a fixed number of fields as they are identified by their position. No problem with empty ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good point, makes sense, so lets keep the "ugly" string when a value was not provided, will also be a good hint for the user/admin itself that a value isn't set correctly.

@nc-fkl nc-fkl requested a review from julien-nc December 7, 2023 17:11
Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

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

Check the unit tests output. They need to be adjusted with the new setting values.

Comment on lines +199 to +205
if ($mapping = $input->getOption('mapping-groups')) {
$this->providerService->setSetting($provider->getId(), ProviderService::SETTING_MAPPING_GROUPS, $mapping);
}
Copy link
Member

Choose a reason for hiding this comment

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

You forgot to add this option in the configure method. This will make the integration tests pass.

@nc-fkl nc-fkl force-pushed the fix/661/additional-attributes branch from d51d4b9 to fd0ef87 Compare December 11, 2023 09:09
@nc-fkl
Copy link
Contributor Author

nc-fkl commented Dec 11, 2023

I guess everything should be fixed and fine now, can you please review again @julien-nc ? Thx

Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

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

Nice, i tried with a few attributes, works like a charm.

It would be nice to hide all those setting fields and make them appear/disappear if user clicks on a "Extra attributes mapping" button.

Also, now there are conflicts with main. Nothing weird, the new options in the UpSert command are added on the same line. Let me know if you need help to solve the conflicts.

Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
…justed

Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
Signed-off-by: Florian Klinger <florian.klinger@nextcloud.com>
@nc-fkl nc-fkl force-pushed the fix/661/additional-attributes branch from c6191fb to 9ea902d Compare December 18, 2023 12:52
@nc-fkl
Copy link
Contributor Author

nc-fkl commented Dec 18, 2023

Nice, i tried with a few attributes, works like a charm.

It would be nice to hide all those setting fields and make them appear/disappear if user clicks on a "Extra attributes mapping" button.

Also, now there are conflicts with main. Nothing weird, the new options in the UpSert command are added on the same line. Let me know if you need help to solve the conflicts.

Rebased and added expandable/collapsable extra attributes. Would be nice if you can review again 🏓 , thank you @julien-nc :)

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

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

Woop woop

@julien-nc julien-nc merged commit 9a5e996 into main Dec 18, 2023
41 checks passed
@julien-nc julien-nc deleted the fix/661/additional-attributes branch December 18, 2023 13:11
@nc-fkl nc-fkl linked an issue Jan 3, 2024 that may be closed by this pull request
@julien-nc julien-nc mentioned this pull request Jan 29, 2024
Copy link

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add commandline argument to set mapping for groups
2 participants