From 28f5d9f227c9b1ec1fb7482be563e126ee17852e Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 28 Feb 2012 21:13:14 -0800 Subject: [PATCH] Remove old audit edit form in favor of Diffusion form Summary: Since we embed comments/audits into Diffusion now, we don't need the old edit interface. Test Plan: Grepped for links to old interface. Reviewers: btrahan, jungejason Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1714 --- src/__phutil_library_map__.php | 2 - ...AphrontDefaultApplicationConfiguration.php | 1 - .../edit/PhabricatorAuditEditController.php | 265 ------------------ .../audit/controller/edit/__init__.php | 38 --- .../PhabricatorOwnerRelatedListController.php | 15 - 5 files changed, 321 deletions(-) delete mode 100644 src/applications/audit/controller/edit/PhabricatorAuditEditController.php delete mode 100644 src/applications/audit/controller/edit/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3b1408ebc8..541af1afeb 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -450,7 +450,6 @@ phutil_register_library_map(array( 'PhabricatorAuditCommitStatusConstants' => 'applications/audit/constants/commitstatus', 'PhabricatorAuditController' => 'applications/audit/controller/base', 'PhabricatorAuditDAO' => 'applications/audit/storage/base', - 'PhabricatorAuditEditController' => 'applications/audit/controller/edit', 'PhabricatorAuditListController' => 'applications/audit/controller/list', 'PhabricatorAuditListView' => 'applications/audit/view/list', 'PhabricatorAuditPreviewController' => 'applications/audit/controller/preview', @@ -1245,7 +1244,6 @@ phutil_register_library_map(array( 'PhabricatorAuditCommitListView' => 'AphrontView', 'PhabricatorAuditController' => 'PhabricatorController', 'PhabricatorAuditDAO' => 'PhabricatorLiskDAO', - 'PhabricatorAuditEditController' => 'PhabricatorAuditController', 'PhabricatorAuditListController' => 'PhabricatorAuditController', 'PhabricatorAuditListView' => 'AphrontView', 'PhabricatorAuditPreviewController' => 'PhabricatorAuditController', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index cd15cc4b82..8f60db7aa8 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -346,7 +346,6 @@ class AphrontDefaultApplicationConfiguration '$' => 'PhabricatorAuditListController', 'view/(?P[^/]+)/(?:(?P[^/]+)/)?$' => 'PhabricatorAuditListController', - 'edit/$' => 'PhabricatorAuditEditController', 'addcomment/$' => 'PhabricatorAuditAddCommentController', 'preview/(?P\d+)/$' => 'PhabricatorAuditPreviewController', ), diff --git a/src/applications/audit/controller/edit/PhabricatorAuditEditController.php b/src/applications/audit/controller/edit/PhabricatorAuditEditController.php deleted file mode 100644 index 7699021ac1..0000000000 --- a/src/applications/audit/controller/edit/PhabricatorAuditEditController.php +++ /dev/null @@ -1,265 +0,0 @@ -request = $this->getRequest(); - $this->user = $this->request->getUser(); - $this->commitPHID = $this->request->getStr('c-phid'); - $this->packagePHID = $this->request->getStr('p-phid'); - - $relationship = id(new PhabricatorOwnersPackageCommitRelationship()) - ->loadOneWhere( - 'commitPHID = %s AND packagePHID=%s', - $this->commitPHID, - $this->packagePHID); - if (!$relationship) { - return new Aphront404Response(); - } - - $package = id(new PhabricatorOwnersPackage())->loadOneWhere( - "phid = %s", - $this->packagePHID); - - $owners = id(new PhabricatorOwnersOwner())->loadAllWhere( - 'packageID = %d', - $package->getID()); - $owners_phids = mpull($owners, 'getUserPHID'); - if (!$this->user->getIsAdmin() && - !in_array($this->user->getPHID(), $owners_phids)) { - return $this->buildStandardPageResponse( - id(new AphrontErrorView()) - ->setSeverity(AphrontErrorView::SEVERITY_ERROR) - ->setTitle("Only admin or owner of the package can audit the ". - "commit."), - array( - 'title' => 'Audit a Commit', - )); - } - - if ($this->request->isFormPost()) { - return $this->saveAuditComments(); - } - - $package_link = phutil_render_tag( - 'a', - array( - 'href' => '/owners/package/'.$package->getID().'/', - ), - phutil_escape_html($package->getName())); - - $phids = array( - $this->commitPHID, - ); - $loader = new PhabricatorObjectHandleData($phids); - $handles = $loader->loadHandles(); - $objects = $loader->loadObjects(); - - $commit_handle = $handles[$this->commitPHID]; - $commit_object = $objects[$this->commitPHID]; - $commit_data = $commit_object->getCommitData(); - $commit_epoch = $commit_handle->getTimeStamp(); - $commit_datetime = phabricator_datetime($commit_epoch, $this->user); - $commit_link = $this->renderHandleLink($commit_handle); - - $revision_author_phid = null; - $revision_reviewedby_phid = null; - $revision_link = null; - $revision_id = $commit_data->getCommitDetail('differential.revisionID'); - if ($revision_id) { - $revision = id(new DifferentialRevision())->load($revision_id); - if ($revision) { - $revision->loadRelationships(); - $revision_author_phid = $revision->getAuthorPHID(); - $revision_reviewedby_phid = $revision->loadReviewedBy(); - $revision_link = phutil_render_tag( - 'a', - array( - 'href' => '/D'.$revision->getID() - ), - phutil_escape_html($revision->getTitle())); - } - } - - $commit_author_phid = $commit_data->getCommitDetail('authorPHID'); - $commit_reviewedby_phid = $commit_data->getCommitDetail('reviewerPHID'); - $conn_r = id(new PhabricatorAuditComment())->establishConnection('r'); - $latest_comment = queryfx_one( - $conn_r, - 'SELECT * FROM %T - WHERE targetPHID = %s and actorPHID in (%Ls) - ORDER BY ID DESC LIMIT 1', - id(new PhabricatorAuditComment())->getTableName(), - $this->commitPHID, - $owners_phids); - $auditor_phid = $latest_comment['actorPHID']; - - $user_phids = array_unique(array_filter(array( - $revision_author_phid, - $revision_reviewedby_phid, - $commit_author_phid, - $commit_reviewedby_phid, - $auditor_phid, - ))); - $user_loader = new PhabricatorObjectHandleData($user_phids); - $user_handles = $user_loader->loadHandles(); - if ($commit_author_phid && isset($handles[$commit_author_phid])) { - $commit_author_link = $handles[$commit_author_phid]->renderLink(); - } else { - $commit_author_link = phutil_escape_html($commit_data->getAuthorName()); - } - - $reasons = $relationship->getAuditReasons(); - $reasons = array_map('phutil_escape_html', $reasons); - $reasons = implode($reasons, '
'); - - $latest_comment_content = id(new AphrontFormTextAreaControl()) - ->setLabel('Audit comments') - ->setName('latest_comments') - ->setReadOnly(true) - ->setValue($latest_comment['content']); - $latest_comment_epoch = $latest_comment['dateModified']; - $latest_comment_datetime = - phabricator_datetime($latest_comment_epoch, $this->user); - - $select = id(new AphrontFormSelectControl()) - ->setLabel('Audit it') - ->setName('action') - ->setValue(PhabricatorAuditActionConstants::ACCEPT) - ->setOptions(PhabricatorAuditActionConstants::getActionNameMap()); - - $comment = id(new AphrontFormTextAreaControl()) - ->setLabel('Audit comments') - ->setName('comments') - ->setCaption("Explain the audit."); - - $submit = id(new AphrontFormSubmitControl()) - ->setValue('Save') - ->addCancelButton('/owners/related/view/audit/?phid='.$this->packagePHID); - - $form = id(new AphrontFormView()) - ->setUser($this->user) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Package') - ->setValue($package_link)) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Commit') - ->setValue($commit_link)) - ->appendChild(new AphrontFormDividerControl()) - ->appendChild(id(new AphrontFormStaticControl()) - ->setLabel('Commit Summary') - ->setValue(phutil_escape_html($commit_data->getSummary()))) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Commit Author') - ->setValue($commit_author_link)) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Commit Reviewed By') - ->setValue( - $this->renderHandleLink( - idx($user_handles, $commit_reviewedby_phid)))) - ->appendChild(id(new AphrontFormStaticControl()) - ->setLabel('Commit Time') - ->setValue($commit_datetime)) - ->appendChild(new AphrontFormDividerControl()) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Revision') - ->setValue($revision_link)) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Revision Author') - ->setValue( - $this->renderHandleLink(idx($user_handles, $revision_author_phid)))) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Revision Reviewed By') - ->setValue( - $this->renderHandleLink( - idx($user_handles, $revision_reviewedby_phid)))) - ->appendChild(new AphrontFormDividerControl()) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Audit Reasons') - ->setValue($reasons)) - ->appendChild(id(new AphrontFormMarkupControl()) - ->setLabel('Latest Auditor') - ->setValue($this->renderHandleLink(idx($user_handles, $auditor_phid)))) - ->appendChild(id(new AphrontFormStaticControl()) - ->setLabel('Latest Audit Status') - ->setValue(idx(PhabricatorAuditStatusConstants::getStatusNameMap(), - $relationship->getAuditStatus()))) - ->appendChild(id(new AphrontFormStaticControl()) - ->setLabel('Latest Audit Time') - ->setValue($latest_comment_datetime)) - ->appendChild($latest_comment_content) - ->appendChild(new AphrontFormDividerControl()) - ->appendChild($select) - ->appendChild($comment) - ->appendChild($submit); - - $panel = id(new AphrontPanelView()) - ->setHeader('Audit a Commit') - ->setWidth(AphrontPanelView::WIDTH_WIDE) - ->appendChild($form); - - return $this->buildStandardPageResponse( - $panel, - array( - 'title' => 'Audit a Commit', - )); - } - - private function saveAuditComments() { - $action = $this->request->getStr('action'); - - $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( - 'phid = %s', - $this->commitPHID); - if (!$commit) { - throw new Exception("No such commit!"); - } - - $comment = id(new PhabricatorAuditComment()) - ->setAction($action) - ->setContent($this->request->getStr('comments')); - - $editor = id(new PhabricatorAuditCommentEditor($commit)) - ->setUser($this->user) - ->addComment($comment); - - return id(new AphrontRedirectResponse()) - ->setURI(sprintf('/audit/edit/?c-phid=%s&p-phid=%s', - $this->commitPHID, - $this->packagePHID)); - } - - private function renderHandleLink($handle) { - if (!$handle) { - return null; - } - - return phutil_render_tag( - 'a', - array( - 'href' => $handle->getURI(), - ), - phutil_escape_html($handle->getName())); - } -} diff --git a/src/applications/audit/controller/edit/__init__.php b/src/applications/audit/controller/edit/__init__.php deleted file mode 100644 index 82377bad8c..0000000000 --- a/src/applications/audit/controller/edit/__init__.php +++ /dev/null @@ -1,38 +0,0 @@ -scope === 'attention') { - $status_link = phutil_escape_html( - idx(PhabricatorAuditStatusConstants::getStatusNameMap(), - $relationship['auditStatus'])); - $status_link = phutil_render_tag( - 'a', - array( - 'href' => sprintf('/audit/edit/?c-phid=%s&p-phid=%s', - idx($relationship, 'commitPHID'), - $package_phid), - ), - $status_link); - $reasons = json_decode($relationship['auditReasons'], true); $reasons = array_map('phutil_escape_html', $reasons); $reasons = implode($reasons, '
'); @@ -339,7 +327,6 @@ class PhabricatorOwnerRelatedListController $row = array_merge( $row, array( - $status_link, $reasons, )); } @@ -360,7 +347,6 @@ class PhabricatorOwnerRelatedListController $headers = array_merge( $headers, array( - 'Audit Status', 'Audit Reasons', )); } @@ -379,7 +365,6 @@ class PhabricatorOwnerRelatedListController $column_classes, array( '', - '', )); } $commit_table->setColumnClasses($column_classes);