mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
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
This commit is contained in:
parent
1eeaeb62e4
commit
28f5d9f227
5 changed files with 0 additions and 321 deletions
|
@ -450,7 +450,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuditCommitStatusConstants' => 'applications/audit/constants/commitstatus',
|
'PhabricatorAuditCommitStatusConstants' => 'applications/audit/constants/commitstatus',
|
||||||
'PhabricatorAuditController' => 'applications/audit/controller/base',
|
'PhabricatorAuditController' => 'applications/audit/controller/base',
|
||||||
'PhabricatorAuditDAO' => 'applications/audit/storage/base',
|
'PhabricatorAuditDAO' => 'applications/audit/storage/base',
|
||||||
'PhabricatorAuditEditController' => 'applications/audit/controller/edit',
|
|
||||||
'PhabricatorAuditListController' => 'applications/audit/controller/list',
|
'PhabricatorAuditListController' => 'applications/audit/controller/list',
|
||||||
'PhabricatorAuditListView' => 'applications/audit/view/list',
|
'PhabricatorAuditListView' => 'applications/audit/view/list',
|
||||||
'PhabricatorAuditPreviewController' => 'applications/audit/controller/preview',
|
'PhabricatorAuditPreviewController' => 'applications/audit/controller/preview',
|
||||||
|
@ -1245,7 +1244,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuditCommitListView' => 'AphrontView',
|
'PhabricatorAuditCommitListView' => 'AphrontView',
|
||||||
'PhabricatorAuditController' => 'PhabricatorController',
|
'PhabricatorAuditController' => 'PhabricatorController',
|
||||||
'PhabricatorAuditDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorAuditDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorAuditEditController' => 'PhabricatorAuditController',
|
|
||||||
'PhabricatorAuditListController' => 'PhabricatorAuditController',
|
'PhabricatorAuditListController' => 'PhabricatorAuditController',
|
||||||
'PhabricatorAuditListView' => 'AphrontView',
|
'PhabricatorAuditListView' => 'AphrontView',
|
||||||
'PhabricatorAuditPreviewController' => 'PhabricatorAuditController',
|
'PhabricatorAuditPreviewController' => 'PhabricatorAuditController',
|
||||||
|
|
|
@ -346,7 +346,6 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'$' => 'PhabricatorAuditListController',
|
'$' => 'PhabricatorAuditListController',
|
||||||
'view/(?P<filter>[^/]+)/(?:(?P<name>[^/]+)/)?$'
|
'view/(?P<filter>[^/]+)/(?:(?P<name>[^/]+)/)?$'
|
||||||
=> 'PhabricatorAuditListController',
|
=> 'PhabricatorAuditListController',
|
||||||
'edit/$' => 'PhabricatorAuditEditController',
|
|
||||||
'addcomment/$' => 'PhabricatorAuditAddCommentController',
|
'addcomment/$' => 'PhabricatorAuditAddCommentController',
|
||||||
'preview/(?P<id>\d+)/$' => 'PhabricatorAuditPreviewController',
|
'preview/(?P<id>\d+)/$' => 'PhabricatorAuditPreviewController',
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,265 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2012 Facebook, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class PhabricatorAuditEditController extends PhabricatorAuditController {
|
|
||||||
|
|
||||||
private $request;
|
|
||||||
private $user;
|
|
||||||
private $commitPHID;
|
|
||||||
private $packagePHID;
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$this->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, '<br>');
|
|
||||||
|
|
||||||
$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()));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is automatically generated. Lint this module to rebuild it.
|
|
||||||
* @generated
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/response/404');
|
|
||||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
|
||||||
phutil_require_module('phabricator', 'applications/audit/constants/action');
|
|
||||||
phutil_require_module('phabricator', 'applications/audit/constants/status');
|
|
||||||
phutil_require_module('phabricator', 'applications/audit/controller/base');
|
|
||||||
phutil_require_module('phabricator', 'applications/audit/editor/comment');
|
|
||||||
phutil_require_module('phabricator', 'applications/audit/storage/auditcomment');
|
|
||||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
|
||||||
phutil_require_module('phabricator', 'applications/owners/storage/owner');
|
|
||||||
phutil_require_module('phabricator', 'applications/owners/storage/package');
|
|
||||||
phutil_require_module('phabricator', 'applications/owners/storage/packagecommitrelationship');
|
|
||||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
|
||||||
phutil_require_module('phabricator', 'applications/repository/storage/commit');
|
|
||||||
phutil_require_module('phabricator', 'storage/queryfx');
|
|
||||||
phutil_require_module('phabricator', 'view/form/base');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/divider');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/markup');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/select');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/static');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/textarea');
|
|
||||||
phutil_require_module('phabricator', 'view/form/error');
|
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
|
||||||
phutil_require_module('phabricator', 'view/utils');
|
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
|
||||||
phutil_require_module('phutil', 'utils');
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('PhabricatorAuditEditController.php');
|
|
|
@ -320,18 +320,6 @@ class PhabricatorOwnerRelatedListController
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->scope === 'attention') {
|
if ($this->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 = json_decode($relationship['auditReasons'], true);
|
||||||
$reasons = array_map('phutil_escape_html', $reasons);
|
$reasons = array_map('phutil_escape_html', $reasons);
|
||||||
$reasons = implode($reasons, '<br>');
|
$reasons = implode($reasons, '<br>');
|
||||||
|
@ -339,7 +327,6 @@ class PhabricatorOwnerRelatedListController
|
||||||
$row = array_merge(
|
$row = array_merge(
|
||||||
$row,
|
$row,
|
||||||
array(
|
array(
|
||||||
$status_link,
|
|
||||||
$reasons,
|
$reasons,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -360,7 +347,6 @@ class PhabricatorOwnerRelatedListController
|
||||||
$headers = array_merge(
|
$headers = array_merge(
|
||||||
$headers,
|
$headers,
|
||||||
array(
|
array(
|
||||||
'Audit Status',
|
|
||||||
'Audit Reasons',
|
'Audit Reasons',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -379,7 +365,6 @@ class PhabricatorOwnerRelatedListController
|
||||||
$column_classes,
|
$column_classes,
|
||||||
array(
|
array(
|
||||||
'',
|
'',
|
||||||
'',
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$commit_table->setColumnClasses($column_classes);
|
$commit_table->setColumnClasses($column_classes);
|
||||||
|
|
Loading…
Reference in a new issue