Skip to content

Commit

Permalink
Editor Toolbox: Media results wrong after adding media from a provider (
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao authored Aug 28, 2024
1 parent c34e640 commit a69a709
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ui/src/editor-core/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,11 @@ Toolbar.prototype.mediaContentPopulate = function(menu) {
const $mediaContent = self.DOMObject.find('#media-content-' + menu);
const $mediaForm = $mediaContainer.find('.media-search-form');

// If media container isn't still loaded, skip
if ($mediaContainer.length === 0) {
return;
}

// Request elements based on filters
const loadData = function(clear = true) {
// Remove show more button
Expand Down Expand Up @@ -3644,4 +3649,15 @@ Toolbar.prototype.loadTemplates = function(
});
};

/**
* Get menu item id from type
* @param {string} type - Menu type
* @return {number} - Menu id
*/
Toolbar.prototype.getMenuIdFromType = function(
type,
) {
return this.menuItems.findIndex((item) => item.name === type);
};

module.exports = Toolbar;
9 changes: 9 additions & 0 deletions ui/src/layout-editor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4678,6 +4678,10 @@ lD.importFromProvider = function(items) {
}
});

// Get item type, if not image/audio/video, set it as library
const itemType =
['image', 'audio', 'video'].indexOf(itemsResult[0].type) == -1 ?
'library' : itemsResult[0].type;
const linkToAPI = urlsForApi.library.connectorImport;
const requestPath = linkToAPI.url;

Expand Down Expand Up @@ -4719,6 +4723,11 @@ lD.importFromProvider = function(items) {
// Filter null results
itemsResult = itemsResult.filter((el) => el);

// Empty toolbar content for this type of media
// so it can be reloaded
const menuId = lD.toolbar.getMenuIdFromType(itemType);
lD.toolbar.DOMObject.find('#content-' + menuId).empty();

resolve(itemsResult);
} else {
lD.common.hideLoadingScreen();
Expand Down
9 changes: 9 additions & 0 deletions ui/src/playlist-editor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,10 @@ pE.importFromProvider = function(items) {
}
});

// Get item type, if not image/audio/video, set it as library
const itemType =
['image', 'audio', 'video'].indexOf(itemsResult[0].type) == -1 ?
'library' : itemsResult[0].type;
const linkToAPI = urlsForApi.library.connectorImport;
const requestPath = linkToAPI.url;

Expand Down Expand Up @@ -1086,6 +1090,11 @@ pE.importFromProvider = function(items) {
// Filter null results
itemsResult = itemsResult.filter((el) => el);

// Empty toolbar content for this type of media
// so it can be reloaded
const menuId = pE.toolbar.getMenuIdFromType(itemType);
pE.toolbar.DOMObject.find('#content-' + menuId).empty();

resolve(itemsResult);
} else {
pE.common.hideLoadingScreen();
Expand Down

0 comments on commit a69a709

Please sign in to comment.