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

Adding group display name support in group backends #26750

Merged
merged 3 commits into from
Dec 9, 2016

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented Nov 30, 2016

A step forward for #7918

TODOs

  • Adjust ShareesController to use the display name
    • requires adjusting the search methods to also return display names
    • adjust search to also search in display name
  • Unit tests

@jvillafanez @DeepDiver1975

@PVince81 PVince81 added this to the 9.2 milestone Nov 30, 2016
@mention-bot
Copy link

@PVince81, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @bartv2 and @macjohnny to be potential reviewers.

@PVince81 PVince81 changed the title Adding group display name support Adding group display name support in group backends Nov 30, 2016
@PVince81
Copy link
Contributor Author

Hmm, I'm surprised that it already works so far. That was easy.

However adjusting all other pieces of the UI to accomodate for the display name will be more work.

In this PR I'll focus mostly on backend support + share display name.

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 1, 2016

Now I see that there is actually another mechanism to add new actions, the implementsAction method.

Do we want to keep doing this ? If yes I'd get rid of IGroupBackend and simply add an action getGroup to the list. I personally would prefer if in the future we'd simply have several interfaces and action availability could be checked with instanceof.

  • clarify if we want to use implementsAction for getGroup instead of a new interface IGroupBackend

@jvillafanez
Copy link
Member

I guess that depends on the number of conditional actions, or how the UI would look like.

Taking the files as an example, each file might show a different set of actions: delete the file, rename the file, share the file... the UI would need to know what actions are available for the file before executing that action to show the corresponding button (if the delete action isn't supported, why would we need to show the button?)
Although this can be implemented by using interfaces, the number of interfaces that we'd need to implement is very high, so this doesn't seem a good approach in this case.

On the other hand, for this case we could have 2 types of group backends: read-only (such as LDAP) and read-write (the default one). If this is the case, using interfaces might be an option, but we MUST consider if all the possible backends would fit in any of those groups.
Notice that with this approach there won't be a backend that might implement only a small action set; it would be all or nothing.

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 3, 2016

Yeah, I know... Ok, I guess I'll just create a new action "has function to get group details (including display name" instead of a brand new interface.

The trouble with "implementsAction" is that there is no interface to enforce method signatures, and also no way to document these functions.

@jvillafanez
Copy link
Member

I wonder if a "command pattern" would fit here (for reference: https://en.wikipedia.org/wiki/Command_pattern). The conditional methods would return a Command object (according to the pattern, not a Symfony Command object) to be run by the manager, or null if it doesn't implement the method.

So, instead of "backend, run this method" would be "backend, I want to run this, get me the method to do so".

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 5, 2016

Hmm not sure, command pattern might sound like overkill. Command pattern is usually better for stuff like real actions, file actions, etc. But here most of the time it's not really an action, it's just reading data from the DB.

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 5, 2016

I guess it's probably better to not invent new ways right now and have half the code use the new way and the half use the old way. I'll use the old way here with "implementsAction".

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 5, 2016

Argh... now I ported everything to implementsAction and I find that it's not possible to mock the new method without having a real class or interface implementing it...

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 5, 2016

Fixed, added unit tests.

I think this is ready for review @jvillafanez @DeepDiver1975

if (!in_array($gid, $groupIds)) {
continue;
}
if (strtolower($gid) === strtolower($search) || strtolower($group->getDisplayName()) === strtolower($search)) {
Copy link
Member

Choose a reason for hiding this comment

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

convert $search to lowercase outside the 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.

when I touched this line I KNEW you would say that 😉

Copy link
Member

Choose a reason for hiding this comment

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

looks like you've changed it in another place but not here 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oaaargghhhhhhhhhhhhhhh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I was so lazy that I searched for strtolower and landed somewhere else... I'll fix all occurences then

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 5, 2016

@jvillafanez fixed now.

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 7, 2016

Fixed all the strtolower now, rebased and squashed for a clean history

@jvillafanez
Copy link
Member

👍

@PVince81 PVince81 merged commit 08da9a8 into master Dec 9, 2016
@PVince81 PVince81 deleted the group-displaynames branch December 9, 2016 14:44
@lock
Copy link

lock bot commented Aug 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants