summaryrefslogtreecommitdiffstats
path: root/application/forms/BasketUploadForm.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:48 +0000
commite6d4dfc040bbe3cb80a2ce65b82493b557f751fc (patch)
tree40bd6366b01b06f4d96fc8638f23a772263cb5e9 /application/forms/BasketUploadForm.php
parentReleasing progress-linux version 1.10.2-2~progress7.99u1. (diff)
downloadicingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.tar.xz
icingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.zip
Merging upstream version 1.11.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/forms/BasketUploadForm.php')
-rw-r--r--application/forms/BasketUploadForm.php28
1 files changed, 12 insertions, 16 deletions
diff --git a/application/forms/BasketUploadForm.php b/application/forms/BasketUploadForm.php
index a88dc06..aa26258 100644
--- a/application/forms/BasketUploadForm.php
+++ b/application/forms/BasketUploadForm.php
@@ -25,10 +25,12 @@ class BasketUploadForm extends DirectorObjectForm
*/
public function setup()
{
- $this->addElement('text', 'basket_name', [
- 'label' => $this->translate('Basket Name'),
- 'required' => true,
- ]);
+ if ($this->object === null) {
+ $this->addElement('text', 'basket_name', [
+ 'label' => $this->translate('Basket Name'),
+ 'required' => true,
+ ]);
+ }
$this->setAttrib('enctype', 'multipart/form-data');
$this->addElement('file', 'uploaded_file', [
@@ -53,16 +55,6 @@ class BasketUploadForm extends DirectorObjectForm
return '\\Icinga\\Module\\Director\\DirectorObject\\Automation\\Basket';
}
- protected function setObjectSuccessUrl()
- {
- /** @var Basket $basket */
- $basket = $this->object();
- $this->setSuccessUrl(
- 'director/basket',
- ['name' => $basket->get('basket_name')]
- );
- }
-
/**
* @return bool
* @throws IcingaException
@@ -134,13 +126,17 @@ class BasketUploadForm extends DirectorObjectForm
$basket->set('owner_type', 'user');
$basket->set('owner_value', $this->getAuth()->getUser()->getUsername());
- $basket->store($this->db);
+ if ($basket->hasBeenLoadedFromDb()) {
+ $this->setSuccessUrl('director/basket/snapshots', ['name' => $basket->get('basket_name')]);
+ } else {
+ $this->setSuccessUrl('director/basket', ['name' => $basket->get('basket_name')]);
+ $basket->store($this->db);
+ }
BasketSnapshot::forBasketFromJson(
$basket,
$this->rawUpload
)->store($this->db);
- $this->setObjectSuccessUrl();
$this->beforeSuccessfulRedirect();
$this->redirectOnSuccess($this->translate('Basket has been uploaded'));
}