Skip to content

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

feat(frontend:files): enhance overwrite handling by updating MIME type on rename and improving file model consistency and UI visuals

johavenf68a07395487
diff --git a/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.html b/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.html
index b4dd1cd3..e629f432 100755
--- a/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.html
+++ b/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.html
@@ -17,16 +17,17 @@
</div>
<div class="modal-body">
@if (renamedTo) {
- <div
- [innerHTML]="'RenameFileToExisting' | translate:locale.language:{ old: files[0].name, new: renamedTo }">
- </div>
+ <div [innerHTML]="'RenameFileToExisting' | translate:locale.language:{ old: files[0].name, new: renamedTo }"></div>
} @else {
- <div l10nTranslate>Do you want to replace the existing file(s)?</div>
- <ul class="my-2" style="padding-left: inherit">
- @for (file of files; track $index) {
- <li><b>{{ file.name }}</b></li>
- }
- </ul>
+ <div class="fw-bold mb-3" l10nTranslate>Do you want to replace the existing file(s)?</div>
+ @for (f of files; track $index) {
+ <div class="d-flex align-items-center mb-1" draggable="true">
+ <img [src]="f.mimeUrl" alt="" height="24" width="24" (error)="f.fallBackMimeUrl()">
+ <div class="d-flex flex-column text-truncate ms-1">
+ <span>{{ f.name }}</span>
+ </div>
+ </div>
+ }
}
</div>
<div class="modal-footer">
diff --git a/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.ts b/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.ts
index b2d78b5a..47d9eb14 100644
--- a/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.ts
+++ b/frontend/src/app/applications/files/components/dialogs/files-overwrite-dialog.component.ts
@@ -9,6 +9,7 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome'
import { faFileShield } from '@fortawesome/free-solid-svg-icons'
import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'
import { LayoutService } from '../../../../layout/layout.service'
+import { FileModel } from '../../models/file.model'
@Component({
selector: 'app-files-overwrite-dialog',
@@ -16,7 +17,7 @@ import { LayoutService } from '../../../../layout/layout.service'
templateUrl: 'files-overwrite-dialog.component.html'
})
export class FilesOverwriteDialogComponent {
- @Input() files: File[] = []
+ @Input() files: FileModel[] = []
@Input() renamedTo: string
public overwrite = output<boolean>()
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
diff --git a/frontend/src/app/applications/files/models/file.model.ts b/frontend/src/app/applications/files/models/file.model.ts
index dfd7ac68..599a6768 100644
--- a/frontend/src/app/applications/files/models/file.model.ts
+++ b/frontend/src/app/applications/files/models/file.model.ts
@@ -117,6 +117,11 @@ export class FileModel implements File {
this.path = [...this.path.split('/').slice(0, -1), this.name].join('/')
}
+ updateMime(mime: string) {
+ this.mime = mime
+ this.setMimeUrl()
+ }
+
private getType(inShare: boolean) {
return this.isDir ? (inShare ? mimeDirectoryShare : mimeDirectory) : mimeFile
}
diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
index c46f4087..c9a8d359 100644
--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
@@ -480,7 +480,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
const f: FileModel = ev.object
const renamedTo = ev.name
let overwrite = false
- const fileExists = this.files.find((file) => file.name.toLowerCase() === renamedTo.toLowerCase() && file.id !== f.id)
+ const fileExists: FileModel = this.files.find((file) => file.name.toLowerCase() === renamedTo.toLowerCase() && file.id !== f.id)
if (fileExists) {
overwrite = await this.filesService.openOverwriteDialog([f], renamedTo)
if (!overwrite) return
@@ -493,6 +493,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
f.rename(dto.name)
f.isEditable = false
if (overwrite) {
+ f.updateMime(fileExists.mime)
this.sortBy(
this.sortTable.sortParam.column,
false,
@@ -584,7 +585,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
if (!overwrite) return
}
} else {
- const exist: File[] = [...ev.files].filter((f: File) => this.files.some((x) => x.name.toLowerCase() === f.name.toLowerCase()))
+ const exist: FileModel[] = this.files.filter((x: FileModel) => [...ev.files].some((f) => f.name.toLowerCase() === x.name.toLowerCase()))
if (exist.length > 0) {
overwrite = await this.filesService.openOverwriteDialog(exist)
if (!overwrite) return
@@ -595,7 +596,9 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
async onDropFiles(ev: { dataTransfer: { files: File[] } }) {
let overwrite = false
- const exist: File[] = [...ev.dataTransfer.files].filter((f: File) => this.files.some((x) => x.name.toLowerCase() === f.name.toLowerCase()))
+ const exist: FileModel[] = this.files.filter((x: FileModel) =>
+ [...ev.dataTransfer.files].some((f) => f.name.toLowerCase() === x.name.toLowerCase())
+ )
if (exist.length > 0) {
overwrite = await this.filesService.openOverwriteDialog(exist)
if (!overwrite) return
diff --git a/frontend/src/assets/mimes/image-bmp.svg b/frontend/src/assets/mimes/image-bmp.svg
new file mode 100644
index 00000000..b6651265
--- /dev/null
+++ b/frontend/src/assets/mimes/image-bmp.svg
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
+ <g fill-opacity=".078" transform="matrix(0.91581, 0, 0, 0.91581, 21.553526, 21.5499)">
+ <path d="m32.554 0c-4.774 0-8.59 3.266-8.59 7.313v497.38c0 4.047 3.816 7.313 8.59 7.313h446.89c4.774 0 8.59-3.266 8.59-7.313v-497.38c0-4.047-3.816-7.313-8.59-7.313h-446.89"/>
+ <path d="m35.614 3.5c-4.709 0-8.479 3.196-8.479 7.188v490.62c0 3.991 3.771 7.188 8.479 7.188h440.77c4.709 0 8.479-3.196 8.479-7.188v-490.62c0-3.991-3.771-7.188-8.479-7.188h-440.78"/>
+ <path d="m38.674 7c-4.643 0-8.369 3.158-8.369 7.094v483.82c0 3.936 3.725 7.094 8.369 7.094h434.65c4.643 0 8.369-3.158 8.369-7.094v-483.81c0-3.936-3.725-7.094-8.369-7.094h-434.65"/>
+ </g>
+ <path d="M 59.774 31.166 C 55.581 31.166 52.212 34.023 52.212 37.577 L 52.212 474.418 C 52.212 477.972 55.581 480.829 59.774 480.829 L 452.226 480.829 C 456.419 480.829 459.788 477.972 459.788 474.418 L 459.788 37.577 C 459.788 34.023 456.419 31.166 452.226 31.166 L 59.764 31.166" fill="#2dcc9f"/>
+ <path d="M 104.892 67.597 C 93.996 67.597 85.231 76.363 85.231 87.258 L 85.231 374.081 C 85.231 384.977 93.996 393.742 104.892 393.742 L 407.109 393.742 C 418.006 393.742 426.771 384.977 426.771 374.081 L 426.771 157.547 L 336.82 67.596 L 104.892 67.596" fill="#fff"/>
+ <path d="M 208.874 135.77 C 188.19 135.77 171.096 152.41 171.096 173.121 C 171.096 193.829 188.171 210.897 208.874 210.897 C 229.582 210.897 246.659 193.823 246.659 173.121 C 246.659 152.411 229.557 135.77 208.874 135.77 M 310.061 209.602 C 292.156 209.338 278.501 218.911 266.624 230.447 C 254.753 241.986 244.627 255.646 232.748 264.756 C 228.716 267.745 224.978 269.612 221.889 270.405 C 218.802 271.195 216.596 270.971 214.508 269.102 C 201.689 252.014 189.508 243.007 178.462 240.436 C 167.346 237.852 157.261 242.184 148.927 249.991 C 132.269 265.597 121.492 295.956 116.792 323.385 L 116.359 325.555 L 395.617 325.555 L 394.314 322.952 C 381.82 297.532 373.14 269.689 361.308 247.81 C 355.392 236.875 348.726 227.229 340.463 220.452 C 332.193 213.675 322.187 209.734 310.067 209.594" fill="#2dcc9f"/>
+ <path d="M 426.772 157.548 L 336.821 67.597 L 336.821 137.886 C 336.821 148.781 345.586 157.547 356.483 157.547 L 426.771 157.547" fill="#a4a4a4"/>
+</svg>
\ No newline at end of file