Skip to content

Commit

Permalink
Change all delete occurrences to remove to maintain consistency
Browse files Browse the repository at this point in the history
- Form button name and labels
- From success message
- Some variable name and code comment
  • Loading branch information
sukhwinder33445 committed Feb 27, 2025
1 parent 364c47d commit c1e4987
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions application/controllers/ChannelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public function indexAction(): void
$form = (new ChannelForm(Database::get()))
->loadChannel($channelId)

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.
->on(ChannelForm::ON_SUCCESS, function (ChannelForm $form) {
if ($form->getPressedSubmitElement()->getName() === 'delete') {
if ($form->getPressedSubmitElement()->getName() === 'remove') {
$form->removeChannel();
Notification::success(sprintf(
t('Deleted channel "%s" successfully'),
t('Removed channel "%s" successfully'),
$form->getValue('name')

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.
));
} else {
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function indexAction(): void
})->on(ContactForm::ON_REMOVE, function (ContactForm $form) {
$form->removeContact();
Notification::success(sprintf(
t('Deleted contact "%s" successfully'),
t('Removed contact "%s" successfully'),
$form->getContactName()
));

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/SourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public function indexAction(): void
->on(SourceForm::ON_SUCCESS, function (SourceForm $form) {
/** @var FormSubmitElement $pressedButton */
$pressedButton = $form->getPressedSubmitElement();
if ($pressedButton->getName() === 'delete') {
if ($pressedButton->getName() === 'remove') {
$form->removeSource();
Notification::success(sprintf(
$this->translate('Deleted source "%s" successfully'),
$this->translate('Removed source "%s" successfully'),
$form->getSourceName()
));
} else {
Expand Down
16 changes: 8 additions & 8 deletions application/forms/ChannelForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ protected function assemble()
->first();
}

/** @var FormSubmitElement $deleteButton */
$deleteButton = $this->createElement(
/** @var FormSubmitElement $removeButton */
$removeButton = $this->createElement(
'submit',
'delete',
'remove',
[
'label' => $this->translate('Delete'),
'label' => $this->translate('Remove'),
'class' => 'btn-remove',
'formnovalidate' => true,
'disabled' => $isInUse !== null,
Expand All @@ -144,16 +144,16 @@ protected function assemble()
]
);

$this->registerElement($deleteButton);
$this->registerElement($removeButton);
$this->getElement('submit')
->getWrapper()
->prepend($deleteButton);
->prepend($removeButton);
}
}

public function isValid()
{
if ($this->getPressedSubmitElement()->getName() === 'delete') {
if ($this->getPressedSubmitElement()->getName() === 'remove') {
$csrfElement = $this->getElement('CSRFToken');

if (! $csrfElement->isValid()) {
Expand All @@ -168,7 +168,7 @@ public function isValid()

public function hasBeenSubmitted()
{
if ($this->getPressedSubmitElement() !== null && $this->getPressedSubmitElement()->getName() === 'delete') {
if ($this->getPressedSubmitElement() !== null && $this->getPressedSubmitElement()->getName() === 'remove') {
return true;
}

Expand Down
12 changes: 6 additions & 6 deletions application/forms/SourceForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,22 +220,22 @@ protected function assemble(): void
);

if ($this->sourceId !== null) {
/** @var FormSubmitElement $deleteButton */
$deleteButton = $this->createElement(
/** @var FormSubmitElement $removeButton */
$removeButton = $this->createElement(
'submit',
'delete',
'remove',
[
'label' => $this->translate('Delete'),
'label' => $this->translate('Remove'),
'class' => 'btn-remove',
'formnovalidate' => true
]
);

$this->registerElement($deleteButton);
$this->registerElement($removeButton);

/** @var BaseHtmlElement $submitWrapper */
$submitWrapper = $this->getElement('save')->getWrapper();
$submitWrapper->prepend($deleteButton);
$submitWrapper->prepend($removeButton);
}
}

Expand Down
16 changes: 8 additions & 8 deletions library/Notifications/Web/Form/ContactForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ContactForm extends CompatForm
{
use CsrfCounterMeasure;

/** @var string Emitted in case the contact should be deleted */
/** @var string Emitted in case the contact should be removed */
public const ON_REMOVE = 'on_remove';

/** @var Connection */
Expand Down Expand Up @@ -56,7 +56,7 @@ private function hasBeenRemoved(): bool
$btn = $this->getPressedSubmitElement();
$csrf = $this->getElement('CSRFToken');

return $csrf !== null && $csrf->isValid() && $btn !== null && $btn->getName() === 'delete';
return $csrf !== null && $csrf->isValid() && $btn !== null && $btn->getName() === 'remove';
}

public function isValidEvent($event)
Expand Down Expand Up @@ -141,21 +141,21 @@ protected function assemble()
]
);
if ($this->contactId !== null) {
/** @var FormSubmitElement $deleteButton */
$deleteButton = $this->createElement(
/** @var FormSubmitElement $removeButton */
$removeButton = $this->createElement(
'submit',
'delete',
'remove',
[
'label' => $this->translate('Delete'),
'label' => $this->translate('Remove'),
'class' => 'btn-remove',
'formnovalidate' => true
]
);

$this->registerElement($deleteButton);
$this->registerElement($removeButton);
$this->getElement('submit')
->getWrapper()
->prepend($deleteButton);
->prepend($removeButton);
}
}

Expand Down

0 comments on commit c1e4987

Please sign in to comment.