1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Make errors in dialogs look reasonable instead of hideous

Summary: I accidentally made these exceptionally ugly recently.

Test Plan: {F137411}

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley, chad

Differential Revision: https://secure.phabricator.com/D8684
This commit is contained in:
epriestley 2014-04-03 11:23:03 -07:00
parent 957b9c1729
commit c9311a9eae
6 changed files with 34 additions and 39 deletions

View file

@ -112,13 +112,10 @@ class AphrontDefaultApplicationConfiguration
} }
if ($ex instanceof PhabricatorSystemActionRateLimitException) { if ($ex instanceof PhabricatorSystemActionRateLimitException) {
$error_view = id(new AphrontErrorView())
->setErrors(array(pht('You are being rate limited.')));
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setTitle(pht('Slow Down!')) ->setTitle(pht('Slow Down!'))
->setUser($user) ->setUser($user)
->appendChild($error_view) ->setErrors(array(pht('You are being rate limited.')))
->appendParagraph($ex->getMessage()) ->appendParagraph($ex->getMessage())
->appendParagraph($ex->getRateExplanation()) ->appendParagraph($ex->getRateExplanation())
->addCancelButton('/', pht('Okaaaaaaaaaaaaaay...')); ->addCancelButton('/', pht('Okaaaaaaaaaaaaaay...'));

View file

@ -156,8 +156,6 @@ final class ConpherenceUpdateController
if ($errors) { if ($errors) {
$error_view = id(new AphrontErrorView()) $error_view = id(new AphrontErrorView())
->setTitle(pht('Errors editing conpherence.'))
->setInsideDialogue(true)
->setErrors($errors); ->setErrors($errors);
} }

View file

@ -15,7 +15,7 @@ final class PhabricatorSystemActionEngine extends Phobject {
foreach ($blocked as $actor => $actor_score) { foreach ($blocked as $actor => $actor_score) {
throw new PhabricatorSystemActionRateLimitException( throw new PhabricatorSystemActionRateLimitException(
$action, $action,
$actor_score + ($score / self::getWindow())); $actor_score);
} }
} }
} }
@ -25,14 +25,17 @@ final class PhabricatorSystemActionEngine extends Phobject {
public static function loadBlockedActors( public static function loadBlockedActors(
array $actors, array $actors,
PhabricatorSystemAction $action) { PhabricatorSystemAction $action,
$score) {
$scores = self::loadScores($actors, $action); $scores = self::loadScores($actors, $action);
$window = self::getWindow();
$blocked = array(); $blocked = array();
foreach ($scores as $actor => $score) { foreach ($scores as $actor => $actor_score) {
if ($action->shouldBlockActor($actor, $score)) { $actor_score = $actor_score + ($score / $window);
$blocked[$actor] = $score; if ($action->shouldBlockActor($actor, $actor_score)) {
$blocked[$actor] = $actor_score;
} }
} }

View file

@ -19,6 +19,7 @@ final class AphrontDialogView extends AphrontView {
private $disableWorkflowOnSubmit; private $disableWorkflowOnSubmit;
private $disableWorkflowOnCancel; private $disableWorkflowOnCancel;
private $width = 'default'; private $width = 'default';
private $errors;
const WIDTH_DEFAULT = 'default'; const WIDTH_DEFAULT = 'default';
const WIDTH_FORM = 'form'; const WIDTH_FORM = 'form';
@ -34,6 +35,11 @@ final class AphrontDialogView extends AphrontView {
return $this; return $this;
} }
public function setErrors(array $errors) {
$this->errors = $errors;
return $this;
}
public function getIsStandalone() { public function getIsStandalone() {
return $this->isStandalone; return $this->isStandalone;
} }
@ -252,6 +258,12 @@ final class AphrontDialogView extends AphrontView {
$children = $this->renderChildren(); $children = $this->renderChildren();
if ($this->errors) {
$children = array(
id(new AphrontErrorView())->setErrors($this->errors),
$children);
}
$header = new PhabricatorActionHeaderView(); $header = new PhabricatorActionHeaderView();
$header->setHeaderTitle($this->title); $header->setHeaderTitle($this->title);
$header->setHeaderColor($this->headerColor); $header->setHeaderColor($this->headerColor);

View file

@ -11,15 +11,6 @@ final class AphrontErrorView extends AphrontView {
private $errors; private $errors;
private $severity; private $severity;
private $id; private $id;
private $insideDialogue;
public function setInsideDialogue($inside_dialogue) {
$this->insideDialogue = $inside_dialogue;
return $this;
}
public function getInsideDialogue() {
return $this->insideDialogue;
}
public function setTitle($title) { public function setTitle($title) {
$this->title = $title; $this->title = $title;
@ -41,15 +32,6 @@ final class AphrontErrorView extends AphrontView {
return $this; return $this;
} }
private function getBaseClass() {
if ($this->getInsideDialogue()) {
$class = 'aphront-error-view-dialogue';
} else {
$class = 'aphront-error-view';
}
return $class;
}
final public function render() { final public function render() {
require_celerity_resource('aphront-error-view-css'); require_celerity_resource('aphront-error-view-css');
@ -88,7 +70,7 @@ final class AphrontErrorView extends AphrontView {
$this->severity = nonempty($this->severity, self::SEVERITY_ERROR); $this->severity = nonempty($this->severity, self::SEVERITY_ERROR);
$classes = array(); $classes = array();
$classes[] = $this->getBaseClass(); $classes[] = 'aphront-error-view';
$classes[] = 'aphront-error-severity-'.$this->severity; $classes[] = 'aphront-error-severity-'.$this->severity;
$classes = implode(' ', $classes); $classes = implode(' ', $classes);

View file

@ -2,22 +2,14 @@
* @provides aphront-error-view-css * @provides aphront-error-view-css
*/ */
.aphront-error-view, .aphront-error-view {
.aphront-error-view-dialogue {
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
} }
form.aphront-dialog-view .aphront-error-view {
margin: 0 0 12px 0;
}
.aphront-error-view { .aphront-error-view {
margin: 16px; margin: 16px;
} }
.aphront-error-view-dialogue {
margin: 0 0 16px 0;
}
.device-phone .aphront-error-view { .device-phone .aphront-error-view {
margin: 8px; margin: 8px;
@ -84,3 +76,14 @@ h1.aphront-error-view-head {
color: {$greytext}; color: {$greytext};
background-color: #fff; background-color: #fff;
} }
.aphront-dialog-body .aphront-error-view {
margin: -16px -16px 16px -16px;
border-width: 0 0 1px 0;
border-bottom: 1px solid {$lightblueborder};
}
.aphront-dialog-body .aphront-error-view .aphront-error-view-list {
margin: 0 0 0 16px;
list-style: disc;
}