diff --git a/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php index 833a56deb7..fafe62ee4e 100644 --- a/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php @@ -1,219 +1,211 @@ getViewer(); $preferences = $this->getPreferences(); $pinned_key = PhabricatorPinnedApplicationsSetting::SETTINGKEY; $pinned = $preferences->getSettingValue($pinned_key); $apps = id(new PhabricatorApplicationQuery()) ->setViewer($viewer) ->withInstalled(true) ->withUnlisted(false) ->withLaunchable(true) ->execute(); $app_list = array(); foreach ($pinned as $app) { if (isset($apps[$app])) { $app_list[$app] = $apps[$app]; } } if ($request->getBool('reset')) { if ($request->isFormPost()) { $this->writePinnedApplications($preferences, null); return id(new AphrontRedirectResponse()) ->setURI($this->getPanelURI()); } return $this->newDialog() ->setTitle(pht('Reset Applications')) ->addHiddenInput('reset', 'true') ->appendParagraph( pht('Reset pinned applications to their defaults?')) ->addSubmitButton(pht('Reset Applications')) ->addCancelButton($this->getPanelURI()); } if ($request->getBool('add')) { $options = array(); foreach ($apps as $app) { $options[get_class($app)] = $app->getName(); } asort($options); unset($options['PhabricatorApplicationsApplication']); if ($request->isFormPost()) { $pin = $request->getStr('pin'); if (isset($options[$pin]) && !in_array($pin, $pinned)) { $pinned[] = $pin; $this->writePinnedApplications($preferences, $pinned); return id(new AphrontRedirectResponse()) ->setURI($this->getPanelURI()); } } $options_control = id(new AphrontFormSelectControl()) ->setName('pin') ->setLabel(pht('Application')) ->setOptions($options) ->setDisabledOptions(array_keys($app_list)); $form = id(new AphrontFormView()) ->setViewer($viewer) ->addHiddenInput('add', 'true') ->appendRemarkupInstructions( pht('Choose an application to pin to your home page.')) ->appendChild($options_control); return $this->newDialog() ->setWidth(AphrontDialogView::WIDTH_FORM) ->setTitle(pht('Pin Application')) ->appendChild($form->buildLayoutView()) ->addSubmitButton(pht('Pin Application')) ->addCancelButton($this->getPanelURI()); } $unpin = $request->getStr('unpin'); if ($unpin) { $app = idx($apps, $unpin); if ($app) { if ($request->isFormPost()) { $pinned = array_diff($pinned, array($unpin)); $this->writePinnedApplications($preferences, $pinned); return id(new AphrontRedirectResponse()) ->setURI($this->getPanelURI()); } return $this->newDialog() ->setTitle(pht('Unpin Application')) ->addHiddenInput('unpin', $unpin) ->appendParagraph( pht( 'Unpin the %s application from your home page?', phutil_tag('strong', array(), $app->getName()))) ->addSubmitButton(pht('Unpin Application')) ->addCancelButton($this->getPanelURI()); } } $order = $request->getStrList('order'); if ($order && $request->validateCSRF()) { $this->writePinnedApplications($preferences, $order); return id(new AphrontRedirectResponse()) ->setURI($this->getPanelURI()); } $list_id = celerity_generate_unique_node_id(); $list = id(new PHUIObjectItemListView()) ->setViewer($viewer) ->setID($list_id); Javelin::initBehavior( 'reorder-applications', array( 'listID' => $list_id, 'panelURI' => $this->getPanelURI(), )); foreach ($app_list as $key => $application) { if ($key == 'PhabricatorApplicationsApplication') { continue; } $icon = $application->getIcon(); if (!$icon) { - $icon = 'application'; + $icon = 'fa-globe'; } - $icon_view = javelin_tag( - 'span', - array( - 'class' => 'phui-icon-view phui-font-fa '.$icon, - 'aural' => false, - ), - ''); - $item = id(new PHUIObjectItemView()) ->setHeader($application->getName()) - ->setImageIcon($icon_view) + ->setImageIcon($icon) ->addAttribute($application->getShortDescription()) ->setGrippable(true); $item->addAction( id(new PHUIListItemView()) ->setIcon('fa-times') ->setHref($this->getPanelURI().'?unpin='.$key) ->setWorkflow(true)); $item->addSigil('pinned-application'); $item->setMetadata( array( 'applicationClass' => $key, )); $list->addItem($item); } $header = id(new PHUIHeaderView()) ->setHeader(pht('Pinned Applications')) ->addActionLink( id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Pin Application')) ->setHref($this->getPanelURI().'?add=true') ->setWorkflow(true) ->setIcon('fa-thumb-tack')) ->addActionLink( id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Reset to Defaults')) ->setHref($this->getPanelURI().'?reset=true') ->setWorkflow(true) ->setIcon('fa-recycle')); $box = id(new PHUIObjectBoxView()) ->setHeader($header) ->setObjectList($list); return $box; } private function writePinnedApplications( PhabricatorUserPreferences $preferences, $pinned) { $pinned_key = PhabricatorPinnedApplicationsSetting::SETTINGKEY; $this->writeSetting($preferences, $pinned_key, $pinned); } }