Edit dashboard panels in a dialog instead of on a separate page
Summary: When you "Edit Panel" on a dashboard, pop a dialog instead of redirecting to a different page. Test Plan: Edited a panel from a dashboard; edited a panel from the panel workflow. Reviewers: chad Reviewed By: chad Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D9499
This commit is contained in:
parent
96a7868fe0
commit
c72e2f35f3
|
@ -121,6 +121,7 @@ final class PhabricatorDashboardPanelEditController
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
|
->addHiddenInput('dashboardID', $request->getInt('dashboardID'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextControl())
|
id(new AphrontFormTextControl())
|
||||||
->setLabel(pht('Name'))
|
->setLabel(pht('Name'))
|
||||||
|
@ -142,12 +143,6 @@ final class PhabricatorDashboardPanelEditController
|
||||||
|
|
||||||
$field_list->appendFieldsToForm($form);
|
$field_list->appendFieldsToForm($form);
|
||||||
|
|
||||||
$form
|
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormSubmitControl())
|
|
||||||
->setValue($button)
|
|
||||||
->addCancelButton($cancel_uri));
|
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb(
|
||||||
pht('Panels'),
|
pht('Panels'),
|
||||||
|
@ -162,6 +157,22 @@ final class PhabricatorDashboardPanelEditController
|
||||||
$crumbs->addTextCrumb(pht('Edit'));
|
$crumbs->addTextCrumb(pht('Edit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->isAjax()) {
|
||||||
|
return $this->newDialog()
|
||||||
|
->setTitle($header)
|
||||||
|
->setWidth(AphrontDialogView::WIDTH_FORM)
|
||||||
|
->setValidationException($validation_exception)
|
||||||
|
->appendChild($form->buildLayoutView())
|
||||||
|
->addCancelButton($cancel_uri)
|
||||||
|
->addSubmitButton($button);
|
||||||
|
} else {
|
||||||
|
$form
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue($button)
|
||||||
|
->addCancelButton($cancel_uri));
|
||||||
|
}
|
||||||
|
|
||||||
$box = id(new PHUIObjectBoxView())
|
$box = id(new PHUIObjectBoxView())
|
||||||
->setHeaderText($header)
|
->setHeaderText($header)
|
||||||
->setValidationException($validation_exception)
|
->setValidationException($validation_exception)
|
||||||
|
|
|
@ -236,6 +236,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
||||||
}
|
}
|
||||||
$action_edit = id(new PHUIIconView())
|
$action_edit = id(new PHUIIconView())
|
||||||
->setIconFont('fa-pencil')
|
->setIconFont('fa-pencil')
|
||||||
|
->setWorkflow(true)
|
||||||
->setHref((string) $edit_uri);
|
->setHref((string) $edit_uri);
|
||||||
$header->addAction($action_edit);
|
$header->addAction($action_edit);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
|
||||||
} else {
|
} else {
|
||||||
$h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_NORMAL;
|
$h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($panel_grid_locations as $column => $panel_column_locations) {
|
foreach ($panel_grid_locations as $column => $panel_column_locations) {
|
||||||
$panel_phids = $panel_column_locations;
|
$panel_phids = $panel_column_locations;
|
||||||
$column_panels = array_select_keys($panels, $panel_phids);
|
$column_panels = array_select_keys($panels, $panel_phids);
|
||||||
|
|
|
@ -19,8 +19,10 @@ final class AphrontDialogView extends AphrontView {
|
||||||
private $disableWorkflowOnSubmit;
|
private $disableWorkflowOnSubmit;
|
||||||
private $disableWorkflowOnCancel;
|
private $disableWorkflowOnCancel;
|
||||||
private $width = 'default';
|
private $width = 'default';
|
||||||
private $errors;
|
private $errors = array();
|
||||||
private $flush;
|
private $flush;
|
||||||
|
private $validationException;
|
||||||
|
|
||||||
|
|
||||||
const WIDTH_DEFAULT = 'default';
|
const WIDTH_DEFAULT = 'default';
|
||||||
const WIDTH_FORM = 'form';
|
const WIDTH_FORM = 'form';
|
||||||
|
@ -162,6 +164,12 @@ final class AphrontDialogView extends AphrontView {
|
||||||
return $this->disableWorkflowOnCancel;
|
return $this->disableWorkflowOnCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setValidationException(
|
||||||
|
PhabricatorApplicationTransactionValidationException $ex = null) {
|
||||||
|
$this->validationException = $ex;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
final public function render() {
|
final public function render() {
|
||||||
require_celerity_resource('aphront-dialog-view-css');
|
require_celerity_resource('aphront-dialog-view-css');
|
||||||
|
|
||||||
|
@ -267,9 +275,19 @@ final class AphrontDialogView extends AphrontView {
|
||||||
|
|
||||||
$children = $this->renderChildren();
|
$children = $this->renderChildren();
|
||||||
|
|
||||||
if ($this->errors) {
|
$errors = $this->errors;
|
||||||
|
|
||||||
|
$ex = $this->validationException;
|
||||||
|
$exception_errors = null;
|
||||||
|
if ($ex) {
|
||||||
|
foreach ($ex->getErrors() as $error) {
|
||||||
|
$errors[] = $error->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($errors) {
|
||||||
$children = array(
|
$children = array(
|
||||||
id(new AphrontErrorView())->setErrors($this->errors),
|
id(new AphrontErrorView())->setErrors($errors),
|
||||||
$children);
|
$children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue