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

Add delete button to modify view #344

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions application/forms/EditNodeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Web\Session\SessionNamespace;
use ipl\Sql\Connection as IcingaDbConnection;
use ipl\Web\Url;
use ipl\Web\Widget\ButtonLink;
use Zend_Form_Element_Note;

class EditNodeForm extends QuickForm
{
Expand All @@ -37,6 +40,8 @@ class EditNodeForm extends QuickForm

protected $host;

protected $deleteButtonName = 'delete_node';

/** @var SessionNamespace */
protected $session;

Expand Down Expand Up @@ -79,6 +84,43 @@ public function setup()
$this->setSubmitLabel($this->translate('Next'));
return;
}

$url = Url::fromRequest();
$params = $url->getParams();

$url->setParams([
'config' => $params->get('config'),
'node' => $params->get('node'),
'unlocked' => 1,
'action' => 'delete',
'deletenode' => $params->get('editmonitorednode')
]);

$deleteButton = (new Zend_Form_Element_Note(
'delete',
[
'value' => new ButtonLink(
$this->translate('Delete'),
$url,
null,
['class' => 'node-delete-button']
)
]
));

$deleteButton->removeDecorator('Label');
$deleteButton->removeDecorator('HtmlTag');

$this->addElement($deleteButton, $this->deleteButtonName);
}

protected function onSetup()
{
$label = $this->translate('Save Changes');
$this->setSubmitLabel($label);
$this->getElement($this->submitButtonName)
->setAttribs(['class' => 'btn-primary'])
->setLabel($label);
}

protected function isService()
Expand Down
42 changes: 42 additions & 0 deletions application/forms/ProcessForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Icinga\Web\Notification;
use Icinga\Web\Session\SessionNamespace;
use ipl\Sql\Connection as IcingaDbConnection;
use ipl\Web\Url;
use ipl\Web\Widget\ButtonLink;
use Zend_Form_Element_Note;

class ProcessForm extends QuickForm
{
Expand All @@ -26,6 +29,8 @@ class ProcessForm extends QuickForm
/** @var SessionNamespace */
protected $session;

protected $deleteButtonName = 'delete_node';

public function setup()
{
if ($this->node !== null) {
Expand Down Expand Up @@ -92,6 +97,43 @@ public function setup()
$this->getElement('url')->setValue($node->getInfoUrl());
}
}

$url = Url::fromRequest();
$params = $url->getParams();

$url->setParams([
'config' => $params->get('config'),
'node' => $params->get('node'),
'unlocked' => 1,
'action' => 'delete',
'deletenode' => $params->get('editnode')
]);

$deleteButton = (new Zend_Form_Element_Note(
'delete',
[
'value' => new ButtonLink(
$this->translate('Delete'),
$url,
null,
['class' => 'node-delete-button']
)
]
));

$deleteButton->removeDecorator('Label');
$deleteButton->removeDecorator('HtmlTag');

$this->addElement($deleteButton, $this->deleteButtonName);
}

protected function onSetup()
{
$label = $this->translate('Save Changes');
$this->setSubmitLabel($label);
$this->getElement($this->submitButtonName)
->setAttribs(['class' => 'btn-primary'])
->setLabel($label);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/Businessprocess/Renderer/TileRenderer/NodeTile.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ protected function addActionLinks()
}
}

if ($this->renderer->getBusinessProcess()->getMetadata()->canModify()) {
if ($this->renderer->getBusinessProcess()->getMetadata()->canModify() && $this->node instanceof ImportedNode) {
sukhwinder33445 marked this conversation as resolved.
Show resolved Hide resolved
$params = array(
'action' => 'delete',
'deletenode' => $this->node->getName(),
Expand Down
7 changes: 7 additions & 0 deletions public/css/module.less
Original file line number Diff line number Diff line change
Expand Up @@ -980,3 +980,10 @@ textarea.smaller {
max-width: 60em;
}
/** END of custom font styling **/

.node-delete-button {
float: left;
color: @state-critical;
background: transparent;
margin-right: 1em;
}