Skip to content

Commit acff9ae

Browse files
authored
FFWEB-3262: Add more information for test connection button
Add more validation information for test connection button
1 parent f5842a1 commit acff9ae

9 files changed

Lines changed: 36 additions & 12 deletions

File tree

src/Api/TestConnectionController.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public function testApiConnection(): JsonResponse
4646
return new JsonResponse(['message' => 'Connection successfully established'], 200);
4747
} catch (\Exception $e) {
4848
$this->factfinderLogger->error($e->getMessage());
49+
$errorDescription = $this->getErrorDescription($e->getMessage());
4950

50-
return new JsonResponse(['message' => 'Connection could not be established'], 400);
51+
return new JsonResponse(['message' => $errorDescription], 400);
5152
}
5253
}
5354

@@ -94,8 +95,9 @@ public function testPushImportApiConnection(): JsonResponse
9495
return new JsonResponse(['message' => 'Connection successfully established'], 200);
9596
} catch (\Exception $e) {
9697
$this->factfinderLogger->error($e->getMessage());
98+
$errorDescription = $this->getErrorDescription($e->getMessage());
9799

98-
return new JsonResponse(['message' => 'Connection could not be established'], 400);
100+
return new JsonResponse(['message' => $errorDescription], 400);
99101
}
100102
}
101103

@@ -106,4 +108,17 @@ private function createTestEndpoint(): string
106108

107109
return "rest/{$apiVersion}/records/{$channel}/compare";
108110
}
111+
112+
private function getErrorDescription(string $errorMessage): string
113+
{
114+
preg_match('/\{.*?\}/', $errorMessage, $matches);
115+
116+
if (!empty($matches[0])) {
117+
$json = json_decode($matches[0], true);
118+
119+
return $json['errorDescription'] ?? 'Check logs for more information.';
120+
}
121+
122+
return 'Check logs for more information.';
123+
}
109124
}

src/Resources/app/administration/src/module/configuration/component/test-api-connection/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ Component.register('test-api-connection', {
4242
});
4343
}
4444
})
45-
.catch(() => {
45+
.catch((error) => {
46+
const errorMessage = error.response?.data?.message ||
47+
Shopware.Snippet.tc('configuration.testConnection.helpText');
48+
4649
this.createNotificationError({
4750
title: Shopware.Snippet.tc('configuration.testConnection.fail'),
48-
message: Shopware.Snippet.tc('configuration.testConnection.helpText')
49-
});
51+
message: errorMessage
52+
});
5053
})
5154
.finally(() => {
5255
this.isSaveSuccessful = true;

src/Resources/app/administration/src/module/configuration/component/test-push-import-connection/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ Component.register('test-push-import-connection', {
4141
});
4242
}
4343
})
44-
.catch(() => {
44+
.catch((error) => {
45+
const errorMessage = error.response?.data?.message ||
46+
Shopware.Snippet.tc('configuration.testConnection.helpText');
47+
4548
this.createNotificationError({
4649
title: Shopware.Snippet.tc('configuration.testConnection.fail'),
47-
message: Shopware.Snippet.tc('configuration.testConnection.helpText')
48-
});
50+
message: errorMessage
51+
});
4952
})
5053
.finally(() => {
5154
this.isSaveSuccessful = true;

src/Resources/app/administration/src/module/configuration/snippet/de-DE.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"testConnection": {
88
"success": "Verbindung erfolgreich hergestellt.",
99
"fail": "Die Verbindung konnte nicht hergestellt werden.",
10-
"helpText": "Bitte speichern Sie Ihre aktuelle Konfiguration, bevor Sie die Verbindung testen"
10+
"helpText": "Bitte speichern Sie Ihre aktuelle Konfiguration, bevor Sie die Verbindung testen und überprüfen Sie die Fehlerprotokolle für weitere Informationen"
1111
},
1212
"testApiConnection": {
1313
"testConnection": "Testverbindung"

src/Resources/app/administration/src/module/configuration/snippet/en-GB.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"testConnection": {
88
"success": "Connection successfully established.",
99
"fail": "Connection could not be established.",
10-
"helpText": "Please save you current configuration before test connection"
10+
"helpText": "Please save you current configuration before test connection and check the error logs for more information"
1111
},
1212
"testApiConnection": {
1313
"testConnection": "Test Connection"

src/Resources/public/administration/.vite/entrypoints.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"dynamic": [],
99
"js": [
10-
"/bundles/omikronfactfinder/administration/assets/omikron-fact-finder-CV20BvN_.js"
10+
"/bundles/omikronfactfinder/administration/assets/omikron-fact-finder-BBWWRWHk.js"
1111
],
1212
"legacy": false,
1313
"preload": []

src/Resources/public/administration/.vite/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"main.js": {
3-
"file": "assets/omikron-fact-finder-CV20BvN_.js",
3+
"file": "assets/omikron-fact-finder-BBWWRWHk.js",
44
"name": "omikron-fact-finder",
55
"src": "main.js",
66
"isEntry": true,

src/Resources/public/administration/assets/omikron-fact-finder-BBWWRWHk.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/public/administration/assets/omikron-fact-finder-BBWWRWHk.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)