Skip to content

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

feat(frontend): show root levels in space breadcrumbs

johaven547fac108ff6
diff --git a/frontend/src/app/applications/admin/components/admin-groups.component.ts b/frontend/src/app/applications/admin/components/admin-groups.component.ts
index 6976d26c..96d4b5dd 100644
--- a/frontend/src/app/applications/admin/components/admin-groups.component.ts
+++ b/frontend/src/app/applications/admin/components/admin-groups.component.ts
@@ -326,7 +326,7 @@ export class AdminGroupsComponent {
url: this.personalGroupsView
? `/${ADMIN_PATH.BASE}/${ADMIN_PATH.PGROUPS}${pathFromRoutes(routes)}`
: `/${ADMIN_PATH.BASE}/${ADMIN_PATH.GROUPS}${pathFromRoutes(routes)}`,
- firstLink: `/${ADMIN_PATH.BASE}/${ADMIN_PATH.GROUPS}`,
+ firstLink: `/${ADMIN_PATH.BASE}/${this.personalGroupsView ? ADMIN_PATH.PGROUPS : ADMIN_PATH.GROUPS}`,
splicing: 1,
translating: true,
sameLink: false,
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 2068253b..b92b1efd 100644
--- a/frontend/src/app/applications/spaces/services/spaces-browser.service.ts
+++ b/frontend/src/app/applications/spaces/services/spaces-browser.service.ts
@@ -1,12 +1,11 @@
-import { HttpClient, HttpErrorResponse } from '@angular/common/http'
+import { HttpClient } from '@angular/common/http'
import { inject, Injectable } from '@angular/core'
import { UrlSegment } from '@angular/router'
import type { LucideIcon } from '@lucide/angular'
import { API_SPACES_BROWSE } from '@sync-in-server/backend/src/applications/spaces/constants/routes'
import { SPACE_REPOSITORY } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
import type { SpaceFiles } from '@sync-in-server/backend/src/applications/spaces/interfaces/space-files.interface'
-import { catchError, Observable, throwError } from 'rxjs'
-import { tap } from 'rxjs/operators'
+import { Observable, tap } from 'rxjs'
import { buildUrlFromRoutes, pathFromRoutes } from '../../../common/utils/functions'
import { BreadCrumbUrl } from '../../../layout/breadcrumb/breadcrumb.interfaces'
import { LayoutService } from '../../../layout/layout.service'
@@ -22,19 +21,19 @@ export class SpacesBrowserService {
private breadCrumbIcon: LucideIcon
private breadCrumbFilesRepo = false
private inShareRepo = false
- private inRootSpace = false
+ private inRootShare = false
setEnvironment(repository: SPACE_REPOSITORY, routes: UrlSegment[]) {
this.breadCrumbFilesRepo = SPACES_PATH.FILES === repository
- this.inPersonalSpace = routes.length && routes[0].path === SPACES_PATH.PERSONAL
+ this.inPersonalSpace = routes[0]?.path === SPACES_PATH.PERSONAL
this.inShareRepo = repository === SPACES_PATH.SHARES
- this.inRootSpace = this.inShareRepo ? routes.length === 0 : routes.length === 1
+ this.inRootShare = this.inShareRepo && routes.length === 0
this.browseApi = buildUrlFromRoutes(`${API_SPACES_BROWSE}/${repository}`, routes, false)
this.breadCrumbUrl = `/${SPACES_PATH.SPACES}/${repository}${pathFromRoutes(routes)}`
this.breadCrumbIcon = this.inShareRepo
? SPACES_ICON.SHARED_WITH_ME
: this.breadCrumbFilesRepo
- ? this.inPersonalSpace && this.breadCrumbFilesRepo
+ ? this.inPersonalSpace
? SPACES_ICON.PERSONAL
: SPACES_ICON.SPACES
: SPACES_ICON.TRASH
@@ -45,42 +44,38 @@ export class SpacesBrowserService {
tap((spaceFiles) => {
this.layout.setBreadcrumbIcon(this.breadCrumbIcon)
this.layout.setBreadcrumbNav(this.breadcrumbNav(spaceFiles.space.name))
- }),
- catchError((e: HttpErrorResponse) => {
- return throwError(() => e)
})
)
}
private breadcrumbNav(spaceName: string): BreadCrumbUrl {
const mutateLevel: NonNullable<BreadCrumbUrl['mutateLevel']> = {}
- if (this.inPersonalSpace && !this.breadCrumbFilesRepo && !this.inRootSpace) {
+ const personalLevel = { setTitle: SPACES_TITLE.PERSONAL_SPACE, translateTitle: true }
+ const inPersonalFiles = this.breadCrumbFilesRepo && this.inPersonalSpace
+ const rootLink = this.inShareRepo
+ ? SPACES_PATH.SPACES_SHARES
+ : inPersonalFiles
+ ? SPACES_PATH.PERSONAL_FILES
+ : this.breadCrumbFilesRepo
+ ? SPACES_PATH.SPACES
+ : SPACES_PATH.TRASH
+ if (inPersonalFiles) {
+ mutateLevel[0] = personalLevel
+ } else if (!this.inRootShare) {
mutateLevel[0] = {
- setTitle: SPACES_TITLE.PERSONAL_SPACE,
+ setTitle: this.inShareRepo ? SPACES_TITLE.SHARED_WITH_ME : this.breadCrumbFilesRepo ? SPACES_TITLE.COLLABORATIVE_SPACES : SPACES_TITLE.TRASH,
translateTitle: true
}
- } else if (spaceName && !this.inPersonalSpace && !(this.inShareRepo && this.inRootSpace)) {
- mutateLevel[0] = { setTitle: spaceName }
+ if (this.inPersonalSpace) mutateLevel[1] = personalLevel
+ else if (spaceName) mutateLevel[1] = { setTitle: spaceName }
}
return {
- url:
- this.inPersonalSpace && this.inRootSpace
- ? `${this.breadCrumbUrl}/${SPACES_TITLE.PERSONAL_SPACE}`
- : this.inShareRepo && this.inRootSpace
- ? `${this.breadCrumbUrl}/${SPACES_TITLE.SHARED_WITH_ME}`
- : this.breadCrumbUrl,
- translating: this.inRootSpace && (this.inPersonalSpace || this.inShareRepo),
- sameLink: this.inRootSpace && (this.inPersonalSpace || this.inShareRepo),
- firstLink:
- this.inPersonalSpace && this.breadCrumbFilesRepo
- ? null
- : this.breadCrumbFilesRepo
- ? SPACES_PATH.SPACES
- : this.inShareRepo
- ? SPACES_PATH.SPACES_SHARES
- : SPACES_PATH.TRASH,
- mutateLevel: Object.keys(mutateLevel).length ? mutateLevel : null,
- splicing: this.inPersonalSpace ? (!this.breadCrumbFilesRepo && !this.inRootSpace ? 2 : 3) : 2
+ url: this.inRootShare ? `${this.breadCrumbUrl}/${SPACES_TITLE.SHARED_WITH_ME}` : this.breadCrumbUrl,
+ translating: this.inRootShare,
+ sameLink: this.inRootShare,
+ firstLink: rootLink,
+ mutateLevel,
+ splicing: this.inRootShare || inPersonalFiles ? 2 : 1
} satisfies BreadCrumbUrl
}
}
diff --git a/frontend/src/app/layout/breadcrumb/breadcrumb.component.html b/frontend/src/app/layout/breadcrumb/breadcrumb.component.html
index a00766df..6dab2dfb 100644
--- a/frontend/src/app/layout/breadcrumb/breadcrumb.component.html
+++ b/frontend/src/app/layout/breadcrumb/breadcrumb.component.html
@@ -1,7 +1,9 @@
<div class="breadcrumb">
<div class="breadcrumb-content">
@for (item of levels; track $index) {
- @if ($index > 1) {
+ @if ($index === 1) {
+ <svg [lucideIcon]="icons.LucideChevronRight"></svg>
+ } @else if ($index > 1) {
<svg
class="breadcrumb-mobile-hidden"
[lucideIcon]="icons.LucideChevronRight">
diff --git a/frontend/src/app/layout/breadcrumb/breadcrumb.component.ts b/frontend/src/app/layout/breadcrumb/breadcrumb.component.ts
index 79116872..b4dbac4e 100644
--- a/frontend/src/app/layout/breadcrumb/breadcrumb.component.ts
+++ b/frontend/src/app/layout/breadcrumb/breadcrumb.component.ts
@@ -1,7 +1,7 @@
import { Component, inject, OnDestroy } from '@angular/core'
import { RouterLink, RouterLinkActive } from '@angular/router'
import type { LucideIcon } from '@lucide/angular'
-import { LucideChevronRight, LucideDynamicIcon, LucideHouse } from '@lucide/angular'
+import { LucideChevronRight, LucideDynamicIcon } from '@lucide/angular'
import { Subscription } from 'rxjs'
import { LayoutService } from '../layout.service'
import { BreadCrumbUrl } from './breadcrumb.interfaces'
@@ -13,7 +13,7 @@ import { BreadCrumbUrl } from './breadcrumb.interfaces'
})
export class BreadcrumbComponent implements OnDestroy {
protected readonly icons = { LucideChevronRight }
- protected breadcrumbIcon: LucideIcon = LucideHouse
+ protected breadcrumbIcon: LucideIcon = null
protected levels: { link: string[] | string; title: string }[] = []
private readonly layout = inject(LayoutService)
private subscriptions: Subscription[] = []
@@ -35,30 +35,25 @@ export class BreadcrumbComponent implements OnDestroy {
const mutateLevel = url.mutateLevel || null
const urlTabs = url.url.split('/').slice(1)
this.levels = []
- if (urlTabs.length >= 1 && urlTabs[0]) {
- // first item with breadcrumb icon only
+ if (urlTabs[0]) {
let link = `/${urlTabs.splice(0, splicing).join('/')}`
- this.levels.push({ link: firstLink || link, title: '' })
for (const { index, item } of urlTabs.filter((i) => i !== '').map((item, index) => ({ index, item }))) {
// ignore url args (ex: ?select=...)
let sanitized_item = item.split('?')[0]
- if (!sameLink || (mutateLevel && mutateLevel[index] && mutateLevel[index].setUrl)) {
+ const mutation = mutateLevel?.[index]
+ if (!sameLink || mutation?.setUrl) {
link += '/' + sanitized_item
}
- if (mutateLevel && mutateLevel[index]) {
- if (mutateLevel[index].hide) continue
- if (mutateLevel[index].setTitle) {
- sanitized_item = mutateLevel[index].translateTitle
- ? this.layout.translateString(mutateLevel[index].setTitle)
- : mutateLevel[index].setTitle
+ if (mutation) {
+ if (mutation.hide) continue
+ if (mutation.setTitle) {
+ sanitized_item = mutation.translateTitle ? this.layout.translateString(mutation.setTitle) : mutation.setTitle
}
} else if (translating) {
sanitized_item = this.layout.translateString(sanitized_item)
}
- this.levels.push({ link, title: sanitized_item })
+ this.levels.push({ link: index === 0 && firstLink ? firstLink : link, title: sanitized_item })
}
- } else {
- this.levels.push({ link: ['/'], title: '' })
}
}
}
diff --git a/frontend/src/styles/components/_header.scss b/frontend/src/styles/components/_header.scss
index 2aa622af..be6b63ca 100644
--- a/frontend/src/styles/components/_header.scss
+++ b/frontend/src/styles/components/_header.scss
@@ -515,13 +515,14 @@
overflow: visible;
> a {
- color: $gray-lightest !important;
+ gap: .4rem;
margin-right: .3rem;
}
}
> a {
display: flex;
+ align-items: center;
min-width: 0;
color: darken($gray-light, 10%);
text-decoration: none;
@@ -544,6 +545,7 @@
}
> .lucide {
+ flex-shrink: 0;
font-size: $font-size-md;
color: $sidebar-light-apps-menu-title-color;
}