Skip to content

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

fix(frontend:files): sync read-only value with opening mode in the text editor

7185dfff2dcf152e
diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html
index 525e6e1f..e2bc7203 100644
--- a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html
+++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html
@@ -30,7 +30,7 @@
<app-files-viewer-document [currentHeight]="currentHeight" [file]="currentFile" [mode]="mode"></app-files-viewer-document>
}
@default {
- <app-files-viewer-text [currentHeight]="currentHeight" [file]="currentFile"></app-files-viewer-text>
+ <app-files-viewer-text [currentHeight]="currentHeight" [file]="currentFile" [mode]="mode"></app-files-viewer-text>
}
}
</div>
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.html b/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.html
index 4320619d..21a736f3 100644
--- a/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.html
+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.html
@@ -9,6 +9,7 @@
<button
(click)="toggleReadonly()"
[tooltip]="'Read-only' | translate:locale.language"
+ [adaptivePosition]="true"
container="body"
class="d-none d-sm-block btn btn-sm btn-secondary me-1"
type="button"
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts
index a3ef5e90..92db046b 100644
--- a/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts
+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts
@@ -6,7 +6,7 @@
import { CodeEditor } from '@acrodata/code-editor'
import { HttpClient } from '@angular/common/http'
-import { Component, inject, input, OnDestroy, OnInit, signal, ViewEncapsulation } from '@angular/core'
+import { Component, inject, input, linkedSignal, OnDestroy, OnInit, signal, ViewEncapsulation } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { LanguageDescription } from '@codemirror/language'
import { languages } from '@codemirror/language-data'
@@ -37,7 +37,8 @@ import { FilesUploadService } from '../../services/files-upload.service'
export class FilesViewerTextComponent implements OnInit, OnDestroy {
currentHeight = input<number>()
file = input<FileModel>()
- isReadonly = signal(true)
+ mode = input<'view' | 'edit'>('view')
+ isReadonly = linkedSignal(() => this.mode() === 'view')
isReadable = signal(false)
isModified = signal(false)
protected openSearchPanel = openSearchPanel