Browse Source

fix: lint erros

feat/user-management-sort
Ramesh Mane 10 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> <script lang="ts" setup>
import { OrgUserRoles } from 'nocodb-sdk' import { OrgUserRoles } from 'nocodb-sdk'
import type { OrgUserReqType, RequestParams, UserType } from 'nocodb-sdk' import type { OrgUserReqType, RequestParams, UserType } from 'nocodb-sdk'
import rfdc from 'rfdc'
import type { User } from '#imports' import type { User } from '#imports'
import { import {
extractSdkResponseErrorMsg, extractSdkResponseErrorMsg,
@ -12,7 +13,6 @@ import {
useNuxtApp, useNuxtApp,
useUserSorts, useUserSorts,
} from '#imports' } from '#imports'
import rfdc from 'rfdc'
const { api, isLoading } = useApi() const { api, isLoading } = useApi()
@ -95,7 +95,7 @@ const updateRole = async (userId: string, roles: string) => {
users.value = clone(users.value).map((user) => { users.value = clone(users.value).map((user) => {
if (user.id === userId) { if (user.id === userId) {
user['roles'] = roles user.roles = roles
} }
return user return user
}) })
@ -210,13 +210,13 @@ const openDeleteModal = (user: UserType) => {
<span> <span>
{{ $t('labels.email') }} {{ $t('labels.email') }}
</span> </span>
<LazyAccountUserMenu :direction="sortDirection['email']" field="email" :handle-user-sort="saveOrUpdate" /> <LazyAccountUserMenu :direction="sortDirection.email" field="email" :handle-user-sort="saveOrUpdate" />
</div> </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"> <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> <span>
{{ $t('objects.role') }} {{ $t('objects.role') }}
</span> </span>
<LazyAccountUserMenu :direction="sortDirection['roles']" field="roles" :handle-user-sort="saveOrUpdate" /> <LazyAccountUserMenu :direction="sortDirection.roles" field="roles" :handle-user-sort="saveOrUpdate" />
</div> </div>
<div class="flex py-3.5 text-gray-500 font-medium text-3.5 w-28 justify-end mr-4" data-rec="true"> <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') }} {{ $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']) => { const sortUserBy = async (direction?: UsersSortType['direction']) => {
handleUserSort({ handleUserSort({
field: field, field,
direction, direction,
}) })
isOpen.value = false isOpen.value = false

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

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

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

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

Loading…
Cancel
Save