1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Refactor PhabricatorBadgesEditRecipientsController to remove dead code

Summary: `$form` in `$dialog = id(new AphrontDialogView())->appendForm($form)` is only defined when `if ($can_edit)` was `true` beforehand. But that was always true. Thus add a variable definition (and remove some unused variables like `$form_box`).

Test Plan:
Visit the page /badges/recipients/1/ or also directly /badges/recipients/1/add/ and add some recipients. It still works as before.

Visit the page without enough permissions. It does not allow to edit them, as before.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25744
This commit is contained in:
Andre Klapper 2024-07-25 15:42:14 +02:00
parent 7909f6a919
commit 59678094fb

View file

@ -49,26 +49,15 @@ final class PhabricatorBadgesEditRecipientsController
->setURI($view_uri); ->setURI($view_uri);
} }
$can_edit = PhabricatorPolicyFilter::hasCapability( $form = new AphrontFormView();
$viewer, $form
$badge, ->setUser($viewer)
PhabricatorPolicyCapability::CAN_EDIT); ->setFullWidth(true)
->appendControl(
$form_box = null; id(new AphrontFormTokenizerControl())
$title = pht('Add Recipient'); ->setName('phids')
if ($can_edit) { ->setLabel(pht('Recipients'))
$header_name = pht('Edit Recipients'); ->setDatasource(new PhabricatorPeopleDatasource()));
$form = new AphrontFormView();
$form
->setUser($viewer)
->setFullWidth(true)
->appendControl(
id(new AphrontFormTokenizerControl())
->setName('phids')
->setLabel(pht('Recipients'))
->setDatasource(new PhabricatorPeopleDatasource()));
}
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($viewer) ->setUser($viewer)