Browse Source

fix: lint erros

feat/user-management-sort
Ramesh Mane 11 months ago
parent
commit
6020999f85
  1. 8
      packages/nc-gui/components/account/UserList.vue
  2. 2
      packages/nc-gui/components/account/UserMenu.vue
  3. 8
      packages/nc-gui/components/project/AccessSettings.vue
  4. 17
      packages/nc-gui/composables/useUserSorts.ts

8
packages/nc-gui/components/account/UserList.vue

@ -1,6 +1,7 @@
<script lang="ts" setup>
import { OrgUserRoles } from 'nocodb-sdk'
import type { OrgUserReqType, RequestParams, UserType } from 'nocodb-sdk'
import rfdc from 'rfdc'
import type { User } from '#imports'
import {
extractSdkResponseErrorMsg,
@ -12,7 +13,6 @@ import {
useNuxtApp,
useUserSorts,
} from '#imports'
import rfdc from 'rfdc'
const { api, isLoading } = useApi()
@ -95,7 +95,7 @@ const updateRole = async (userId: string, roles: string) => {
users.value = clone(users.value).map((user) => {
if (user.id === userId) {
user['roles'] = roles
user.roles = roles
}
return user
})
@ -210,13 +210,13 @@ const openDeleteModal = (user: UserType) => {
<span>
{{ $t('labels.email') }}
</span>
<LazyAccountUserMenu :direction="sortDirection['email']" field="email" :handle-user-sort="saveOrUpdate" />
<LazyAccountUserMenu :direction="sortDirection.email" field="email" :handle-user-sort="saveOrUpdate" />
</div>
<div class="py-3.5 text-gray-500 font-medium text-3.5 w-1/3 text-start flex items-center space-x-2" data-rec="true">
<span>
{{ $t('objects.role') }}
</span>
<LazyAccountUserMenu :direction="sortDirection['roles']" field="roles" :handle-user-sort="saveOrUpdate" />
<LazyAccountUserMenu :direction="sortDirection.roles" field="roles" :handle-user-sort="saveOrUpdate" />
</div>
<div class="flex py-3.5 text-gray-500 font-medium text-3.5 w-28 justify-end mr-4" data-rec="true">
{{ $t('labels.action') }}

2
packages/nc-gui/components/account/UserMenu.vue

@ -12,7 +12,7 @@ const isOpen = ref(false)
const sortUserBy = async (direction?: UsersSortType['direction']) => {
handleUserSort({
field: field,
field,
direction,
})
isOpen.value = false

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

@ -90,10 +90,6 @@ const loadListData = async ($state: any) => {
$state.loaded()
}
const updateCollaboratorLocalState = ()=>{
}
const updateCollaborator = async (collab: any, roles: ProjectRoles) => {
try {
if (
@ -200,14 +196,14 @@ onMounted(async () => {
<span>
{{ $t('objects.users') }}
</span>
<LazyAccountUserMenu :direction="sortDirection['email']" field="email" :handle-user-sort="saveOrUpdate" />
<LazyAccountUserMenu :direction="sortDirection.email" field="email" :handle-user-sort="saveOrUpdate" />
</div>
<div class="text-gray-700 date-joined-grid">{{ $t('title.dateJoined') }}</div>
<div class="text-gray-700 user-access-grid flex items-center space-x-2">
<span>
{{ $t('general.access') }}
</span>
<LazyAccountUserMenu :direction="sortDirection['roles']" field="roles" :handle-user-sort="saveOrUpdate" />
<LazyAccountUserMenu :direction="sortDirection.roles" field="roles" :handle-user-sort="saveOrUpdate" />
</div>
</div>

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

@ -1,7 +1,7 @@
import rfdc from 'rfdc'
import { OrgUserRoles, ProjectRoles, WorkspaceUserRoles } from 'nocodb-sdk'
import type { UsersSortType } from '~/lib'
import { useGlobal } from '#imports'
import { extractRolesObj, ProjectRoles, OrgUserRoles, WorkspaceUserRoles } from 'nocodb-sdk'
/**
* Hook for managing user sorts and sort configurations.
@ -105,28 +105,27 @@ export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
data = clone(data)
let superUserIndex = data.findIndex((user) => user?.roles?.includes('super'))
let superUser = superUserIndex !== -1 ? data.splice(superUserIndex, 1) : null
const superUserIndex = data.findIndex((user) => user?.roles?.includes('super'))
const superUser = superUserIndex !== -1 ? data.splice(superUserIndex, 1) : null
// console.log('super', superUser)
let sortedData = data.sort((a, b) => {
switch (sortsConfig.field) {
case 'roles': {
case 'roles':
const roleA = a?.roles?.split(',')[0]
const roleB = b?.roles?.split(',')[0]
if (sortsConfig.direction === 'asc') {
return userRoleOrder.indexOf(roleA) - userRoleOrder.indexOf(roleB)
} else if (sortsConfig.direction === 'desc') {
} else {
return userRoleOrder.indexOf(roleB) - userRoleOrder.indexOf(roleA)
}
}
case 'email': {
case 'email':
if (sortsConfig.direction === 'asc') {
return a[sortsConfig.field]?.localeCompare(b[sortsConfig.field])
} else if (sortsConfig.direction === 'desc') {
} else {
return b[sortsConfig.field]?.localeCompare(a[sortsConfig.field])
}
}
}
return 0

Loading…
Cancel
Save