Skip to content

Commit b3d5255

Browse files
committed
#29715: Corrected standalone actions and upgrade script
1 parent 748eb4f commit b3d5255

File tree

3 files changed

+95
-4
lines changed

3 files changed

+95
-4
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\MediaGalleryUi\Block\Adminhtml;
9+
10+
use Magento\Backend\Block\Template;
11+
use Magento\Directory\Helper\Data as DirectoryHelperData;
12+
use Magento\Framework\AuthorizationInterface;
13+
use Magento\Framework\Json\Helper\Data as JsonHelperData;
14+
use Magento\Framework\Serialize\Serializer\Json;
15+
16+
/**
17+
* Image details block
18+
*
19+
* @api
20+
*/
21+
class ImageDetailsStandalone extends Template
22+
{
23+
/**
24+
* @var AuthorizationInterface
25+
*/
26+
private $authorization;
27+
28+
/**
29+
* @var Json
30+
*/
31+
private $json;
32+
33+
/**
34+
* @param AuthorizationInterface $authorization
35+
* @param Template\Context $context
36+
* @param array $data
37+
* @param JsonHelperData|null $jsonHelper
38+
* @param DirectoryHelperData|null $directoryHelper
39+
*/
40+
public function __construct(
41+
AuthorizationInterface $authorization,
42+
Json $json,
43+
Template\Context $context,
44+
array $data = [],
45+
?JsonHelperData $jsonHelper = null,
46+
?DirectoryHelperData $directoryHelper = null
47+
) {
48+
$this->authorization = $authorization;
49+
$this->json = $json;
50+
parent::__construct($context, $data, $jsonHelper, $directoryHelper);
51+
}
52+
53+
/**
54+
* Retrieve actions json
55+
*
56+
* @return string
57+
*/
58+
public function getActionsJson(): string
59+
{
60+
$actions = [
61+
[
62+
'title' => __('Cancel'),
63+
'handler' => 'closeModal',
64+
'name' => 'cancel',
65+
'classes' => 'action-default scalable cancel action-quaternary'
66+
]
67+
];
68+
69+
if ($this->authorization->isAllowed('Magento_MediaGalleryUiApi::delete_assets')) {
70+
$actions[] = [
71+
'title' => __('Delete Image'),
72+
'handler' => 'deleteImageAction',
73+
'name' => 'delete',
74+
'classes' => 'action-default scalable delete action-quaternary'
75+
];
76+
}
77+
78+
if ($this->authorization->isAllowed('Magento_MediaGalleryUiApi::edit_assets')) {
79+
$actions[] = [
80+
'title' => __('Edit Details'),
81+
'handler' => 'editImageAction',
82+
'name' => 'edit',
83+
'classes' => 'action-default scalable edit action-quaternary'
84+
];
85+
}
86+
87+
return $this->json->serialize($actions);
88+
}
89+
}

app/code/Magento/MediaGalleryUi/Setup/Patch/Data/AddMediaGalleryPermissions.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,30 @@ private function getInsertData(array $roleIds): array
7878
];
7979
}
8080
}
81+
82+
return $data;
8183
}
8284

8385
/**
8486
* @inheritdoc
8587
*/
86-
public function getAliases()
88+
public function getAliases(): array
8789
{
8890
return [];
8991
}
9092

9193
/**
9294
* @inheritdoc
9395
*/
94-
public static function getDependencies()
96+
public static function getDependencies(): array
9597
{
9698
return [];
9799
}
98100

99101
/**
100102
* @inheritdoc
101103
*/
102-
public static function getVersion()
104+
public static function getVersion(): string
103105
{
104106
return '2.4.2';
105107
}

app/code/Magento/MediaGalleryUi/view/adminhtml/layout/media_gallery_media_index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<body>
1111
<referenceContainer htmlTag="div" htmlClass="media-gallery-container" name="content">
1212
<uiComponent name="standalone_media_gallery_listing"/>
13-
<block name="image.details" class="Magento\MediaGalleryUi\Block\Adminhtml\ImageDetails" template="Magento_MediaGalleryUi::image_details_standalone.phtml">
13+
<block name="image.details" class="Magento\MediaGalleryUi\Block\Adminhtml\ImageDetailsStandalone" template="Magento_MediaGalleryUi::image_details_standalone.phtml">
1414
<arguments>
1515
<argument name="imageDetailsUrl" xsi:type="url" path="media_gallery/image/details"/>
1616
</arguments>

0 commit comments

Comments
 (0)