Differential D17348 Diff 41726 src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
Show All 17 Lines | $dashboard = id(new PhabricatorDashboardQuery()) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$dashboard) { | if (!$dashboard) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$redirect_uri = $this->getApplicationURI( | $redirect_uri = $this->getApplicationURI( | ||||
'arrange/'.$dashboard->getID().'/'); | 'arrange/'.$dashboard->getID().'/'); | ||||
$v_panel = $request->getStr('panel'); | $v_panel = head($request->getArr('panel')); | ||||
chad: feels janky. | |||||
Not Done Inline ActionsThis is the best available way to do it, but I agree it feels a little janky. epriestley: This is the best available way to do it, but I agree it feels a little janky. | |||||
$e_panel = true; | $e_panel = true; | ||||
$errors = array(); | $errors = array(); | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
if (strlen($v_panel)) { | if (strlen($v_panel)) { | ||||
$panel = id(new PhabricatorDashboardPanelQuery()) | $panel = id(new PhabricatorDashboardPanelQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array($v_panel)) | ->withIDs(array($v_panel)) | ||||
->executeOne(); | ->executeOne(); | ||||
Show All 30 Lines | if (!$panels) { | ||||
pht( | pht( | ||||
'You have not created any dashboard panels yet, so you can not '. | 'You have not created any dashboard panels yet, so you can not '. | ||||
'add an existing panel.')) | 'add an existing panel.')) | ||||
->appendParagraph( | ->appendParagraph( | ||||
pht('Instead, add a new panel.')) | pht('Instead, add a new panel.')) | ||||
->addCancelButton($redirect_uri); | ->addCancelButton($redirect_uri); | ||||
} | } | ||||
$panel_options = array(); | |||||
foreach ($panels as $panel) { | |||||
$panel_options[$panel->getID()] = pht( | |||||
'%s %s', | |||||
$panel->getMonogram(), | |||||
$panel->getName()); | |||||
} | |||||
$form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->addHiddenInput('column', $request->getInt('column')) | ->addHiddenInput('column', $request->getInt('column')) | ||||
->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
pht('Choose a panel to add to this dashboard:')) | pht('Choose a panel to add to this dashboard:')) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSelectControl()) | id(new AphrontFormTokenizerControl()) | ||||
->setUser($this->getViewer()) | |||||
->setDatasource(new PhabricatorDashboardPanelDatasource()) | |||||
->setLimit(1) | |||||
->setName('panel') | ->setName('panel') | ||||
->setLabel(pht('Panel')) | ->setLabel(pht('Panel')) | ||||
->setValue($v_panel) | ->setValue($v_panel)); | ||||
->setError($e_panel) | |||||
->setOptions($panel_options)); | |||||
return $this->newDialog() | return $this->newDialog() | ||||
->setTitle(pht('Add Panel')) | ->setTitle(pht('Add Panel')) | ||||
->setErrors($errors) | ->setErrors($errors) | ||||
->appendChild($form->buildLayoutView()) | ->appendChild($form->buildLayoutView()) | ||||
->addCancelButton($redirect_uri) | ->addCancelButton($redirect_uri) | ||||
->addSubmitButton(pht('Add Panel')); | ->addSubmitButton(pht('Add Panel')); | ||||
} | } | ||||
} | } |
feels janky.