Differential D17020 Diff 41522 src/applications/release/changes/actions/ReleaseChangeRequestMergeAction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/release/changes/actions/ReleaseChangeRequestMergeAction.php
- This file was added.
<?php | |||||
final class ReleaseChangeRequestMergeAction | |||||
extends ReleaseChangeRequestAction { | |||||
public function getPrompt(ReleaseChangeRequest $change) { | |||||
return array( | |||||
pht( | |||||
'This action will just mark this Change as "Merged", without actually '. | |||||
'doing any work; You would need to perform the actual merging on your '. | |||||
'own.'), | |||||
phutil_tag('br'), | |||||
pht( | |||||
'You might want to implement a replacement for this action as an '. | |||||
'extension, which will implement both merging and marking the change.'), | |||||
phutil_tag('br'), | |||||
pht( | |||||
'You can hide this button by configuring %s to %s.', | |||||
phutil_tag('tt', array(), 'release.show-debug-tools'), | |||||
phutil_tag('tt', array(), 'false')), | |||||
); | |||||
} | |||||
public function getFormTitle(ReleaseChangeRequest $change) { | |||||
return pht('Merge Change Request'); | |||||
} | |||||
public function isEnabledForRequest(ReleaseChangeRequest $change) { | |||||
return $change->getStatus() == ReleaseChangeRequest::STATUS_PENDING; | |||||
} | |||||
public function act(ReleaseChangeRequest $change, AphrontRequest $request) { | |||||
$viewer = $request->getViewer(); | |||||
$xaction_type = ReleaseChangeRequestStateTransaction::TRANSACTIONTYPE; | |||||
$status = ReleaseChangeRequest::STATUS_INCLUDED; | |||||
$xaction = id(new ReleaseChangeRequestTransaction()) | |||||
->setTransactionType($xaction_type) | |||||
->setNewValue($status); | |||||
$editor = id(new ReleaseChangeRequestEditor()) | |||||
->setActor($viewer) | |||||
->setContentSourceFromRequest($request) | |||||
->setContinueOnNoEffect(true); | |||||
$editor->applyTransactions($change, array($xaction)); | |||||
return $change->getURI(); | |||||
} | |||||
public function getActionName() { | |||||
return 'Mark Merged'; | |||||
} | |||||
public function getActionIcon() { | |||||
return 'fa-plane'; | |||||
} | |||||
public function getActionKey() { | |||||
return 'markmerged'; | |||||
} | |||||
public function generateActions() { | |||||
// Ideally, we should detect the commit in Diffusion, like with Revisions, | |||||
// but I'm not sure how complex that would be (And how scalable across | |||||
// Implmentations). | |||||
// Or maybe just out-right remove it and let users download it from the docs | |||||
if (PhabricatorEnv::getEnvConfig('release.show-debug-tools')) { | |||||
return array($this); | |||||
} else { | |||||
return array(); | |||||
} | |||||
} | |||||
} |