Browse Source

fix: small changes

pull/7342/head
Ramesh Mane 10 months ago
parent
commit
d93b548d80
  1. 5
      packages/nc-gui/components/account/UserList.vue
  2. 2
      packages/nc-gui/components/account/UserMenu.vue
  3. 4
      packages/nc-gui/components/project/AccessSettings.vue
  4. 18
      packages/nc-gui/composables/useUserSorts.ts
  5. 3
      packages/nc-gui/lang/en.json

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

@ -28,12 +28,12 @@ const { user: loggedInUser } = useGlobal()
const { copy } = useCopy()
const { sorts, sortDirection, loadSorts, saveOrUpdate, handleGetSortsData } = useUserSorts('Org')
const { sorts, sortDirection, loadSorts, saveOrUpdate, handleGetSortedData } = useUserSorts('Org')
const users = ref<UserType[]>([])
const sortedUsers = computed(() => {
return handleGetSortsData(users.value, sorts.value) as UserType[]
return handleGetSortedData(users.value, sorts.value) as UserType[]
})
const currentPage = ref(1)
@ -93,7 +93,6 @@ const updateRole = async (userId: string, roles: string) => {
if (user.id === userId) {
user.roles = roles
}
return user
})
$e('a:org-user:role-updated', { role: roles })

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

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

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

@ -18,7 +18,7 @@ const { activeProjectId } = storeToRefs(basesStore)
const { orgRoles, baseRoles } = useRoles()
const { sorts, sortDirection, loadSorts, saveOrUpdate, handleGetSortsData } = useUserSorts('Project')
const { sorts, sortDirection, loadSorts, saveOrUpdate, handleGetSortedData } = useUserSorts('Project')
const isSuper = computed(() => orgRoles.value?.[OrgUserRoles.SUPER_ADMIN])
@ -40,7 +40,7 @@ const isSearching = ref(false)
const accessibleRoles = ref<(typeof ProjectRoles)[keyof typeof ProjectRoles][]>([])
const sortedCollaborators = computed(() => {
return handleGetSortsData(collaborators.value, sorts.value)
return handleGetSortedData(collaborators.value, sorts.value)
})
const loadCollaborators = async () => {

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

@ -44,15 +44,17 @@ export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
const sortConfig = storedConfig ? JSON.parse(storedConfig) : ({} as Record<string, UsersSortType>)
if (sortConfig && isValidSortConfig(sortConfig)) {
sorts.value = sortConfig
// Load user-specific sort configurations or default configurations
sorts.value = user.value?.id ? sortConfig[user.value.id] || {} : sortConfig[defaultUserId] || {}
} else {
// remove sortConfig from localStorage if it's invalid
localStorage.removeItem(userSortConfigKey)
sorts.value = {}
throw new Error('Invalid sort config stored in local storage')
}
} catch {
} catch (error) {
console.error(error)
// remove sortConfig from localStorage in case of error
localStorage.removeItem(userSortConfigKey)
// Set sorts to an empty obj in case of an error
sorts.value = {}
}
@ -88,7 +90,7 @@ export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
localStorage.setItem(userSortConfigKey, JSON.stringify(sortConfig))
} catch (error) {
console.error('Error while retrieving sort configuration from local storage:', error)
console.error('Error while saving sort configuration into local storage:', error)
}
}
@ -100,7 +102,7 @@ export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
* @returns A new array containing sorted objects.
* @template T - The type of objects in the input array.
*/
function handleGetSortsData<T extends Record<string, any>>(data: T[], sortsConfig: UsersSortType = sorts.value): T[] {
function handleGetSortedData<T extends Record<string, any>>(data: T[], sortsConfig: UsersSortType = sorts.value): T[] {
let userRoleOrder: string[] = []
if (roleType === 'Workspace') {
userRoleOrder = Object.values(WorkspaceUserRoles)
@ -171,5 +173,5 @@ export function useUserSorts(roleType: 'Workspace' | 'Org' | 'Project') {
return true
}
return { sorts, sortDirection, loadSorts, saveOrUpdate, handleGetSortsData }
return { sorts, sortDirection, loadSorts, saveOrUpdate, handleGetSortedData }
}

3
packages/nc-gui/lang/en.json

@ -189,8 +189,7 @@
"shift": "Shift",
"enter": "Enter",
"seconds": "Seconds",
"paste": "Paste",
"resetSort": "Reset Sort"
"paste": "Paste"
},
"objects": {
"workspace": "Workspace",

Loading…
Cancel
Save