Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionCommitController.php
| Show First 20 Lines • Show All 733 Lines • ▼ Show 20 Lines | $comment_view = id(new DiffusionCommitEditEngine()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->buildEditEngineCommentView($commit); | ->buildEditEngineCommentView($commit); | ||||
| $comment_view->setTransactionTimeline($timeline); | $comment_view->setTransactionTimeline($timeline); | ||||
| return $comment_view; | return $comment_view; | ||||
| } | } | ||||
| /** | |||||
| * Return a map of available audit actions for rendering into a <select />. | |||||
| * This shows the user valid actions, and does not show nonsense/invalid | |||||
| * actions (like closing an already-closed commit, or resigning from a commit | |||||
| * you have no association with). | |||||
| */ | |||||
| private function getAuditActions( | |||||
| PhabricatorRepositoryCommit $commit, | |||||
| array $audit_requests) { | |||||
| assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest'); | |||||
| $viewer = $this->getViewer(); | |||||
| $user_is_author = ($commit->getAuthorPHID() == $viewer->getPHID()); | |||||
| $user_request = null; | |||||
| foreach ($audit_requests as $audit_request) { | |||||
| if ($audit_request->getAuditorPHID() == $viewer->getPHID()) { | |||||
| $user_request = $audit_request; | |||||
| break; | |||||
| } | |||||
| } | |||||
| $actions = array(); | |||||
| $actions[PhabricatorAuditActionConstants::COMMENT] = true; | |||||
| // We allow you to accept your own commits. A use case here is that you | |||||
| // notice an issue with your own commit and "Raise Concern" as an indicator | |||||
| // to other auditors that you're on top of the issue, then later resolve it | |||||
| // and "Accept". You can not accept on behalf of projects or packages, | |||||
| // however. | |||||
| $actions[PhabricatorAuditActionConstants::ACCEPT] = true; | |||||
| $actions[PhabricatorAuditActionConstants::CONCERN] = true; | |||||
| // To resign, a user must have authority on some request and not be the | |||||
| // commit's author. | |||||
| if (!$user_is_author) { | |||||
| $may_resign = false; | |||||
| $authority_map = array_fill_keys($this->auditAuthorityPHIDs, true); | |||||
| foreach ($audit_requests as $request) { | |||||
| if (empty($authority_map[$request->getAuditorPHID()])) { | |||||
| continue; | |||||
| } | |||||
| $may_resign = true; | |||||
| break; | |||||
| } | |||||
| // If the user has already resigned, don't show "Resign...". | |||||
| $status_resigned = PhabricatorAuditStatusConstants::RESIGNED; | |||||
| if ($user_request) { | |||||
| if ($user_request->getAuditStatus() == $status_resigned) { | |||||
| $may_resign = false; | |||||
| } | |||||
| } | |||||
| if ($may_resign) { | |||||
| $actions[PhabricatorAuditActionConstants::RESIGN] = true; | |||||
| } | |||||
| } | |||||
| $status_concern = PhabricatorAuditCommitStatusConstants::CONCERN_RAISED; | |||||
| $concern_raised = ($commit->getAuditStatus() == $status_concern); | |||||
| $can_close_option = PhabricatorEnv::getEnvConfig( | |||||
| 'audit.can-author-close-audit'); | |||||
| if ($can_close_option && $user_is_author && $concern_raised) { | |||||
| $actions[PhabricatorAuditActionConstants::CLOSE] = true; | |||||
| } | |||||
| $actions[PhabricatorAuditActionConstants::ADD_AUDITORS] = true; | |||||
| $actions[PhabricatorAuditActionConstants::ADD_CCS] = true; | |||||
| foreach ($actions as $constant => $ignored) { | |||||
| $actions[$constant] = | |||||
| PhabricatorAuditActionConstants::getActionName($constant); | |||||
| } | |||||
| return $actions; | |||||
| } | |||||
| private function buildMergesTable(PhabricatorRepositoryCommit $commit) { | private function buildMergesTable(PhabricatorRepositoryCommit $commit) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
| $repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
| $merges = $this->getCommitMerges(); | $merges = $this->getCommitMerges(); | ||||
| if (!$merges) { | if (!$merges) { | ||||
| return null; | return null; | ||||
| ▲ Show 20 Lines • Show All 383 Lines • Show Last 20 Lines | |||||