diff --git a/src/applications/project/controller/PhabricatorProjectArchiveController.php b/src/applications/project/controller/PhabricatorProjectArchiveController.php --- a/src/applications/project/controller/PhabricatorProjectArchiveController.php +++ b/src/applications/project/controller/PhabricatorProjectArchiveController.php @@ -52,7 +52,46 @@ $button = pht('Activate Project'); } else { $title = pht('Really archive project?'); - $body = pht('This project will be moved to the archive.'); + + // Make dialog mention Herald rules which use the project in conditions + $affected_rules = id(new HeraldRuleQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withDisabled(false) + ->withAffectedObjectPHIDs(array($project->getPHID())) + ->execute(); + if ($affected_rules) { + $affected_rules = array_keys($affected_rules); + sort($affected_rules); + $prefixed_rules = array_map(function ($key) { + return 'H'.$key; + }, $affected_rules); + $prefixed_rules = implode(', ', $prefixed_rules); + + // Render a link if acting user has Herald "Can Use Application" rights + $can_herald = PhabricatorApplication::isClassInstalledForViewer( + 'PhabricatorHeraldApplication', + $viewer); + if ($can_herald) { + $affected_rules = implode(',', $affected_rules); + $herald_uri = new PhutilURI( + PhabricatorEnv::getEnvConfig('phabricator.base-uri'). + '/herald/?ids='.$affected_rules.'#R'); + $herald_query_uri = phutil_tag('a', array( + 'href' => $herald_uri, + 'target' => '_blank', + ), + $prefixed_rules); + $body = pht('This project will be moved to the archive. Herald '. + 'rule(s) %s use this project in their conditions and may require '. + 'changes.', $herald_query_uri); + } else { + $body = pht('This project will be moved to the archive. Herald '. + 'rule(s) %s use this project in their conditions and may require '. + 'changes. Please inform your Herald magician.', $prefixed_rules); + } + } else { + $body = pht('This project will be moved to the archive.'); + } $button = pht('Archive Project'); }