diff options
Diffstat (limited to 'library/Director/Web/Widget/BranchedObjectHint.php')
-rw-r--r-- | library/Director/Web/Widget/BranchedObjectHint.php | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/library/Director/Web/Widget/BranchedObjectHint.php b/library/Director/Web/Widget/BranchedObjectHint.php index ec16094..c50f923 100644 --- a/library/Director/Web/Widget/BranchedObjectHint.php +++ b/library/Director/Web/Widget/BranchedObjectHint.php @@ -15,33 +15,45 @@ class BranchedObjectHint extends HtmlDocument { use TranslationHelper; - public function __construct(Branch $branch, Auth $auth, BranchedObject $object = null) + public function __construct(Branch $branch, Auth $auth, BranchedObject $object = null, $hasPreferredBranch = false) { if (! $branch->isBranch()) { - return; - } - $hook = Branch::requireHook(); - - $name = $branch->getName(); - if (substr($name, 0, 1) === '/') { - $label = $this->translate('this configuration branch'); + if ($hasPreferredBranch) { + $main = true; + $hintMethod = 'warning'; + $link = $this->translate('the main configuration branch'); + $deployHint = ' ' . $this->translate('This will be part of the next deployment'); + } else { + return; + } } else { - $label = $name; + $main = false; + $hintMethod = 'info'; + $deployHint = ' ' . $this->translate('This will not be part of any deployment, unless being merged'); + $hook = Branch::requireHook(); + $name = $branch->getName(); + if (substr($name, 0, 1) === '/') { + $label = $this->translate('this configuration branch'); + } else { + $label = $name; + } + $link = $hook->linkToBranch($branch, $auth, $label); } - $link = $hook->linkToBranch($branch, $auth, $label); + if ($object === null) { - $this->add(Hint::info(Html::sprintf($this->translate( - 'This object will be created in %s. It will not be part of any deployment' - . ' unless being merged' - ), $link))); + $this->add(Hint::$hintMethod(Html::sprintf($this->translate( + 'This object will be created in %s.' + ) . $deployHint, $link))); return; } if (! $object->hasBeenTouchedByBranch()) { - $this->add(Hint::info(Html::sprintf($this->translate( - 'Your changes will be stored in %s. The\'ll not be part of any deployment' - . ' unless being merged' - ), $link))); + $this->add(Hint::$hintMethod(Html::sprintf($this->translate( + 'Your changes are going to be stored in %s.' + ) . $deployHint, $link))); + return; + } + if ($main) { return; } |