Skip to content

Commit e8e654f

Browse files
committed
Refactor per review comments
1 parent b4fe70c commit e8e654f

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

app/code/Magento/Cms/Model/Wysiwyg/Gallery/DefaultConfigProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Fram
7777

7878
if (is_string($this->currentTreePath)) {
7979
$fileBrowserUrlParams = [
80-
'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath),
81-
'tree_path' => $this->currentTreePath . '&'
82-
80+
'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath)
8381
];
8482
}
8583

app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection/MediaGallerySection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<element name="WysiwygArrow" type="button" selector="#d3lzaXd5Zw-- &gt; .jstree-icon"/>
3535
<element name="checkIfWysiwygArrowExpand" type="button" selector="//li[@id='d3lzaXd5Zw--' and contains(@class,'jstree-closed')]"/>
3636
<element name="confirmDelete" type="button" selector=".action-primary.action-accept"/>
37-
<element name="higlightedFolder" type="block" selector="//li[@id='{{folderId}}']/a[@class='jstree-clicked']" parameterized="true"/>
37+
<element name="highlightedFolder" type="block" selector="//li[@id='{{folderId}}']/a[@class='jstree-clicked']" parameterized="true"/>
3838
<element name="imageBlockByName" type="block" selector="//div[@data-row='file'][contains(., '{{imageName}}')]" parameterized="true"/>
3939
</section>
4040
</sections>

app/code/Magento/Cms/Test/Mftf/Test/AdminVerifyDefaultCurrentTreePathTest.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<annotations>
1212
<features value="Cms"/>
1313
<group value="Cms"/>
14-
<stories value="MediaGallery Verify Preselcted folders on Category Page"/>
15-
<title value="Admin should be see preselcted default folder in Media Gallery"/>
16-
<description value="Admin should be see preselcted default folder in Media Gallery"/>
14+
<stories value="MediaGallery verify preselcted folders on Category Page"/>
15+
<title value="Admin should be able to see preselected default folder in Media Gallery"/>
16+
<description value="Admin should be able to see preselected default folder in Media Gallery"/>
1717
</annotations>
1818
<before>
1919
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
@@ -26,10 +26,10 @@
2626
<actionGroup ref="NavigateToMediaGalleryActionGroup" stepKey="navigateToMediaGallery"/>
2727
<!-- Verify catalog/category folder selected -->
2828
<waitForPageLoad stepKey="waitForFoldersLoad"/>
29-
<seeElement selector="{{MediaGallerySection.higlightedFolder('Y2F0YWxvZy9jYXRlZ29yeQ--')}}" stepKey="assertCategoryFolder"/>
30-
<actionGroup ref="AdminCloseMediaGalleryActionGroup" stepKey="closeMEdiaGallery"/>
29+
<seeElement selector="{{MediaGallerySection.highlightedFolder('Y2F0YWxvZy9jYXRlZ29yeQ--')}}" stepKey="assertCategoryFolder"/>
30+
<actionGroup ref="AdminCloseMediaGalleryActionGroup" stepKey="closeMediaGallery"/>
3131
<actionGroup ref="AdminOpenMediaGalleryTinyMce4ActionGroup" stepKey="opneMediaGalleryFromTinyMce4"/>
3232
<!-- Verify wysiwyg folder selected -->
33-
<seeElement selector="{{MediaGallerySection.higlightedFolder('d3lzaXd5Zw--')}}" stepKey="assertWysiwygFolder"/>
33+
<seeElement selector="{{MediaGallerySection.highlightedFolder('d3lzaXd5Zw--')}}" stepKey="assertWysiwygFolder"/>
3434
</test>
3535
</tests>

app/code/Magento/Ui/view/base/web/js/form/element/image-uploader.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ define([
7878
'/type/image/?isAjax=true';
7979

8080
if (this.mediaGallery.initialOpenSubpath) {
81-
openDialogUrl += '/tree_path/' + this.mediaGallery.initialOpenSubpath;
8281
openDialogUrl += '&current_tree_path=' + Base64.mageEncode(this.mediaGallery.initialOpenSubpath);
8382
}
8483

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/image-uploader.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ define([
7575

7676
expect(browser.openDialog).toHaveBeenCalledWith(
7777
'http://example.com/target_element_id/theTargetId/store/3/type/image/' +
78-
'?isAjax=true/tree_path/wysiwyg&current_tree_path=d3lzaXd5Zw,,',
78+
'?isAjax=true&current_tree_path=d3lzaXd5Zw,,',
7979
null,
8080
null,
8181
'Hello world',

lib/web/mage/adminhtml/browser.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ define([
2121
windowId: 'modal_dialog_message',
2222
modalLoaded: false,
2323
targetElementId: false,
24-
currentTreePath: '',
2524
pathId: '',
2625

2726
/**
@@ -63,6 +62,7 @@ define([
6362

6463
this.modal.modal('openModal');
6564
this.setTargetElementId(options, url);
65+
this.setPathId(url);
6666
$(window).trigger('reload.MediaGallery');
6767

6868
return;
@@ -87,19 +87,25 @@ define([
8787
this.modal.html(data).trigger('contentUpdated');
8888
this.modalLoaded = true;
8989
this.setTargetElementId(options, url);
90+
this.setPathId(url);
9091
}.bind(this));
9192

9293
},
9394

95+
/**
96+
* Setter for endcoded path id
97+
*/
98+
setPathId: function (url) {
99+
this.pathId = url.match(/(&|\/|%26)current_tree_path(=|\/)([\s\S].*?)(\/|$)/)[3];
100+
},
101+
94102
/**
95103
* Setter for targetElementId property
96104
*
97105
* @param {Object} options
98106
* @param {String} url
99107
*/
100108
setTargetElementId: function (options, url) {
101-
this.currentTreePath = url.match(/\/tree_path\/([\s\S].*?)(&|%26)/)[1];
102-
this.pathId = url.match(/(&|\/|%26)current_tree_path(=|\/)([\s\S].*?)(\/|$)/)[3];
103109
this.targetElementId = options && options.targetElementId ?
104110
options.targetElementId
105111
: url.match(/\/target_element_id\/([\s\S].*?)\//)[1];

0 commit comments

Comments
 (0)