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 support for teams in usergroup column #1326

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/ToDo list.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"title":"ToDo list","emoji":"\u2705","columns":[{"id":491,"tableId":132,"title":"Task","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"line","mandatory":true,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":492,"tableId":132,"title":"Description","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"Title or short description","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":493,"tableId":132,"title":"Target","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"Date, time or whatever","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":494,"tableId":132,"title":"Progress","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"number","subtype":"progress","mandatory":false,"description":"","numberDefault":0,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":495,"tableId":132,"title":"Comments","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":496,"tableId":132,"title":"Proofed","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"selection","subtype":"check","mandatory":false,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false}],"views":[],"description":"","tablesVersion":"0.8.0-beta.2"}
{"title":"ToDo list","emoji":"\u2705","columns":[{"id":491,"tableId":132,"title":"Task","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"line","mandatory":true,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"usergroupSelectTeams":false,"showUserStatus":false},{"id":492,"tableId":132,"title":"Description","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"Title or short description","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"usergroupSelectTeams":false,"showUserStatus":false},{"id":493,"tableId":132,"title":"Target","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"Date, time or whatever","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"usergroupSelectTeams":false,"showUserStatus":false},{"id":494,"tableId":132,"title":"Progress","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"number","subtype":"progress","mandatory":false,"description":"","numberDefault":0,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"usergroupSelectTeams":false,"showUserStatus":false},{"id":495,"tableId":132,"title":"Comments","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"usergroupSelectTeams":false,"showUserStatus":false},{"id":496,"tableId":132,"title":"Proofed","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"selection","subtype":"check","mandatory":false,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"usergroupSelectTeams":false, "showUserStatus":false}],"views":[],"description":"","tablesVersion":"0.8.0-beta.2"}
6 changes: 3 additions & 3 deletions cypress/e2e/column-usergroup.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Test column ' + columnTitle, () => {
it('Create column and rows with default values', () => {
cy.createTable(tableTitle)
cy.loadTable(tableTitle)
cy.createUsergroupColumn(columnTitle, true, true, true, [localUser.userId, nonLocalUser.userId], true)
cy.createUsergroupColumn(columnTitle, true, true, true, true, [localUser.userId, nonLocalUser.userId], true)
cy.get('button').contains('Create row').click()
cy.get('[data-cy="createRowSaveButton"]').click()
cy.get('[data-cy="ncTable"] table tr td .user-bubble__name').contains(localUser.userId).should('be.visible')
Expand All @@ -41,7 +41,7 @@ describe('Test column ' + columnTitle, () => {
it('Create column and rows without default values', () => {
cy.createTable(tableTitle)
cy.loadTable(tableTitle)
cy.createUsergroupColumn(columnTitle, true, false, false, [], true)
cy.createUsergroupColumn(columnTitle, true, false, false, false, [], true)

cy.get('button').contains('Create row').click()
cy.get('[data-cy="usergroupRowSelect"] input').type(nonLocalUser.userId)
Expand All @@ -53,7 +53,7 @@ describe('Test column ' + columnTitle, () => {
it('Create and edit rows', () => {
cy.createTable(tableTitle)
cy.loadTable(tableTitle)
cy.createUsergroupColumn(columnTitle, true, true, true, [localUser.userId], true)
cy.createUsergroupColumn(columnTitle, true, true, true, true, [localUser.userId], true)
cy.get('button').contains('Create row').click()
cy.get('[data-cy="createRowSaveButton"]').click()
cy.get('[data-cy="ncTable"] table tr td .user-bubble__name').contains(localUser.userId).should('be.visible')
Expand Down
17 changes: 10 additions & 7 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Cypress.Commands.add('unifiedSearch', (term) => {
cy.get('.unified-search__results .unified-search__result-line-one span').contains(term, { matchCase: false }).should('exist')
})

Cypress.Commands.add('createUsergroupColumn', (title, selectUsers, selectGroups, hasMultipleValues, defaultValue, isFirstColumn) => {
Cypress.Commands.add('createUsergroupColumn', (title, selectUsers, selectGroups, selectTeams, hasMultipleValues, defaultValue, isFirstColumn) => {
cy.openCreateColumnModal(isFirstColumn)
cy.get('[data-cy="columnTypeFormInput"]').clear().type(title)
cy.get('.columnTypeSelection .vs__open-indicator').click({ force: true })
Expand All @@ -128,12 +128,15 @@ Cypress.Commands.add('createUsergroupColumn', (title, selectUsers, selectGroups,
cy.get('[data-cy="usergroupMultipleSwitch"] .checkbox-content').click({ force: true })
}

if (selectUsers && selectGroups) {
cy.get('[data-cy="userAndGroupSwitch"] .checkbox-content').click()
} else if (selectUsers) {
cy.get('[data-cy="userSwitch"] .checkbox-content').click()
} else if (selectGroups) {
cy.get('[data-cy="groupSwitch"] .checkbox-content').click()
if (selectGroups) {
cy.get('[data-cy="groupsSwitch"] input').click({ force: true })
}
if (selectTeams) {
cy.get('[data-cy="teamsSwitch"] input').click({ force: true })
}
// Users is always checked by default, and we can only disable it if some other option is already enabled
if (!selectUsers & (selectGroups || selectTeams)) {
cy.get('[data-cy="usersSwitch"] input').click({ force: true })
}

defaultValue.forEach((value) => {
Expand Down
9 changes: 9 additions & 0 deletions lib/Controller/Api1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ public function indexViewColumns(int $viewId): DataResponse {
* @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
* @param int[]|null $selectedViewIds View IDs where this column should be added to be presented
*
Expand Down Expand Up @@ -806,6 +807,7 @@ public function createColumn(
?bool $usergroupMultipleItems = null,
?bool $usergroupSelectUsers = null,
?bool $usergroupSelectGroups = null,
?bool $usergroupSelectTeams = null,
?bool $usergroupShowUserStatus = null,

?array $selectedViewIds = []
Expand Down Expand Up @@ -837,6 +839,7 @@ public function createColumn(
usergroupMultipleItems: $usergroupMultipleItems,
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $usergroupShowUserStatus
),
$selectedViewIds
Expand Down Expand Up @@ -880,6 +883,7 @@ public function createColumn(
* @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
Expand Down Expand Up @@ -916,6 +920,7 @@ public function updateColumn(
?bool $usergroupMultipleItems,
?bool $usergroupSelectUsers,
?bool $usergroupSelectGroups,
?bool $usergroupSelectTeams,
?bool $usergroupShowUserStatus,

): DataResponse {
Expand Down Expand Up @@ -945,6 +950,7 @@ public function updateColumn(
usergroupMultipleItems: $usergroupMultipleItems,
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $usergroupShowUserStatus
)
);
Expand Down Expand Up @@ -1472,6 +1478,7 @@ public function createTableShare(int $tableId, string $receiver, string $receive
* @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
* @param int[]|null $selectedViewIds View IDs where this column should be added to be presented
*
Expand Down Expand Up @@ -1513,6 +1520,7 @@ public function createTableColumn(
?bool $usergroupMultipleItems = null,
?bool $usergroupSelectUsers = null,
?bool $usergroupSelectGroups = null,
?bool $usergroupSelectTeams = null,
?bool $usergroupShowUserStatus = null,
?array $selectedViewIds = []
): DataResponse {
Expand Down Expand Up @@ -1543,6 +1551,7 @@ public function createTableColumn(
usergroupMultipleItems: $usergroupMultipleItems,
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $usergroupShowUserStatus
),
$selectedViewIds
Expand Down
4 changes: 3 additions & 1 deletion lib/Controller/ApiColumnsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
* @param boolean $usergroupMultipleItems Whether you can select multiple users or/and groups
* @param boolean $usergroupSelectUsers Whether you can select users
* @param boolean $usergroupSelectGroups Whether you can select groups
* @param boolean $usergroupSelectTeams Whether you can select teams
* @param boolean $showUserStatus Whether to show the user's status
* @param string|null $description Description
* @param int[]|null $selectedViewIds View IDs where this columns should be added
Expand All @@ -311,7 +312,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
*/
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
public function createUsergroupColumn(int $baseNodeId, string $title, ?string $usergroupDefault, bool $usergroupMultipleItems = null, bool $usergroupSelectUsers = null, bool $usergroupSelectGroups = null, bool $showUserStatus = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
public function createUsergroupColumn(int $baseNodeId, string $title, ?string $usergroupDefault, bool $usergroupMultipleItems = null, bool $usergroupSelectUsers = null, bool $usergroupSelectGroups = null, bool $usergroupSelectTeams = null, bool $showUserStatus = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
$column = $this->service->create(
Expand All @@ -327,6 +328,7 @@ public function createUsergroupColumn(int $baseNodeId, string $title, ?string $u
usergroupMultipleItems: $usergroupMultipleItems,
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $showUserStatus
),
$selectedViewIds
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/ApiTablesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function createFromScheme(string $title, string $emoji, string $descripti
usergroupMultipleItems: $column['usergroupMultipleItems'],
usergroupSelectUsers: $column['usergroupSelectUsers'],
usergroupSelectGroups: $column['usergroupSelectGroups'],
usergroupSelectTeams: $column['usergroupSelectTeams'],
showUserStatus: $column['showUserStatus'],
)
);
Expand Down
6 changes: 6 additions & 0 deletions lib/Controller/ColumnController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function create(
?bool $usergroupMultipleItems,
?bool $usergroupSelectUsers,
?bool $usergroupSelectGroups,
?bool $usergroupSelectTeams,
?bool $showUserStatus,

?array $selectedViewIds
Expand Down Expand Up @@ -129,6 +130,7 @@ public function create(
$usergroupMultipleItems,
$usergroupSelectUsers,
$usergroupSelectGroups,
$usergroupSelectTeams,
$showUserStatus,

$selectedViewIds) {
Expand Down Expand Up @@ -158,6 +160,7 @@ public function create(
usergroupMultipleItems: $usergroupMultipleItems,
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $showUserStatus
),
$selectedViewIds
Expand Down Expand Up @@ -195,6 +198,7 @@ public function update(
?bool $usergroupMultipleItems,
?bool $usergroupSelectUsers,
?bool $usergroupSelectGroups,
?bool $usergroupSelectTeams,
?bool $showUserStatus
): DataResponse {
return $this->handleError(function () use (
Expand Down Expand Up @@ -226,6 +230,7 @@ public function update(
$usergroupMultipleItems,
$usergroupSelectUsers,
$usergroupSelectGroups,
$usergroupSelectTeams,
$showUserStatus
) {
return $this->service->update(
Expand Down Expand Up @@ -254,6 +259,7 @@ public function update(
usergroupMultipleItems: $usergroupMultipleItems,
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $showUserStatus
)
);
Expand Down
Loading
Loading