Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(spaces): enforce role capabilities and reserve personal aliases
johaven3877fa06644d
diff --git a/backend/src/applications/shares/services/shares-queries.service.ts b/backend/src/applications/shares/services/shares-queries.service.tsindex 193180d1..e4d3a3ba 100644--- a/backend/src/applications/shares/services/shares-queries.service.ts+++ b/backend/src/applications/shares/services/shares-queries.service.ts@@ -27,6 +27,7 @@ import type { SpaceBrowseDetails } from '../../spaces/interfaces/space-files.intimport { SpaceEnv } from '../../spaces/models/space-env.model'import { spacesRoots } from '../../spaces/schemas/spaces-roots.schema'import { spaceGroupConcatPermissions, spaces } from '../../spaces/schemas/spaces.schema'+import { createUniqueAlias } from '../../spaces/utils/alias'import { syncClients } from '../../sync/schemas/sync-clients.schema'import { syncPaths } from '../../sync/schemas/sync-paths.schema'import { GROUP_TYPE } from '../../users/constants/group'@@ -67,14 +68,7 @@ export class SharesQueries {) {}async uniqueShareAlias(name: string, excludedShareId?: number): Promise<string> {- const originalAlias = createSlug(name, true)- let alias = originalAlias- let count = 0- while (await this.shareExistsForAlias(alias, excludedShareId)) {- count += 1- alias = `${originalAlias}-${count}`- }- return alias+ return createUniqueAlias(createSlug(name, true), (alias: string) => this.shareExistsForAlias(alias, excludedShareId))}shareExistsForOwner(userId: number, shareId: number): any | undefined {diff --git a/backend/src/applications/spaces/guards/space.guard.spec.ts b/backend/src/applications/spaces/guards/space.guard.spec.tsindex 483fa75d..4758874b 100644--- a/backend/src/applications/spaces/guards/space.guard.spec.ts+++ b/backend/src/applications/spaces/guards/space.guard.spec.ts@@ -390,6 +390,21 @@ describe(SpaceGuard.name, () => {}})+ it('should deny guest and link access to the trash repository', async () => {+ spacesManager.spaceEnv = vi.fn()+ for (const role of [USER_ROLE.GUEST, USER_ROLE.LINK]) {+ userTest.role = role+ context.switchToHttp().getRequest.mockReturnValueOnce({+ method: 'GET',+ user: userTest,+ params: { '*': 'trash/project/document.txt' }+ })+ await expect(spacesGuard.canActivate(context)).rejects.toMatchObject({ status: HttpStatus.FORBIDDEN })+ }+ expect(spacesManager.spaceEnv).not.toHaveBeenCalled()+ userTest.role = USER_ROLE.USER+ })+it('should fail with space disabled', async () => {userTest.role = USER_ROLE.USERspacesManager.spaceEnv = vi.fn().mockReturnValueOnce({diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.tsindex a6dfc372..8b38091e 100644--- a/backend/src/applications/spaces/services/spaces-manager.service.ts+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts@@ -20,6 +20,7 @@ import type { ShareProps } from '../../shares/interfaces/share-props.interface'import type { ShareChild } from '../../shares/models/share-child.model'import { SharesManager } from '../../shares/services/shares-manager.service'import { MEMBER_TYPE } from '../../users/constants/member'+import { USER_PERMISSION, USER_ROLE } from '../../users/constants/user'import { UserModel } from '../../users/models/user.model'import { UsersQueries } from '../../users/services/users-queries.service'import {@@ -44,6 +45,7 @@ import { SpaceModel } from '../models/space.model'import type { SpaceRoot } from '../schemas/space-root.interface'import type { Space } from '../schemas/space.interface'import { spaces } from '../schemas/spaces.schema'+import { createUniqueAlias } from '../utils/alias'import { haveSpacePermission } from '../utils/permissions'import { SpacesQueries } from './spaces-queries.service'import { FilesQuotaManager } from '../../files/services/files-quota-manager.service'@@ -182,7 +184,9 @@ export class SpacesManager {ctime: 0,enabled: true}- for (const space of [...(await this.listSpaces(user.id)), personalTrash] as SpaceTrash[]) {+ const spaces = (await this.listSpaces(user.id)) as SpaceTrash[]+ if (user.havePermission(USER_PERMISSION.PERSONAL_SPACE)) spaces.push(personalTrash)+ for (const space of spaces) {const rPath = space.alias === SPACE_ALIAS.PERSONAL ? user.trashPath : SpaceModel.getTrashPath(space.alias)try {space.nb = 0@@ -221,6 +225,7 @@ export class SpacesManager {async createSpace(user: UserModel, createOrUpdateSpaceDto: CreateOrUpdateSpaceDto): Promise<SpaceProps> {/* only users with admin space role can create a space */+ await this.validateManagers(createOrUpdateSpaceDto.managers)// create spaceconst space: SpaceProps = new SpaceProps({name: createOrUpdateSpaceDto.name,@@ -251,6 +256,7 @@ export class SpacesManager {async updateSpace(user: UserModel, spaceId: number, createOrUpdateSpaceDto: CreateOrUpdateSpaceDto): Promise<SpaceProps> {/* only managers of the space can update it */const space: SpaceProps = await this.userCanAccessSpace(user, spaceId, true)+ await this.validateManagers(createOrUpdateSpaceDto.managers)// check and update space infolet mustInvalidateCache = falselet renamedSpaceAlias: string@@ -552,6 +558,16 @@ export class SpacesManager {return rmRootOwners}+ private async validateManagers(managers: SpaceMemberDto[]): Promise<void> {+ const managersHaveUserRole = await this.usersQueries.usersHaveRole(+ managers.map((manager) => manager.id),+ USER_ROLE.USER+ )+ if (managers.some((manager) => manager.type !== MEMBER_TYPE.USER) || !managersHaveUserRole) {+ throw new HttpException('Only users can be space managers', HttpStatus.BAD_REQUEST)+ }+ }+private async updateRoots(user: UserModel,space: Partial<SpaceProps>,@@ -766,19 +782,9 @@ export class SpacesManager {}private async uniqueSpaceAlias(name: string, replaceCount = false, excludedSpaceId?: number): Promise<string> {- const originalAlias = this.createAliasSlug(name, replaceCount)- let alias = originalAlias- let count = 0- // Personal space name is reserved- if (alias === SPACE_ALIAS.PERSONAL) {- count += 1- alias = `${originalAlias}-${count}`- }- while (await this.spacesQueries.spaceExistsForAlias(alias, excludedSpaceId)) {- count += 1- alias = `${originalAlias}-${count}`- }- return alias+ return createUniqueAlias(this.createAliasSlug(name, replaceCount), (alias: string) =>+ this.spacesQueries.spaceExistsForAlias(alias, excludedSpaceId)+ )}private createAliasSlug(name: string, replaceCount = false): string {diff --git a/backend/src/applications/spaces/spaces.controller.ts b/backend/src/applications/spaces/spaces.controller.tsindex 8eb11586..6e31f41d 100644--- a/backend/src/applications/spaces/spaces.controller.ts+++ b/backend/src/applications/spaces/spaces.controller.ts@@ -95,8 +95,8 @@ export class SpacesController {return this.spacesManager.listSpacesAsAdmin()}- @UserHavePermission([USER_PERMISSION.PERSONAL_SPACE, USER_PERMISSION.SPACES])@Get(`${SPACES_ROUTE.TRASH}/${SPACES_ROUTE.LIST}`)+ @UserHavePermission([USER_PERMISSION.PERSONAL_SPACE, USER_PERMISSION.SPACES])listTrashes(@GetUser() user: UserModel): Promise<SpaceTrash[]> {return this.spacesManager.listTrashes(user)}diff --git a/backend/src/applications/spaces/utils/alias.ts b/backend/src/applications/spaces/utils/alias.tsnew file mode 100644index 00000000..7b80557e--- /dev/null+++ b/backend/src/applications/spaces/utils/alias.ts@@ -0,0 +1,14 @@+import { SPACE_ALIAS } from '../constants/spaces'++const RESERVED_ALIASES = new Set<string>([SPACE_ALIAS.PERSONAL])++export async function createUniqueAlias(alias: string, aliasExists: (alias: string) => Promise<unknown>): Promise<string> {+ const originalAlias = alias+ let count = 0++ while (RESERVED_ALIASES.has(alias) || (await aliasExists(alias))) {+ count += 1+ alias = `${originalAlias}-${count}`+ }+ return alias+}diff --git a/backend/src/applications/spaces/utils/permissions.ts b/backend/src/applications/spaces/utils/permissions.tsindex 14c8ca02..d2975cc5 100644--- a/backend/src/applications/spaces/utils/permissions.ts+++ b/backend/src/applications/spaces/utils/permissions.ts@@ -39,6 +39,7 @@ export function removePermissions(permissions: string, rmPermissions: SPACE_OPER}export function canAccessToSpaceUrl(user: UserModel, urlSegments: string[]): boolean {+ if (urlSegments[0] === SPACE_REPOSITORY.TRASH && !user.isUser) return falseif (urlSegments[1] === SPACE_ALIAS.PERSONAL && (urlSegments[0] === SPACE_REPOSITORY.FILES || urlSegments[0] === SPACE_REPOSITORY.TRASH)) {return user.havePermission(USER_PERMISSION.PERSONAL_SPACE)} else if (urlSegments[0] === SPACE_REPOSITORY.FILES) {@@ -52,6 +53,7 @@ export function canAccessToSpaceUrl(user: UserModel, urlSegments: string[]): boo}export function canAccessToSpace(user: UserModel, space: SpaceEnv): boolean {+ if (space.inTrashRepository && !user.isUser) return falseif (space.inPersonalSpace) {return user.havePermission(USER_PERMISSION.PERSONAL_SPACE)} else if (space.inFilesRepository) {diff --git a/backend/src/applications/users/services/users-queries.service.ts b/backend/src/applications/users/services/users-queries.service.tsindex 763a639b..b35d6a1f 100644--- a/backend/src/applications/users/services/users-queries.service.ts+++ b/backend/src/applications/users/services/users-queries.service.ts@@ -215,6 +215,16 @@ export class UsersQueries {.where(and(...where))}+ async usersHaveRole(userIds: number[], role: USER_ROLE): Promise<boolean> {+ const uniqueUserIds = [...new Set(userIds)]+ if (!uniqueUserIds.length) return true+ const matchingUsers = await this.db+ .select({ id: users.id })+ .from(users)+ .where(and(inArray(users.id, uniqueUserIds), lte(users.role, role)))+ return matchingUsers.length === uniqueUserIds.length+ }+async selectUserProperties(userId: number, fields: Partial<keyof User>[]): Promise<Partial<User>> {const select: Record<keyof User, any> = convertToSelect(users, fields)const [r]: Record<string, any>[] = await this.db.select(select).from(users).where(eq(users.id, userId)).limit(1)diff --git a/backend/src/applications/users/users.md b/backend/src/applications/users/users.mdindex 0ac8da6a..c453bb40 100644--- a/backend/src/applications/users/users.md+++ b/backend/src/applications/users/users.md@@ -113,7 +113,7 @@ The available `USER_PERMISSION` values are:|-------------------------|-------------------------|-------------------------------------------------------------|| `PERSONAL_SPACE` | `personal_space` | Access personal files and the personal trash. || `SPACES` | `spaces_access` | Browse spaces available to the user. |-| `SPACES_ADMIN` | `spaces_admin` | Create and administer spaces and their roots. |+| `SPACES_ADMIN` | `spaces_admin` | Create collaborative spaces. || `SHARES` | `shares_access` | Browse shares available to the user. || `SHARES_ADMIN` | `shares_admin` | Create and administer shares and share links. || `GUESTS_ADMIN` | `guests_admin` | Create and administer guest accounts. |@@ -126,6 +126,49 @@ Permissions do not imply one another. When `@UserHavePermission()` receives an aof them. Endpoint guards and storage-context checks can also impose a role, membership, or repository permission in addition to the applicationpermission.+For a regular user, `SPACES_ADMIN` allows space creation but does not grant management over every existing space. Updating a space, its members,+roots, or originating shares still requires the user to be one of that space's managers. Administrators can administer every space.++`SHARES_ADMIN` allows a regular user to create and administer outgoing shares and share links. When the source belongs to a collaborative space, the+effective space or anchored-root permissions must also include `SHARE_OUTSIDE`. Conversely, a space manager's oversight of existing shares originating+from that space does not depend on `SHARES_ADMIN`.++## Guest and link capabilities in collaborative spaces++Guests and link pseudo-users are content collaborators, not space administrators. Both can browse the collaborative spaces available to their+identity and can act on their content according to the effective permissions granted by the space and, when applicable, by an anchored root.++| Capability | Guest | Space link pseudo-user |+|-------------------------------------------------------|---------------------------------------------------------------------|---------------------------------------------------|+| Access scope | Spaces granted directly or through an allowed collaboration context | Only the space attached to the authenticated link |+| Read and download | Yes | Yes |+| Create, upload, copy, or move content into a location | Requires `ADD` | Requires `ADD` |+| Edit, rename, overwrite, or lock content | Requires `MODIFY` | Requires `MODIFY` |+| Delete content or move it out of a location | Requires `DELETE`; a move also requires `ADD` on the destination | Same |+| Comments | Yes, on accessible content | Yes, on accessible content |+| Favorites | Yes | No |+| WebDAV | Yes | No |+| Personal space and personal trash | No | No |+| Collaborative-space trash | No | No |+| Personal-file anchoring | No | No |+| Create shares, share links, or child shares | No | No |+| Manage a collaborative space or its shares | No | No |+| Desktop synchronization | No | No |++Only administrators and regular users can be collaborative-space managers. Guests can be space members but cannot be promoted to manager, and link+pseudo-users are always link-scoped members. A manager of an originating collaborative space can administer the shares created from that space through+the space-management endpoints; this manager oversight is distinct from the global `SHARES_ADMIN` application permission.++`SHARE_INSIDE` and `SHARE_OUTSIDE` are not independently usable by guests or link pseudo-users. Anchoring requires a personal source that these roles+do not have, while share creation and child-share creation require an authorized regular user and the share-administration capability. Link settings+normally expose only `ADD`, `MODIFY`, and `DELETE`.++Collaborative-space trash is a recovery scope reserved for administrators and regular users. Guests and link pseudo-users can move active content to+the trash when their effective permissions include `DELETE`, but they cannot list, browse, restore, permanently delete, or empty the trash.++Link access remains subject to the link state and settings, including activation, expiration, access limits, and optional password authentication.+Link pseudo-users cannot use the normal login flow.+### Revocation and persisted stateRevoking an application permission prevents subsequent protected actions, but it does not delete relationships or configurations that were createddiff --git a/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts b/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.tsindex aa8ab189..410d491f 100644--- a/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts+++ b/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts@@ -15,6 +15,7 @@ import { LINK_TYPE } from '@sync-in-server/backend/src/applications/links/constaimport { SPACE_MAX_DISABLED_DAYS, SPACE_OPERATION, SPACE_ROLE } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'import { SpaceProps } from '@sync-in-server/backend/src/applications/spaces/models/space-props.model'import type { SpaceRootProps } from '@sync-in-server/backend/src/applications/spaces/models/space-root-props.model'+import { USER_ROLE } from '@sync-in-server/backend/src/applications/users/constants/user'import type { SearchMembersDto } from '@sync-in-server/backend/src/applications/users/dto/search-members.dto'import { L10N_LOCALE, L10nLocale, L10nTranslateDirective } from 'angular-l10n'import { BsModalRef } from 'ngx-bootstrap/modal'@@ -116,7 +117,8 @@ export class SpaceDialogComponent implements OnInit {...this.space.managers.map((m: MemberModel) => m.id),...this.space.members.filter((m: MemberModel) => m.isUser).map((m: MemberModel) => m.id)],- onlyUsers: true+ onlyUsers: true,+ usersRole: USER_ROLE.USER}return this.memberSearchService.searchMembers(search)}diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.html b/frontend/src/app/applications/spaces/components/spaces-browser.component.htmlindex dbcb5397..4438ef7f 100644--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.html+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.html@@ -69,7 +69,7 @@</button>}<!--Start Share Button-->- @if (!isTrashRepo && !inSharesList && canShare.outside) {+ @if (!isTrashRepo && !inSharesList && (canShare.outside || isPersonalSpace)) {<div class="btn-group"[isDisabled]="!hasSelection"dropdown>@@ -81,17 +81,19 @@<span class="app-top-menu-tool-bar__label" l10nTranslate>Share</span></button><ul *dropdownMenu class="dropdown-menu" role="menu">- <li role="menuitem">- <a (click)="openShareDialog()" class="dropdown-item">- <span l10nTranslate><svg [lucideIcon]="icons.SHARED"></svg>New share</span>- </a>- </li>- <li role="menuitem">- <a (click)="openShareLinkDialog()" class="dropdown-item">- <span l10nTranslate><svg [lucideIcon]="icons.LucideLink"></svg>New share link</span>- </a>- </li>- @if (isFilesRepo) {+ @if (canShare.outside) {+ <li role="menuitem">+ <a (click)="openShareDialog()" class="dropdown-item">+ <span l10nTranslate><svg [lucideIcon]="icons.SHARED"></svg>New share</span>+ </a>+ </li>+ <li role="menuitem">+ <a (click)="openShareLinkDialog()" class="dropdown-item">+ <span l10nTranslate><svg [lucideIcon]="icons.LucideLink"></svg>New share link</span>+ </a>+ </li>+ }+ @if (isPersonalSpace) {<li role="menuitem"><a (click)="openSpaceAnchorFileDialog()" class="dropdown-item"><span l10nTranslate><svg [lucideIcon]="icons.LucideAnchor"></svg>Anchor to a space</span>@@ -152,7 +154,7 @@<span l10nTranslate><svg [lucideIcon]="icons.SELECTION"></svg>View selection</span></a></li>- @if (inSharesList && selection.length === 1 && selection[0]?.canBeReShared) {+ @if (canAdminShares && inSharesList && selection.length === 1 && selection[0]?.canBeReShared) {<li class="dropdown-divider"></li><li role="menuitem"><a (click)="openShareDialog()" class="dropdown-item">@@ -667,13 +669,13 @@}}@if (!isTrashRepo) {- @if (canShare.outside || inSharesList && selection[0]?.canBeReShared) {+ @if (canShare.outside || isPersonalSpace || canAdminShares && inSharesList && selection[0]?.canBeReShared) {<ng-template [subMenu]="ShareContextMenu" contextMenuItem><span l10nTranslate><svg [lucideIcon]="icons.SHARED"></svg>Share</span></ng-template>}}- @if (!hasDisabledItemsInSelection || selection.length === 1 && !isTrashRepo && !inSharesList || !isTrashRepo && canCompress || !isTrashRepo && (canShare.outside || inSharesList && selection[0]?.canBeReShared)) {+ @if (!hasDisabledItemsInSelection || selection.length === 1 && !isTrashRepo && !inSharesList || !isTrashRepo && canCompress || !isTrashRepo && (canShare.outside || isPersonalSpace || canAdminShares && inSharesList && selection[0]?.canBeReShared)) {<ng-template [divider]="true" contextMenuItem></ng-template>}@if (selection.length === 1 && !isTrashRepo && isElectronApp && selection[0].isDir) {@@ -710,13 +712,15 @@}</context-menu><context-menu #ShareContextMenu>- <ng-template (execute)="openShareDialog()" contextMenuItem>- <span l10nTranslate><svg [lucideIcon]="icons.SHARED"></svg>New share</span>- </ng-template>- <ng-template (execute)="openShareLinkDialog()" contextMenuItem>- <span l10nTranslate><svg [lucideIcon]="icons.LucideLink"></svg>New share link</span>- </ng-template>- @if (isFilesRepo) {+ @if (canShare.outside || canAdminShares && inSharesList && selection[0]?.canBeReShared) {+ <ng-template (execute)="openShareDialog()" contextMenuItem>+ <span l10nTranslate><svg [lucideIcon]="icons.SHARED"></svg>New share</span>+ </ng-template>+ <ng-template (execute)="openShareLinkDialog()" contextMenuItem>+ <span l10nTranslate><svg [lucideIcon]="icons.LucideLink"></svg>New share link</span>+ </ng-template>+ }+ @if (isPersonalSpace) {<ng-template (execute)="openSpaceAnchorFileDialog()" contextMenuItem><span l10nTranslate><svg [lucideIcon]="icons.LucideAnchor"></svg>Anchor to a space</span></ng-template>diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts b/frontend/src/app/applications/spaces/components/spaces-browser.component.tsindex 16ff31b0..575f2317 100644--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts@@ -43,6 +43,7 @@ import { FileTaskStatus } from '@sync-in-server/backend/src/applications/files/mimport { SHARE_TYPE } from '@sync-in-server/backend/src/applications/shares/constants/shares'import { SPACE_OPERATION, SPACE_REPOSITORY } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'import type { SpaceFiles } from '@sync-in-server/backend/src/applications/spaces/interfaces/space-files.interface'+import { USER_PERMISSION } from '@sync-in-server/backend/src/applications/users/constants/user'import { intersectPermissions } from '@sync-in-server/backend/src/common/shared'import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'import { BsDropdownModule } from 'ngx-bootstrap/dropdown'@@ -82,6 +83,7 @@ import { ShareDialogComponent } from '../../shares/components/dialogs/share-dialimport { ShareModel } from '../../shares/models/share.model'import { SYNC_ICON, SYNC_PATH } from '../../sync/sync.constants'import { UserAvatarComponent } from '../../users/components/utils/user-avatar.component'+import { UserService } from '../../users/user.service'import { SpaceModel } from '../models/space.model'import { SpacesBrowserService } from '../services/spaces-browser.service'import { SPACES_ICON, SPACES_PATH } from '../spaces.constants'@@ -182,6 +184,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroyprotected inSharesList: booleanprotected hasRoots = falseprotected canShare: { inside: boolean; outside: boolean } = { inside: false, outside: false }+ protected canAdminShares = falseprotected spacePermissions: string// Actionsprotected multipleSelection = false@@ -249,6 +252,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroyprivate readonly zone = inject(NgZone)private readonly renderer = inject(Renderer2)private readonly store = inject(StoreService)+ private readonly userService = inject(UserService)protected isElectronApp = this.store.isElectronApp()private readonly spacesBrowser = inject(SpacesBrowserService)private readonly filesService = inject(FilesService)@@ -256,7 +260,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy// Spaceprivate baseRepoUrl: stringprivate currentRoute: string- private isPersonalSpace: boolean+ protected isPersonalSpace: boolean// Othersprivate subscriptions: Subscription[] = []private focusOnSelect: string@@ -291,6 +295,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroyprivate moveFromDrag = falsengOnInit() {+ this.canAdminShares = this.userService.userHavePermission(USER_PERMISSION.SHARES_ADMIN)this.galleryMode = this.btnNavigationView.currentView()this.supportUploadFolder = this.filesUpload.supportUploadDirectorythis.activatedRoute.queryParams.subscribe((params) => this.focusOn(params.select))@@ -325,7 +330,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroynext: (spacesFiles: SpaceFiles) => {this.spacePermissions = spacesFiles.permissionsthis.canManageFavorite = !this.store.user.getValue()?.isLink && !this.isTrashRepo- this.canShare.outside = this.spacePermissions.indexOf(SPACE_OPERATION.SHARE_OUTSIDE) > -1+ this.canShare.outside = this.canAdminShares && this.spacePermissions.indexOf(SPACE_OPERATION.SHARE_OUTSIDE) > -1// todo: share inside is not used, this should allow the file anchor dialog to add a personal file to the current space (?)this.canShare.inside = this.spacePermissions.indexOf(SPACE_OPERATION.SHARE_INSIDE) > -1this.hasRoots = spacesFiles.hasRootsdiff --git a/frontend/src/app/applications/spaces/components/spaces.component.html b/frontend/src/app/applications/spaces/components/spaces.component.htmlindex 1e468709..872329fc 100644--- a/frontend/src/app/applications/spaces/components/spaces.component.html+++ b/frontend/src/app/applications/spaces/components/spaces.component.html@@ -11,30 +11,34 @@<span class="app-top-menu-tool-bar__label" l10nTranslate>New space</span></button>}- <button (click)="openSpaceDialog()"- [attr.aria-label]="'Edit space' | translate:locale.language"- [disabled]="!canEditSpace"- class="btn btn-default app-top-menu-tool-bar__action--quiet"- type="button">- <svg [lucideIcon]="icons.LucidePencil"></svg>- <span class="app-top-menu-tool-bar__label" l10nTranslate>Edit space</span>- </button>- <button (click)="openChildShareDialog()"- [attr.aria-label]="'Edit children shares' | translate:locale.language"- [disabled]="!canEditSpace || !selected?.counts.shares"- class="btn btn-default"- [tooltip]="'Edit children shares' | translate:locale.language"- type="button">- <svg [lucideIcon]="icons.SHARES"></svg>- </button>- <button (click)="openSpaceRootsDialog()"- [attr.aria-label]="'Manage my anchored files' | translate:locale.language"- [disabled]="!canManageRoots"- class="btn btn-default"- [tooltip]="'Manage my anchored files' | translate:locale.language"- type="button">- <svg [lucideIcon]="icons.LucideAnchor"></svg>- </button>+ @if (canManageSpaces) {+ <button (click)="openSpaceDialog()"+ [attr.aria-label]="'Edit space' | translate:locale.language"+ [disabled]="!canEditSpace"+ class="btn btn-default app-top-menu-tool-bar__action--quiet"+ type="button">+ <svg [lucideIcon]="icons.LucidePencil"></svg>+ <span class="app-top-menu-tool-bar__label" l10nTranslate>Edit space</span>+ </button>+ <button (click)="openChildShareDialog()"+ [attr.aria-label]="'Edit children shares' | translate:locale.language"+ [disabled]="!canEditSpace || !selected?.counts.shares"+ class="btn btn-default"+ [tooltip]="'Edit children shares' | translate:locale.language"+ type="button">+ <svg [lucideIcon]="icons.SHARES"></svg>+ </button>+ }+ @if (canUsePersonalSpace) {+ <button (click)="openSpaceRootsDialog()"+ [attr.aria-label]="'Manage my anchored files' | translate:locale.language"+ [disabled]="!canManageRoots"+ class="btn btn-default"+ [tooltip]="'Manage my anchored files' | translate:locale.language"+ type="button">+ <svg [lucideIcon]="icons.LucideAnchor"></svg>+ </button>+ }<button (click)="loadSpaces()"[attr.aria-label]="'Refresh' | translate:locale.language"class="d-none d-md-block btn btn-default"diff --git a/frontend/src/app/applications/spaces/components/spaces.component.ts b/frontend/src/app/applications/spaces/components/spaces.component.tsindex 3780098e..4173a436 100644--- a/frontend/src/app/applications/spaces/components/spaces.component.ts+++ b/frontend/src/app/applications/spaces/components/spaces.component.ts@@ -134,7 +134,9 @@ export class SpacesComponent implements OnInit {protected selected: SpaceModel = nullprotected canCreateSpace = falseprotected canEditSpace = false+ protected canManageSpaces = falseprotected canManageRoots = false+ protected canUsePersonalSpace = falseprivate readonly router = inject(Router)private readonly activatedRoute = inject(ActivatedRoute)private readonly spacesService = inject(SpacesService)@@ -154,6 +156,8 @@ export class SpacesComponent implements OnInit {constructor() {this.loadSpaces()this.canCreateSpace = this.userService.userHavePermission(USER_PERMISSION.SPACES_ADMIN)+ this.canManageSpaces = this.userService.user.isUser+ this.canUsePersonalSpace = this.userService.userHavePermission(USER_PERMISSION.PERSONAL_SPACE)this.layout.setBreadcrumbIcon(SPACES_ICON.SPACES)this.layout.setBreadcrumbNav({ url: `/${SPACES_PATH.SPACES}/${SPACES_TITLE.COLLABORATIVE_SPACES}`, translating: true, sameLink: true })this.activatedRoute.queryParams.subscribe((params) => (this.focusOnSelect = params.select))@@ -196,7 +200,7 @@ export class SpacesComponent implements OnInit {if (space) {this.selected = spacethis.canEditSpace = !!space.managers.find((m: Member) => m.id === this.userService.user.id)- this.canManageRoots = this.canEditSpace || space.havePermission(SPACE_OPERATION.SHARE_INSIDE)+ this.canManageRoots = this.canUsePersonalSpace && (this.canEditSpace || space.havePermission(SPACE_OPERATION.SHARE_INSIDE))} else {this.selected = nullthis.canEditSpace = falsediff --git a/frontend/src/app/applications/spaces/services/spaces-browser.service.ts b/frontend/src/app/applications/spaces/services/spaces-browser.service.tsindex b92b1efd..9f07d504 100644--- a/frontend/src/app/applications/spaces/services/spaces-browser.service.ts+++ b/frontend/src/app/applications/spaces/services/spaces-browser.service.ts@@ -25,8 +25,8 @@ export class SpacesBrowserService {setEnvironment(repository: SPACE_REPOSITORY, routes: UrlSegment[]) {this.breadCrumbFilesRepo = SPACES_PATH.FILES === repository- this.inPersonalSpace = routes[0]?.path === SPACES_PATH.PERSONALthis.inShareRepo = repository === SPACES_PATH.SHARES+ this.inPersonalSpace = routes[0]?.path === SPACES_PATH.PERSONALthis.inRootShare = this.inShareRepo && routes.length === 0this.browseApi = buildUrlFromRoutes(`${API_SPACES_BROWSE}/${repository}`, routes, false)this.breadCrumbUrl = `/${SPACES_PATH.SPACES}/${repository}${pathFromRoutes(routes)}`