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

Full implement group display names #8255

Merged
merged 17 commits into from
Mar 15, 2018
Merged

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Feb 8, 2018

  • Personal settings show group id instead of display names in list
  • Activities use group id instead of display names
  • Select2 in the WorkflowEngine shows the id on load, dropdown and selecting new values works
  • Select2 in the OC.Settings.setupGroupsSelect shows the id on load, dropdown and selecting new values works
  • User management: user group and subadmin selection is messed up
  • Tests

Need someone with better JS/select2 skills to solve this.

Good patch for testing

diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php
index 6795f0e2f5..24e8a7ad00 100644
--- a/lib/private/Group/Group.php
+++ b/lib/private/Group/Group.php
@@ -87,9 +87,9 @@ class Group implements IGroup {
 
        public function getDisplayName() {
                if (is_null($this->displayName)) {
-                       return $this->gid;
+                       return 'DisplayName{' . $this->gid . '}';
                }
-               return $this->displayName;
+               return 'DisplayName{' . $this->displayName . '}';
        }
 
        /**

Fixes #742

@nickvergessen
Copy link
Member Author

@nextcloud/javascript who could help?

@MorrisJobke
Copy link
Member

@nextcloud/javascript who could help?

maybe @danxuliu or @skjnldsv

@skjnldsv skjnldsv self-assigned this Mar 2, 2018
@codecov
Copy link

codecov bot commented Mar 2, 2018

Codecov Report

Merging #8255 into master will decrease coverage by 16.87%.
The diff coverage is 4.91%.

@@              Coverage Diff              @@
##             master    #8255       +/-   ##
=============================================
- Coverage     51.87%   34.99%   -16.88%     
+ Complexity    25422    25376       -46     
=============================================
  Files          1609     1607        -2     
  Lines         95343    95159      -184     
  Branches       1378     1378               
=============================================
- Hits          49455    33297    -16158     
- Misses        45888    61862    +15974
Impacted Files Coverage Δ Complexity Δ
settings/templates/users/part.grouplist.php 0% <ø> (ø) 0 <0> (ø) ⬇️
apps/dav/lib/CalDAV/Activity/Provider/Base.php 0% <0%> (-76.79%) 19 <7> (+3)
apps/dav/lib/CalDAV/Activity/Provider/Calendar.php 0% <0%> (ø) 65 <1> (ø) ⬇️
settings/templates/users/main.php 0% <0%> (ø) 0 <0> (ø) ⬇️
lib/private/Group/MetaData.php 0% <0%> (-77.03%) 19 <0> (ø)
apps/dav/lib/CalDAV/Activity/Provider/Event.php 0% <0%> (ø) 25 <1> (ø) ⬇️
lib/private/SubAdmin.php 21.31% <0%> (-74.49%) 27 <1> (+1)
settings/Controller/GroupsController.php 10% <0%> (-54.62%) 9 <0> (ø)
lib/private/Settings/Personal/PersonalInfo.php 0% <0%> (ø) 30 <0> (ø) ⬇️
...ps/files_sharing/lib/Activity/Providers/Groups.php 0% <0%> (ø) 22 <5> (+5) ⬆️
... and 559 more

@skjnldsv
Copy link
Member

skjnldsv commented Mar 2, 2018

Select2 issue is a big one!
Basically, since we store only the value of the select (aka groupid) and considering the fact that we only retrieve the groups data onclick on the select, the default text can't be anything else than the group id.
One solution would be to create the select as html with all of its options and apply select2 directly on it. I didn't test it, but it should work

@skjnldsv
Copy link
Member

skjnldsv commented Mar 2, 2018

I'll change my view! I tried a different approach where I fetch the groups on page load only (no need to fetch them on each select2 click).
So I added on handlebar Views an ajax requests that get all the groups and cache them.
Then re-render the full select2. It works perfectly! :)

It quickly displays the id for a short moment, the time to requests the groups, then update itself with the proper displayName!

@skjnldsv skjnldsv force-pushed the bugfix/noid/group-display-name branch from a76d28e to 2be5980 Compare March 2, 2018 17:21
@skjnldsv
Copy link
Member

skjnldsv commented Mar 3, 2018

I could use a hand on tests fixing for the last tests please @nickvergessen :)

All tests fixed

@skjnldsv
Copy link
Member

skjnldsv commented Mar 5, 2018

Test passes, failure unrelated :)

Please review

@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Mar 5, 2018
@skjnldsv skjnldsv added the high label Mar 5, 2018
}).done(function(response) {
// add admin groups
$.each(response.data.adminGroups, function(id, group) {
self.groups.push({ id: group.id, displayname: group.name+'FIXME' });
Copy link
Member Author

Choose a reason for hiding this comment

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

Still broken

Copy link
Member Author

Choose a reason for hiding this comment

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

okay, here it works, just need to remove the FIXME

Copy link
Member

Choose a reason for hiding this comment

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

Ahaha oups! 🙈

});
// add groups
$.each(response.data.groups, function(id, group) {
self.groups.push({ id: group.id, displayname: group.name+'FIXME' });
Copy link
Member Author

Choose a reason for hiding this comment

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

Still broken

Copy link
Member Author

Choose a reason for hiding this comment

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

okay, here it works, just need to remove the FIXME

id: groupName,
displayname: groupName
id: groupId,
displayname: groupId + 'FIXME' // FIXME
Copy link
Member Author

Choose a reason for hiding this comment

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

Still broken (test with "exclude group from sharing")

Copy link
Member

Choose a reason for hiding this comment

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

In file access control or workflow?

Copy link
Member

Choose a reason for hiding this comment

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

AH okay, I see. I did not see it was there :)

Copy link
Member Author

Choose a reason for hiding this comment

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

in admin> sharing>

bildschirmfoto von 2018-03-05 13-07-20

@nickvergessen
Copy link
Member Author

nickvergessen commented Mar 5, 2018

  • Creating a new user and also adding them to a group (while creating the user) is broken, send data for groups is corrupted...
email |  
groups[ug-test][displayName] | DisplayName{ug-test}
password | 12346
username | test2e3e

Fixed with 3a9297e

),
Http::STATUS_CREATED
);
$group = $this->groupManager->createGroup($id);
Copy link
Member

Choose a reason for hiding this comment

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

there's not method to set the group name? not needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

No not needed atm

if (groupId && groups.length > 0) {
callback({
id: groupId,
displayname: groups.find(group =>group.id === groupId).displayname
Copy link
Member

Choose a reason for hiding this comment

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

Hum, this is ES6, I'm not sure IE11 supports it 🤔

Copy link
Member

Choose a reason for hiding this comment

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

We should not do this yet.

Copy link
Member

Choose a reason for hiding this comment

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

Fixed

@skjnldsv
Copy link
Member

skjnldsv commented Mar 5, 2018

  • search not working anymore

@oparoz oparoz removed the high label Mar 6, 2018
@rullzer
Copy link
Member

rullzer commented Mar 7, 2018

@skjnldsv #8255 (comment)

So I added on handlebar Views an ajax requests that get all the groups and cache them.

does this scale? Like even when you are on ldap and there are a few thousand groups?

@skjnldsv
Copy link
Member

skjnldsv commented Mar 7, 2018

@rullzer I have no idea! The request was made anyway, I just did it before loading the select2 instead of after initialising it :)

@skjnldsv
Copy link
Member

skjnldsv commented Mar 8, 2018

Failure related:

Scenario: Getting subadmin groups                               # /drone/src/github.com/nextcloud/server/build/integration/features/provisioning-v1.feature:252
  Given As an "admin"                                           # FeatureContext::asAn()
[Wed Mar  7 09:44:38 2018] 127.0.0.1:53098 [200]: /ocs/v2.php/cloud/users/brand-new-user
[Wed Mar  7 09:44:38 2018] 127.0.0.1:53108 [200]: /ocs/v2.php/cloud/users/brand-new-user
  And user "brand-new-user" exists                              # FeatureContext::assureUserExists()
[Wed Mar  7 09:44:38 2018] 127.0.0.1:53110 [200]: /ocs/v2.php/cloud/groups/new-group
[Wed Mar  7 09:44:38 2018] 127.0.0.1:53114 [200]: /ocs/v2.php/cloud/groups/new-group
  And group "new-group" exists                                  # FeatureContext::assureGroupExists()
[Wed Mar  7 09:44:38 2018] 127.0.0.1:53122 [200]: /ocs/v1.php/cloud/users/brand-new-user/subadmins
  When sending "GET" to "/cloud/users/brand-new-user/subadmins" # FeatureContext::sendingTo()
  Then subadmin groups returned are                             # FeatureContext::theSubadminGroupsShouldBe()
    | new-group |
    Failed asserting that two arrays are equal.
    --- Expected
    +++ Actual
    @@ @@
     Array (
    -    0 => 'new-group'
     )

EDIT: FIXED! 🚀

@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 3. to review Waiting for reviews 2. developing Work in progress labels Mar 8, 2018
nickvergessen and others added 17 commits March 8, 2018 17:13
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsv skjnldsv force-pushed the bugfix/noid/group-display-name branch from 4a2818b to 23a1553 Compare March 8, 2018 16:13
@skjnldsv
Copy link
Member

skjnldsv commented Mar 8, 2018

Failure unrelated: swift

@nickvergessen
Copy link
Member Author

Backported the user facing stuff in #8779

Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

External storages shows group id, i'm okay if this gets adjusted in a follow up PR though.

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

Lets do this and fix other occurences when we find them

@blizzz blizzz merged commit 208e38e into master Mar 15, 2018
@blizzz blizzz deleted the bugfix/noid/group-display-name branch March 15, 2018 11:07
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.

6 participants