private function buildPanelTypeResponse($cancel_uri)
 {
     $panel_types = PhabricatorDashboardPanelType::getAllPanelTypes();
     $viewer = $this->getViewer();
     $request = $this->getRequest();
     $e_type = null;
     $errors = array();
     if ($request->isFormPost()) {
         $e_type = pht('Required');
         $errors[] = pht('To create a new dashboard panel, you must select a panel type.');
     }
     $type_control = id(new AphrontFormRadioButtonControl())->setLabel(pht('Panel Type'))->setName('panelType')->setError($e_type);
     foreach ($panel_types as $key => $type) {
         $type_control->addButton($key, $type->getPanelTypeName(), $type->getPanelTypeDescription());
     }
     $form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions(pht('Choose the type of dashboard panel to create:'))->appendChild($type_control);
     if ($request->isAjax()) {
         return $this->newDialog()->setTitle(pht('Add New Panel'))->setWidth(AphrontDialogView::WIDTH_FORM)->setErrors($errors)->appendForm($form)->addCancelButton($cancel_uri)->addSubmitButton(pht('Continue'));
     }
     $form->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($cancel_uri));
     $title = pht('Create Dashboard Panel');
     $header_icon = 'fa-plus-square';
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'));
     $crumbs->addTextCrumb(pht('New Panel'));
     $crumbs->setBorder(true);
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Panel'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon($header_icon);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter($box);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $status = $saved_query->getParameter('status', '');
     $paneltype = $saved_query->getParameter('paneltype', '');
     $panel_types = PhabricatorDashboardPanelType::getAllPanelTypes();
     $panel_types = mpull($panel_types, 'getPanelTypeName', 'getPanelTypeKey');
     asort($panel_types);
     $panel_types = array('' => pht('(All Types)')) + $panel_types;
     $form->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setValue($status)->setOptions(array('' => pht('(All Panels)'), 'active' => pht('Active Panels'), 'archived' => pht('Archived Panels'))))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Panel Type'))->setName('paneltype')->setValue($paneltype)->setOptions($panel_types));
 }
 public function getImplementation()
 {
     return idx(PhabricatorDashboardPanelType::getAllPanelTypes(), $this->getPanelType());
 }
 private function processPanelTypeRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $types = PhabricatorDashboardPanelType::getAllPanelTypes();
     $v_type = null;
     $errors = array();
     if ($request->isFormPost()) {
         $v_type = $request->getStr('type');
         if (!isset($types[$v_type])) {
             $errors[] = pht('You must select a type of panel to create.');
         }
     }
     $cancel_uri = $this->getApplicationURI('panel/');
     if (!$v_type) {
         $v_type = key($types);
     }
     $panel_types = id(new AphrontFormRadioButtonControl())->setName('type')->setValue($v_type);
     foreach ($types as $key => $type) {
         $panel_types->addButton($key, $type->getPanelTypeName(), $type->getPanelTypeDescription());
     }
     $form = id(new AphrontFormView())->setUser($viewer)->addHiddenInput('dashboardID', $request->getInt('dashboardID'))->addHiddenInput('column', $request->getInt('column'))->appendRemarkupInstructions(pht('Choose the type of dashboard panel to create:'))->appendChild($panel_types);
     if ($request->isAjax()) {
         return $this->newDialog()->setTitle(pht('Add New Panel'))->setWidth(AphrontDialogView::WIDTH_FORM)->setErrors($errors)->appendChild($form->buildLayoutView())->addCancelbutton($cancel_uri)->addSubmitButton(pht('Continue'));
     } else {
         $form->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($cancel_uri));
     }
     $title = pht('Create Dashboard Panel');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'));
     $crumbs->addTextCrumb(pht('New Panel'));
     $box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $box), array('title' => $title));
 }