Browse Source

fix: update collaborator state issue

pull/7342/head
Ramesh Mane 11 months ago
parent
commit
ee4a354551
  1. 2
      packages/nc-gui/components/project/AccessSettings.vue
  2. 19
      packages/nc-gui/composables/useUserSorts.ts

2
packages/nc-gui/components/project/AccessSettings.vue

@ -8,7 +8,7 @@ import {
parseStringDateTime, parseStringDateTime,
timeAgo, timeAgo,
} from 'nocodb-sdk' } from 'nocodb-sdk'
import type { WorkspaceUserRoles } from 'nocodb-sdk' import type { Roles, WorkspaceUserRoles } from 'nocodb-sdk'
import InfiniteLoading from 'v3-infinite-loading' import InfiniteLoading from 'v3-infinite-loading'
import { isEeUI, storeToRefs, useUserSorts } from '#imports' import { isEeUI, storeToRefs, useUserSorts } from '#imports'

19
packages/nc-gui/composables/useUserSorts.ts

@ -5,7 +5,9 @@ import { useGlobal } from '#imports'
/** /**
* Hook for managing user sorts and sort configurations. * Hook for managing user sorts and sort configurations.
* @returns An object containing reactive values and functions related to user sorts. *
* @param {string} roleType - The type of role for which user sorts are managed ('Workspace', 'Org', or 'Project').
* @returns {object} An object containing reactive values and functions related to user sorts.
*/ */
export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') { export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
const clone = rfdc() const clone = rfdc()
@ -107,10 +109,10 @@ export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
const superUserIndex = data.findIndex((user) => user?.roles?.includes('super')) const superUserIndex = data.findIndex((user) => user?.roles?.includes('super'))
const superUser = superUserIndex !== -1 ? data.splice(superUserIndex, 1) : null const superUser = superUserIndex !== -1 ? data.splice(superUserIndex, 1) : null
// console.log('super', superUser)
let sortedData = data.sort((a, b) => { let sortedData = data.sort((a, b) => {
switch (sortsConfig.field) { switch (sortsConfig.field) {
case 'roles': case 'roles': {
const roleA = a?.roles?.split(',')[0] const roleA = a?.roles?.split(',')[0]
const roleB = b?.roles?.split(',')[0] const roleB = b?.roles?.split(',')[0]
@ -119,23 +121,24 @@ export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
} else { } else {
return userRoleOrder.indexOf(roleB) - userRoleOrder.indexOf(roleA) return userRoleOrder.indexOf(roleB) - userRoleOrder.indexOf(roleA)
} }
}
case 'email': case 'email': {
if (sortsConfig.direction === 'asc') { if (sortsConfig.direction === 'asc') {
return a[sortsConfig.field]?.localeCompare(b[sortsConfig.field]) return a[sortsConfig.field]?.localeCompare(b[sortsConfig.field])
} else { } else {
return b[sortsConfig.field]?.localeCompare(a[sortsConfig.field]) return b[sortsConfig.field]?.localeCompare(a[sortsConfig.field])
} }
}
} }
return 0 return 0
}) })
if (superUser && superUser.length) { if (superUser && superUser.length) {
if (sortsConfig.direction === 'desc') { if (sortsConfig.direction === 'asc') {
sortedData = [...sortedData, superUser[0]]
} else {
sortedData = [superUser[0], ...sortedData] sortedData = [superUser[0], ...sortedData]
} else {
sortedData = [...sortedData, superUser[0]]
} }
} }

Loading…
Cancel
Save