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
feat(favorites): show persisted file detail badges
johavena785d56126b7
diff --git a/backend/src/applications/files/interfaces/file-props.interface.ts b/backend/src/applications/files/interfaces/file-props.interface.tsindex 098cb046..35c48ffa 100644--- a/backend/src/applications/files/interfaces/file-props.interface.ts+++ b/backend/src/applications/files/interfaces/file-props.interface.ts@@ -43,7 +43,7 @@ export interface FileProps extends Omit<File, 'ownerId' | 'spaceId' | 'spaceExte// used by the file browser to enrich filesspaces?: Pick<Space, 'id' | 'alias' | 'name'>[]shares?: Pick<Share, 'id' | 'alias' | 'name' | 'type'>[]- syncs?: Pick<SyncPath, 'clientId' | 'id'> & { clientName: string }[]+ syncs?: (Pick<SyncPath, 'clientId' | 'id'> & { clientName: string })[]hasComments?: booleanisFavorite?: boolean}diff --git a/backend/src/applications/files/services/files-favorites-manager.service.spec.ts b/backend/src/applications/files/services/files-favorites-manager.service.spec.tsindex d1d423a8..f13a3169 100644--- a/backend/src/applications/files/services/files-favorites-manager.service.spec.ts+++ b/backend/src/applications/files/services/files-favorites-manager.service.spec.ts@@ -62,10 +62,11 @@ describe(FilesFavoritesManager.name, () => {service = module.get(FilesFavoritesManager)})- const userWithPermissions = (applications: USER_PERMISSION[] = [], isAdmin = false) =>+ const userWithPermissions = (applications: USER_PERMISSION[] = [], isAdmin = false, isUser = true) =>({id: 7,isAdmin,+ isUser,havePermission: (permission: USER_PERMISSION) => isAdmin || applications.includes(permission)}) as any@@ -123,7 +124,7 @@ describe(FilesFavoritesManager.name, () => {expect(spacesQueries.spaceIdentities).toHaveBeenCalledWith(7)expect(sharesQueries.shareIdentities).toHaveBeenCalledWith(7, 1)- expect(filesFavoritesQueries.getFavoritesFromUser).toHaveBeenCalledWith(7, true)+ expect(filesFavoritesQueries.getFavoritesFromUser).toHaveBeenCalledWith(7, true, true)expect(filesFavoritesQueries.getFavoriteLocationsFromSpaces).toHaveBeenCalledWith(7, [10])expect(filesFavoritesQueries.getFavoriteLocationsFromShares).toHaveBeenCalledWith(7, [20])expect(result[0]).toMatchObject({@@ -152,12 +153,18 @@ describe(FilesFavoritesManager.name, () => {expect(spacesQueries.spaceIdentities).not.toHaveBeenCalled()expect(sharesQueries.shareIdentities).not.toHaveBeenCalled()- expect(filesFavoritesQueries.getFavoritesFromUser).toHaveBeenCalledWith(7, false)+ expect(filesFavoritesQueries.getFavoritesFromUser).toHaveBeenCalledWith(7, false, true)expect(filesFavoritesQueries.getFavoriteLocationsFromSpaces).not.toHaveBeenCalled()expect(filesFavoritesQueries.getFavoriteLocationsFromShares).not.toHaveBeenCalled()expect(result).toEqual([{ fileId: 1, id: 1, name: 'stored.txt', path: 'stored', isDisabled: true }])})+ it('should skip sync details for guests', async () => {+ await service.getFavorites(userWithPermissions([], false, false))++ expect(filesFavoritesQueries.getFavoritesFromUser).toHaveBeenCalledWith(7, false, false)+ })+it('should add an already indexed favorite', async () => {filesQueries.getOrCreateSpaceFile.mockResolvedValueOnce(42)const space = makeSpace()diff --git a/backend/src/applications/files/services/files-favorites-manager.service.ts b/backend/src/applications/files/services/files-favorites-manager.service.tsindex 310d796a..06ca8c8d 100644--- a/backend/src/applications/files/services/files-favorites-manager.service.ts+++ b/backend/src/applications/files/services/files-favorites-manager.service.ts@@ -29,10 +29,12 @@ export class FilesFavoritesManager {async getFavorites(user: UserModel): Promise<FileFavorite[]> {const hasPersonal = user.havePermission(USER_PERMISSION.PERSONAL_SPACE)+ const hasSpaces = user.havePermission(USER_PERMISSION.SPACES)+ const hasShares = user.havePermission(USER_PERMISSION.SHARES)const [favorites, spaces, shares] = await Promise.all([- this.filesFavoritesQueries.getFavoritesFromUser(user.id, hasPersonal),- 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([])+ this.filesFavoritesQueries.getFavoritesFromUser(user.id, hasPersonal, user.isUser),+ hasSpaces ? this.spacesQueries.spaceIdentities(user.id) : Promise.resolve([]),+ hasShares ? this.sharesQueries.shareIdentities(user.id, +user.isAdmin) : Promise.resolve([])])if (!favorites.length) {return []diff --git a/backend/src/applications/files/services/files-favorites-queries.e2e-spec.ts b/backend/src/applications/files/services/files-favorites-queries.e2e-spec.tsindex 5ecdc2e3..cc526c08 100644--- a/backend/src/applications/files/services/files-favorites-queries.e2e-spec.ts+++ b/backend/src/applications/files/services/files-favorites-queries.e2e-spec.ts@@ -16,6 +16,9 @@ import { spacesMembers } from '../../spaces/schemas/spaces-members.schema'import { spacesRoots } from '../../spaces/schemas/spaces-roots.schema'import { spaces } from '../../spaces/schemas/spaces.schema'import { SpacesQueries } from '../../spaces/services/spaces-queries.service'+import { SYNC_CLIENT_TYPE, SYNC_PATH_CONFLICT_MODE, SYNC_PATH_DIFF_MODE, SYNC_PATH_MODE, SYNC_PATH_SCHEDULER_UNIT } from '../../sync/constants/sync'+import { syncClients } from '../../sync/schemas/sync-clients.schema'+import { syncPaths } from '../../sync/schemas/sync-paths.schema'import { users } from '../../users/schemas/users.schema'import { FILE_REPOSITORY } from '../constants/operations'import { filesFavorites } from '../schemas/files-favorites.schema'@@ -34,13 +37,16 @@ describe('Files favorites queries (e2e)', () => {let memberId: number | undefinedlet spaceId: number | undefinedlet shareId: number | undefined+ let rootFileId: number | undefinedlet activeFileId: number | undefinedlet trashedFileId: number | undefined+ let syncPathId: number | undefinedconst suffix = randomUUID().replaceAll('-', '').slice(0, 12)const rootName = `favorite-root-${suffix}`const spaceAlias = `e2e-favorite-space-${suffix}`const shareAlias = `e2e-favorite-share-${suffix}`+ const syncClientId = randomUUID()const noCache = {genSlugKey: vi.fn((...args: unknown[]) => args.join(':')),get: vi.fn().mockResolvedValue(undefined),@@ -72,7 +78,7 @@ describe('Files favorites queries (e2e)', () => {}))- const rootFileId = dbGetInsertedId(await db.insert(files).values({ ownerId, path: '.', name: rootName, isDir: true }))+ rootFileId = dbGetInsertedId(await db.insert(files).values({ ownerId, path: '.', name: rootName, isDir: true }))activeFileId = dbGetInsertedId(await db.insert(files).values({ ownerId, path: rootName, name: 'active.txt', isDir: false }))trashedFileId = dbGetInsertedId(await db.insert(files).values({ ownerId, path: rootName, name: 'trashed.txt', isDir: false, inTrash: true }))spaceId = dbGetInsertedId(await db.insert(spaces).values({ alias: spaceAlias, name: 'Favorite space' }))@@ -81,7 +87,43 @@ describe('Files favorites queries (e2e)', () => {shareId = dbGetInsertedId(await db.insert(shares).values({ ownerId, fileId: rootFileId, alias: shareAlias, name: 'Favorite share' }))await db.insert(sharesMembers).values({ shareId, userId: memberId, permissions: 'd:m' })+ await db.insert(syncClients).values({+ id: syncClientId,+ ownerId,+ token: randomUUID(),+ tokenExpiration: Number.MAX_SAFE_INTEGER,+ info: {+ node: 'Favorite client',+ os: 'test',+ osRelease: 'test',+ user: 'test',+ type: SYNC_CLIENT_TYPE.DESKTOP,+ version: 'test'+ }+ })+ syncPathId = dbGetInsertedId(+ await db.insert(syncPaths).values({+ clientId: syncClientId,+ ownerId,+ fileId: rootFileId,+ settings: {+ name: 'Favorite sync',+ localPath: '/favorites',+ remotePath: `personal/${rootName}`,+ permissions: '',+ mode: SYNC_PATH_MODE.BOTH,+ enabled: true,+ diffMode: SYNC_PATH_DIFF_MODE.FAST,+ conflictMode: SYNC_PATH_CONFLICT_MODE.RECENT,+ filters: [],+ scheduler: { value: 0, unit: SYNC_PATH_SCHEDULER_UNIT.DISABLED },+ timestamp: 0,+ lastSync: new Date(0)+ }+ })+ )await db.insert(filesFavorites).values([+ { userId: ownerId, fileId: rootFileId },{ userId: ownerId, fileId: trashedFileId },{ userId: memberId, fileId: trashedFileId },{ userId: memberId, fileId: activeFileId }@@ -135,6 +177,32 @@ describe('Files favorites queries (e2e)', () => {)})+ it('returns browser details', async () => {+ const favorites = await favoritesQueries.getFavoritesFromUser(ownerId, true, true)+ const rootFavorite = favorites.find(({ fileId }) => fileId === rootFileId)+ const commentedFavorite = favorites.find(({ fileId }) => fileId === trashedFileId)++ expect(rootFavorite).toEqual(+ expect.objectContaining({+ spaces: [{ id: spaceId, alias: spaceAlias, name: 'Favorite space' }],+ shares: [{ id: shareId, alias: shareAlias, name: 'Favorite share', type: 0 }],+ syncs: [{ id: syncPathId, clientId: syncClientId, clientName: 'Favorite client' }],+ hasComments: false+ })+ )+ expect(commentedFavorite).toEqual(expect.objectContaining({ hasComments: true }))++ const favoritesWithoutSyncs = await favoritesQueries.getFavoritesFromUser(ownerId, true, false)+ const rootFavoriteWithoutSyncs = favoritesWithoutSyncs.find(({ fileId }) => fileId === rootFileId)+ expect(rootFavoriteWithoutSyncs).toEqual(+ expect.objectContaining({+ spaces: [{ id: spaceId, alias: spaceAlias, name: 'Favorite space' }],+ shares: [{ id: shareId, alias: shareAlias, name: 'Favorite share', type: 0 }]+ })+ )+ expect(rootFavoriteWithoutSyncs).not.toHaveProperty('syncs')+ })+it('does not resolve a trashed child through its former space anchor', async () => {const spaceIds = (await spacesQueries.spaceIdentities(memberId)).map(({ id }) => id)const locations = await favoritesQueries.getFavoriteLocationsFromSpaces(memberId, spaceIds)@@ -143,9 +211,11 @@ describe('Files favorites queries (e2e)', () => {expect(locations.some(({ fileId }) => fileId === trashedFileId)).toBe(false)await expect(commentsQueries.getRecentsFromSpaces(memberId, spaceIds, 10)).resolves.toEqual([])- await expect(favoritesQueries.getFavoritesFromUser(ownerId, true)).resolves.toEqual([- expect.objectContaining({ fileId: trashedFileId, repository: SPACE_ALIAS.PERSONAL, path: `trash/personal/${rootName}`, isDisabled: false })- ])+ await expect(favoritesQueries.getFavoritesFromUser(ownerId, true, true)).resolves.toEqual(+ expect.arrayContaining([+ expect.objectContaining({ fileId: trashedFileId, repository: SPACE_ALIAS.PERSONAL, path: `trash/personal/${rootName}`, isDisabled: false })+ ])+ )await expect(commentsQueries.getRecentsFromPersonal(ownerId, 10)).resolves.toEqual([expect.objectContaining({ file: expect.objectContaining({ path: `trash/personal/${rootName}` }) })])diff --git a/backend/src/applications/files/services/files-favorites-queries.service.ts b/backend/src/applications/files/services/files-favorites-queries.service.tsindex 4a8d81d5..d43ff557 100644--- a/backend/src/applications/files/services/files-favorites-queries.service.ts+++ b/backend/src/applications/files/services/files-favorites-queries.service.ts@@ -3,11 +3,15 @@ import { and, desc, eq, inArray, isNotNull, isNull, or, SelectedFields, sql } frimport { alias, unionAll } from 'drizzle-orm/mysql-core'import { DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants'import type { DBSchema } from '../../../infrastructure/database/interfaces/database.interface'+import { concatDistinctObjectsInArray } from '../../../infrastructure/database/utils'+import { fileHasCommentsSubquerySQL } from '../../comments/schemas/comments.schema'import { shares } from '../../shares/schemas/shares.schema'import { externalShareScopeSQL } from '../../shares/utils/external-share-scope.sql'import { SPACE_ALIAS, SPACE_REPOSITORY } from '../../spaces/constants/spaces'import { spacesRoots } from '../../spaces/schemas/spaces-roots.schema'import { spaces } from '../../spaces/schemas/spaces.schema'+import { syncClients } from '../../sync/schemas/sync-clients.schema'+import { syncPaths } from '../../sync/schemas/sync-paths.schema'import { FILE_REPOSITORY } from '../constants/operations'import type { FileFavorite, FileFavoriteLocation, FileFavoriteRepository } from '../schemas/file-favorite.interface'import { filesFavorites } from '../schemas/files-favorites.schema'@@ -17,9 +21,9 @@ import { filePathSQL, files } from '../schemas/files.schema'export class FilesFavoritesQueries {constructor(@Inject(DB_TOKEN_PROVIDER) private readonly db: DBSchema) {}- getFavoritesFromUser(userId: number, withPersonal: boolean): Promise<FileFavorite[]> {+ getFavoritesFromUser(userId: number, withPersonal: boolean, withSyncs: boolean): Promise<FileFavorite[]> {const isPersonal = sql`${+withPersonal} = 1 AND ${files.ownerId} <=> ${userId}`- return this.db+ const q = this.db.select({fileId: filesFavorites.fileId,createdAt: filesFavorites.createdAt,@@ -42,12 +46,36 @@ export class FilesFavoritesQueries {size: files.size,mtime: files.mtime,ctime: files.ctime,+ spaces: concatDistinctObjectsInArray(spaces.id, { id: spaces.id, alias: spaces.alias, name: spaces.name }),+ shares: concatDistinctObjectsInArray(shares.id, {+ id: shares.id,+ alias: shares.alias,+ name: shares.name,+ type: shares.type+ }),+ ...(withSyncs && {+ syncs: concatDistinctObjectsInArray(syncPaths.id, {+ id: syncPaths.id,+ clientId: syncClients.id,+ clientName: sql`JSON_VALUE(${syncClients.info}, '$.node')`+ })+ }),+ hasComments: sql`${fileHasCommentsSubquerySQL(files.id)}`.mapWith(Boolean),repository: sql<FileFavoriteRepository>`IF (${isPersonal}, ${SPACE_ALIAS.PERSONAL}, NULL)`.as('repository'),displayRootName: sql<string>`NULL`.as('displayRootName')} satisfies FileFavorite | SelectedFields<any, any>).from(filesFavorites).innerJoin(files, eq(files.id, filesFavorites.fileId))+ .leftJoin(spacesRoots, and(isPersonal, eq(spacesRoots.fileId, files.id)))+ .leftJoin(spaces, eq(spaces.id, spacesRoots.spaceId))+ .leftJoin(shares, and(eq(shares.ownerId, userId), eq(shares.fileId, files.id), isNull(shares.parentId)))+ if (withSyncs) {+ q.leftJoin(syncClients, eq(syncClients.ownerId, userId))+ q.leftJoin(syncPaths, and(eq(syncPaths.clientId, syncClients.id), eq(syncPaths.fileId, files.id)))+ }+ return q.where(eq(filesFavorites.userId, userId))+ .groupBy(files.id, filesFavorites.createdAt).orderBy(desc(filesFavorites.createdAt), desc(filesFavorites.fileId))}diff --git a/backend/src/applications/spaces/services/spaces-browser.service.spec.ts b/backend/src/applications/spaces/services/spaces-browser.service.spec.tsindex b18908be..6e224c51 100644--- a/backend/src/applications/spaces/services/spaces-browser.service.spec.ts+++ b/backend/src/applications/spaces/services/spaces-browser.service.spec.ts@@ -13,7 +13,6 @@ 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 { USER_PERMISSION } from '../../users/constants/user'import type { UserModel } from '../../users/models/user.model'import { UsersQueries } from '../../users/services/users-queries.service'import type { SpaceEnv } from '../models/space-env.model'@@ -87,19 +86,19 @@ describe(SpacesBrowser.name, () => {it.each([{- name: 'regular user with sync permissions',+ name: 'regular user whose sync permissions were removed',+ isUser: true,isLink: false,- permissions: [USER_PERMISSION.DESKTOP_APP, USER_PERMISSION.DESKTOP_APP_SYNC],syncs: true,favorites: true},- { name: 'regular user without all sync permissions', isLink: false, permissions: [USER_PERMISSION.DESKTOP_APP], syncs: false, favorites: true },- { name: 'link user', isLink: true, permissions: [], syncs: false, favorites: false }- ])('resolves and propagates browse details for a $name', async ({ isLink, permissions, syncs, favorites }) => {+ { name: 'guest user', isUser: false, isLink: false, syncs: false, favorites: true },+ { name: 'link user', isUser: false, isLink: true, syncs: false, favorites: false }+ ])('resolves and propagates browse details for a $name', async ({ isUser, isLink, syncs, favorites }) => {const user = {id: 1,- isLink,- havePermission: vi.fn((permission: USER_PERMISSION) => permissions.includes(permission))+ isUser,+ isLink} as unknown as UserModelconst space = {alias: 'communication',diff --git a/backend/src/applications/spaces/services/spaces-browser.service.ts b/backend/src/applications/spaces/services/spaces-browser.service.tsindex 2c31eace..364c1d74 100644--- a/backend/src/applications/spaces/services/spaces-browser.service.ts+++ b/backend/src/applications/spaces/services/spaces-browser.service.ts@@ -10,7 +10,6 @@ import { FilesQueries } from '../../files/services/files-queries.service'import { FilesRecents } from '../../files/services/files-recents.service'import { dirName, fileName, getProps, isInternalTemporaryEntry } from '../../files/utils/files'import { SharesQueries } from '../../shares/services/shares-queries.service'-import { USER_PERMISSION } from '../../users/constants/user'import { UserModel } from '../../users/models/user.model'import { SpaceBrowseDetails, SpaceFiles } from '../interfaces/space-files.interface'import { SpaceEnv } from '../models/space-env.model'@@ -34,7 +33,7 @@ export class SpacesBrowser {async browse(user: UserModel, space: SpaceEnv, withDetails = false): Promise<SpaceFiles> {const details: SpaceBrowseDetails = withDetails? {- syncs: user.havePermission(USER_PERMISSION.DESKTOP_APP) && user.havePermission(USER_PERMISSION.DESKTOP_APP_SYNC),+ syncs: user.isUser,favorites: !user.isLink}: nulldiff --git a/backend/src/applications/users/users.md b/backend/src/applications/users/users.mdindex 6ac8ebd5..363f6f70 100644--- a/backend/src/applications/users/users.md+++ b/backend/src/applications/users/users.md@@ -25,6 +25,51 @@ every authenticated user type. The numeric order is therefore security-sensitive`isLink` match only their exact roles. `USER_GROUP_ROLE` values (`MEMBER` and`MANAGER`) describe membership inside a group and are independent of these user types.+## Application permissions++Application permissions control access to features and protected operations. They are independent from the role hierarchy and from the permissions+granted inside a particular space, root, or share.++For a regular user, the effective permissions are the union of the permissions assigned directly to the account and those inherited from its user+groups. They are stored as comma-separated values and exposed by `UserModel` through the `applications` list. `UserModel.havePermission()` checks that+effective list, with the following role-specific behavior:++- administrators satisfy every application permission;+- regular users receive their direct and inherited permissions;+- guests always receive `SPACES`, `SHARES`, and `WEBDAV`, but never `PERSONAL_SPACE`;+- link pseudo-users do not use normal application permissions and are restricted to their linked context.++The available `USER_PERMISSION` values are:++| Permission | Persisted value | Scope |+|-------------------------|-------------------------|-------------------------------------------------------------|+| `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. |+| `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. |+| `PERSONAL_GROUPS_ADMIN` | `personal_groups_admin` | Create and administer personal groups. |+| `DESKTOP_APP` | `desktop_app_access` | Register, authenticate, and administer desktop clients. |+| `DESKTOP_APP_SYNC` | `desktop_app_sync` | Configure and execute synchronization paths and operations. |+| `WEBDAV` | `webdav_access` | Access files through WebDAV. |++Permissions do not imply one another. When `@UserHavePermission()` receives an array, the guard accepts any listed permission; it does not require all+of them. Endpoint guards and storage-context checks can also impose a role, membership, or repository permission in addition to the application+permission.++### Revocation and persisted state++Revoking an application permission prevents subsequent protected actions, but it does not delete relationships or configurations that were created+while the permission was granted. Existing space roots, shares, desktop clients, and synchronization paths therefore remain persisted until an+authorized actor explicitly changes or removes them.++File detail badges report that existing state independently from the current action permissions. A regular user can still see that one of their files+belongs to a space, is shared, or has a synchronization path after the corresponding permission is revoked. Queries must keep those details scoped to+resources owned by or otherwise visible to the authenticated user. Creating, updating, deleting, browsing, or executing the related resource remains+protected by its normal guards and context permissions. Guests and link pseudo-users do not load synchronization details because they cannot own+desktop synchronization clients.+## Homes and temporary filesTemporary working data is stored with the targeted storage rather than with the authenticated actor. Archives produced for user download are thediff --git a/frontend/src/app/applications/favorites/components/favorites.component.html b/frontend/src/app/applications/favorites/components/favorites.component.htmlindex f9a96c3c..95610add 100644--- a/frontend/src/app/applications/favorites/components/favorites.component.html+++ b/frontend/src/app/applications/favorites/components/favorites.component.html@@ -61,6 +61,65 @@<span class="badge bg-purple">{{ f.hTimeAgo }}</span></span>}+ <span class="label-bottom-right">+ @let maxBadges = galleryMode.maxBadges || 0;+ @let hiddenBadges = f.nbBadges - maxBadges;+ @for (badge of f.galleryBadges; track badge; let i = $index) {+ @if (i < maxBadges) {+ @switch (badge) {+ @case ('comments') {+ <span (click)="goToDetails($event, f, TAB_MENU.COMMENTS)"+ class="badge bg-success cursor-pointer">+ <svg [lucideIcon]="icons.LucideMessageSquareMore"></svg>+ </span>+ }+ @case ('shares') {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer">+ <svg [lucideIcon]="icons.SHARED"></svg>+ @if (f.shares.length > 1) {+ {{ f.shares.length }}+ }+ </span>+ }+ @case ('spaces') {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer">+ <svg [lucideIcon]="icons.SPACES"></svg>+ @if (f.spaces.length > 1) {+ {{ f.spaces.length }}+ }+ </span>+ }+ @case ('links') {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer">+ <svg [lucideIcon]="icons.LINKS"></svg>+ @if (f.links.length > 1) {+ {{ f.links.length }}+ }+ </span>+ }+ @case ('syncs') {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer">+ <svg [lucideIcon]="icons.SYNC"></svg>+ @if (f.syncs.length > 1) {+ {{ f.syncs.length }}+ }+ </span>+ }+ }+ }+ }+ @if (hiddenBadges > 0) {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer">+ <svg [lucideIcon]="icons.LucideCirclePlus"></svg>+ {{ hiddenBadges }}+ </span>+ }+ </span>@if (f.isDisabled) {<span class="label-bottom-left"><span class="badge bg-warning text-dark" l10nTranslate>@@ -141,14 +200,60 @@<app-file-location [location]="f" [displayAsRepository]="true"></app-file-location>}}+ @case ('info') {+ @if (f.hasComments) {+ <span (click)="goToDetails($event, f, TAB_MENU.COMMENTS)"+ class="badge bg-success cursor-pointer me-1">+ <svg [lucideIcon]="icons.LucideMessageSquareMore"></svg>+ </span>+ }+ @if (f.shares.length) {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer me-1">+ <svg [lucideIcon]="icons.SHARED"></svg>+ @if (f.shares.length > 1) {+ {{ f.shares.length }}+ }+ </span>+ }+ @if (f.links.length) {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer me-1">+ <svg [lucideIcon]="icons.LINKS"></svg>+ @if (f.links.length > 1) {+ {{ f.links.length }}+ }+ </span>+ }+ @if (f.spaces.length) {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer me-1">+ <svg [lucideIcon]="icons.SPACES"></svg>+ @if (f.spaces.length > 1) {+ {{ f.spaces.length }}+ }+ </span>+ }+ @if (f.syncs.length) {+ <span (click)="goToDetails($event, f, TAB_MENU.SELECTION)"+ class="badge bg-primary cursor-pointer">+ <svg [lucideIcon]="icons.SYNC"></svg>+ @if (f.syncs.length > 1) {+ {{ f.syncs.length }}+ }+ </span>+ }+ }@case ('size') {<span>{{ f.isDir && f.size === 0 ? '●' : (f.size | toBytes:0:true) }}</span>}@case ('modified') {- <span>{{ f.mtime | amLiveTimeAgo }}</span>+ <span class="{{th.value.newly && f[th.value.newly] ? 'badge prop-newly-' + f[th.value.newly] : ''}}">+ <span>{{ f.hTimeAgo }}</span>+ </span>}@case ('created') {- <span>{{ f.createdAt | amLiveTimeAgo }}</span>+ <span>{{ f.createdAt | amLiveTimeAgo:true }}</span>}}</td>diff --git a/frontend/src/app/applications/favorites/components/favorites.component.ts b/frontend/src/app/applications/favorites/components/favorites.component.tsindex 8f4f4f99..39ecae5b 100644--- a/frontend/src/app/applications/favorites/components/favorites.component.ts+++ b/frontend/src/app/applications/favorites/components/favorites.component.ts@@ -2,7 +2,17 @@ import { KeyValuePipe, NgTemplateOutlet } from '@angular/common'import { HttpErrorResponse } from '@angular/common/http'import { Component, ElementRef, inject, OnInit, ViewChild } from '@angular/core'import { ActivatedRoute, Router } from '@angular/router'-import { LucideArrowDown, LucideArrowUp, LucideDynamicIcon, LucideMapPin, LucideRotateCw, LucideStarOff, LucideTriangleAlert } from '@lucide/angular'+import {+ LucideArrowDown,+ LucideArrowUp,+ LucideCirclePlus,+ LucideDynamicIcon,+ LucideMapPin,+ LucideMessageSquareMore,+ LucideRotateCw,+ LucideStarOff,+ LucideTriangleAlert+} from '@lucide/angular'import { ContextMenuComponent, ContextMenuModule } from '@perfectmemory/ngx-contextmenu'import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'import { TooltipModule } from 'ngx-bootstrap/tooltip'@@ -17,11 +27,13 @@ import { LiveTimeAgoPipe } from '../../../common/pipes/time-ago-live.pipe'import { ToBytesPipe } from '../../../common/pipes/to-bytes.pipe'import { originalOrderKeyValue } from '../../../common/utils/functions'import { SortSettings, SortTable } from '../../../common/utils/sort-table'+import { TAB_MENU } from '../../../layout/layout.interfaces'import { LayoutService } from '../../../layout/layout.service'import { FileLocationComponent } from '../../files/components/utils/file-location.component'import { FileFavoriteModel } from '../../files/models/file-favorite.model'import { FilesService } from '../../files/services/files.service'-import { SPACES_PATH } from '../../spaces/spaces.constants'+import { SPACES_ICON, SPACES_PATH } from '../../spaces/spaces.constants'+import { SYNC_ICON } from '../../sync/sync.constants'import { FAVORITES_ICON, FAVORITES_PATH, FAVORITES_TITLE } from '../favorites.constants'@Component({@@ -59,22 +71,29 @@ export class FavoritesComponent implements OnInit {protected readonly layout = inject(LayoutService)protected readonly icons = {FAVORITES: FAVORITES_ICON,+ SHARED: SPACES_ICON.SHARED_WITH_OTHERS,+ SPACES: SPACES_ICON.SPACES,+ LINKS: SPACES_ICON.LINKS,+ SYNC: SYNC_ICON.SYNC,LucideRotateCw,LucideArrowDown,LucideArrowUp,+ LucideCirclePlus,LucideMapPin,+ LucideMessageSquareMore,LucideTriangleAlert,REMOVE_FAVORITE: LucideStarOff}protected readonly originalOrderKeyValue = originalOrderKeyValue+ protected readonly TAB_MENU = TAB_MENUprotected loading = falseprotected galleryMode: ViewModeprotected favorites: FileFavoriteModel[] = []protected selected: FileFavoriteModel = null- protected tableHeaders: Record<'name' | 'location' | 'size' | 'modified' | 'created', TableHeaderConfig> = {+ protected tableHeaders: Record<'name' | 'location' | 'info' | 'size' | 'modified' | 'created', TableHeaderConfig> = {name: {label: 'Name',- width: 35,+ width: 30,textCenter: false,class: '',show: true,@@ -82,12 +101,13 @@ export class FavoritesComponent implements OnInit {},location: {label: 'Location',- width: 35,+ width: 25,textCenter: false,class: 'd-none d-md-table-cell fs-sm',show: true,sortable: true},+ info: { label: 'Info', width: 15, textCenter: true, class: 'd-none d-md-table-cell', show: true },size: {label: 'Size',width: 10,@@ -98,15 +118,16 @@ export class FavoritesComponent implements OnInit {},modified: {label: 'Modified',- width: 12,+ width: 10,textCenter: true,class: 'd-none d-sm-table-cell',+ newly: 'newly',show: true,sortable: true},created: {- label: 'Created',- width: 13,+ label: 'Added',+ width: 10,textCenter: true,class: 'd-none d-lg-table-cell',show: true,@@ -186,13 +207,23 @@ export class FavoritesComponent implements OnInit {this.layout.openContextMenu(ev, this.targetContextMenu)}- goTo(favorite: FileFavoriteModel = this.selected) {+ goTo(favorite: FileFavoriteModel = this.selected, tab?: TAB_MENU) {if (!favorite) returnif (favorite.isDisabled) {this.layout.sendNotification('warning', favorite.name, 'No longer accessible')return}- this.router.navigate([SPACES_PATH.SPACES, ...favorite.path.split('/')], { queryParams: { select: favorite.name } }).catch(console.error)+ this.router+ .navigate([SPACES_PATH.SPACES, ...favorite.path.split('/')], { queryParams: { select: favorite.name } })+ .then((navigated) => {+ if (navigated && tab) this.layout.showRSideBarTab(tab, true)+ })+ .catch(console.error)+ }++ goToDetails(ev: Event, favorite: FileFavoriteModel, tab: TAB_MENU) {+ ev.stopPropagation()+ this.goTo(favorite, tab)}removeFavorite(favorite: FileFavoriteModel = this.selected, ev?: Event) {diff --git a/frontend/src/app/applications/files/models/file-favorite.model.ts b/frontend/src/app/applications/files/models/file-favorite.model.tsindex f971cfe2..41d2f828 100644--- a/frontend/src/app/applications/files/models/file-favorite.model.ts+++ b/frontend/src/app/applications/files/models/file-favorite.model.ts@@ -9,13 +9,43 @@ export class FileFavoriteModel extends FileLocationModel implements FileFavoritesize: numberctime: numbercreatedAt: Date+ hasComments: boolean+ shares: { id: number; alias: string; name: string; type: number }[] = []+ links: { id: number; alias: string; name: string; type: number }[] = []+ spaces: { id: number; alias: string; name: string }[] = []+ syncs: { clientId: string; clientName: string; id: number }[] = []isDisabled: booleanhTimeAgo: string+ nbBadges = 0+ galleryBadges: ('shares' | 'spaces' | 'links' | 'syncs' | 'comments')[] = []newly = 0constructor(props: FileFavorite) {super(props, props.repository)+ this.setShares(props.shares)+ this.spaces = props.spaces || []+ this.syncs = props.syncs || []this.hTimeAgo = dJs(this.mtime).fromNow(true)this.newly = getNewly(this.mtime)+ this.updateNbBadges()+ }++ private updateNbBadges() {+ if (this.shares.length) this.galleryBadges.push('shares')+ if (this.spaces.length) this.galleryBadges.push('spaces')+ if (this.links.length) this.galleryBadges.push('links')+ if (this.syncs.length) this.galleryBadges.push('syncs')+ if (this.hasComments) this.galleryBadges.push('comments')+ this.nbBadges = this.galleryBadges.length+ }++ private setShares(shares: { id: number; alias: string; name: string; type: number }[]) {+ for (const share of shares || []) {+ if (share.type === 0) {+ this.shares.push(share)+ } else {+ this.links.push(share)+ }+ }}}