Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Prevent multiple imports of the same remote asset in the frontend #5117

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Neos.Media.Browser/Resources/Private/Layouts/Default.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
<div class="neos-media-content{f:if(condition: '{tags -> f:count()} > 25', then: ' neos-media-aside-condensed')}">
<div class="neos-media-assets">
<div class="neos-notification-container">
<div id=="neos-notification-container" class="neos-notification-container">
<f:render partial="FlashMessages"/>
</div>
<f:render section="Content"/>
Expand Down
6 changes: 6 additions & 0 deletions Neos.Media.Browser/Resources/Private/Translations/en/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@
<trans-unit id="createMissingVariants" xml:space="preserve">
<source>Create missing variants</source>
</trans-unit>
<trans-unit id="assetImport.importInfo" xml:space="preserve">
<source>Asset is being imported. Please wait.</source>
</trans-unit>
<trans-unit id="assetImport.importInProcess" xml:space="preserve">
<source>Import still in process. Please wait.</source>
</trans-unit>
</body>
</file>
</xliff>
42 changes: 32 additions & 10 deletions Neos.Media.Browser/Resources/Public/JavaScript/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,39 @@ window.addEventListener('DOMContentLoaded', (event) => {
if (localAssetIdentifier !== '') {
window.parent.NeosMediaBrowserCallbacks.assetChosen(localAssetIdentifier);
} else {
$.post(
$('link[rel="neos-media-browser-service-assetproxies-import"]').attr('href'),
{
assetSourceIdentifier: $(this).attr('data-asset-source-identifier'),
assetIdentifier: $(this).attr('data-asset-identifier'),
__csrfToken: $('body').attr('data-csrf-token')
},
function(data) {
window.parent.NeosMediaBrowserCallbacks.assetChosen(data.localAssetIdentifier);
}
if ($(this).attr('data-import-in-process') !== 'true') {
Sebobo marked this conversation as resolved.
Show resolved Hide resolved
$(this).attr('data-import-in-process', 'true')
const message = window.NeosCMS.I18n.translate(
'assetImport.importInfo',
'Asset is being imported. Please wait.',
'Neos.Media.Browser',
'Main',
[]
)
window.NeosCMS.Notification.ok(message)
$.post(
$('link[rel="neos-media-browser-service-assetproxies-import"]').attr('href'),
{
assetSourceIdentifier: $(this).attr('data-asset-source-identifier'),
assetIdentifier: $(this).attr('data-asset-identifier'),
__csrfToken: $('body').attr('data-csrf-token')
},
function (data) {
window.parent.NeosMediaBrowserCallbacks.assetChosen(data.localAssetIdentifier);
$(this).removeAttr('data-import-in-process')
}
);
}
else {
const message = window.NeosCMS.I18n.translate(
'assetImport.importInProcess',
'Import still in process. Please wait.',
'Neos.Media.Browser',
'Main',
[]
)
window.NeosCMS.Notification.warning(message)
}
}
e.preventDefault();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCollectionValueByPath, isNil } from "../Helper";

const hasConfiguration = !isNil(window.NeosCMS?.Configuration);
let hasConfiguration = !isNil(window.NeosCMS?.Configuration);

const init = () => {
if (isNil(window.NeosCMS)) {
Expand All @@ -9,6 +9,7 @@ const init = () => {

if (isNil(window.NeosCMS.Configuration)) {
window.NeosCMS.Configuration = {};
hasConfiguration = true;
}

// append xliff uri
Expand Down
Loading