Skip to content

Commit ce524ce

Browse files
authored
ENGCOM-7573: Provide pathId param on browser.js #28219
2 parents 4040a32 + ec5e835 commit ce524ce

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

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

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

8080
if (this.mediaGallery.initialOpenSubpath) {
81-
openDialogUrl += '&current_tree_path=' + Base64.mageEncode(this.mediaGallery.initialOpenSubpath);
81+
openDialogUrl += '&current_tree_path=' + Base64.idEncode(this.mediaGallery.initialOpenSubpath);
8282
}
8383

8484
browser.openDialog(

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&current_tree_path=d3lzaXd5Zw,,',
78+
'?isAjax=true&current_tree_path=d3lzaXd5Zw--',
7979
null,
8080
null,
8181
'Hello world',

dev/tests/js/jasmine/tests/lib/mage/browser.test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ define([
99
], function (browser, $) {
1010
'use strict';
1111

12-
var obj;
12+
var obj,
13+
openUrl = 'http://example.com/target_element_id/theTargetId/tree_path/wysiwyg&current_tree_path=d3lzaXd5Zw,';
1314

1415
beforeEach(function () {
1516
/**
@@ -41,8 +42,9 @@ define([
4142
}
4243
};
4344
});
44-
obj.openDialog('instance/url', 100, 100, 'title', options);
45-
obj.openDialog('instance/url', 100, 100, 'title', options);
45+
obj.openDialog(openUrl, 100, 100, 'title', options);
46+
obj.openDialog(openUrl, 100, 100, 'title', options);
47+
expect(obj.pathId).toBe('d3lzaXd5Zw,');
4648
expect($.ajax.calls.count()).toBe(1);
4749
});
4850

@@ -59,9 +61,10 @@ define([
5961
}
6062
};
6163
});
62-
obj.openDialog('instance/url/target_element_id/YDW2424/', 100, 100, 'title', undefined);
63-
obj.openDialog('instance/target_element_id/Y45GDRg/', 100, 100, 'title', undefined);
64+
obj.openDialog(openUrl, 100, 100, 'title', undefined);
65+
obj.openDialog(openUrl, 100, 100, 'title', undefined);
6466
expect($.ajax.calls.count()).toBe(1);
67+
expect(obj.pathId).toBe('d3lzaXd5Zw,');
6568
});
6669
});
6770
});

lib/web/mage/adminhtml/browser.js

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

2526
/**
2627
* @return {Number}
@@ -61,6 +62,7 @@ define([
6162

6263
this.modal.modal('openModal');
6364
this.setTargetElementId(options, url);
65+
this.setPathId(url);
6466
$(window).trigger('reload.MediaGallery');
6567

6668
return;
@@ -85,10 +87,18 @@ define([
8587
this.modal.html(data).trigger('contentUpdated');
8688
this.modalLoaded = true;
8789
this.setTargetElementId(options, url);
90+
this.setPathId(url);
8891
}.bind(this));
8992

9093
},
9194

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+
92102
/**
93103
* Setter for targetElementId property
94104
*

0 commit comments

Comments
 (0)