Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(frontend:admin): allow admins to see all users when selecting members in spaces and child shares

johavencba4eeb77523
diff --git a/frontend/src/app/applications/admin/admin.service.ts b/frontend/src/app/applications/admin/admin.service.ts
index 6d3830f5..82560aab 100644
--- a/frontend/src/app/applications/admin/admin.service.ts
+++ b/frontend/src/app/applications/admin/admin.service.ts
@@ -29,7 +29,7 @@ import type { GroupBrowse } from '@sync-in-server/backend/src/applications/users
import type { GuestUser } from '@sync-in-server/backend/src/applications/users/interfaces/guest-user.interface'
import type { Member } from '@sync-in-server/backend/src/applications/users/interfaces/member.interface'
import type { LoginResponseDto } from '@sync-in-server/backend/src/authentication/dto/login-response.dto'
-import { catchError, map, Observable } from 'rxjs'
+import { catchError, map, Observable, of } from 'rxjs'
import { AuthService } from '../../auth/auth.service'
import { SpaceModel } from '../spaces/models/space.model'
import { GroupBrowseModel } from '../users/models/group-browse.model'
@@ -44,6 +44,7 @@ import {
API_FILES_INDEXING_STOP
} from '@sync-in-server/backend/src/applications/files/constants/routes'
import type { IndexingStatus } from '@sync-in-server/backend/src/applications/files/interfaces/indexing.interface'
+import type { SPACE_OPERATION } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
@Injectable({
providedIn: 'root'
@@ -124,17 +125,10 @@ export class AdminService {
return this.http.delete<void>(`${API_ADMIN_GROUPS}/${groupId}/${ADMIN_USERS_ROUTE.USERS}/${userId}`)
}
- searchMembers(search: SearchMembersDto, removeDescription = false): Observable<MemberModel[]> {
+ searchMembers(search: SearchMembersDto, omitPermissions: SPACE_OPERATION[] = []): Observable<MemberModel[]> {
return this.http.request<Member[]>('search', API_ADMIN_MEMBERS, { body: search }).pipe(
- map((members: Member[]) =>
- members.map((m: Member) => {
- if (removeDescription) {
- delete m.description
- }
- return new MemberModel(m)
- })
- ),
- catchError(() => [])
+ map((members: Member[]) => members.map((m: Member) => new MemberModel(m, omitPermissions))),
+ catchError(() => of([]))
)
}
diff --git a/frontend/src/app/applications/admin/components/admin-spaces.component.ts b/frontend/src/app/applications/admin/components/admin-spaces.component.ts
index 8042e80b..c92ac03e 100644
--- a/frontend/src/app/applications/admin/components/admin-spaces.component.ts
+++ b/frontend/src/app/applications/admin/components/admin-spaces.component.ts
@@ -192,7 +192,9 @@ export class AdminSpacesComponent {
openSpaceDialog(add = false) {
if (add) {
- const modalRef: BsModalRef<SpaceDialogComponent> = this.layout.openDialog(SpaceDialogComponent, 'xl')
+ const modalRef: BsModalRef<SpaceDialogComponent> = this.layout.openDialog(SpaceDialogComponent, 'xl', {
+ initialState: { fromAdmin: true } as SpaceDialogComponent
+ })
modalRef.content.spaceChange.pipe(take(1)).subscribe((r: ['add' | string, SpaceModel]) => {
const [action, s] = r
if (action === 'add') {
@@ -204,7 +206,7 @@ export class AdminSpacesComponent {
this.spacesService.getSpace(this.selected.id).subscribe({
next: (space: SpaceModel) => {
const modalRef: BsModalRef<SpaceDialogComponent> = this.layout.openDialog(SpaceDialogComponent, 'xl', {
- initialState: { space: space } as SpaceDialogComponent
+ initialState: { space: space, fromAdmin: true } as SpaceDialogComponent
})
modalRef.content.spaceChange.pipe(take(1)).subscribe((r: ['update' | 'delete' | string, SpaceModel]) => {
const [action, s] = r
@@ -237,7 +239,7 @@ export class AdminSpacesComponent {
openChildShareDialog(space?: SpaceModel) {
if (space) this.onSelect(space)
const modalRef: BsModalRef<SharedChildrenDialogComponent> = this.layout.openDialog(SharedChildrenDialogComponent, null, {
- initialState: { space: this.selected } as SharedChildrenDialogComponent
+ initialState: { space: this.selected, fromAdmin: true } as SharedChildrenDialogComponent
})
modalRef.content.sharesCountEvent.subscribe((sharesCount: number) => (this.selected.counts.shares = sharesCount))
}
diff --git a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts
index 30be957f..91b7e260 100644
--- a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts
+++ b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts
@@ -1,5 +1,5 @@
import { HttpErrorResponse } from '@angular/common/http'
-import { Component, EventEmitter, inject, Input, OnInit, Output } from '@angular/core'
+import { Component, EventEmitter, inject, Injector, Input, OnInit, Output } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
import { faCog, faPlus, faSpinner, faUsers, faUserShield } from '@fortawesome/free-solid-svg-icons'
@@ -33,6 +33,9 @@ import { ShareModel } from '../../models/share.model'
import { SharesService } from '../../services/shares.service'
import { ShareFileNameComponent } from '../utils/share-file-name.component'
import { ShareRepositoryComponent } from '../utils/share-repository.component'
+import { StoreService } from '../../../../store/store.service'
+import { UserType } from '../../../users/interfaces/user.interface'
+import { AdminService } from '../../../admin/admin.service'
@Component({
selector: 'app-share-dialog',
@@ -61,6 +64,7 @@ export class ShareDialogComponent implements OnInit {
@Input() isSharesRepo = false
@Input() inSharesList = false
@Input() allowFilesOptions = true
+ @Input() fromAdmin = false
@Output() shareChange = new EventEmitter<['add' | 'update' | 'delete', ShareModel]>()
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
protected readonly layout = inject(LayoutService)
@@ -79,13 +83,16 @@ export class ShareDialogComponent implements OnInit {
protected confirmDeletion = false
protected loading = false
protected submitted = false
- private readonly userService = inject(UserService)
- protected readonly user = this.userService.user
+ private readonly injector = inject(Injector)
+ private memberSearchService!: Pick<UserService, 'searchMembers'> | Pick<AdminService, 'searchMembers'>
+ private readonly store = inject(StoreService)
private readonly sharesService = inject(SharesService)
private readonly linksService = inject(LinksService)
private readonly spacesService = inject(SpacesService)
+ protected readonly user: UserType = this.store.user.getValue()
ngOnInit() {
+ this.memberSearchService = this.fromAdmin ? this.injector.get(AdminService) : this.injector.get(UserService)
if (!this.share) {
// new share
;[this.share, this.parentShareId] = this.sharesService.initShareFromFile(this.user, this.file, this.isSharesRepo, this.inSharesList)
@@ -103,7 +110,7 @@ export class ShareDialogComponent implements OnInit {
],
ignoreGroupIds: this.share.members.filter((m: MemberModel) => m.isGroup).map((m: MemberModel) => m.id)
}
- return this.userService.searchMembers(search, [SPACE_OPERATION.SHARE_INSIDE])
+ return this.memberSearchService.searchMembers(search, [SPACE_OPERATION.SHARE_INSIDE])
}
openSelectRootDialog() {
diff --git a/frontend/src/app/applications/shares/components/dialogs/shared-children-dialog.component.ts b/frontend/src/app/applications/shares/components/dialogs/shared-children-dialog.component.ts
index bdd9c04b..c91b2ac5 100644
--- a/frontend/src/app/applications/shares/components/dialogs/shared-children-dialog.component.ts
+++ b/frontend/src/app/applications/shares/components/dialogs/shared-children-dialog.component.ts
@@ -29,9 +29,9 @@ import { ShareDialogComponent } from './share-dialog.component'
styleUrls: ['shared-children-dialog.component.scss']
})
export class SharedChildrenDialogComponent implements OnInit {
- @Input() fromAdmin = false
@Input() share: ShareFileModel
@Input() space: SpaceModel
+ @Input() fromAdmin = false
@Output() sharesCountEvent = new EventEmitter<number>()
protected readonly layout = inject(LayoutService)
protected readonly icons = { SHARED: SPACES_ICON.SHARED_WITH_OTHERS, LINKS: SPACES_ICON.LINKS }
@@ -126,7 +126,8 @@ export class SharedChildrenDialogComponent implements OnInit {
initialState: {
...(this.share ? { parentShareId: this.share.id } : {}),
...(this.space ? { parentSpaceId: this.space.id } : {}),
- share: share
+ share: share,
+ fromAdmin: this.fromAdmin
} as ShareDialogComponent
})
modalRef.content.shareChange.pipe(take(1)).subscribe((r: ['update' | 'delete' | string, ShareModel]) => {
diff --git a/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts b/frontend/src/app/applications/spaces/components/dialogs/space-dialog.component.ts
index 153d0862..4db77126 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
@@ -1,5 +1,5 @@
import { HttpErrorResponse } from '@angular/common/http'
-import { Component, EventEmitter, inject, Input, OnInit, Output } from '@angular/core'
+import { Component, EventEmitter, inject, Injector, Input, OnInit, Output } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
import { faAnchor, faCog, faPen, faPlus, faSpinner, faUsers, faUserShield } from '@fortawesome/free-solid-svg-icons'
@@ -32,6 +32,8 @@ import { SpacesService } from '../../services/spaces.service'
import { SPACES_ICON } from '../../spaces.constants'
import { SpaceManageRootsComponent } from '../utils/space-manage-roots.component'
import { ExternalFilePathEvent, SpaceRootPathDialogComponent } from './space-root-path-dialog.component'
+import { StoreService } from '../../../../store/store.service'
+import { AdminService } from '../../../admin/admin.service'
@Component({
selector: 'app-space-dialog',
@@ -61,6 +63,7 @@ export class SpaceDialogComponent implements OnInit {
storageUsage: 0,
storageQuota: null
} as SpaceProps)
+ @Input() fromAdmin = false
@Output() spaceChange = new EventEmitter<['add' | 'update' | 'delete', SpaceModel]>()
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
protected readonly layout = inject(LayoutService)
@@ -84,12 +87,15 @@ export class SpaceDialogComponent implements OnInit {
protected confirmDeletion = false
protected loading = false
protected submitted = false
- private readonly userService = inject(UserService)
- protected readonly user: UserType = this.userService.user
+ private readonly injector = inject(Injector)
+ private memberSearchService!: Pick<UserService, 'searchMembers'> | Pick<AdminService, 'searchMembers'>
+ private readonly store = inject(StoreService)
private readonly spacesService = inject(SpacesService)
private readonly linksService = inject(LinksService)
+ protected readonly user: UserType = this.store.user.getValue()
ngOnInit() {
+ this.memberSearchService = this.fromAdmin ? this.injector.get(AdminService) : this.injector.get(UserService)
if (!this.space.id) {
this.space.managers.unshift(ownerToMember(this.user, SPACE_ROLE.IS_MANAGER))
}
@@ -104,7 +110,7 @@ export class SpaceDialogComponent implements OnInit {
],
onlyUsers: true
}
- return this.userService.searchMembers(search)
+ return this.memberSearchService.searchMembers(search)
}
searchMembers(query: string): Observable<MemberModel[]> {
@@ -116,7 +122,7 @@ export class SpaceDialogComponent implements OnInit {
],
ignoreGroupIds: this.space.members.filter((m: MemberModel) => m.isGroup).map((m: MemberModel) => m.id)
}
- return this.userService.searchMembers(search)
+ return this.memberSearchService.searchMembers(search)
}
openSelectRootDialog() {
diff --git a/frontend/src/app/applications/users/user.service.ts b/frontend/src/app/applications/users/user.service.ts
index 1d81a602..3e7970fa 100644
--- a/frontend/src/app/applications/users/user.service.ts
+++ b/frontend/src/app/applications/users/user.service.ts
@@ -54,7 +54,7 @@ import type {
} from '@sync-in-server/backend/src/authentication/providers/two-fa/auth-two-fa.interfaces'
import { BsModalRef } from 'ngx-bootstrap/modal'
import { Socket } from 'ngx-socket-io'
-import { catchError, map, Observable } from 'rxjs'
+import { catchError, map, Observable, of } from 'rxjs'
import { AppMenu } from '../../layout/layout.interfaces'
import { LayoutService } from '../../layout/layout.service'
import { StoreService } from '../../store/store.service'
@@ -258,7 +258,7 @@ export class UserService {
searchMembers(search: SearchMembersDto, omitPermissions: SPACE_OPERATION[] = []): Observable<MemberModel[]> {
return this.http.request<Member[]>('search', USERS_ROUTE.BASE, { body: search }).pipe(
map((members: Member[]) => members.map((m: Member) => new MemberModel(m, omitPermissions))),
- catchError(() => [])
+ catchError(() => of([]))
)
}