1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01: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) {
$error_view = id(new AphrontErrorView())
->setErrors(array(pht('You are being rate limited.')));
$dialog = id(new AphrontDialogView())
->setTitle(pht('Slow Down!'))
->setUser($user)
->appendChild($error_view)
->setErrors(array(pht('You are being rate limited.')))
->appendParagraph($ex->getMessage())
->appendParagraph($ex->getRateExplanation())
->addCancelButton('/', pht('Okaaaaaaaaaaaaaay...'));

View file

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

View file

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

View file

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

View file

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

View file

@ -2,22 +2,14 @@
* @provides aphront-error-view-css
*/
.aphront-error-view,
.aphront-error-view-dialogue {
.aphront-error-view {
border-style: solid;
border-width: 1px;
}
form.aphront-dialog-view .aphront-error-view {
margin: 0 0 12px 0;
}
.aphront-error-view {
margin: 16px;
}
.aphront-error-view-dialogue {
margin: 0 0 16px 0;
}
.device-phone .aphront-error-view {
margin: 8px;
@ -84,3 +76,14 @@ h1.aphront-error-view-head {
color: {$greytext};
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;
}