Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileBrowser - Permissions Incorrect during Open of Dialog #1095

Closed
WatchfulEyeOfZod opened this issue Mar 10, 2024 · 0 comments
Closed

FileBrowser - Permissions Incorrect during Open of Dialog #1095

WatchfulEyeOfZod opened this issue Mar 10, 2024 · 0 comments

Comments

@WatchfulEyeOfZod
Copy link

Jodit Version: 4.0

Browser: Chrome
OS: Mac
Is React App: False

Description

When the filebrowser is opened, it attempts to determine the visibility of buttons with the dataprovider.canI() method. However, this results in the the canI call being made before the permissions have been fetched from the back end resulting in incorrect permissions. In addition, the __getButtons method only adds the buttons to the toolbar (or not) during dialog open, so if the initial set of permissions are not correct, the buttons never show regardless of permissions on other folders or sources.

The __getButtons() call should be eliminated.

Code

--- a/src/modules/file-browser/file-browser.ts
+++ b/src/modules/file-browser/file-browser.ts
@@ -271,7 +271,13 @@ export class FileBrowser extends ViewWithToolbar implements IFileBrowser, Dlgs {

                                const header = this.c.div();

-                               this.toolbar?.build(this.__getButtons()).appendTo(header);
+                               // the __getButtons() call is not valid. It prevents the buttons from EVER displaying
+                               // regardless of permissions since they are never added to the header.
+                               // this.toolbar?.build(this.__getButtons()).appendTo(header);
+
+                               this.toolbar
+                                       ?.build(this.o.buttons ?? ([] as ButtonsOption))
+                                       .appendTo(header);

                                this._dialog.open(this.browser, header);

The getButtons call should not filter the existence of the buttons, but rather set the enabled/disabled state of the button.

Expected behavior:
Buttons are enabled/ disabled based on the permissions returned from the backend

Actual behavior:
Buttons are added/removed removed based on the results of the first call to the canI method which may not be correct for all sources/folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants