How can set file manager to readonly,
eg: hide “Add New” button, file context menu, or hide disk usage
Hello finzaiko
To hide “Add New” button and statistics information you need to customize filemanager view. Create your own view class by inheriting it from fileManager.views.folders. In this class you need to redefine the init function. You can get the “Add New” button and statistics using method queryView().
This code will return the first button found in the container:
const addNewButton = this.getRoot().queryView("button");
This code will return the view with the localId: “fs:stats”.
const stats = this.getRoot().queryView({localId: "fs:stats"})
After getting the access to the necessary views you can hide them this way:
addNewButton.hide();
stats.hide();
To hide filecontext menu you need to override the config method of the fileManager.views[“menus/contextmenu”] this way:
menu.on.onBeforeShow = e => {
return false;
};
Here return false will block the default onBeforeShow event.
After that replace the default classes with the custom classes via the override map:
override: new Map([
[fileManager.views.folders, CustomFolders],
[fileManager.views["menus/contextmenu"], CustomContextMenu]
])
Please take a look at the example: Code Snippet
Hi @Natalia_Shilova
Thanks for the explanation and giving me some references, its working expected