Skip to content
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
12 changes: 6 additions & 6 deletions playwright/e2e/column-usergroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ test.describe('Test column ' + columnTitle, () => {
await page.locator('[data-cy="createRowSaveButton"]').waitFor({ state: 'visible' })
await page.locator('[data-cy="createRowSaveButton"]').click()

await expect(page.locator('[data-cy="ncTable"] table tr td .user-bubble__name').filter({ hasText: user.userId }).first()).toBeVisible()
await expect(page.locator('[data-cy="ncTable"] table tr td .user-bubble__name').filter({ hasText: nonLocalUser.userId }).first()).toBeVisible()
await expect(page.locator('[data-cy="ncTable"] table tr td .usergroup-entry').filter({ hasText: user.userId }).first()).toBeVisible()
await expect(page.locator('[data-cy="ncTable"] table tr td .usergroup-entry').filter({ hasText: nonLocalUser.userId }).first()).toBeVisible()
})

test('Create column and rows without default values', async ({ userPage: { page }, request }) => {
Expand All @@ -51,7 +51,7 @@ test.describe('Test column ' + columnTitle, () => {
await page.locator('.vs__dropdown-menu li').filter({ hasText: nonLocalUser.userId }).first().click()
await page.locator('[data-cy="createRowSaveButton"]').click()

await expect(page.locator('[data-cy="ncTable"] table tr td .user-bubble__name').filter({ hasText: nonLocalUser.userId }).first()).toBeVisible()
await expect(page.locator('[data-cy="ncTable"] table tr td .usergroup-entry').filter({ hasText: nonLocalUser.userId }).first()).toBeVisible()
})

test('Create and edit rows', async ({ userPage: { page, user }, request }) => {
Expand All @@ -65,7 +65,7 @@ test.describe('Test column ' + columnTitle, () => {

await page.locator('button').filter({ hasText: 'Create row' }).click()
await page.locator('[data-cy="createRowSaveButton"]').click()
await expect(page.locator('[data-cy="ncTable"] table tr td .user-bubble__name').filter({ hasText: user.userId }).first()).toBeVisible()
await expect(page.locator('[data-cy="ncTable"] table tr td .usergroup-entry').filter({ hasText: user.userId }).first()).toBeVisible()

const firstRow = page.locator('[data-cy="ncTable"] [data-cy="customTableRow"]').first()
await openRowActionMenu(page, firstRow)
Expand All @@ -85,7 +85,7 @@ test.describe('Test column ' + columnTitle, () => {

await saveEditRow(page)

await expect(page.locator('[data-cy="ncTable"] table tr td .user-bubble__name', { hasText: user.userId })).toBeHidden()
await expect(page.locator('[data-cy="ncTable"] table tr td .user-bubble__name').filter({ hasText: nonLocalUser.userId }).first()).toBeVisible()
await expect(page.locator('[data-cy="ncTable"] table tr td .usergroup-entry', { hasText: user.userId })).toBeHidden()
await expect(page.locator('[data-cy="ncTable"] table tr td .usergroup-entry').filter({ hasText: nonLocalUser.userId }).first()).toBeVisible()
})
})
49 changes: 46 additions & 3 deletions src/shared/components/ncTable/partials/TableCellUsergroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
<div v-if="!isEditing" class="non-edit-mode" @click="handleStartEditing">
<div v-if="value" class="table-cell-usergroup">
<div v-for="item in value" :key="item.id" class="inline usergroup-entry">
<NcUserBubble :user="item.id" :avatar-image="getAvatarImage(item)" :is-no-user="!isUser(item)" :display-name="item.displayName ?? item.id" :show-user-status="isUser(item) && column.showUserStatus" :size="column.showUserStatus ? 34 : 20" :primary="isCurrentUser(item)" />
<span v-if="isUser(item)"
class="usergroup-user"
:class="{ 'usergroup-user--current': isCurrentUser(item) }"
@click="stopClickOnAvatarMenu">
<span class="usergroup-user__avatar">
<NcAvatar :user="item.id" :display-name="item.displayName ?? item.id" :size="column.showUserStatus ? 30 : 20" :hide-status="!column.showUserStatus" :disable-menu="isPublicShare" :disable-tooltip="true" />
</span>
{{ item.displayName ?? item.id }}
</span>
<NcUserBubble v-else :user="item.id" :avatar-image="getAvatarImage(item)" :is-no-user="true" :display-name="item.displayName ?? item.id" :size="column.showUserStatus ? 34 : 20" />
</div>
</div>
</div>
Expand Down Expand Up @@ -45,7 +54,8 @@

<script>
import { getCurrentUser } from '@nextcloud/auth'
import { NcUserBubble, NcSelect } from '@nextcloud/vue'
import { NcAvatar, NcSelect, NcUserBubble } from '@nextcloud/vue'
import { useDataStore } from '../../../../store/data.js'
import { USERGROUP_TYPE } from '../../../constants.ts'
import cellEditMixin from '../mixins/cellEditMixin.js'
import searchUserGroup from '../../../mixins/searchUserGroup.js'
Expand All @@ -58,8 +68,9 @@ export default {
name: 'TableCellUsergroup',

components: {
NcUserBubble,
NcAvatar,
NcSelect,
NcUserBubble,
},

mixins: [
Expand Down Expand Up @@ -97,6 +108,9 @@ export default {
isCurrentUser() {
return (item) => this.isUser(item) && item.id === currentUser?.uid
},
isPublicShare() {
return !!useDataStore().publicToken
},
isUser() {
return (item) => item.type === USERGROUP_TYPE.USER
},
Expand Down Expand Up @@ -133,6 +147,17 @@ export default {
event.stopPropagation()
},

/**
* Let a click on an avatar open its menu instead of starting to edit the cell
*
* @param {MouseEvent} event the click event
*/
stopClickOnAvatarMenu(event) {
if (event.target.closest('.avatardiv--with-menu')) {
event.stopPropagation()
}
},

getAvatarImage(item) {
if (item.type === USERGROUP_TYPE.GROUP) {
return 'icon-group'
Expand Down Expand Up @@ -217,6 +242,24 @@ export default {
padding-inline-end: 10px;
}

.usergroup-user {
display: inline-flex;
align-items: center;
gap: var(--default-grid-baseline);
padding: 2px 8px 2px 2px;
border-radius: var(--border-radius-pill);
background-color: var(--color-background-dark);

&--current {
background-color: var(--color-primary-element);
color: var(--color-primary-element-text);
}
Comment on lines +253 to +256

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The old bubble marked the current user with primary. It would be nice to keep that

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.


&__avatar {
display: flex;
}
}

.edit-mode {
padding: 10px 0;

Expand Down
2 changes: 1 addition & 1 deletion src/shared/mixins/searchUserGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
maxAutocompleteResults: 20,
suggestions: [],
recommendations: [],
currentUserId: getCurrentUser().uid,
currentUserId: getCurrentUser()?.uid ?? null,
}
},
computed: {
Expand Down