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(frontend:files): refine copy-move navigation and tree roots
johaven7f20da3898e3
diff --git a/frontend/src/app/applications/comments/models/comment-recent.model.ts b/frontend/src/app/applications/comments/models/comment-recent.model.tsindex 436399f0..c03ce5f5 100644--- a/frontend/src/app/applications/comments/models/comment-recent.model.ts+++ b/frontend/src/app/applications/comments/models/comment-recent.model.ts@@ -1,6 +1,6 @@import { IconDefinition } from '@fortawesome/fontawesome-svg-core'import type { CommentRecent } from '@sync-in-server/backend/src/applications/comments/interfaces/comment-recent.interface'-import { resolveFileLocation } from '../../files/file-location.utils'+import { resolveFileLocation } from '../../files/components/utils/file-location.utils'import { getAssetsMimeUrl } from '../../files/files.constants'import { OwnerType } from '../../users/interfaces/owner.interface'import { userAvatarUrl } from '../../users/user.functions'diff --git a/frontend/src/app/applications/files/components/sidebar/files-tree.component.html b/frontend/src/app/applications/files/components/sidebar/files-tree.component.htmlindex 94b6fb99..37b69b9f 100644--- a/frontend/src/app/applications/files/components/sidebar/files-tree.component.html+++ b/frontend/src/app/applications/files/components/sidebar/files-tree.component.html@@ -1,13 +1,7 @@@if (sideBarHeader) {<div class="sidebar-component-title justify-content-between position-relative"><div class="sidebar-component-title-side"></div>- <div class="sidebar-component-title-label">- @if (errorMsg && !srcAllowed) {- <span class="text-danger fs-sm p-1" l10nTranslate>{{ errorMsg }}</span>- } @else {- <span l10nTranslate>Navigation</span>- }- </div>+ <div class="sidebar-component-title-label" l10nTranslate>Navigation</div><div class="sidebar-component-title-side"><button (click)="onRefresh()" class="btn btn-sm btn-default" type="button"><fa-icon [icon]="icons.faArrowRotateRight"></fa-icon>@@ -21,13 +15,13 @@<div #copyMovePanel class="bg-white p-2 fs-sm"><div class="d-flex"><div class="d-flex flex-column align-items-center me-2 text-muted">- <span class="border rounded-circle d-flex align-items-center justify-content-center p-1 lh-1">+ <span class="border rounded-circle d-flex align-items-center justify-content-center p-2 lh-1"><fa-icon[icon]="files.length === 1 ? (files[0].isDir ? icons.faFolder : icons.faFile) : files.length > 1 ? icons.faObjectGroup : icons.faQuestion"[fixedWidth]="true"></fa-icon></span>- <span class="border-start flex-grow-1"></span>+ <span class="copy-move-connector border-start flex-grow-1"></span></div><div class="flex-grow-1 overflow-hidden pb-2"><div class="text-muted mb-1">@@ -66,12 +60,15 @@<app-files-summary [files]="files"></app-files-summary>}}+ @if (errorMsg && !srcAllowed) {+ <div class="text-danger mt-1" l10nTranslate>{{ errorMsg }}</div>+ }</div></div><div class="d-flex"><div class="d-flex flex-column align-items-center me-2 text-muted">- <span class="border rounded-circle d-flex align-items-center justify-content-center p-1 lh-1">+ <span class="border rounded-circle d-flex align-items-center justify-content-center p-2 lh-1"><fa-icon [icon]="destination?.icon || icons.faQuestion" [fixedWidth]="true"></fa-icon></span></div>@@ -84,18 +81,19 @@}</div><div class="app-small-card files-summary-card border rounded d-flex align-items-center px-2 py-2">- @if (errorMsg && !dstAllowed) {- <span class="text-danger text-truncate mx-auto" l10nTranslate>{{ errorMsg }}</span>- } @else if (selection && dstAllowed) {+ @if (selection && dstAllowed) {<span class="text-bold text-truncate">{{ selection.data.name }}</span>} @else {<fa-icon [icon]="icons.faQuestion" class="text-muted mx-auto"></fa-icon>}</div>+ @if (errorMsg && !dstAllowed) {+ <div class="text-danger mt-1" l10nTranslate>{{ errorMsg }}</div>+ }</div></div>- <div class="d-flex gap-2 pt-1 w-100 mt-2">+ <div class="d-flex gap-2 w-100 mt-3"><button (click)="actionMove()"[disabled]="!selection || !files.length || !srcAllowed || !dstAllowed"class="btn btn-sm btn-warning flex-fill"@@ -134,6 +132,9 @@class="node-wrapper"><tree-node-expander [class.toggle-children-file]="!node.data.isDir"[class.toggle-children-shared]="node.data.inShare"+ [class.tree-root-personal]="node.data.id === 0"+ [class.tree-root-shares]="node.data.id === -2"+ [class.tree-root-spaces]="node.data.id === -1"[node]="node"></tree-node-expander><div [class.node-content-wrapper-active]="node.isActive" class="node-content-wrapper">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.tsindex e8077d64..5da66e59 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@@ -20,7 +20,7 @@ import { LayoutService } from '../../../../layout/layout.service'import { StoreService } from '../../../../store/store.service'import { SPACES_PATH, SPACES_TITLE } from '../../../spaces/spaces.constants'import { UserService } from '../../../users/user.service'-import { resolveFileLocation } from '../../file-location.utils'+import { resolveFileLocation } from '../utils/file-location.utils'import { mimeDirectory } from '../../files.constants'import type { FileModel } from '../../models/file.model'import { FilesService } from '../../services/files.service'@@ -194,10 +194,16 @@ export class FilesTreeComponent implements OnInit, OnDestroy {return resolveFileLocation(selection.data.path, {repository: selection.data.inShare ? 'share' : undefined,excludeLeaf: true,- displayLeafName: selection.parent?.data?.name+ displayRootName: this.getRepositoryRootName(selection)})}+ private getRepositoryRootName(selection: TreeNode): string | undefined {+ let repositoryRoot = selection+ while (repositoryRoot.parent && ![0, -1, -2].includes(repositoryRoot.parent.data?.id)) repositoryRoot = repositoryRoot.parent+ return [-1, -2].includes(repositoryRoot.parent?.data?.id) ? repositoryRoot.data.name : undefined+ }+private initRoot() {this.nodes = []if (this.user.userHavePermission(USER_PERMISSION.PERSONAL_SPACE)) {diff --git a/frontend/src/app/applications/files/file-location.utils.ts b/frontend/src/app/applications/files/components/utils/file-location.utils.tssimilarity index 90%rename from frontend/src/app/applications/files/file-location.utils.tsrename to frontend/src/app/applications/files/components/utils/file-location.utils.tsindex 65f52406..c6e56b1c 100644--- a/frontend/src/app/applications/files/file-location.utils.ts+++ b/frontend/src/app/applications/files/components/utils/file-location.utils.ts@@ -1,6 +1,6 @@import type { IconDefinition } from '@fortawesome/fontawesome-svg-core'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 } from '../../../spaces/spaces.constants'type FileLocationRepository = 'personal' | 'space' | 'share'@@ -15,7 +15,7 @@ interface FileLocationOptions {repository?: FileLocationRepositoryappendName?: stringexcludeLeaf?: boolean- displayLeafName?: string+ displayRootName?: string}const FILE_LOCATION_PRESENTATION: Record<FileLocationRepository, Pick<FileLocationPresentation, 'icon' | 'iconClass'>> = {@@ -32,7 +32,7 @@ export function resolveFileLocation(path: string, options: FileLocationOptions =if (!repository) return undefinedconst relativeSegments = segments.slice(segments[1] === SPACE_ALIAS.PERSONAL ? 2 : segments.length ? 1 : 0)if (options.excludeLeaf) relativeSegments.pop()- if (options.displayLeafName && relativeSegments.length) relativeSegments[relativeSegments.length - 1] = options.displayLeafName+ if (repository !== 'personal' && options.displayRootName && relativeSegments.length) relativeSegments[0] = options.displayRootNameif (options.appendName) relativeSegments.push(options.appendName)return {repository,diff --git a/frontend/src/app/applications/files/models/file-content.model.ts b/frontend/src/app/applications/files/models/file-content.model.tsindex 3cf9b27a..b4e37788 100644--- a/frontend/src/app/applications/files/models/file-content.model.ts+++ b/frontend/src/app/applications/files/models/file-content.model.ts@@ -1,6 +1,6 @@import { IconDefinition } from '@fortawesome/fontawesome-svg-core'import type { FileContent } from '@sync-in-server/backend/src/applications/files/schemas/file-content.interface'-import { resolveFileLocation } from '../file-location.utils'+import { resolveFileLocation } from '../components/utils/file-location.utils'import { defaultMimeUrl, getAssetsMimeUrl } from '../files.constants'export class FileContentModel implements FileContent {diff --git a/frontend/src/app/applications/files/models/file-recent.model.ts b/frontend/src/app/applications/files/models/file-recent.model.tsindex 74e8ccfb..d9b5be5f 100644--- a/frontend/src/app/applications/files/models/file-recent.model.ts+++ b/frontend/src/app/applications/files/models/file-recent.model.ts@@ -1,7 +1,7 @@import { IconDefinition } from '@fortawesome/fontawesome-svg-core'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 { resolveFileLocation } from '../file-location.utils'+import { resolveFileLocation } from '../components/utils/file-location.utils'import { defaultMimeUrl, getAssetsMimeUrl } from '../files.constants'export class FileRecentModel implements FileRecent {diff --git a/frontend/src/app/applications/sync/models/sync-path.model.ts b/frontend/src/app/applications/sync/models/sync-path.model.tsindex 2de76919..1b0eaa3c 100644--- a/frontend/src/app/applications/sync/models/sync-path.model.ts+++ b/frontend/src/app/applications/sync/models/sync-path.model.ts@@ -11,7 +11,7 @@ import {mimeDirectoryShare,mimeDirectorySync} from '../../files/files.constants'-import { resolveFileLocation } from '../../files/file-location.utils'+import { resolveFileLocation } from '../../files/components/utils/file-location.utils'import { hasWritePermission } from '../sync.utils'export class SyncPathModel implements Partial<SyncPath> {diff --git a/frontend/src/styles/components/_theme_dark.scss b/frontend/src/styles/components/_theme_dark.scssindex 0e09cd2a..616e8336 100755--- a/frontend/src/styles/components/_theme_dark.scss+++ b/frontend/src/styles/components/_theme_dark.scss@@ -69,6 +69,10 @@color: $gray-light;}+ .copy-move-connector {+ border-color: $dark-surface-border !important;+ }+hr {border-top-color: $dark-control-sidebar-separator-color !important;opacity: 1;diff --git a/frontend/src/styles/components/_tree.scss b/frontend/src/styles/components/_tree.scssindex c460c3fe..7a2dd65b 100644--- a/frontend/src/styles/components/_tree.scss+++ b/frontend/src/styles/components/_tree.scss@@ -2,6 +2,10 @@@return "rgb(#{red($hexColor)},#{green($hexColor)},#{blue($hexColor)})";}+$tree-root-personal-icon: 'M448 448L64 448c-35.3 0-64-28.7-64-64l0-176 512 0 0 176c0 35.3-28.7 64-64 64zm64-288L0 160 0 96C0 60.7 28.7 32 64 32l138.7 0c13.8 0 27.3 4.5 38.4 12.8l38.4 28.8c5.5 4.2 12.3 6.4 19.2 6.4L448 80c35.3 0 64 28.7 64 64l0 16z';+$tree-root-spaces-icon: 'M232.5 5.2c14.9-6.9 32.1-6.9 47 0l218.6 101c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 149.8C5.4 145.8 0 137.3 0 128s5.4-17.9 13.9-21.8L232.5 5.2zM48.1 218.4l164.3 75.9c27.7 12.8 59.6 12.8 87.3 0l164.3-75.9 34.1 15.8c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 277.8C5.4 273.8 0 265.3 0 256s5.4-17.9 13.9-21.8l34.1-15.8zM13.9 362.2l34.1-15.8 164.3 75.9c27.7 12.8 59.6 12.8 87.3 0l164.3-75.9 34.1 15.8c8.5 3.9 13.9 12.4 13.9 21.8s-5.4 17.9-13.9 21.8l-218.6 101c-14.9 6.9-32.1 6.9-47 0L13.9 405.8C5.4 401.8 0 393.3 0 384s5.4-17.9 13.9-21.8z';+$tree-root-shares-icon: 'M384 192c53 0 96-43 96-96s-43-96-96-96-96 43-96 96c0 5.4 .5 10.8 1.3 16L159.6 184.1c-16.9-15-39.2-24.1-63.6-24.1-53 0-96 43-96 96s43 96 96 96c24.4 0 46.6-9.1 63.6-24.1L289.3 400c-.9 5.2-1.3 10.5-1.3 16 0 53 43 96 96 96s96-43 96-96-43-96-96-96c-24.4 0-46.6 9.1-63.6 24.1L190.7 272c.9-5.2 1.3-10.5 1.3-16s-.5-10.8-1.3-16l129.7-72.1c16.9 15 39.2 24.1 63.6 24.1z';+@mixin directory($color) {content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#{hexToRGBString($color)}" d="M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H288c-10.1 0-19.6-4.7-25.6-12.8L243.2 57.6C231.1 41.5 212.1 32 192 32H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"/></svg>');display: inline-block;@@ -11,10 +15,40 @@@mixin caret($color) {content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path fill="#{hexToRGBString($color)}" d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z"/></svg>');display: inline-block;- width: 10px;+ width: 8px;+ position: absolute;+ left: 4px;+ top: 6px;+}++@mixin tree-root-icon($color, $path) {+ content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#{hexToRGBString($color)}" d="#{$path}"/></svg>');+ width: 13px;position: absolute;- left: 3px;- top: 4px;+ left: 50%;+ top: 50%;+ transform: translate(-50%, -50%);+}++@mixin tree-root($color, $path) {+ .toggle-children-wrapper .toggle-children {+ width: 26px;+ height: 24px;+ border-radius: 0.25rem;+ background-color: $color;++ &:before {+ @include tree-root-icon($gray, $path);+ }++ &:after {+ content: none;+ }+ }++ .toggle-children-wrapper-expanded .toggle-children:before {+ @include tree-root-icon(white, $path);+ }}@mixin file($color) {@@ -124,6 +158,18 @@}}+ .tree-root-personal {+ @include tree-root($primary, $tree-root-personal-icon);+ }++ .tree-root-spaces {+ @include tree-root($primary, $tree-root-spaces-icon);+ }++ .tree-root-shares {+ @include tree-root($purple, $tree-root-shares-icon);+ }+.toggle-children-shared {.toggle-children-placeholder {&:before {