Differential D20287 Diff 48426 src/applications/project/controller/PhabricatorProjectColumnRemoveTriggerController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/PhabricatorProjectColumnRemoveTriggerController.php
- This file was added.
<?php | |||||
final class PhabricatorProjectColumnRemoveTriggerController | |||||
extends PhabricatorProjectBoardController { | |||||
public function handleRequest(AphrontRequest $request) { | |||||
$viewer = $request->getViewer(); | |||||
$id = $request->getURIData('id'); | |||||
$column = id(new PhabricatorProjectColumnQuery()) | |||||
->setViewer($viewer) | |||||
->withIDs(array($id)) | |||||
->requireCapabilities( | |||||
array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
)) | |||||
->executeOne(); | |||||
if (!$column) { | |||||
return new Aphront404Response(); | |||||
} | |||||
$done_uri = $column->getBoardURI(); | |||||
if (!$column->getTriggerPHID()) { | |||||
return $this->newDialog() | |||||
->setTitle(pht('No Trigger')) | |||||
->appendParagraph( | |||||
pht('This column does not have a trigger.')) | |||||
->addCancelButton($done_uri); | |||||
} | |||||
if ($request->isFormPost()) { | |||||
$column_xactions = array(); | |||||
$column_xactions[] = $column->getApplicationTransactionTemplate() | |||||
->setTransactionType( | |||||
PhabricatorProjectColumnTriggerTransaction::TRANSACTIONTYPE) | |||||
->setNewValue(null); | |||||
$column_editor = $column->getApplicationTransactionEditor() | |||||
->setActor($viewer) | |||||
->setContentSourceFromRequest($request) | |||||
->setContinueOnNoEffect(true) | |||||
->setContinueOnMissingFields(true); | |||||
$column_editor->applyTransactions($column, $column_xactions); | |||||
return id(new AphrontRedirectResponse())->setURI($done_uri); | |||||
} | |||||
$body = pht('Really remove the trigger from this column?'); | |||||
return $this->newDialog() | |||||
->setTitle(pht('Remove Trigger')) | |||||
->appendParagraph($body) | |||||
->addSubmitButton(pht('Remove Trigger')) | |||||
->addCancelButton($done_uri); | |||||
amckinley: Maybe add a count of the number of other columns which currently use the trigger? I guess you'd… | |||||
epriestleyAuthorUnsubmitted Done Inline ActionsYeah, this is just "Detach trigger from this column". Possibly we should count and give the user an option to destroy it (or, more likely, banish it to the shadow realm). Elsewhere, I'm policy-violating on count/existence anyway to provide users a hint before they edit a trigger in use on a lot of boards they can't see, so I think this is fine from a policy perspective. It's generally okay to know that objects exist and what their PHIDs are, just rarely much more than that. (For example, you can generally see all the edges attached to an object, even if D123 is attached to T123 which you can't see.) epriestley: Yeah, this is just "Detach trigger from this column".
Possibly we should count and give the… | |||||
epriestleyAuthorUnsubmitted Done Inline Actions(In D20308, I ended up just counting use in active columns instead of having a separate "status".) epriestley: (In D20308, I ended up just counting use in active columns instead of having a separate… | |||||
} | |||||
} |
Maybe add a count of the number of other columns which currently use the trigger? I guess you'd have to do a policy-violating query to include the comfort-inducing "no other columns use this trigger" text, but I think that's pretty ok? Or inversely, just a warning "X other columns are currently using this trigger".
NB: I assumed this code was invoking destroyObjectPermanently; disregard.