Skip to content

Commit

Permalink
api/forms: Use the first success notification as success message
Browse files Browse the repository at this point in the history
refs #9606
  • Loading branch information
lippserd committed Sep 7, 2015
1 parent 91b9a83 commit b20eb68
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions library/Icinga/Web/Form.php
Expand Up @@ -1116,10 +1116,16 @@ public function handleRequest(Request $request = null)
if ($this->getIsApiTarget() || $this->getRequest()->isApiRequest()) {
// API targets and API requests will never redirect but immediately respond w/ JSON-encoded
// notifications
$messages = Notification::getInstance()->popMessages();
// @TODO(el): Remove the type from the message
$notifications = Notification::getInstance()->popMessages();
$message = null;
foreach ($notifications as $notification) {
if ($notification['type'] === Notification::SUCCESS) {
$message = $notification['message'];
break;
}
}
$this->getResponse()->json()
->setSuccessData(array('message' => array_pop($messages)))
->setSuccessData($message !== null ? array('message' => $message) : null)
->sendResponse();
} elseif (! $frameUpload) {
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
Expand Down

0 comments on commit b20eb68

Please sign in to comment.