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 18 commits
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
1 change: 0 additions & 1 deletion .github/workflows/gui-changed-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
.github/workflows/gui*
.github/workflows/storybook.yml
files_ignore: |
app/ide-desktop/**
app/gui/scripts/**
app/gui/.gitignore
.git-*
Expand Down
24 changes: 20 additions & 4 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 Expand Up @@ -488,7 +504,7 @@ export interface UserPermission {

/** User permission for a specific user group. */
export interface UserGroupPermission {
readonly userGroup: UserGroupInfo
readonly userGroup: UserGroup
readonly permission: permissions.PermissionAction
}

Expand Down Expand Up @@ -544,7 +560,7 @@ export function isUserGroupPermissionAnd(predicate: (permission: UserGroupPermis

/** Get the property representing the name on an arbitrary variant of {@link UserPermission}. */
export function getAssetPermissionName(permission: AssetPermission) {
return isUserPermission(permission) ? permission.user.name : permission.userGroup.groupName
return isUserPermission(permission) ? permission.user.name : permission.userGroup.name
}

/** Get the property representing the id on an arbitrary variant of {@link UserPermission}. */
Expand Down Expand Up @@ -1170,8 +1186,8 @@ export function compareAssetPermissions(a: AssetPermission, b: AssetPermission)
} else {
// NOTE [NP]: Although `userId` is unique, and therefore sufficient to sort permissions, sort
// name first, so that it's easier to find a permission in a long list (i.e., for readability).
const aName = 'user' in a ? a.user.name : a.userGroup.groupName
const bName = 'user' in b ? b.user.name : b.userGroup.groupName
const aName = 'user' in a ? a.user.name : a.userGroup.name
const bName = 'user' in b ? b.user.name : b.userGroup.name
const aUserId = 'user' in a ? a.user.userId : a.userGroup.id
const bUserId = 'user' in b ? b.user.userId : b.userGroup.id
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
/** @file A column listing the users with which this asset is shared. */
import * as React from 'react'

import Plus2Icon from '#/assets/plus2.svg'
import { Button } from '#/components/AriaComponents'
import type { AssetColumnProps } from '#/components/dashboard/column'
import PermissionDisplay from '#/components/dashboard/PermissionDisplay'
import { useRemoveSelfPermissionMutation } from '#/hooks/backendHooks'
import ManagePermissionsModal from '#/modals/ManagePermissionsModal'
import { useFullUserSession } from '#/providers/AuthProvider'
import { useSetModal } from '#/providers/ModalProvider'
import { getAssetPermissionId, getAssetPermissionName } from '#/services/Backend'
import { PermissionAction, tryFindSelfPermission } from '#/utilities/permissions'
import { PermissionAction } from '#/utilities/permissions'

// ========================
// === SharedWithColumn ===
Expand All @@ -30,21 +22,10 @@ interface SharedWithColumnPropsInternal extends Pick<AssetColumnProps, 'item'> {

/** A column listing the users with which this asset is shared. */
export default function SharedWithColumn(props: SharedWithColumnPropsInternal) {
const { item, state, isReadonly = false } = props
const { backend, category, setQuery } = state

const { user } = useFullUserSession()

const removeSelfPermissionMutation = useRemoveSelfPermissionMutation(backend)
const { item, state } = props
const { category, setQuery } = state

const assetPermissions = item.permissions ?? []
const { setModal } = useSetModal()
const self = tryFindSelfPermission(user, item.permissions)
const plusButtonRef = React.useRef<HTMLButtonElement>(null)
const managesThisAsset =
!isReadonly &&
category.type !== 'trash' &&
(self?.permission === PermissionAction.own || self?.permission === PermissionAction.admin)

return (
<div className="group flex items-center gap-column-items [content-visibility:auto]">
Expand Down Expand Up @@ -73,29 +54,6 @@ export default function SharedWithColumn(props: SharedWithColumnPropsInternal) {
{getAssetPermissionName(other)}
</PermissionDisplay>
))}
{managesThisAsset && (
<Button
ref={plusButtonRef}
size="medium"
variant="ghost"
icon={Plus2Icon}
showIconOnHover
onPress={() => {
setModal(
<ManagePermissionsModal
backend={backend}
category={category}
item={item}
self={self}
eventTarget={plusButtonRef.current}
doRemoveSelf={() => {
removeSelfPermissionMutation.mutate(item.id)
}}
/>,
)
}}
/>
)}
</div>
)
}
12 changes: 4 additions & 8 deletions app/gui/src/dashboard/hooks/backendHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ export function useNewFolder(backend: Backend, category: Category) {
const setSelectedAssets = useSetSelectedAssets()
const { user } = useFullUserSession()
const { data: users } = useBackendQuery(backend, 'listUsers', [])
const { data: userGroups } = useBackendQuery(backend, 'listUserGroups', [])
const createDirectoryMutation = useMutation(backendMutationOptions(backend, 'createDirectory'))

return useEventCallback(async (parentId: DirectoryId, parentPath: string | null | undefined) => {
Expand All @@ -658,7 +657,7 @@ export function useNewFolder(backend: Backend, category: Category) {
category,
user,
users ?? [],
userGroups ?? [],
user.groups ?? [],
),
)

Expand All @@ -681,7 +680,6 @@ export function useNewProject(backend: Backend, category: Category) {

const { user } = useFullUserSession()
const { data: users } = useBackendQuery(backend, 'listUsers', [])
const { data: userGroups } = useBackendQuery(backend, 'listUserGroups', [])
const createProjectMutation = useMutation(backendMutationOptions(backend, 'createProject'))

return useEventCallback(
Expand Down Expand Up @@ -721,7 +719,7 @@ export function useNewProject(backend: Backend, category: Category) {
category,
user,
users ?? [],
userGroups ?? [],
user.groups ?? [],
),
user,
path,
Expand Down Expand Up @@ -759,7 +757,6 @@ export function useNewSecret(backend: Backend, category: Category) {
const toggleDirectoryExpansion = useToggleDirectoryExpansion()
const { user } = useFullUserSession()
const { data: users } = useBackendQuery(backend, 'listUsers', [])
const { data: userGroups } = useBackendQuery(backend, 'listUserGroups', [])
const createSecretMutation = useMutation(backendMutationOptions(backend, 'createSecret'))

return useEventCallback(
Expand All @@ -778,7 +775,7 @@ export function useNewSecret(backend: Backend, category: Category) {
category,
user,
users ?? [],
userGroups ?? [],
user.groups ?? [],
),
)

Expand All @@ -798,7 +795,6 @@ export function useNewDatalink(backend: Backend, category: Category) {
const toggleDirectoryExpansion = useToggleDirectoryExpansion()
const { user } = useFullUserSession()
const { data: users } = useBackendQuery(backend, 'listUsers', [])
const { data: userGroups } = useBackendQuery(backend, 'listUserGroups', [])
const createDatalinkMutation = useMutation(backendMutationOptions(backend, 'createDatalink'))

return useEventCallback(
Expand All @@ -817,7 +813,7 @@ export function useNewDatalink(backend: Backend, category: Category) {
category,
user,
users ?? [],
userGroups ?? [],
user.groups ?? [],
),
)

Expand Down
3 changes: 1 addition & 2 deletions app/gui/src/dashboard/hooks/backendUploadFilesHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function useUploadFiles(backend: Backend, category: Category) {
const { setModal } = useSetModal()
const { user } = useFullUserSession()
const { data: users } = useBackendQuery(backend, 'listUsers', [])
const { data: userGroups } = useBackendQuery(backend, 'listUserGroups', [])
const uploadFileMutation = useUploadFileWithToastMutation(backend)
const setSelectedAssets = useSetSelectedAssets()

Expand All @@ -83,7 +82,7 @@ export function useUploadFiles(backend: Backend, category: Category) {
category,
user,
users ?? [],
userGroups ?? [],
user.groups ?? [],
)
const files = reversedFiles.filter(fileIsNotProject).map((file) => {
const asset = createPlaceholderFileAsset(
Expand Down
33 changes: 2 additions & 31 deletions app/gui/src/dashboard/layouts/AssetContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as React from 'react'
import * as reactQuery from '@tanstack/react-query'
import * as toast from 'react-toastify'

import * as billingHooks from '#/hooks/billing'
import * as copyHooks from '#/hooks/copyHooks'
import * as projectHooks from '#/hooks/projectHooks'
import * as toastAndLogHooks from '#/hooks/toastAndLogHooks'
Expand All @@ -24,7 +23,6 @@ import Separator from '#/components/styled/Separator'

import ConfirmDeleteModal from '#/modals/ConfirmDeleteModal'
import ManageLabelsModal from '#/modals/ManageLabelsModal'
import ManagePermissionsModal from '#/modals/ManagePermissionsModal'

import * as backendModule from '#/services/Backend'
import * as localBackendModule from '#/services/LocalBackend'
Expand All @@ -36,7 +34,7 @@ import {
downloadAssetsMutationOptions,
restoreAssetsMutationOptions,
} from '#/hooks/backendBatchedHooks'
import { useNewProject, useRemoveSelfPermissionMutation } from '#/hooks/backendHooks'
import { useNewProject } from '#/hooks/backendHooks'
import { useUploadFileWithToastMutation } from '#/hooks/backendUploadFilesHooks'
import { usePasteData } from '#/providers/DriveProvider'
import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '#/services/remoteBackendPaths'
Expand Down Expand Up @@ -64,7 +62,7 @@ export interface AssetContextMenuProps {

/** The context menu for an arbitrary {@link backendModule.Asset}. */
export default function AssetContextMenu(props: AssetContextMenuProps) {
const { innerProps, rootDirectoryId, event, eventTarget, hidden = false, triggerRef } = props
const { innerProps, rootDirectoryId, event, hidden = false, triggerRef } = props
const { doCopy, doCut, doPaste } = props
const { asset, path: pathRaw, state, setRowState } = innerProps
const { backend, category, nodeMap } = state
Expand All @@ -84,7 +82,6 @@ export default function AssetContextMenu(props: AssetContextMenuProps) {
const restoreAssetsMutation = reactQuery.useMutation(restoreAssetsMutationOptions(backend))
const copyAssetsMutation = reactQuery.useMutation(copyAssetsMutationOptions(backend))
const downloadAssetsMutation = reactQuery.useMutation(downloadAssetsMutationOptions(backend))
const removeSelfPermissionMutation = useRemoveSelfPermissionMutation(backend)
const openProjectMutation = projectHooks.useOpenProjectMutation()
const self = permissions.tryFindSelfPermission(user, asset.permissions)
const isCloud = categoryModule.isCloudCategory(category)
Expand All @@ -102,9 +99,6 @@ export default function AssetContextMenu(props: AssetContextMenuProps) {
const uploadFileToCloudMutation = useUploadFileWithToastMutation(remoteBackend)
const disabledTooltip = !canOpenProjects ? getText('downloadToOpenWorkflow') : undefined

const { isFeatureUnderPaywall } = billingHooks.usePaywall({ plan: user.plan })
const isUnderPaywall = isFeatureUnderPaywall('share')

const newProject = useNewProject(backend, category)

const systemApi = window.systemApi
Expand Down Expand Up @@ -430,29 +424,6 @@ export default function AssetContextMenu(props: AssetContextMenuProps) {
)}
{isCloud && <Separator hidden={hidden} />}

{isCloud && managesThisAsset && self != null && (
<PaywallContextMenuEntry
feature="share"
isUnderPaywall={isUnderPaywall}
action="share"
hidden={hidden}
doAction={() => {
setModal(
<ManagePermissionsModal
backend={backend}
category={category}
item={asset}
self={self}
eventTarget={eventTarget}
doRemoveSelf={() => {
removeSelfPermissionMutation.mutate(asset.id)
}}
/>,
)
}}
/>
)}

{isCloud && (
<ContextMenuEntry
hidden={hidden}
Expand Down
6 changes: 5 additions & 1 deletion app/gui/src/dashboard/layouts/AssetsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,11 @@ export function AssetsTableAssetsUnselector(props: AssetsTableAssetsUnselectorPr
invariant(onlyChild != null, 'Children must be a single element when `asChild` is true')
invariant(isValidElement(onlyChild), 'Children must be a JSX element when `asChild` is true')

return cloneElement(onlyChild, pressProps)
return cloneElement(
onlyChild,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any, no-restricted-syntax
mergeProps<any>()(pressProps as any, onlyChild.props as any),
)
}

return (
Expand Down
6 changes: 3 additions & 3 deletions app/gui/src/dashboard/layouts/CategorySwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function CategorySwitcher(props: CategorySwitcherProps) {
/>
)}

{teamCategories?.map((teamCategory) => (
{teamCategories.map((teamCategory) => (
<CategorySwitcherItem
key={teamCategory.id}
{...itemProps}
Expand All @@ -278,8 +278,8 @@ function CategorySwitcher(props: CategorySwitcherProps) {
icon={teamCategory.icon}
label={teamCategory.label}
isDisabled={isOffline}
buttonLabel={getText('teamCategoryButtonLabel', teamCategory.team.groupName)}
dropZoneLabel={getText('teamCategoryDropZoneLabel', teamCategory.team.groupName)}
buttonLabel={getText('teamCategoryButtonLabel', teamCategory.team.name)}
dropZoneLabel={getText('teamCategoryDropZoneLabel', teamCategory.team.name)}
/>
))}

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 @@ -16,8 +16,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 @@ -72,7 +72,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
Loading
Loading