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

feat: add backend for new user/group column #1090

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

enjeck
Copy link
Contributor

@enjeck enjeck commented May 13, 2024

Contributes to #586

This adds to the backend to support adding a new column that receives users or groups.

We expect the row values of this column to be array of objects with format {id: string, type: int}

Creating a column

Request

curl --silent \
    -X POST \
    -u admin:admin \
    -H "OCS-APIRequest: true" \
    -H "Content-Type: application/json" \
    -d '{ "baseNodeId": 1, "title": "New Column", "usergroupDefault": "[{\"id\": \"admin\", \"type\": 0}]" }' \
'http://nextcloud.local/ocs/v2.php/apps/tables/api/2/columns/usergroup?format=json' | jq

Result

{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 200,
      "message": "OK"
    },
    "data": {
      "id": 7,
      "tableId": 1,
      "title": "New Column",
      "createdBy": "admin",
      "createdByDisplayName": "admin",
      "createdAt": "2024-05-13 15:25:29",
      "lastEditBy": "admin",
      "lastEditByDisplayName": "admin",
      "lastEditAt": "2024-05-13 15:25:29",
      "type": "usergroup",
      "subtype": "",
      "mandatory": false,
      "description": "",
      "numberDefault": null,
      "numberMin": null,
      "numberMax": null,
      "numberDecimals": null,
      "numberPrefix": "",
      "numberSuffix": "",
      "textDefault": null,
      "textAllowedPattern": null,
      "textMaxLength": null,
      "selectionOptions": [],
      "selectionDefault": null,
      "datetimeDefault": null,
      "usergroupDefault": [
        {
          "id": "admin",
          "type": 0,
        }
      ],
      "usergroupMultipleItems": null,
      "usergroupSelectUsers": null,
      "usergroupSelectGroups": null,
      "showUserStatus": null
    }
  }
}

Copy link
Contributor

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!

@enjeck enjeck changed the base branch from main to consolidate-ncselect June 4, 2024 08:31
@enjeck enjeck self-assigned this Jun 4, 2024
@enjeck enjeck requested a review from juliushaertl June 4, 2024 09:33
@juliushaertl juliushaertl linked an issue Jun 6, 2024 that may be closed by this pull request
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.

First glance looks good, have not tested myself yet

  • Integration test can be extended around inserting, modifying and delete column values
  • a new migration class is needed to add the new columns on existing installations (existing steps are not executed again).

lib/Db/Column.php Outdated Show resolved Hide resolved
lib/Db/Column.php Outdated Show resolved Hide resolved
lib/Db/LegacyRowMapper.php Outdated Show resolved Hide resolved
lib/Db/Row2Mapper.php Outdated Show resolved Hide resolved
$rowValues[$compositeKey] = [$value];
}
} else {
$rowValues[$compositeKey] = $value;
Copy link
Member

Choose a reason for hiding this comment

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

Will it be easier to have just one common format, with the array as above? Or would it be somehow backwards-incompatible or require too many unrelated changes elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be nice to have one common format. But other column types aren't arrays and I think it would take many changes to make them as such.

lib/Db/Row2Mapper.php Outdated Show resolved Hide resolved
lib/Db/Row2Mapper.php Outdated Show resolved Hide resolved
lib/Db/Row2Mapper.php Outdated Show resolved Hide resolved
lib/Service/ColumnTypes/UsergroupBusiness.php Outdated Show resolved Hide resolved

class UsergroupColumnQB extends SuperColumnQB implements IColumnTypeQB {
public function passSearchValue(IQueryBuilder $qb, string $unformattedSearchValue, string $operator, string $searchValuePlaceHolder): void {
// TODO how to handle searching for multiple users/groups?
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 mean, if multiple users/groups are part of the search string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. But I guess we can consider this later on

@enjeck enjeck force-pushed the consolidate-ncselect branch 2 times, most recently from ef7e9f2 to 87e80be Compare June 20, 2024 06:59
Base automatically changed from consolidate-ncselect to main June 27, 2024 10:26
@enjeck enjeck marked this pull request as ready for review July 2, 2024 21:24
@enjeck enjeck force-pushed the new-usergroup-column branch 3 times, most recently from d07cbe5 to 5c276de Compare July 8, 2024 04:41
@enjeck enjeck changed the title feat: add new column for user and group to backend feat: add backend for new user/group column Jul 8, 2024
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
@enjeck
Copy link
Contributor Author

enjeck commented Jul 8, 2024

  • Integration test can be extended around inserting, modifying and delete column values

Not sure what this entails. Do we already have this for other column types? @blizzz

Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
@enjeck enjeck requested a review from blizzz July 12, 2024 11:02
@blizzz
Copy link
Member

blizzz commented Jul 12, 2024

  • Integration test can be extended around inserting, modifying and delete column values

Not sure what this entails. Do we already have this for other column types? @blizzz

I think you already covert inserting with a user.

Then there are some tests in Apiv1 on modification, e.g.

Scenario: Create, modify and delete rows

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.

Nitpick, otherwise the recent changes look good, have to test yet.

]);
}
return $schema;
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
}
return null;

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.

Column type user and groups
3 participants