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

[Bug]: Import of Data Importer configuration #898

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 17 additions & 13 deletions src/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,19 +576,23 @@ public function exportConfiguration(Request $request, ExportService $exportServi
*/
public function importConfiguration(Request $request, ImportService $importService): JsonResponse
{
$this->checkPermission(self::CONFIG_NAME);
$json = file_get_contents($_FILES['Filedata']['tmp_name']);
$configuration = $importService->importConfigurationJson($json);

$response = $this->jsonResponse([
'success' => true,
'type' => $configuration->getType(),
'name' => $configuration->getName(),
]);
// set content-type to text/html, otherwise (when application/json is sent) chrome will complain in
// Ext.form.Action.Submit and mark the submission as failed
$response->headers->set('Content-Type', 'text/html');
try {
$this->checkPermission(self::CONFIG_NAME);
$json = file_get_contents($_FILES['Filedata']['tmp_name']);
$configuration = $importService->importConfigurationJson($json);

return $response;
$response = $this->jsonResponse([
'success' => true,
'type' => $configuration->getType(),
'name' => $configuration->getName(),
]);
// set content-type to text/html, otherwise (when application/json is sent) chrome will complain in
// Ext.form.Action.Submit and mark the submission as failed
$response->headers->set('Content-Type', 'text/html');

return $response;
} catch (\Exception $e) {
return $this->jsonResponse(['success' => false, 'message' => $e->getMessage()]);
}
}
}
6 changes: 4 additions & 2 deletions src/Resources/public/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ pimcore.plugin.datahub.config = Class.create({
this.refreshTree();

}.bind(this),
function () {
Ext.MessageBox.alert(t("error"), t("error"));
function (response) {
response = response.response;
const data = Ext.decode(response.responseText);
Ext.MessageBox.alert(t("error"), data.message);
}
);
}.bind(this)
Expand Down
Loading