Skip to content

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

feat(frontend): display space and share names (#256)

Johan Legrand612eae4f632f
diff --git a/backend/src/applications/comments/interfaces/comment-recent.interface.ts b/backend/src/applications/comments/interfaces/comment-recent.interface.ts
index ee1ede1c..3a306129 100644
--- a/backend/src/applications/comments/interfaces/comment-recent.interface.ts
+++ b/backend/src/applications/comments/interfaces/comment-recent.interface.ts
@@ -5,5 +5,5 @@ export interface CommentRecent {
content: string
modifiedAt: Date
author: Owner
- file: { name: string; path: string; mime: string; inTrash: number; fromSpace: number; fromShare: number }
+ file: { name: string; path: string; mime: string; inTrash: number; fromSpace: number; fromShare: number; displayRootName?: string }
}
diff --git a/backend/src/applications/comments/services/comments-queries.service.ts b/backend/src/applications/comments/services/comments-queries.service.ts
index d9fff60c..b89ec4d9 100644
--- a/backend/src/applications/comments/services/comments-queries.service.ts
+++ b/backend/src/applications/comments/services/comments-queries.service.ts
@@ -118,7 +118,8 @@ export class CommentsQueries {
mime: files.mime,
inTrash: sql<number>`0`.as('inTrash'),
fromSpace: sql<number>`0`.as('fromSpace'),
- fromShare: sql<number>`1`.as('fromShare')
+ fromShare: sql<number>`1`.as('fromShare'),
+ displayRootName: shares.name
}
} satisfies CommentRecent | SelectedFields<any, any>)
.from(shares)
@@ -204,7 +205,8 @@ export class CommentsQueries {
mime: files.mime,
inTrash: sql<number>`${files.inTrash}`.as('inTrash'),
fromSpace: sql<number>`IF (${files.ownerId} = ${userId}, 0, 1)`.as('fromSpace'),
- fromShare: sql<number>`0`.as('fromShare')
+ fromShare: sql<number>`0`.as('fromShare'),
+ displayRootName: sql<string>`IF (${files.ownerId} = ${userId}, NULL, ${spaces.name})`.as('displayRootName')
}
} satisfies CommentRecent | SelectedFields<any, any>)
.from(spaces)
@@ -236,10 +238,12 @@ export class CommentsQueries {
async getRecentsFromUser(user: UserModel, limit = 10): Promise<CommentRecent[]> {
const hasPersonal = user.havePermission(USER_PERMISSION.PERSONAL_SPACE)
- const [spaceIds, shareIds] = await Promise.all([
- user.havePermission(USER_PERMISSION.SPACES) ? this.spacesQueries.spaceIds(user.id) : Promise.resolve([]),
- user.havePermission(USER_PERMISSION.SHARES) ? this.sharesQueries.shareIds(user.id, +user.isAdmin) : Promise.resolve([])
+ const [spaces, shares] = await Promise.all([
+ user.havePermission(USER_PERMISSION.SPACES) ? this.spacesQueries.spaceIdentities(user.id) : Promise.resolve([]),
+ user.havePermission(USER_PERMISSION.SHARES) ? this.sharesQueries.shareIdentities(user.id, +user.isAdmin) : Promise.resolve([])
])
+ const spaceIds = spaces.map(({ id }) => id)
+ const shareIds = shares.map(({ id }) => id)
const hasSpaces = spaceIds.length > 0
const hasShares = shareIds.length > 0
const sourceCount = +hasPersonal + +hasSpaces + +hasShares
diff --git a/backend/src/applications/files/schemas/file-content.interface.ts b/backend/src/applications/files/schemas/file-content.interface.ts
index 12695f93..7c28a565 100644
--- a/backend/src/applications/files/schemas/file-content.interface.ts
+++ b/backend/src/applications/files/schemas/file-content.interface.ts
@@ -11,6 +11,8 @@ export interface FileContent {
matches?: string[]
// used for search
score?: number
+ // used for search display
+ displayRootName?: string
}
export type FileContentRecordMetadata = Pick<FileContent, 'name' | 'path' | 'size'>
diff --git a/backend/src/applications/files/schemas/file-recent.interface.ts b/backend/src/applications/files/schemas/file-recent.interface.ts
index 984647f9..d0a4c6d4 100644
--- a/backend/src/applications/files/schemas/file-recent.interface.ts
+++ b/backend/src/applications/files/schemas/file-recent.interface.ts
@@ -12,6 +12,7 @@ export class FileRecent implements FileRecentSchema {
name: string
mime: string
mtime: number
+ displayRootName?: string
}
export interface FileRecentLocation {
diff --git a/backend/src/applications/files/services/files-queries.service.ts b/backend/src/applications/files/services/files-queries.service.ts
index 9cb34502..f84296c2 100644
--- a/backend/src/applications/files/services/files-queries.service.ts
+++ b/backend/src/applications/files/services/files-queries.service.ts
@@ -297,9 +297,12 @@ export class FilesQueries {
path: filesRecents.path,
name: filesRecents.name,
mime: filesRecents.mime,
- mtime: filesRecents.mtime
+ mtime: filesRecents.mtime,
+ displayRootName: sql<string>`COALESCE(${spaces.name}, ${shares.name})`.as('displayRootName')
} satisfies FileRecent | SelectedFields<any, any>)
.from(filesRecents)
+ .leftJoin(spaces, eq(spaces.id, filesRecents.spaceId))
+ .leftJoin(shares, eq(shares.id, filesRecents.shareId))
.where(or(...where))
.groupBy(filesRecents.id)
.orderBy(desc(filesRecents.mtime))
diff --git a/backend/src/applications/files/services/files-recents.service.spec.ts b/backend/src/applications/files/services/files-recents.service.spec.ts
index d94b30be..14c3a32e 100644
--- a/backend/src/applications/files/services/files-recents.service.spec.ts
+++ b/backend/src/applications/files/services/files-recents.service.spec.ts
@@ -21,10 +21,10 @@ describe(FilesRecents.name, () => {
upsertRecent: Mock
}
let spacesQueries: {
- spaceIds: Mock
+ spaceIdentities: Mock
}
let sharesQueries: {
- shareIds: Mock
+ shareIdentities: Mock
}
beforeEach(async () => {
@@ -38,10 +38,10 @@ describe(FilesRecents.name, () => {
upsertRecent: vi.fn().mockResolvedValue(undefined)
}
spacesQueries = {
- spaceIds: vi.fn().mockResolvedValue([])
+ spaceIdentities: vi.fn().mockResolvedValue([])
}
sharesQueries = {
- shareIds: vi.fn().mockResolvedValue([])
+ shareIdentities: vi.fn().mockResolvedValue([])
}
const module: TestingModule = await Test.createTestingModule({
providers: [
@@ -74,8 +74,11 @@ describe(FilesRecents.name, () => {
it('should load recents from user accessible spaces and shares', async () => {
const recents = [{ id: 1, name: 'a.txt' }]
- spacesQueries.spaceIds.mockResolvedValueOnce([10, 11])
- sharesQueries.shareIds.mockResolvedValueOnce([20])
+ spacesQueries.spaceIdentities.mockResolvedValueOnce([
+ { id: 10, alias: 'first', name: 'First' },
+ { id: 11, alias: 'second', name: 'Second' }
+ ])
+ sharesQueries.shareIdentities.mockResolvedValueOnce([{ id: 20, alias: 'shared', name: 'Shared' }])
filesQueries.getRecentsFromUser.mockResolvedValueOnce(recents)
const result = await service.getRecents(
@@ -83,8 +86,8 @@ describe(FilesRecents.name, () => {
25
)
- expect(spacesQueries.spaceIds).toHaveBeenCalledWith(7)
- expect(sharesQueries.shareIds).toHaveBeenCalledWith(7, 1)
+ expect(spacesQueries.spaceIdentities).toHaveBeenCalledWith(7)
+ expect(sharesQueries.shareIdentities).toHaveBeenCalledWith(7, 1)
expect(filesQueries.getRecentsFromUser).toHaveBeenCalledWith(7, [10, 11], [20], 25)
expect(result).toBe(recents)
})
@@ -92,36 +95,36 @@ describe(FilesRecents.name, () => {
it('should only load personal recents when user only has personal space permission', async () => {
await service.getRecents(userWithPermissions([USER_PERMISSION.PERSONAL_SPACE]), 10)
- expect(spacesQueries.spaceIds).not.toHaveBeenCalled()
- expect(sharesQueries.shareIds).not.toHaveBeenCalled()
+ expect(spacesQueries.spaceIdentities).not.toHaveBeenCalled()
+ expect(sharesQueries.shareIdentities).not.toHaveBeenCalled()
expect(filesQueries.getRecentsFromUser).toHaveBeenCalledWith(7, [], [], 10)
})
it('should only load space recents when user only has spaces permission', async () => {
- spacesQueries.spaceIds.mockResolvedValueOnce([10])
+ spacesQueries.spaceIdentities.mockResolvedValueOnce([{ id: 10, alias: 'space', name: 'Space' }])
await service.getRecents(userWithPermissions([USER_PERMISSION.SPACES]), 10)
- expect(spacesQueries.spaceIds).toHaveBeenCalledWith(7)
- expect(sharesQueries.shareIds).not.toHaveBeenCalled()
+ expect(spacesQueries.spaceIdentities).toHaveBeenCalledWith(7)
+ expect(sharesQueries.shareIdentities).not.toHaveBeenCalled()
expect(filesQueries.getRecentsFromUser).toHaveBeenCalledWith(undefined, [10], [], 10)
})
it('should only load share recents when user only has shares permission', async () => {
- sharesQueries.shareIds.mockResolvedValueOnce([20])
+ sharesQueries.shareIdentities.mockResolvedValueOnce([{ id: 20, alias: 'share', name: 'Share' }])
await service.getRecents(userWithPermissions([USER_PERMISSION.SHARES]), 10)
- expect(spacesQueries.spaceIds).not.toHaveBeenCalled()
- expect(sharesQueries.shareIds).toHaveBeenCalledWith(7, 0)
+ expect(spacesQueries.spaceIdentities).not.toHaveBeenCalled()
+ expect(sharesQueries.shareIdentities).toHaveBeenCalledWith(7, 0)
expect(filesQueries.getRecentsFromUser).toHaveBeenCalledWith(undefined, [], [20], 10)
})
it('should not load any recents source without matching permission', async () => {
await service.getRecents(userWithPermissions(), 10)
- expect(spacesQueries.spaceIds).not.toHaveBeenCalled()
- expect(sharesQueries.shareIds).not.toHaveBeenCalled()
+ expect(spacesQueries.spaceIdentities).not.toHaveBeenCalled()
+ expect(sharesQueries.shareIdentities).not.toHaveBeenCalled()
expect(filesQueries.getRecentsFromUser).toHaveBeenCalledWith(undefined, [], [], 10)
})
diff --git a/backend/src/applications/files/services/files-recents.service.ts b/backend/src/applications/files/services/files-recents.service.ts
index 534696e3..0f55372a 100644
--- a/backend/src/applications/files/services/files-recents.service.ts
+++ b/backend/src/applications/files/services/files-recents.service.ts
@@ -23,12 +23,17 @@ export class FilesRecents {
) {}
async getRecents(user: UserModel, limit: number): Promise<FileRecent[]> {
- const [spaceIds, shareIds] = await Promise.all([
- user.havePermission(USER_PERMISSION.SPACES) ? this.spacesQueries.spaceIds(user.id) : Promise.resolve([]),
- user.havePermission(USER_PERMISSION.SHARES) ? this.sharesQueries.shareIds(user.id, +user.isAdmin) : Promise.resolve([])
+ const [spaces, shares] = await Promise.all([
+ user.havePermission(USER_PERMISSION.SPACES) ? this.spacesQueries.spaceIdentities(user.id) : Promise.resolve([]),
+ user.havePermission(USER_PERMISSION.SHARES) ? this.sharesQueries.shareIdentities(user.id, +user.isAdmin) : Promise.resolve([])
])
const ownerId = user.havePermission(USER_PERMISSION.PERSONAL_SPACE) ? user.id : undefined
- return this.filesQueries.getRecentsFromUser(ownerId, spaceIds, shareIds, limit)
+ return this.filesQueries.getRecentsFromUser(
+ ownerId,
+ spaces.map(({ id }) => id),
+ shares.map(({ id }) => id),
+ limit
+ )
}
async updateRecents(user: UserModel, space: SpaceEnv, files: FileProps[]): Promise<void> {
diff --git a/backend/src/applications/files/services/files-search-manager.service.spec.ts b/backend/src/applications/files/services/files-search-manager.service.spec.ts
index 309ec916..abae101a 100644
--- a/backend/src/applications/files/services/files-search-manager.service.spec.ts
+++ b/backend/src/applications/files/services/files-search-manager.service.spec.ts
@@ -20,10 +20,10 @@ describe(FilesSearchManager.name, () => {
allPaths: Mock
}
let spacesQueries: {
- spaceIds: Mock
+ spaceIdentities: Mock
}
let sharesQueries: {
- shareIds: Mock
+ shareIdentities: Mock
}
let contentIndexingEnabled: boolean
@@ -45,10 +45,10 @@ describe(FilesSearchManager.name, () => {
allPaths: vi.fn()
}
spacesQueries = {
- spaceIds: vi.fn().mockResolvedValue([])
+ spaceIdentities: vi.fn().mockResolvedValue([])
}
sharesQueries = {
- shareIds: vi.fn().mockResolvedValue([])
+ shareIdentities: vi.fn().mockResolvedValue([])
}
const module: TestingModule = await Test.createTestingModule({
providers: [
@@ -88,21 +88,27 @@ describe(FilesSearchManager.name, () => {
it('should route to full-text search with space and share ids', async () => {
configuration.applications.files.contentIndexing.enabled = true
- spacesQueries.spaceIds.mockResolvedValueOnce([1, 2])
- sharesQueries.shareIds.mockResolvedValueOnce([4])
+ spacesQueries.spaceIdentities.mockResolvedValueOnce([
+ { id: 1, alias: 'first', name: 'First' },
+ { id: 2, alias: 'second', name: 'Second' }
+ ])
+ sharesQueries.shareIdentities.mockResolvedValueOnce([{ id: 4, alias: 'shared', name: 'Shared' }])
const fullTextSpy = vi.spyOn(service as any, 'searchFullText').mockResolvedValueOnce([fileContent('match.md')])
const result = await service.search({ id: 10, isAdmin: true } as any, { content: 'match', fullText: true, limit: 5 } as any)
- expect(spacesQueries.spaceIds).toHaveBeenCalledWith(10)
- expect(sharesQueries.shareIds).toHaveBeenCalledWith(10, 1)
+ expect(spacesQueries.spaceIdentities).toHaveBeenCalledWith(10)
+ expect(sharesQueries.shareIdentities).toHaveBeenCalledWith(10, 1)
expect(fullTextSpy).toHaveBeenCalledWith(10, [1, 2], [4], 'match', 5)
expect(result).toEqual([fileContent('match.md')])
})
it('should route to filename search when fullText is false', async () => {
- spacesQueries.spaceIds.mockResolvedValueOnce([6])
- sharesQueries.shareIds.mockResolvedValueOnce([8, 9])
+ spacesQueries.spaceIdentities.mockResolvedValueOnce([{ id: 6, alias: 'reports', name: 'Reports' }])
+ sharesQueries.shareIdentities.mockResolvedValueOnce([
+ { id: 8, alias: 'first-share', name: 'First share' },
+ { id: 9, alias: 'second-share', name: 'Second share' }
+ ])
const nameSearchSpy = vi.spyOn(service as any, 'searchFileNames').mockResolvedValueOnce([fileContent('report.pdf')])
const result = await service.search({ id: 3, isAdmin: false } as any, { content: 'report', fullText: false, limit: 2 } as any)
@@ -111,6 +117,20 @@ describe(FilesSearchManager.name, () => {
expect(result).toEqual([fileContent('report.pdf')])
})
+ it('adds current space and share names to search results', async () => {
+ spacesQueries.spaceIdentities.mockResolvedValueOnce([{ id: 6, alias: 'communication', name: 'Communication' }])
+ sharesQueries.shareIdentities.mockResolvedValueOnce([{ id: 8, alias: 'public-access', name: 'Public access' }])
+ vi.spyOn(service as any, 'searchFileNames').mockResolvedValueOnce([
+ { ...fileContent('space.md'), path: 'files/communication/docs' },
+ { ...fileContent('share.md'), path: 'shares/public-access/docs' },
+ { ...fileContent('personal.md'), path: 'files/personal/docs' }
+ ])
+
+ const result = await service.search({ id: 3, isAdmin: false } as any, { content: 'docs', fullText: false, limit: 3 } as any)
+
+ expect(result.map(({ displayRootName }) => displayRootName)).toEqual(['Communication', 'Public access', undefined])
+ })
+
it('should normalize search limit before routing', async () => {
const nameSearchSpy = vi.spyOn(service as any, 'searchFileNames').mockResolvedValue([])
diff --git a/backend/src/applications/files/services/files-search-manager.service.ts b/backend/src/applications/files/services/files-search-manager.service.ts
index c605c4da..616d1044 100644
--- a/backend/src/applications/files/services/files-search-manager.service.ts
+++ b/backend/src/applications/files/services/files-search-manager.service.ts
@@ -4,6 +4,7 @@ import { Stats } from 'node:fs'
import path from 'node:path'
import { configuration } from '../../../configuration/config.environment'
import { SharesQueries } from '../../shares/services/shares-queries.service'
+import { SPACE_REPOSITORY } from '../../spaces/constants/spaces'
import { SpacesQueries } from '../../spaces/services/spaces-queries.service'
import { UserModel } from '../../users/models/user.model'
import { SearchFilesDto } from '../dto/file-operations.dto'
@@ -32,12 +33,16 @@ export class FilesSearchManager {
throw new HttpException('Full-text search is disabled', HttpStatus.BAD_REQUEST)
}
const limit = normalizeSearchLimit(search.limit)
- const [spaceIds, shareIds] = await Promise.all([this.spacesQueries.spaceIds(user.id), this.sharesQueries.shareIds(user.id, +user.isAdmin)])
- if (search.fullText) {
- return await this.searchFullText(user.id, spaceIds, shareIds, search.content, limit)
- } else {
- return await this.searchFileNames(user.id, spaceIds, shareIds, search.content, limit)
- }
+ const [userSpaces, userShares] = await Promise.all([
+ this.spacesQueries.spaceIdentities(user.id),
+ this.sharesQueries.shareIdentities(user.id, +user.isAdmin)
+ ])
+ const spaceIds = userSpaces.map((space) => space.id)
+ const shareIds = userShares.map((share) => share.id)
+ const fileContents = await (search.fullText
+ ? this.searchFullText(user.id, spaceIds, shareIds, search.content, limit)
+ : this.searchFileNames(user.id, spaceIds, shareIds, search.content, limit))
+ return this.setDisplayRootNames(fileContents, userSpaces, userShares)
}
private async searchFullText(userId: number, spaceIds: number[], shareIds: number[], search: string, limit: number): Promise<FileContent[]> {
@@ -73,6 +78,7 @@ export class FilesSearchManager {
const f = await this.analyzeFile(p.realPath, p.pathPrefix, regexBasePath, regexpTerms)
if (f !== null) {
fileContents.push(f)
+ if (fileContents.length >= limit) return fileContents
}
continue
}
@@ -117,4 +123,25 @@ export class FilesSearchManager {
mtime: stats.mtime.getTime()
}
}
+
+ private setDisplayRootNames(
+ fileContents: FileContent[],
+ userSpaces: { alias?: string; name?: string }[],
+ userShares: { alias?: string; name?: string }[]
+ ): FileContent[] {
+ if (fileContents.length === 0) return fileContents
+ const displayRootNames = new Map<string, string>()
+ for (const { alias, name } of userSpaces) {
+ if (alias && name) displayRootNames.set(`${SPACE_REPOSITORY.FILES}/${alias}`, name)
+ }
+ for (const { alias, name } of userShares) {
+ if (alias && name) displayRootNames.set(`${SPACE_REPOSITORY.SHARES}/${alias}`, name)
+ }
+ for (const fileContent of fileContents) {
+ const [repository, alias] = fileContent.path.split('/', 2)
+ const displayRootName = displayRootNames.get(`${repository}/${alias}`)
+ if (displayRootName) fileContent.displayRootName = displayRootName
+ }
+ return fileContents
+ }
}
diff --git a/backend/src/applications/shares/services/shares-manager.service.spec.ts b/backend/src/applications/shares/services/shares-manager.service.spec.ts
index b1b6450a..3b98bfc4 100644
--- a/backend/src/applications/shares/services/shares-manager.service.spec.ts
+++ b/backend/src/applications/shares/services/shares-manager.service.spec.ts
@@ -96,6 +96,7 @@ describe(SharesManager.name, () => {
updateMembers: vi.fn(),
shareExistsForOwner: vi.fn(),
childExistsForShareOwner: vi.fn(),
+ clearCacheIdentities: vi.fn().mockResolvedValue(true),
clearCachePermissions: vi.fn().mockResolvedValue(true)
}
diff --git a/backend/src/applications/shares/services/shares-manager.service.ts b/backend/src/applications/shares/services/shares-manager.service.ts
index 53b2ee64..e453c157 100644
--- a/backend/src/applications/shares/services/shares-manager.service.ts
+++ b/backend/src/applications/shares/services/shares-manager.service.ts
@@ -234,12 +234,14 @@ export class SharesManager {
// asAdmin: true if the user is the owner of the parent share or if the share is requested from the administration
const share: ShareProps = await this.getShareWithMembers(user, shareId, asAdmin)
// check and update share info
+ let renamedShareAlias: string
const shareDiffProps: Partial<ShareProps> = { modifiedAt: new Date() }
const props: (keyof CreateOrUpdateShareDto)[] = ['name', 'description', 'enabled', 'storageQuota', 'storageIndexing']
for (const prop of props) {
if (createOrUpdateShareDto[prop] !== share[prop]) {
shareDiffProps[prop] = createOrUpdateShareDto[prop]
if (prop === 'name') {
+ renamedShareAlias = share.alias
shareDiffProps.alias = await this.sharesQueries.uniqueShareAlias(shareDiffProps.name)
} else if (prop === 'enabled') {
shareDiffProps.disabledAt = shareDiffProps[prop] ? null : new Date()
@@ -250,6 +252,9 @@ export class SharesManager {
if (!(await this.sharesQueries.updateShare(shareId, shareDiffProps))) {
throw new HttpException('Unable to update share', HttpStatus.INTERNAL_SERVER_ERROR)
}
+ if (renamedShareAlias) {
+ void this.sharesQueries.clearCachePermissions(renamedShareAlias)
+ }
// update quota in cache
if ('storageQuota' in shareDiffProps) {
void this.filesQuotaManager.updateStorageQuota(shareId, FILE_REPOSITORY.SHARE, shareDiffProps.storageQuota)
@@ -683,6 +688,9 @@ export class SharesManager {
}
try {
await this.linksQueries.updateLinkFromSpaceOrShare(link, spaceOrShareId, updateUser, updateLink, updateShare, updateMember)
+ if ('name' in updateShare) {
+ void this.sharesQueries.clearCacheIdentities()
+ }
this.logger.debug({
tag: this.updateLinkFromSpaceOrShare.name,
msg: `link (${linkId}) updated : ${JSON.stringify({
diff --git a/backend/src/applications/shares/services/shares-queries.service.ts b/backend/src/applications/shares/services/shares-queries.service.ts
index cc236b5d..5d68c26b 100644
--- a/backend/src/applications/shares/services/shares-queries.service.ts
+++ b/backend/src/applications/shares/services/shares-queries.service.ts
@@ -52,7 +52,7 @@ import { shares } from '../schemas/shares.schema'
export class SharesQueries {
private readonly logger = new Logger(SharesQueries.name)
private sharesListQuery: MySql2PreparedQuery<any> = null
- private shareIdsQuery: MySql2PreparedQuery<any> = null
+ private shareIdentitiesQuery: MySql2PreparedQuery<any> = null
private shareLinksListQuery: MySql2PreparedQuery<any> = null
private shareWithMembersQuery: MySql2PreparedQuery<any> = null
private sharePermissionsQuery: MySql2PreparedQuery<any> = null
@@ -473,16 +473,17 @@ export class SharesQueries {
}
@CacheDecorator()
- async shareIds(userId: number, isAdmin: number): Promise<number[]> {
- if (!this.shareIdsQuery) {
- const unionAlias = union(
- this.fromUserQuery({ id: shares.id }),
- this.fromGroupsQuery({ id: shares.id }),
- this.fromAdminSharesQuery({ id: shares.id })
- ).as('unionAlias')
- this.shareIdsQuery = this.db.select({ id: unionAlias.id }).from(unionAlias).groupBy(unionAlias.id).prepare()
+ async shareIdentities(userId: number, isAdmin: number): Promise<Pick<Share, 'id' | 'alias' | 'name'>[]> {
+ if (!this.shareIdentitiesQuery) {
+ const select = { id: shares.id, alias: shares.alias, name: shares.name }
+ const unionAlias = union(this.fromUserQuery(select), this.fromGroupsQuery(select), this.fromAdminSharesQuery(select)).as('unionAlias')
+ this.shareIdentitiesQuery = this.db
+ .select({ id: unionAlias.id, alias: unionAlias.alias, name: unionAlias.name })
+ .from(unionAlias)
+ .groupBy(unionAlias.id, unionAlias.alias, unionAlias.name)
+ .prepare()
}
- return (await this.shareIdsQuery.execute({ userId: userId, isAdmin: +isAdmin })).map((r: { id: number }) => r.id)
+ return this.shareIdentitiesQuery.execute({ userId: userId, isAdmin: +isAdmin })
}
async listShares(user: UserModel): Promise<ShareFile[]> {
@@ -898,9 +899,21 @@ export class SharesQueries {
return r.length ? r[0].count : 0
}
- async clearCachePermissions(shareAlias: string, userIds: number[]) {
+ async clearCacheIdentities(userIds?: number[]) {
+ for (const userId of userIds ?? ['*']) {
+ const pattern = this.cache.genSlugKey(this.constructor.name, this.shareIdentities.name, userId, '*')
+ const keys = await this.cache.keys(pattern)
+ if (keys.length) {
+ this.logger.verbose({ tag: this.clearCacheIdentities.name, msg: `${JSON.stringify(keys)}` })
+ this.cache.mdel(keys).catch((e: Error) => this.logger.error({ tag: this.clearCacheIdentities.name, msg: `${e}` }))
+ }
+ }
+ }
+
+ async clearCachePermissions(shareAlias: string, userIds?: number[]) {
// `permissions` argument must match with `this.permissions.name` function
- for (const userId of userIds) {
+ await this.clearCacheIdentities(userIds)
+ for (const userId of userIds ?? ['*']) {
const pattern = this.cache.genSlugKey(this.constructor.name, this.permissions.name, userId, shareAlias, '*')
const keys = await this.cache.keys(pattern)
if (keys.length) {
diff --git a/backend/src/applications/spaces/interfaces/space-files.interface.ts b/backend/src/applications/spaces/interfaces/space-files.interface.ts
index 752f347a..bf748b54 100644
--- a/backend/src/applications/spaces/interfaces/space-files.interface.ts
+++ b/backend/src/applications/spaces/interfaces/space-files.interface.ts
@@ -1,6 +1,10 @@
import type { FileProps } from '../../files/interfaces/file-props.interface'
export interface SpaceFiles {
+ space: {
+ alias: string
+ name: string
+ }
files: FileProps[]
hasRoots: boolean
permissions: string
diff --git a/backend/src/applications/spaces/services/spaces-browser.service.spec.ts b/backend/src/applications/spaces/services/spaces-browser.service.spec.ts
index b16dffea..442b5527 100644
--- a/backend/src/applications/spaces/services/spaces-browser.service.spec.ts
+++ b/backend/src/applications/spaces/services/spaces-browser.service.spec.ts
@@ -4,6 +4,7 @@ import { exportConfiguration } from '../../../configuration/config.environment'
import { Cache } from '../../../infrastructure/cache/cache.service'
import { ContextManager } from '../../../infrastructure/context/services/context-manager.service'
import { DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants'
+import { FilesQuotaManager } from '../../files/services/files-quota-manager.service'
import { FilesLockManager } from '../../files/services/files-lock-manager.service'
import { FilesQueries } from '../../files/services/files-queries.service'
import { FilesRecents } from '../../files/services/files-recents.service'
@@ -11,11 +12,12 @@ import { LinksQueries } from '../../links/services/links-queries.service'
import { NotificationsManager } from '../../notifications/services/notifications-manager.service'
import { SharesManager } from '../../shares/services/shares-manager.service'
import { SharesQueries } from '../../shares/services/shares-queries.service'
+import type { UserModel } from '../../users/models/user.model'
import { UsersQueries } from '../../users/services/users-queries.service'
+import type { SpaceEnv } from '../models/space-env.model'
import { SpacesBrowser } from './spaces-browser.service'
import { SpacesManager } from './spaces-manager.service'
import { SpacesQueries } from './spaces-queries.service'
-import { FilesQuotaManager } from '../../files/services/files-quota-manager.service'
describe(SpacesBrowser.name, () => {
let spacesBrowserService: SpacesBrowser
@@ -54,4 +56,24 @@ describe(SpacesBrowser.name, () => {
it('should be defined', () => {
expect(spacesBrowserService).toBeDefined()
})
+
+ it('should expose the space name while preserving its alias', async () => {
+ const user = { id: 1 } as UserModel
+ const space = {
+ alias: 'communication',
+ name: 'Communication',
+ inSharesList: false,
+ inTrashRepository: false,
+ browsePermissions: vi.fn().mockReturnValue('a:m')
+ } as unknown as SpaceEnv
+
+ vi.spyOn(spacesBrowserService as any, 'parseFS').mockResolvedValue([])
+ vi.spyOn(spacesBrowserService as any, 'parseDB').mockResolvedValue([])
+ vi.spyOn(spacesBrowserService as any, 'parseRootFiles').mockResolvedValue([])
+ vi.spyOn((spacesBrowserService as any).filesRecents, 'updateRecents').mockResolvedValue(undefined)
+
+ const result = await spacesBrowserService.browse(user, space)
+
+ expect(result.space).toEqual({ alias: 'communication', name: 'Communication' })
+ })
})
diff --git a/backend/src/applications/spaces/services/spaces-browser.service.ts b/backend/src/applications/spaces/services/spaces-browser.service.ts
index 6cac9a49..d7105edd 100644
--- a/backend/src/applications/spaces/services/spaces-browser.service.ts
+++ b/backend/src/applications/spaces/services/spaces-browser.service.ts
@@ -43,7 +43,12 @@ export class SpacesBrowser {
): Promise<SpaceFiles> {
// check sync permission
options.withSyncs = options.withSyncs && user.havePermission(USER_PERMISSION.DESKTOP_APP) && user.havePermission(USER_PERMISSION.DESKTOP_APP_SYNC)
- const spaceFiles: SpaceFiles = { files: [], hasRoots: false, permissions: space.browsePermissions() }
+ const spaceFiles: SpaceFiles = {
+ space: { alias: space.alias, name: space.name },
+ files: [],
+ hasRoots: false,
+ permissions: space.browsePermissions()
+ }
const [fsFiles, dbFiles, rootFiles] = await Promise.all([
this.parseFS(space),
this.parseDB(user.id, space, options),
diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.ts
index f6cc9680..cd76c2dd 100644
--- a/backend/src/applications/spaces/services/spaces-manager.service.ts
+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts
@@ -237,12 +237,14 @@ export class SpacesManager {
const space: SpaceProps = await this.userCanAccessSpace(user, spaceId, true)
// check and update space info
let mustInvalidateCache = false
+ let renamedSpaceAlias: string
const spaceDiffProps: Partial<SpaceProps> = { modifiedAt: new Date() }
const props: (keyof CreateOrUpdateSpaceDto)[] = ['name', 'description', 'enabled', 'storageQuota', 'storageIndexing']
for (const prop of props) {
if (createOrUpdateSpaceDto[prop] !== space[prop]) {
spaceDiffProps[prop] = createOrUpdateSpaceDto[prop]
if (prop === 'name') {
+ renamedSpaceAlias = space.alias
spaceDiffProps.alias = await this.uniqueSpaceAlias(spaceDiffProps.name, true)
if (space.alias !== spaceDiffProps.alias) {
// must move the space to match the new alias
@@ -262,6 +264,9 @@ export class SpacesManager {
if (!(await this.spacesQueries.updateSpace(spaceId, spaceDiffProps))) {
throw new HttpException('Unable to update space', HttpStatus.INTERNAL_SERVER_ERROR)
}
+ if (renamedSpaceAlias) {
+ void this.spacesQueries.clearCachePermissions(renamedSpaceAlias)
+ }
// update quota in cache
if ('storageQuota' in spaceDiffProps) {
void this.filesQuotaManager.updateStorageQuota(spaceId, FILE_REPOSITORY.SPACE, spaceDiffProps.storageQuota)
diff --git a/backend/src/applications/spaces/services/spaces-queries.service.ts b/backend/src/applications/spaces/services/spaces-queries.service.ts
index 04d2b1fb..326fb411 100644
--- a/backend/src/applications/spaces/services/spaces-queries.service.ts
+++ b/backend/src/applications/spaces/services/spaces-queries.service.ts
@@ -54,7 +54,7 @@ export class SpacesQueries {
private spaceAndRootPermissionsQuery: MySql2PreparedQuery<any> = null
private spacesWithDetailsQuery: MySql2PreparedQuery<any> = null
private spacesQuery: MySql2PreparedQuery<any> = null
- private spaceIdsQuery: MySql2PreparedQuery<any> = null
+ private spaceIdentitiesQuery: MySql2PreparedQuery<any> = null
private spaceQuery: MySql2PreparedQuery<any> = null
private spacesWithPermissionsQuery: MySql2PreparedQuery<any> = null
private spaceFromIdWithPermissionsQuery: MySql2PreparedQuery<any> = null
@@ -476,13 +476,17 @@ export class SpacesQueries {
}
@CacheDecorator()
- async spaceIds(userId: number): Promise<number[]> {
- if (!this.spaceIdsQuery) {
- const unionAlias = this.fromUserAndGroups({ id: spaces.id })
- this.spaceIdsQuery = this.db.select({ id: unionAlias.id }).from(unionAlias).groupBy(unionAlias.id).prepare()
+ async spaceIdentities(userId: number): Promise<Pick<Space, 'id' | 'alias' | 'name'>[]> {
+ if (!this.spaceIdentitiesQuery) {
+ const unionAlias = this.fromUserAndGroups({ id: spaces.id, alias: spaces.alias, name: spaces.name })
+ this.spaceIdentitiesQuery = this.db
+ .select({ id: unionAlias.id, alias: unionAlias.alias, name: unionAlias.name })
+ .from(unionAlias)
+ .groupBy(unionAlias.id, unionAlias.alias, unionAlias.name)
+ .prepare()
}
// `userId` is used in `fromUserAndGroups` function
- return (await this.spaceIdsQuery.execute({ userId })).map((r: { id: number }) => r.id)
+ return this.spaceIdentitiesQuery.execute({ userId })
}
@CacheDecorator()
@@ -712,6 +716,8 @@ export class SpacesQueries {
// clear cache on space root
rootAliases.forEach((rAlias: string) => patterns.push(this.cache.genSlugKey(...basePattern, rAlias)))
} else {
+ // clear cache on accessible space identities
+ patterns.push(this.cache.genSlugKey(this.constructor.name, this.spaceIdentities.name, uid))
// clear cache on spaces list
patterns.push(this.cache.genSlugKey(...[this.constructor.name, this.spaces.name, uid]))
patterns.push(this.cache.genSlugKey(...[this.constructor.name, this.spaces.name, uid, '*']))
diff --git a/frontend/src/app/applications/comments/models/comment-recent.model.ts b/frontend/src/app/applications/comments/models/comment-recent.model.ts
index c03ce5f5..cb34acf8 100644
--- a/frontend/src/app/applications/comments/models/comment-recent.model.ts
+++ b/frontend/src/app/applications/comments/models/comment-recent.model.ts
@@ -1,5 +1,7 @@
import { IconDefinition } from '@fortawesome/fontawesome-svg-core'
import type { CommentRecent } from '@sync-in-server/backend/src/applications/comments/interfaces/comment-recent.interface'
+import { FILE_REPOSITORY } from '@sync-in-server/backend/src/applications/files/constants/operations'
+import { SPACE_ALIAS } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
import { resolveFileLocation } from '../../files/components/utils/file-location.utils'
import { getAssetsMimeUrl } from '../../files/files.constants'
import { OwnerType } from '../../users/interfaces/owner.interface'
@@ -10,7 +12,7 @@ export class CommentRecentModel implements CommentRecent {
content: string
modifiedAt: Date
author: OwnerType
- file: { name: string; path: string; mime: string; inTrash: number; fromSpace: number; fromShare: number }
+ file: CommentRecent['file']
// Computed
mimeUrl: string
@@ -26,8 +28,9 @@ export class CommentRecentModel implements CommentRecent {
}
this.mimeUrl = getAssetsMimeUrl(this.file.mime)
const location = resolveFileLocation(this.file.path, {
- repository: this.file.fromShare ? 'share' : this.file.fromSpace ? 'space' : 'personal',
- appendName: this.file.name
+ repository: this.file.fromShare ? FILE_REPOSITORY.SHARE : this.file.fromSpace ? FILE_REPOSITORY.SPACE : SPACE_ALIAS.PERSONAL,
+ appendName: this.file.name,
+ displayRootName: this.file.displayRootName
})
this.icon = location.icon
this.iconClass = location.iconClass
diff --git a/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.html b/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.html
index c5ff6188..1841e50f 100644
--- a/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.html
+++ b/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.html
@@ -17,20 +17,20 @@
@if (files.length) {
<div class="px-2 pt-2 pb-2 fs-xs">
<app-files-summary [files]="files" class="mb-2"></app-files-summary>
- <div class="d-flex justify-content-between">
+ <div class="d-flex">
<select [(ngModel)]="selectedAction" class="form-select form-select-sm">
@for (item of operations| keyvalue: originalOrderKeyValue; track item.key) {
<option [ngValue]="item.key" l10nTranslate>{{ item.value.text }}</option>
}
</select>
- <button (click)="doAction()" class="btn btn-xs btn-primary ms-1" type="button" l10nTranslate>Confirm</button>
+ <button (click)="doAction()" class="btn btn-sm btn-primary ms-1" type="button" l10nTranslate>Confirm</button>
</div>
</div>
- <hr class="mx-0 my-2">
+ <hr class="mx-0 my-1">
<div appAutoResize class="sidebar-item" [resizeOffset]="170">
@for (f of files; track f.id) {
<div class="sidebar-item-container">
- <div class="sidebar-item-content" [tooltip]="f.path">
+ <div class="sidebar-item-content" [tooltip]="fileLocation(f)">
<img [src]="f.mimeUrl" alt="" height="28" width="28" (error)="f.fallBackMimeUrl()">
<div class="text-truncate fs-sm">{{ f.name }}</div>
<button (click)="remove(f)" class="btn btn-xs btn-default ms-auto">
diff --git a/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.ts b/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.ts
index 4df103cb..3fd8b9ac 100644
--- a/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.ts
+++ b/frontend/src/app/applications/files/components/sidebar/files-clipboard.component.ts
@@ -18,6 +18,7 @@ import { StoreService } from '../../../../store/store.service'
import { FileModel } from '../../models/file.model'
import { FilesService } from '../../services/files.service'
import { FilesCompressionDialogComponent } from '../dialogs/files-compression-dialog.component'
+import { resolveFileLocation } from '../utils/file-location.utils'
import { FilesSummaryComponent } from '../utils/files-summary.component'
@Component({
@@ -72,6 +73,12 @@ export class FilesClipboardComponent implements OnDestroy {
}
}
+ protected fileLocation(file: FileModel): string {
+ const location = resolveFileLocation(file.path)
+ if (!location) return file.path
+ return [this.layout.translateString(location.repositoryTitle), location.relativePath].filter(Boolean).join('/')
+ }
+
doAction() {
if (this.selectedAction === 'copyPaste' || this.selectedAction === 'cutPaste') {
this.filesService.onPasteClipboard(this.selectedAction)
diff --git a/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts b/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts
index 5da66e59..0eea3969 100644
--- a/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts
+++ b/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts
@@ -6,7 +6,7 @@ import { Router } from '@angular/router'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
import { faFile } from '@fortawesome/free-regular-svg-icons'
import { faArrowRotateRight, faArrowsAlt, faClone, faFolder, faObjectGroup, faQuestion, faSpinner, faTimes } from '@fortawesome/free-solid-svg-icons'
-import { FILE_OPERATION } from '@sync-in-server/backend/src/applications/files/constants/operations'
+import { FILE_OPERATION, FILE_REPOSITORY } from '@sync-in-server/backend/src/applications/files/constants/operations'
import type { FileTree } from '@sync-in-server/backend/src/applications/files/interfaces/file-tree.interface'
import { SPACE_ALIAS, SPACE_ALL_OPERATIONS, SPACE_OPERATION } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
import { USER_PERMISSION } from '@sync-in-server/backend/src/applications/users/constants/user'
@@ -192,7 +192,7 @@ export class FilesTreeComponent implements OnInit, OnDestroy {
const selection = this.selection
if (!selection) return null
return resolveFileLocation(selection.data.path, {
- repository: selection.data.inShare ? 'share' : undefined,
+ repository: selection.data.inShare ? FILE_REPOSITORY.SHARE : undefined,
excludeLeaf: true,
displayRootName: this.getRepositoryRootName(selection)
})
diff --git a/frontend/src/app/applications/files/components/utils/file-location.utils.ts b/frontend/src/app/applications/files/components/utils/file-location.utils.ts
index c6e56b1c..75911559 100644
--- a/frontend/src/app/applications/files/components/utils/file-location.utils.ts
+++ b/frontend/src/app/applications/files/components/utils/file-location.utils.ts
@@ -1,11 +1,13 @@
import type { IconDefinition } from '@fortawesome/fontawesome-svg-core'
+import { FILE_REPOSITORY } from '@sync-in-server/backend/src/applications/files/constants/operations'
import { SPACE_ALIAS, SPACE_REPOSITORY } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
-import { SPACES_ICON } from '../../../spaces/spaces.constants'
+import { SPACES_ICON, SPACES_TITLE } from '../../../spaces/spaces.constants'
-type FileLocationRepository = 'personal' | 'space' | 'share'
+type FileLocationRepository = SPACE_ALIAS.PERSONAL | FILE_REPOSITORY.SPACE | FILE_REPOSITORY.SHARE
interface FileLocationPresentation {
repository: FileLocationRepository
+ repositoryTitle: string
relativePath: string
icon: IconDefinition
iconClass: 'primary' | 'purple'
@@ -18,10 +20,14 @@ interface FileLocationOptions {
displayRootName?: string
}
-const FILE_LOCATION_PRESENTATION: Record<FileLocationRepository, Pick<FileLocationPresentation, 'icon' | 'iconClass'>> = {
- personal: { icon: SPACES_ICON.PERSONAL, iconClass: 'primary' },
- space: { icon: SPACES_ICON.SPACES, iconClass: 'primary' },
- share: { icon: SPACES_ICON.SHARES, iconClass: 'purple' }
+const FILE_LOCATION_PRESENTATION: Record<FileLocationRepository, Pick<FileLocationPresentation, 'repositoryTitle' | 'icon' | 'iconClass'>> = {
+ [SPACE_ALIAS.PERSONAL]: {
+ repositoryTitle: SPACES_TITLE.PERSONAL_FILES,
+ icon: SPACES_ICON.PERSONAL,
+ iconClass: 'primary'
+ },
+ [FILE_REPOSITORY.SPACE]: { repositoryTitle: SPACES_TITLE.SPACES, icon: SPACES_ICON.SPACES, iconClass: 'primary' },
+ [FILE_REPOSITORY.SHARE]: { repositoryTitle: SPACES_TITLE.SHARES, icon: SPACES_ICON.SHARES, iconClass: 'purple' }
}
export function resolveFileLocation(path: string, options: FileLocationOptions & { repository: FileLocationRepository }): FileLocationPresentation
@@ -32,7 +38,7 @@ export function resolveFileLocation(path: string, options: FileLocationOptions =
if (!repository) return undefined
const relativeSegments = segments.slice(segments[1] === SPACE_ALIAS.PERSONAL ? 2 : segments.length ? 1 : 0)
if (options.excludeLeaf) relativeSegments.pop()
- if (repository !== 'personal' && options.displayRootName && relativeSegments.length) relativeSegments[0] = options.displayRootName
+ if (repository !== SPACE_ALIAS.PERSONAL && options.displayRootName && relativeSegments.length) relativeSegments[0] = options.displayRootName
if (options.appendName) relativeSegments.push(options.appendName)
return {
repository,
@@ -42,10 +48,10 @@ export function resolveFileLocation(path: string, options: FileLocationOptions =
}
function inferRepository(segments: string[]): FileLocationRepository | undefined {
- if (segments[0] === SPACE_REPOSITORY.SHARES) return 'share'
- if (segments[0] === SPACE_ALIAS.PERSONAL || segments[1] === SPACE_ALIAS.PERSONAL) return 'personal'
+ if (segments[0] === SPACE_REPOSITORY.SHARES) return FILE_REPOSITORY.SHARE
+ if (segments[0] === SPACE_ALIAS.PERSONAL || segments[1] === SPACE_ALIAS.PERSONAL) return SPACE_ALIAS.PERSONAL
if (segments[0] === SPACE_ALIAS.SPACES || segments[0] === SPACE_REPOSITORY.FILES || segments[0] === SPACE_REPOSITORY.TRASH) {
- return 'space'
+ return FILE_REPOSITORY.SPACE
}
return undefined
}
diff --git a/frontend/src/app/applications/files/models/file-content.model.ts b/frontend/src/app/applications/files/models/file-content.model.ts
index b4e37788..05ec8805 100644
--- a/frontend/src/app/applications/files/models/file-content.model.ts
+++ b/frontend/src/app/applications/files/models/file-content.model.ts
@@ -11,6 +11,7 @@ export class FileContentModel implements FileContent {
size: number
mtime: number
matches: string[]
+ displayRootName?: string
// Computed
mimeUrl: string
@@ -29,7 +30,7 @@ export class FileContentModel implements FileContent {
}
private setProperties() {
- const location = resolveFileLocation(this.path)
+ const location = resolveFileLocation(this.path, { displayRootName: this.displayRootName })
if (!location) return
this.showedPath = location.relativePath
this.iconClass = location.iconClass
diff --git a/frontend/src/app/applications/files/models/file-recent.model.ts b/frontend/src/app/applications/files/models/file-recent.model.ts
index d9b5be5f..00885418 100644
--- a/frontend/src/app/applications/files/models/file-recent.model.ts
+++ b/frontend/src/app/applications/files/models/file-recent.model.ts
@@ -1,6 +1,7 @@
import { IconDefinition } from '@fortawesome/fontawesome-svg-core'
+import { FILE_REPOSITORY } from '@sync-in-server/backend/src/applications/files/constants/operations'
import type { FileRecent } from '@sync-in-server/backend/src/applications/files/schemas/file-recent.interface'
-import { SPACE_REPOSITORY } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
+import { SPACE_ALIAS, SPACE_REPOSITORY } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
import { resolveFileLocation } from '../components/utils/file-location.utils'
import { defaultMimeUrl, getAssetsMimeUrl } from '../files.constants'
@@ -13,6 +14,7 @@ export class FileRecentModel implements FileRecent {
path: string
shareId: number
spaceId: number
+ displayRootName?: string
// Computed
mimeUrl: string
@@ -24,7 +26,10 @@ export class FileRecentModel implements FileRecent {
constructor(props: Partial<FileRecent>) {
Object.assign(this, props)
this.mimeUrl = getAssetsMimeUrl(this.mime)
- const location = resolveFileLocation(this.path, { repository: this.shareId ? 'share' : this.spaceId ? 'space' : 'personal' })
+ const location = resolveFileLocation(this.path, {
+ repository: this.shareId ? FILE_REPOSITORY.SHARE : this.spaceId ? FILE_REPOSITORY.SPACE : SPACE_ALIAS.PERSONAL,
+ displayRootName: this.displayRootName
+ })
this.iconClass = location.iconClass
this.icon = location.icon
this.showedPath = location.relativePath
diff --git a/frontend/src/app/applications/spaces/services/spaces-browser.service.ts b/frontend/src/app/applications/spaces/services/spaces-browser.service.ts
index 11cb03cc..f5518014 100644
--- a/frontend/src/app/applications/spaces/services/spaces-browser.service.ts
+++ b/frontend/src/app/applications/spaces/services/spaces-browser.service.ts
@@ -42,9 +42,9 @@ export class SpacesBrowserService {
loadFiles(): Observable<SpaceFiles> {
return this.http.get<SpaceFiles>(this.browseApi).pipe(
- tap(() => {
+ tap((spaceFiles) => {
this.layout.setBreadcrumbIcon(this.breadCrumbIcon)
- this.layout.setBreadcrumbNav(this.breadcrumbNav())
+ this.layout.setBreadcrumbNav(this.breadcrumbNav(spaceFiles.space.name))
}),
catchError((e: HttpErrorResponse) => {
return throwError(() => e)
@@ -52,7 +52,16 @@ export class SpacesBrowserService {
)
}
- private breadcrumbNav(): BreadCrumbUrl {
+ private breadcrumbNav(spaceName: string): BreadCrumbUrl {
+ const mutateLevel: NonNullable<BreadCrumbUrl['mutateLevel']> = {}
+ if (this.inPersonalSpace && !this.breadCrumbFilesRepo && !this.inRootSpace) {
+ mutateLevel[0] = {
+ setTitle: SPACES_TITLE.PERSONAL_FILES,
+ translateTitle: true
+ }
+ } else if (spaceName && !this.inPersonalSpace && !(this.inShareRepo && this.inRootSpace)) {
+ mutateLevel[0] = { setTitle: spaceName }
+ }
return {
url:
this.inPersonalSpace && this.inRootSpace
@@ -70,15 +79,7 @@ export class SpacesBrowserService {
: this.inShareRepo
? SPACES_PATH.SPACES_SHARES
: SPACES_PATH.TRASH,
- mutateLevel:
- this.inPersonalSpace && !this.breadCrumbFilesRepo && !this.inRootSpace
- ? {
- 0: {
- setTitle: SPACES_TITLE.PERSONAL_FILES,
- translateTitle: true
- }
- }
- : null,
+ mutateLevel: Object.keys(mutateLevel).length ? mutateLevel : null,
splicing: this.inPersonalSpace ? (!this.breadCrumbFilesRepo && !this.inRootSpace ? 2 : 3) : 2
} satisfies BreadCrumbUrl
}
diff --git a/frontend/src/app/applications/sync/models/sync-path.model.ts b/frontend/src/app/applications/sync/models/sync-path.model.ts
index 1b0eaa3c..0dc13d8b 100644
--- a/frontend/src/app/applications/sync/models/sync-path.model.ts
+++ b/frontend/src/app/applications/sync/models/sync-path.model.ts
@@ -1,4 +1,5 @@
import { IconDefinition } from '@fortawesome/fontawesome-svg-core'
+import { FILE_REPOSITORY } from '@sync-in-server/backend/src/applications/files/constants/operations'
import { SyncPathFromClient, SyncPathSettings } from '@sync-in-server/backend/src/applications/sync/interfaces/sync-path.interface'
import type { SyncPath } from '@sync-in-server/backend/src/applications/sync/schemas/sync-path.interface'
import { popFromObject } from '@sync-in-server/backend/src/common/shared'
@@ -97,6 +98,6 @@ export class SyncPathModel implements Partial<SyncPath> {
this.showedPath = location.relativePath
this.iconClass = location.iconClass
this.icon = location.icon
- this.mime = location.repository === 'share' ? mimeDirectoryShare : mimeDirectory
+ this.mime = location.repository === FILE_REPOSITORY.SHARE ? mimeDirectoryShare : mimeDirectory
}
}