File tree 9 files changed +91
-27
lines changed
app/code/Magento/MediaGalleryUi
9 files changed +91
-27
lines changed Original file line number Diff line number Diff line change @@ -36,15 +36,17 @@ public function __construct(
36
36
*/
37
37
public function getButtonData ()
38
38
{
39
- if (!$ this ->authorization ->isAllowed (self ::ACL_CREATE_FOLDER )) {
40
- return [];
41
- }
42
-
43
- return [
39
+ $ buttonData = [
44
40
'label ' => __ ('Create Folder ' ),
45
41
'on_click ' => 'jQuery("#create_folder").trigger("create_folder"); ' ,
46
42
'class ' => 'action-default scalable add media-gallery-actions-buttons ' ,
47
43
'sort_order ' => 10 ,
48
44
];
45
+
46
+ if (!$ this ->authorization ->isAllowed (self ::ACL_CREATE_FOLDER )) {
47
+ $ buttonData ['disabled ' ] = 'disabled ' ;
48
+ }
49
+
50
+ return $ buttonData ;
49
51
}
50
52
}
Original file line number Diff line number Diff line change @@ -34,17 +34,19 @@ public function __construct(
34
34
/**
35
35
* @return array
36
36
*/
37
- public function getButtonData ()
37
+ public function getButtonData (): array
38
38
{
39
- if (!$ this ->authorization ->isAllowed (self ::ACL_DELETE_ASSETS )) {
40
- return [];
41
- }
42
-
43
- return [
39
+ $ buttonData = [
44
40
'label ' => __ ('Delete Images... ' ),
45
41
'on_click ' => 'jQuery(window).trigger("massAction.MediaGallery") ' ,
46
42
'class ' => 'action-default scalable add media-gallery-actions-buttons ' ,
47
43
'sort_order ' => 50 ,
48
44
];
45
+
46
+ if (!$ this ->authorization ->isAllowed (self ::ACL_DELETE_ASSETS )) {
47
+ $ buttonData ['disabled ' ] = 'disabled ' ;
48
+ }
49
+
50
+ return $ buttonData ;
49
51
}
50
52
}
Original file line number Diff line number Diff line change @@ -36,16 +36,17 @@ public function __construct(
36
36
*/
37
37
public function getButtonData ()
38
38
{
39
- if (!$ this ->authorization ->isAllowed (self ::ACL_DELETE_FOLDER )) {
40
- return [];
41
- }
42
-
43
- return [
39
+ $ buttonData = [
44
40
'label ' => __ ('Delete Folder ' ),
45
41
'disabled ' => 'disabled ' ,
46
42
'on_click ' => 'jQuery("#delete_folder").trigger("delete_folder"); ' ,
47
43
'class ' => 'action-default scalable add media-gallery-actions-buttons ' ,
48
44
'sort_order ' => 30 ,
49
45
];
46
+ if (!$ this ->authorization ->isAllowed (self ::ACL_DELETE_FOLDER )) {
47
+ $ buttonData ['disabled ' ] = 'disabled ' ;
48
+ }
49
+
50
+ return $ buttonData ;
50
51
}
51
52
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \MediaGalleryUi \Ui \Component \Control ;
7
+
8
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
9
+ use Magento \Framework \AuthorizationInterface ;
10
+
11
+ /**
12
+ * Add selected button
13
+ */
14
+ class InsertAsstes implements ButtonProviderInterface
15
+ {
16
+ private const ACL_INSERT_ASSETS = 'Magento_MediaGallery::insert_assets ' ;
17
+
18
+ /**
19
+ * @var AuthorizationInterface
20
+ */
21
+ private $ authorization ;
22
+
23
+ /**
24
+ * Constructor.
25
+ *
26
+ * @param AuthorizationInterface $authorization
27
+ */
28
+ public function __construct (
29
+ AuthorizationInterface $ authorization
30
+ ) {
31
+ $ this ->authorization = $ authorization ;
32
+ }
33
+
34
+ /**
35
+ * @inheritdoc
36
+ */
37
+ public function getButtonData ()
38
+ {
39
+ $ buttonData = [
40
+ 'label ' => __ ('Add Selected ' ),
41
+ 'on_click ' => 'return false;"); ' ,
42
+ 'class ' => 'action-primary no-display media-gallery-add-selected ' ,
43
+ 'sort_order ' => 110 ,
44
+ ];
45
+
46
+ if (!$ this ->authorization ->isAllowed (self ::ACL_INSERT_ASSETS )) {
47
+ $ buttonData ['disabled ' ] = 'disabled ' ;
48
+ }
49
+
50
+ return $ buttonData ;
51
+ }
52
+ }
Original file line number Diff line number Diff line change @@ -36,16 +36,18 @@ public function __construct(
36
36
*/
37
37
public function getButtonData ()
38
38
{
39
- if (!$ this ->authorization ->isAllowed (self ::ACL_UPLOAD_ASSETS )) {
40
- return [];
41
- }
42
-
43
- return [
39
+ $ buttonData = [
44
40
'label ' => __ ('Upload Image ' ),
45
41
'disabled ' => 'disabled ' ,
46
42
'on_click ' => 'jQuery("#image-uploader-input").click(); ' ,
47
43
'class ' => 'action-default scalable add media-gallery-actions-buttons ' ,
48
44
'sort_order ' => 20 ,
49
45
];
46
+
47
+ if (!$ this ->authorization ->isAllowed (self ::ACL_UPLOAD_ASSETS )) {
48
+ $ buttonData ['disabled ' ] = 'disabled ' ;
49
+ }
50
+
51
+ return $ buttonData ;
50
52
}
51
53
}
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ public function prepare(): void
50
50
array_replace_recursive (
51
51
(array ) $ this ->getData ('config ' ),
52
52
[
53
+ 'allowedActions ' => [],
53
54
'getDirectoryTreeUrl ' => $ this ->url ->getUrl ("media_gallery/directories/gettree " ),
54
55
'deleteDirectoryUrl ' => $ this ->url ->getUrl ("media_gallery/directories/delete " ),
55
56
'createDirectoryUrl ' => $ this ->url ->getUrl ("media_gallery/directories/create " )
Original file line number Diff line number Diff line change 16
16
</argument >
17
17
<settings >
18
18
<buttons >
19
- <button name =" add_selected" >
20
- <param name =" on_click" xsi : type =" string" >return false;</param >
21
- <param name =" sort_order" xsi : type =" number" >110</param >
22
- <class >action-primary no-display media-gallery-add-selected</class >
23
- <label translate =" true" >Add Selected</label >
24
- </button >
19
+ <button name =" add_selected" class =" Magento\MediaGalleryUi\Ui\Component\Control\InsertAsstes" />
25
20
<button name =" cancel" >
26
21
<param name =" on_click" xsi : type =" string" >MediabrowserUtility.closeDialog();</param >
27
22
<param name =" sort_order" xsi : type =" number" >1</param >
Original file line number Diff line number Diff line change @@ -179,6 +179,10 @@ define([
179
179
* @param {String } folderId
180
180
*/
181
181
setActive : function ( folderId ) {
182
+ if ( ! $ . inArray ( 'delete_folder' , this . allowedActions ) ) {
183
+ return ;
184
+ }
185
+
182
186
this . selectedFolder ( folderId ) ;
183
187
$ ( this . deleteButtonSelector ) . removeAttr ( 'disabled' ) . removeClass ( 'disabled' ) ;
184
188
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ define([
16
16
17
17
return Component . extend ( {
18
18
defaults : {
19
+ allowedActions : [ ] ,
19
20
deleteButtonSelector : '#delete_selected_massaction' ,
20
21
deleteImagesSelector : '#delete_massaction' ,
21
22
mediaGalleryImageDetailsName : 'mediaGalleryImageDetails' ,
@@ -106,6 +107,10 @@ define([
106
107
* If images records less than one, disable "delete images" button
107
108
*/
108
109
checkButtonVisibility : function ( ) {
110
+ if ( ! $ . inArray ( 'delete_assets' , this . allowedActions ) ) {
111
+ return ;
112
+ }
113
+
109
114
if ( this . imageItems . length < 1 ) {
110
115
$ ( this . deleteImagesSelector ) . addClass ( 'disabled' ) ;
111
116
} else {
You can’t perform that action at this time.
0 commit comments