private function setInBranchFromAction(ReleephRequest $rq, ReleephRequestTransaction $xaction) { $action = $xaction->getMetadataValue('action'); switch ($action) { case 'pick': $rq->setInBranch(1); break; case 'revert': $rq->setInBranch(0); break; default: $id = $rq->getID(); $type = $xaction->getTransactionType(); $new = $xaction->getNewValue(); phlog(pht("Unknown discovery action '%s' for xaction of type %s " . "with new value %s mentioning %s!", $action, $type, $new, 'RQ' . $id)); break; } return $this; }
private function buildActionList(ReleephRequest $pull) { $viewer = $this->getUser(); $id = $pull->getID(); $edit_uri = '/releeph/request/edit/' . $id . '/'; $view = id(new PhabricatorActionListView())->setUser($viewer); $product = $pull->getBranch()->getProduct(); $viewer_is_pusher = $product->isAuthoritativePHID($viewer->getPHID()); $viewer_is_requestor = $pull->getRequestUserPHID() == $viewer->getPHID(); if ($viewer_is_pusher) { $yes_text = pht('Approve Pull'); $no_text = pht('Reject Pull'); $yes_icon = 'fa-check'; $no_icon = 'fa-times'; } else { if ($viewer_is_requestor) { $yes_text = pht('Request Pull'); $no_text = pht('Cancel Pull'); $yes_icon = 'fa-check'; $no_icon = 'fa-times'; } else { $yes_text = pht('Support Pull'); $no_text = pht('Discourage Pull'); $yes_icon = 'fa-thumbs-o-up'; $no_icon = 'fa-thumbs-o-down'; } } $yes_href = '/releeph/request/action/want/' . $id . '/'; $no_href = '/releeph/request/action/pass/' . $id . '/'; $intents = $pull->getUserIntents(); $current_intent = idx($intents, $viewer->getPHID()); $yes_disabled = $current_intent == ReleephRequest::INTENT_WANT; $no_disabled = $current_intent == ReleephRequest::INTENT_PASS; $use_workflow = !$this->getIsListView(); $view->addAction(id(new PhabricatorActionView())->setName($yes_text)->setHref($yes_href)->setWorkflow($use_workflow)->setRenderAsForm($use_workflow)->setDisabled($yes_disabled)->addSigil('releeph-request-state-change')->addSigil('want')->setIcon($yes_icon)); $view->addAction(id(new PhabricatorActionView())->setName($no_text)->setHref($no_href)->setWorkflow($use_workflow)->setRenderAsForm($use_workflow)->setDisabled($no_disabled)->addSigil('releeph-request-state-change')->addSigil('pass')->setIcon($no_icon)); if ($viewer_is_pusher || $viewer_is_requestor) { $pulled_href = '/releeph/request/action/mark-manually-picked/' . $id . '/'; $revert_href = '/releeph/request/action/mark-manually-reverted/' . $id . '/'; if ($pull->getInBranch()) { $view->addAction(id(new PhabricatorActionView())->setName(pht('Mark as Reverted'))->setHref($revert_href)->setWorkflow($use_workflow)->setRenderAsForm($use_workflow)->addSigil('releeph-request-state-change')->addSigil('mark-manually-reverted')->setIcon($no_icon)); } else { $view->addAction(id(new PhabricatorActionView())->setName(pht('Mark as Pulled'))->setHref($pulled_href)->setWorkflow($use_workflow)->setRenderAsForm($use_workflow)->addSigil('releeph-request-state-change')->addSigil('mark-manually-picked')->setIcon('fa-exclamation-triangle')); } } if (!$this->getIsListView()) { $view->addAction(id(new PhabricatorActionView())->setName(pht('Edit Pull Request'))->setIcon('fa-pencil')->setHref($edit_uri)); } return $view; }
private function setInBranchFromAction(ReleephRequest $rq, ReleephRequestTransaction $xaction) { $action = $xaction->getMetadataValue('action'); switch ($action) { case 'pick': $rq->setInBranch(1); break; case 'revert': $rq->setInBranch(0); break; default: $id = $rq->getID(); $type = $xaction->getTransactionType(); $new = $xaction->getNewValue(); phlog("Unknown discovery action '{$action}' " . "for xaction of type {$type} " . "with new value {$new} " . "mentioning RQ{$id}!"); break; } }