Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14011858
D8903.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D8903.diff
View Options
diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php
--- a/src/applications/diffusion/controller/DiffusionController.php
+++ b/src/applications/diffusion/controller/DiffusionController.php
@@ -4,6 +4,18 @@
protected $diffusionRequest;
+ public function setDiffusionRequest(DiffusionRequest $request) {
+ $this->diffusionRequest = $request;
+ return $this;
+ }
+
+ protected function getDiffusionRequest() {
+ if (!$this->diffusionRequest) {
+ throw new Exception("No Diffusion request object!");
+ }
+ return $this->diffusionRequest;
+ }
+
public function willBeginExecution() {
$request = $this->getRequest();
@@ -24,20 +36,26 @@
$drequest = DiffusionRequest::newFromAphrontRequestDictionary(
$data,
$this->getRequest());
- $this->diffusionRequest = $drequest;
+ $this->setDiffusionRequest($drequest);
}
}
- public function setDiffusionRequest(DiffusionRequest $request) {
- $this->diffusionRequest = $request;
- return $this;
- }
-
- protected function getDiffusionRequest() {
- if (!$this->diffusionRequest) {
- throw new Exception("No Diffusion request object!");
+ public function buildApplicationPage($view, array $options) {
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+ $error_view = $this->buildRepositoryWarning($repository);
+
+ $views = array();
+ $not_inserted = true;
+ foreach ($view as $view_object_or_array) {
+ $views[] = $view_object_or_array;
+ if ($not_inserted &&
+ $view_object_or_array instanceof PhabricatorCrumbsView) {
+ $views[] = $error_view;
+ $not_inserted = false;
+ }
}
- return $this->diffusionRequest;
+ return parent::buildApplicationPage($views, $options);
}
public function buildCrumbs(array $spec = array()) {
@@ -235,4 +253,22 @@
->appendChild($body);
}
+ private function buildRepositoryWarning(PhabricatorRepository $repository) {
+ $error_view = null;
+ if ($repository->isImporting()) {
+ $title = pht('This repository is still importing.');
+ $body = pht('Things may not work properly until the import finishes.');
+ } else if (!$repository->isTracked()) {
+ $title = pht('This repository is not tracked.');
+ $body = pht(
+ 'Things may not work properly until tracking is enabled and '.
+ 'importing finishes.');
+ }
+
+ if ($title) {
+ $error_view = $this->renderStatusMessage($title, $body);
+ }
+
+ return $error_view;
+ }
}
diff --git a/src/applications/herald/controller/HeraldTranscriptController.php b/src/applications/herald/controller/HeraldTranscriptController.php
--- a/src/applications/herald/controller/HeraldTranscriptController.php
+++ b/src/applications/herald/controller/HeraldTranscriptController.php
@@ -83,6 +83,9 @@
$nav->appendChild($notice);
}
+ $warning_panel = $this->buildWarningPanel($xscript);
+ $nav->appendChild($warning_panel);
+
$apply_xscript_panel = $this->buildApplyTranscriptPanel(
$xscript);
$nav->appendChild($apply_xscript_panel);
@@ -287,7 +290,47 @@
$keep_rule_xscripts));
}
- private function buildApplyTranscriptPanel($xscript) {
+ private function buildWarningPanel(HeraldTranscript $xscript) {
+ $request = $this->getRequest();
+ $panel = null;
+ if ($xscript->getObjectTranscript()) {
+ $handles = $this->handles;
+ $object_xscript = $xscript->getObjectTranscript();
+ $handle = $handles[$object_xscript->getPHID()];
+ if ($handle->getType() ==
+ PhabricatorRepositoryPHIDTypeCommit::TYPECONST) {
+ $commit = id(new DiffusionCommitQuery())
+ ->setViewer($request->getUser())
+ ->withPHIDs(array($handle->getPHID()))
+ ->executeOne();
+ if ($commit) {
+ $repository = $commit->getRepository();
+ if ($repository->isImporting()) {
+ $title = pht(
+ 'The %s repository is still importing.',
+ $repository->getMonogram());
+ $body = pht(
+ 'Herald rules will not trigger until import completes.');
+ } else if (!$repository->isTracked()) {
+ $title = pht(
+ 'The %s repository is not tracked.',
+ $repository->getMonogram());
+ $body = pht(
+ 'Herald rules will not trigger until tracking is enabled.');
+ } else {
+ return $panel;
+ }
+ $panel = id(new AphrontErrorView())
+ ->setSeverity(AphrontErrorView::SEVERITY_WARNING)
+ ->setTitle($title)
+ ->appendChild($body);
+ }
+ }
+ }
+ return $panel;
+ }
+
+ private function buildApplyTranscriptPanel(HeraldTranscript $xscript) {
$handles = $this->handles;
$adapter = $this->getAdapter();
@@ -350,7 +393,7 @@
return $box;
}
- private function buildActionTranscriptPanel($xscript) {
+ private function buildActionTranscriptPanel(HeraldTranscript $xscript) {
$action_xscript = mgroup($xscript->getApplyTranscripts(), 'getRuleID');
$adapter = $this->getAdapter();
@@ -442,7 +485,7 @@
return $box;
}
- private function buildObjectTranscriptPanel($xscript) {
+ private function buildObjectTranscriptPanel(HeraldTranscript $xscript) {
$adapter = $this->getAdapter();
$field_names = $adapter->getFieldNameMap();
@@ -452,7 +495,7 @@
$data = array();
if ($object_xscript) {
$phid = $object_xscript->getPHID();
- $handles = $this->loadViewerHandles(array($phid));
+ $handles = $this->handles;
$data += array(
pht('Object Name') => $object_xscript->getName(),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 2, 5:31 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714108
Default Alt Text
D8903.diff (5 KB)
Attached To
Mode
D8903: Diffusion + Herald - warn users if importing repository
Attached
Detach File
Event Timeline
Log In to Comment