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 the group selector drop down #33442

Merged
merged 1 commit into from
Nov 23, 2018
Merged

Fix the group selector drop down #33442

merged 1 commit into from
Nov 23, 2018

Conversation

sharidas
Copy link
Contributor

@sharidas sharidas commented Nov 6, 2018

This change gets the group selector drop
down

Signed-off-by: Sujith H [email protected]

Description

Fix the group selector in the core. After moving the code to user_management app, the ajax request to get the groups available for the user did not worked. The reason for this is there is no controller in the core to address the request. This PR fixes the issue.

Related Issue

Motivation and Context

Fix the group selector in the core. After moving the code to user_management app the ajax request to get the groups available for user did not worked in the master branch of core. There was no route and controller to address the request. This PR tries to fix the issue by adding a new route and controller to core which accepts the request and provides the response back.

How Has This Been Tested?

  • Login as admin and create users group1, group2
  • Tick the exclude shares check box mentioned in the issue
  • Admin user can see admin, group1 and group2 listed.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

@sharidas sharidas self-assigned this Nov 6, 2018
@sharidas sharidas added this to the development milestone Nov 6, 2018
@sharidas
Copy link
Contributor Author

sharidas commented Nov 6, 2018

Current state of the PR:

  • Added MetaData.php from user_management to core
  • Created a new controller for the group selector request.
  • Update the unit tests

* @param int $sortGroups
* @return DataResponse
*/
public function index($pattern = '', $filterGroups = false, $sortGroups = MetaData::SORT_USERCOUNT) {
Copy link
Member

Choose a reason for hiding this comment

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

you need all parameters here?


use OCP\IUserSession;

class MetaData {
Copy link
Member

Choose a reason for hiding this comment

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

As explained I don't want to see this class in code

@sharidas
Copy link
Contributor Author

sharidas commented Nov 7, 2018

Current state of the PR:

  • Added separate controller for group selector
  • This PR has no dependency with user_management. Meaning, user_management remains untouched.
  • Added unit test for the change made.

@sharidas sharidas changed the title [WIP] Fix the group selector drop down Fix the group selector drop down Nov 7, 2018
@codecov
Copy link

codecov bot commented Nov 7, 2018

Codecov Report

Merging #33442 into master will increase coverage by 0.01%.
The diff coverage is 85%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #33442      +/-   ##
============================================
+ Coverage     64.22%   64.23%   +0.01%     
- Complexity    18269    18278       +9     
============================================
  Files          1193     1194       +1     
  Lines         69076    69116      +40     
  Branches       1277     1277              
============================================
+ Hits          44363    44397      +34     
- Misses        24341    24347       +6     
  Partials        372      372
Flag Coverage Δ Complexity Δ
#javascript 52.91% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.54% <85%> (+0.01%) 18278 <9> (+9) ⬆️
Impacted Files Coverage Δ Complexity Δ
settings/routes.php 100% <ø> (ø) 0 <0> (ø) ⬇️
settings/Application.php 55.27% <28.57%> (-1.22%) 34 <1> (+1)
settings/Controller/GroupsController.php 96.96% <96.96%> (ø) 8 <8> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6d3396...229f014. Read the comment docs.

settings/Controller/GroupsController.php Outdated Show resolved Hide resolved
settings/Controller/GroupsController.php Outdated Show resolved Hide resolved
settings/Controller/GroupsController.php Show resolved Hide resolved
settings/Controller/GroupsController.php Show resolved Hide resolved
settings/Controller/GroupsController.php Show resolved Hide resolved
@sharidas
Copy link
Contributor Author

@DeepDiver1975 kindly review my change. The updated PR includes:

  • Updated the message when the user is null
  • Added missing PHP Doc ( for both controller and the test )
  • Updated the get request with NoCSRFRequired annotation. Grepped through the source code, and figured out that the GET requests are using the same. Hence adapting it.
  • Updated the code to use getDisplayName for the group name ( earlier getGID was used ).
  • Updated the code to return IGroup[] ( earlier it was array|IGroup[] )

@PVince81
Copy link
Contributor

@sharidas mind adding a summary at the top to explain why this PR fixes the issue ?

I see a lot of controller stuff being shuffled around but it's not clear why this helps fixing the issue.

@sharidas
Copy link
Contributor Author

@PVince81

@sharidas mind adding a summary at the top to explain why this PR fixes the issue ?

I see a lot of controller stuff being shuffled around but it's not clear why this helps fixing the issue.

I have updated the Description and Motivation and Context section of the PR. A breif summary has been added to know why this change is added.

@PVince81
Copy link
Contributor

@sharidas is this a brand new controller written from scratch or does it reuse some of the code that was moved to the user_management app ?

@sharidas
Copy link
Contributor Author

@sharidas is this a brand new controller written from scratch or does it reuse some of the code that was moved to the user_management app ?

@PVince81 Yes this is a new controller. It is inspired or lets say influenced from user_management's https://github.com/owncloud/user_management/blob/master/lib/Controller/GroupsController.php. Here is the comment, which helped to create this PR owncloud-archive/user_management#96 (comment). Also I have tried to avoid code duplication while writing this controller. Hope this address your query.

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

See comment.
Looks ok otherwise.

settings/Controller/GroupsController.php Outdated Show resolved Hide resolved
@sharidas
Copy link
Contributor Author

Current state of the PR

Hence kindly request for review @PVince81

@sharidas
Copy link
Contributor Author

  • Updated the test with more than one user in a group.
    • Though there is a test which I updated in this version, I have tried to add another test. In the new test I have not used mocks. It directly alters the db.

@PVince81 I have updated the new version with the unit tests updated. I missed updating the test, in my previous version :(

@sharidas sharidas force-pushed the group-selector-fix branch 3 times, most recently from b34a17a to e811ad4 Compare November 19, 2018 07:23
@sharidas sharidas force-pushed the group-selector-fix branch 2 times, most recently from 42379f9 to bd9aa79 Compare November 20, 2018 15:16
Fix the group selector drop down

Signed-off-by: Sujith H <[email protected]>
@PVince81
Copy link
Contributor

@sharidas can you click "resolve conversation" on the review items that you solved ?

@sharidas
Copy link
Contributor Author

@sharidas can you click "resolve conversation" on the review items that you solved ?

I have clicked "resolve conversation" on the review items, that were solved with respect to the current state of the PR.

@DeepDiver1975 DeepDiver1975 merged commit 1111586 into master Nov 23, 2018
@DeepDiver1975 DeepDiver1975 deleted the group-selector-fix branch November 23, 2018 08:07
@phil-davis
Copy link
Contributor

Note: This PR would need to be backported to stable10 if we some-day release the user_management app as a separate app, along with a core 10.* release.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 2, 2020
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.

"Exclude groups from sharing" checkbox broken on master branch
4 participants