Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove listGroups while building categories #11988

Merged
merged 35 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d1ca8d5
Remove listGroups while building categories
MrFlashAccount Jan 6, 2025
f79c342
Small adjustment
MrFlashAccount Jan 6, 2025
2931659
Fix lint errors
MrFlashAccount Jan 7, 2025
768c40d
Fix types
MrFlashAccount Jan 7, 2025
4514e5d
Fix types
MrFlashAccount Jan 8, 2025
7350325
Some fixes in types
MrFlashAccount Jan 10, 2025
1674030
Merge branch 'develop' into wip/sergeigarin/remove-list-usergroups
MrFlashAccount Jan 13, 2025
2b54294
Remove manage permissions modal
MrFlashAccount Jan 13, 2025
5f18ecc
FIx types
MrFlashAccount Jan 13, 2025
2180b0e
Fix types
MrFlashAccount Jan 13, 2025
2a3d04d
Fix types -_-
MrFlashAccount Jan 13, 2025
dc29b2b
Remove unused var
MrFlashAccount Jan 13, 2025
96a4477
Refactor Setup Organization dialog
MrFlashAccount Jan 13, 2025
cfd8cc5
Better detection for Enso's NI when launching Language Server (#12034)
hubertp Jan 13, 2025
01294f5
Fix eslint
MrFlashAccount Jan 13, 2025
39ccccb
Fix lint
MrFlashAccount Jan 13, 2025
1dddea2
Include IDE changes into GUI workflow
MrFlashAccount Jan 13, 2025
31e5b80
Fix lint
MrFlashAccount Jan 13, 2025
9d48120
Merge branch 'develop' into wip/sergeigarin/remove-list-usergroups
MrFlashAccount Jan 14, 2025
85dd211
Revert "Disable visualizations for subexpressions (#11949)" (#12050)
hubertp Jan 14, 2025
4f31294
Invalidate queries when the user goes online + Fix offline mode (#11944)
MrFlashAccount Jan 14, 2025
93c7c62
Fix Login/logout cache invalidation
MrFlashAccount Jan 15, 2025
08ef9fc
Merge branch 'develop' into wip/sergeigarin/remove-list-usergroups
MrFlashAccount Jan 15, 2025
1b4e94d
Fix imports
MrFlashAccount Jan 15, 2025
7a0e10b
Fix ci
MrFlashAccount Jan 15, 2025
6890e5b
Lint x2
MrFlashAccount Jan 15, 2025
fb5a7f4
Small fixes
MrFlashAccount Jan 15, 2025
e6ff591
Try fix activity
MrFlashAccount Jan 15, 2025
5791ad2
Fix tests
MrFlashAccount Jan 15, 2025
80100d1
fix
MrFlashAccount Jan 15, 2025
21ddca8
Fix login
MrFlashAccount Jan 15, 2025
0551633
FIx tests x2
MrFlashAccount Jan 15, 2025
353ed78
Fix
MrFlashAccount Jan 15, 2025
04c570e
Fix login
MrFlashAccount Jan 15, 2025
a5f140f
Fix login
MrFlashAccount Jan 15, 2025
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
16 changes: 16 additions & 0 deletions app/common/src/services/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,25 @@ export interface User extends UserInfo {
readonly isOrganizationAdmin: boolean
readonly rootDirectoryId: DirectoryId
readonly profilePicture?: HttpsUrl
/**
* Contains the IDs of the user groups that the user is a member of.
* @deprecated Use `groups` instead.
*/
readonly userGroups: readonly UserGroupId[] | null
readonly removeAt?: dateTime.Rfc3339DateTime | null
readonly plan?: Plan | undefined
/**
* Contains the user groups that the user is a member of.
* Has enriched metadata, like the name of the group and the home directory ID.
*/
readonly groups?: readonly UserGroup[]
}

/** A user related to the current user. */
export interface UserGroup {
readonly id: UserGroupId
readonly name: string
readonly homeDirectoryId: DirectoryId
}

/** A `Directory` returned by `createDirectory`. */
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/layouts/Drive/Categories/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
type DirectoryId,
type Path,
type User,
type UserGroup,
type UserGroupId,
type UserGroupInfo,
} from '#/services/Backend'
import { newDirectoryId } from '#/services/LocalBackend'

Expand Down Expand Up @@ -73,7 +73,7 @@ export const TEAM_CATEGORY_SCHEMA = z
.object({
type: z.literal('team'),
id: z.custom<UserGroupId>(() => true),
team: z.custom<UserGroupInfo>(() => true),
team: z.custom<UserGroup>(() => true),
rootPath: PATH_SCHEMA,
homeDirectoryId: DIRECTORY_ID_SCHEMA,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* It's not the same as the categories like LocalBackend
*/

import { useSuspenseQuery } from '@tanstack/react-query'

import CloudIcon from '#/assets/cloud.svg'
import ComputerIcon from '#/assets/computer.svg'
import FolderFilledIcon from '#/assets/folder_filled.svg'
Expand All @@ -18,21 +16,16 @@ import Trash2Icon from '#/assets/trash2.svg'

import { useUser } from '#/providers/AuthProvider'

import { backendQueryOptions } from '#/hooks/backendHooks'
import { useEventCallback } from '#/hooks/eventCallbackHooks'
import { useOffline } from '#/hooks/offlineHooks'
import { useSearchParamsState } from '#/hooks/searchParamsStateHooks'
import { useBackend, useLocalBackend, useRemoteBackend } from '#/providers/BackendProvider'
import { useBackend, useLocalBackend } from '#/providers/BackendProvider'
import { useLocalStorageState } from '#/providers/LocalStorageProvider'
import { useText } from '#/providers/TextProvider'
import type Backend from '#/services/Backend'
import { type DirectoryId, Path, userHasUserAndTeamSpaces } from '#/services/Backend'
import { newDirectoryId } from '#/services/LocalBackend'
import {
organizationIdToDirectoryId,
userGroupIdToDirectoryId,
userIdToDirectoryId,
} from '#/services/RemoteBackend'
import { organizationIdToDirectoryId, userIdToDirectoryId } from '#/services/RemoteBackend'
import { getFileName } from '#/utilities/fileInfo'
import LocalStorage from '#/utilities/LocalStorage'
import type { ReactNode } from 'react'
Expand Down Expand Up @@ -75,8 +68,6 @@ export type CloudCategoryResult = ReturnType<typeof useCloudCategoryList>
* List of categories in the Cloud.
*/
export function useCloudCategoryList() {
const remoteBackend = useRemoteBackend()

const user = useUser()
const { getText } = useText()

Expand Down Expand Up @@ -115,13 +106,6 @@ export function useCloudCategoryList() {
trashCategory,
]

const { data: allUserGroupsRaw } = useSuspenseQuery(
backendQueryOptions(remoteBackend, 'listUserGroups', []),
)

const allUserGroups =
allUserGroupsRaw.length === 0 || !hasUserAndTeamSpaces ? null : allUserGroupsRaw

const userSpace: UserCategory | null =
hasUserAndTeamSpaces ?
{
Expand All @@ -135,29 +119,19 @@ export function useCloudCategoryList() {
}
: null

const doesHaveUserGroups =
user.userGroups != null && user.userGroups.length > 0 && allUserGroups != null
const doesHaveUserGroups = user.groups != null && user.groups.length > 0

const userGroupDynamicCategories =
doesHaveUserGroups ?
user.userGroups.map<TeamCategory>((id) => {
const group = allUserGroups.find((userGroup) => userGroup.id === id)

invariant(
group != null,
`Unable to find user group by id: ${id}, allUserGroups: ${JSON.stringify(allUserGroups, null, 2)}`,
)

return {
type: 'team',
id,
team: group,
rootPath: Path(`enso://Teams/${group.groupName}`),
homeDirectoryId: userGroupIdToDirectoryId(group.id),
label: getText('teamCategory', group.groupName),
icon: PeopleIcon,
}
})
user.groups.map<TeamCategory>((group) => ({
type: 'team',
id: group.id,
team: group,
rootPath: Path(`enso://Teams/${group.name}`),
homeDirectoryId: group.homeDirectoryId,
label: getText('teamCategory', group.name),
icon: PeopleIcon,
}))
: null

const categories = [
Expand Down
Loading