mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Allow to uninstall (hide) Audit application
Summary: While many Phorge applications can be uninstalled (such as Differential for pre-merge commit review), this has not been the case for Audit (post-merge commit review) since rP11861265fe94fa97e4d0563c5bdb7b8cac27282d. In installations which do not use Audit in their workflows, exposing Audit related UI elements creates additional clutter and complexity. Fixes T15129 Test Plan: * Go to `/applications/view/PhabricatorAuditApplication/` and click "Uninstall" * View an individual merged commit in Diffusion, click "Edit Commit" in the sidebar to go to `/diffusion/commit/edit/1/`, see that "Auditors" datasource is not displayed * View an individual merged commit in Diffusion, click the "Add Action..." dropdown, see that the "Audit Action" section and its entries "Accept Commit" and "Raise Concern" are not displayed * View an individual merged commit in Diffusion, click the "Add Action..." dropdown, see that the "Change Auditors" entry is not displayed * Go to `/conduit/` and see that the API method "audit.query" and the entire section "audit" is not displayed * Go to `/diffusion/commit/` and see no "Active Audits" and "Audited" searches in the left side bar * Go to `/diffusion/commit/query/all/` and see that no "Auditors" entry is shown for each commit * Go to `/diffusion/commit/query/all/` and see that no audit related entry is shown in the grey column on the right (if Harbormaster is not installed, there will be no grey column at all) * Go to `/herald/edit/?content_type=commit&rule_type=global` and see that no Condition entry "Auditors" and no Condition entry "Affected packages that need audit" is displayed * Go to `/herald/edit/?content_type=commit&rule_type=personal` and see that no "Add me as an auditor" Herald action and no "Added Auditors" Herald condition is displayed Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15129 Differential Revision: https://we.phorge.it/D25503
This commit is contained in:
parent
b445e1d80d
commit
821708414e
11 changed files with 79 additions and 32 deletions
|
@ -19,9 +19,7 @@ final class PhabricatorAuditApplication extends PhabricatorApplication {
|
|||
}
|
||||
|
||||
public function canUninstall() {
|
||||
// Audit was once a separate application, but has largely merged with
|
||||
// Diffusion.
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isPinnedByDefault(PhabricatorUser $viewer) {
|
||||
|
|
|
@ -4,7 +4,7 @@ abstract class AuditConduitAPIMethod extends ConduitAPIMethod {
|
|||
|
||||
final public function getApplication() {
|
||||
return PhabricatorApplication::getByClass(
|
||||
'PhabricatorDiffusionApplication');
|
||||
'PhabricatorAuditApplication');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ final class PhabricatorCommitSearchEngine
|
|||
}
|
||||
|
||||
protected function buildCustomSearchFields() {
|
||||
$show_audit_fields = (id(new PhabricatorAuditApplication())->isInstalled());
|
||||
$show_packages = PhabricatorApplication::isClassInstalled(
|
||||
'PhabricatorPackagesApplication');
|
||||
return array(
|
||||
|
@ -95,6 +96,7 @@ final class PhabricatorCommitSearchEngine
|
|||
->setConduitKey('auditors')
|
||||
->setAliases(array('auditor', 'auditors', 'auditorPHID'))
|
||||
->setDatasource(new DiffusionAuditorFunctionDatasource())
|
||||
->setIsHidden(!$show_audit_fields)
|
||||
->setDescription(
|
||||
pht(
|
||||
'Find commits where given users, projects, or packages are '.
|
||||
|
@ -106,6 +108,7 @@ final class PhabricatorCommitSearchEngine
|
|||
->setOptions(DiffusionCommitAuditStatus::newOptions())
|
||||
->setDeprecatedOptions(
|
||||
DiffusionCommitAuditStatus::newDeprecatedOptions())
|
||||
->setIsHidden(!$show_audit_fields)
|
||||
->setDescription(pht('Find commits with given audit statuses.')),
|
||||
id(new PhabricatorSearchDatasourceField())
|
||||
->setLabel(pht('Repositories'))
|
||||
|
@ -172,10 +175,14 @@ final class PhabricatorCommitSearchEngine
|
|||
$names = array();
|
||||
|
||||
if ($this->requireViewer()->isLoggedIn()) {
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
$names['active'] = pht('Active Audits');
|
||||
}
|
||||
$names['authored'] = pht('Authored');
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
$names['audited'] = pht('Audited');
|
||||
}
|
||||
}
|
||||
|
||||
$names['all'] = pht('All Commits');
|
||||
|
||||
|
@ -224,9 +231,11 @@ final class PhabricatorCommitSearchEngine
|
|||
|
||||
$bucket = $this->getResultBucket($query);
|
||||
|
||||
// hide "Auditors" on /diffusion/commit/query/all/ if Audit not installed
|
||||
$show_auditors = id(new PhabricatorAuditApplication())->isInstalled();
|
||||
$template = id(new DiffusionCommitGraphView())
|
||||
->setViewer($viewer)
|
||||
->setShowAuditors(true);
|
||||
->setShowAuditors($show_auditors);
|
||||
|
||||
$views = array();
|
||||
if ($bucket) {
|
||||
|
|
|
@ -100,7 +100,9 @@ final class DiffusionCommitEditEngine
|
|||
$data = $object->getCommitData();
|
||||
|
||||
$fields = array();
|
||||
|
||||
// remove "Change Auditors" from "Add Action" dropdown etc
|
||||
// if Audit is not installed
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
$fields[] = id(new PhabricatorDatasourceEditField())
|
||||
->setKey('auditors')
|
||||
->setLabel(pht('Auditors'))
|
||||
|
@ -113,6 +115,7 @@ final class DiffusionCommitEditEngine
|
|||
->setConduitDescription(pht('Change the auditors for this commit.'))
|
||||
->setConduitTypeDescription(pht('New auditors.'))
|
||||
->setValue($object->getAuditorPHIDsForEdit());
|
||||
}
|
||||
|
||||
$actions = DiffusionCommitActionTransaction::loadAllActions();
|
||||
$actions = msortv($actions, 'getCommitActionOrderVector');
|
||||
|
|
|
@ -9,8 +9,13 @@ final class DiffusionAuditorsAddAuditorsHeraldAction
|
|||
return pht('Add auditors');
|
||||
}
|
||||
|
||||
// hide "Add auditors" Herald action if Audit not installed
|
||||
public function supportsRuleType($rule_type) {
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function applyEffect($object, HeraldEffect $effect) {
|
||||
|
|
|
@ -9,8 +9,13 @@ final class DiffusionAuditorsAddSelfHeraldAction
|
|||
return pht('Add me as an auditor');
|
||||
}
|
||||
|
||||
// hide "Add me as an auditor" Herald action if Audit not installed
|
||||
public function supportsRuleType($rule_type) {
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
return ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function applyEffect($object, HeraldEffect $effect) {
|
||||
|
|
|
@ -5,6 +5,15 @@ final class DiffusionCommitAuditorsHeraldField
|
|||
|
||||
const FIELDCONST = 'diffusion.commit.auditors';
|
||||
|
||||
// hide "Auditors" Herald condition if Audit not installed
|
||||
public function supportsObject($object) {
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
return ($object instanceof PhabricatorRepositoryCommit);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Auditors');
|
||||
}
|
||||
|
|
|
@ -5,6 +5,16 @@ final class DiffusionCommitPackageAuditHeraldField
|
|||
|
||||
const FIELDCONST = 'diffusion.commit.package.audit';
|
||||
|
||||
// hide "Affected packages that need audit" Herald condition
|
||||
// if Audit not installed
|
||||
public function supportsObject($object) {
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
return ($object instanceof PhabricatorRepositoryCommit);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Affected packages that need audit');
|
||||
}
|
||||
|
|
|
@ -169,7 +169,10 @@ final class DiffusionCommitGraphView
|
|||
$this->addBuildAction($item_view, $hash);
|
||||
}
|
||||
|
||||
// hide Audit entry on /diffusion/commit/query/all if Audit not installed
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
$this->addAuditAction($item_view, $hash);
|
||||
}
|
||||
|
||||
if ($show_auditors) {
|
||||
$auditor_list = $item_view->newMapView();
|
||||
|
|
|
@ -8,6 +8,9 @@ abstract class DiffusionCommitActionTransaction
|
|||
}
|
||||
|
||||
public function isActionAvailable($object, PhabricatorUser $viewer) {
|
||||
if (!id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$this->validateAction($object, $viewer);
|
||||
return true;
|
||||
|
|
|
@ -275,6 +275,7 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||
->setOptions($orders);
|
||||
}
|
||||
|
||||
if (id(new PhabricatorAuditApplication())->isInstalled()) {
|
||||
$buckets = $this->newResultBuckets();
|
||||
if ($query && $buckets) {
|
||||
$bucket_options = array(
|
||||
|
@ -286,6 +287,7 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||
->setKey('bucket')
|
||||
->setOptions($bucket_options);
|
||||
}
|
||||
}
|
||||
|
||||
$field_map = array();
|
||||
foreach ($fields as $field) {
|
||||
|
|
Loading…
Reference in a new issue