feat: add file view (#1064)
This commit is contained in:
@@ -30,6 +30,7 @@ export class FilesController extends AbstractViewController {
|
||||
allFiles: FileItem[] = []
|
||||
attachedFiles: FileItem[] = []
|
||||
showFileContextMenu = false
|
||||
showProtectedOverlay = false
|
||||
fileContextMenuLocation: FileContextMenuLocation = { x: 0, y: 0 }
|
||||
|
||||
override deinit(): void {
|
||||
@@ -52,9 +53,12 @@ export class FilesController extends AbstractViewController {
|
||||
showFileContextMenu: observable,
|
||||
fileContextMenuLocation: observable,
|
||||
|
||||
showProtectedOverlay: observable,
|
||||
|
||||
reloadAllFiles: action,
|
||||
reloadAttachedFiles: action,
|
||||
setShowFileContextMenu: action,
|
||||
setShowProtectedOverlay: action,
|
||||
setFileContextMenuLocation: action,
|
||||
})
|
||||
|
||||
@@ -79,6 +83,10 @@ export class FilesController extends AbstractViewController {
|
||||
this.showFileContextMenu = enabled
|
||||
}
|
||||
|
||||
setShowProtectedOverlay = (enabled: boolean) => {
|
||||
this.showProtectedOverlay = enabled
|
||||
}
|
||||
|
||||
setFileContextMenuLocation = (location: FileContextMenuLocation) => {
|
||||
this.fileContextMenuLocation = location
|
||||
}
|
||||
@@ -404,9 +412,15 @@ export class FilesController extends AbstractViewController {
|
||||
|
||||
setProtectionForFiles = async (protect: boolean, files: FileItem[]) => {
|
||||
if (protect) {
|
||||
await this.application.mutator.protectItems(files)
|
||||
const protectedItems = await this.application.mutator.protectItems(files)
|
||||
if (protectedItems) {
|
||||
this.setShowProtectedOverlay(true)
|
||||
}
|
||||
} else {
|
||||
await this.application.mutator.unprotectItems(files, ChallengeReason.UnprotectFile)
|
||||
const unprotectedItems = await this.application.mutator.unprotectItems(files, ChallengeReason.UnprotectFile)
|
||||
if (unprotectedItems) {
|
||||
this.setShowProtectedOverlay(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,8 @@ export class NavigationController extends AbstractViewController {
|
||||
setContextMenuClickLocation: action,
|
||||
setContextMenuPosition: action,
|
||||
setContextMenuMaxHeight: action,
|
||||
|
||||
isInFilesView: computed,
|
||||
})
|
||||
|
||||
this.disposers.push(
|
||||
@@ -257,6 +259,10 @@ export class NavigationController extends AbstractViewController {
|
||||
}
|
||||
}
|
||||
|
||||
public get isInFilesView(): boolean {
|
||||
return this.selectedUuid === SystemViewId.Files
|
||||
}
|
||||
|
||||
public get allLocalRootTags(): SNTag[] {
|
||||
if (this.editing_ instanceof SNTag && this.application.items.isTemplateItem(this.editing_)) {
|
||||
return [this.editing_, ...this.rootTags]
|
||||
|
||||
Reference in New Issue
Block a user