mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 20:10:55 +01:00
Converted the pinned applications selector to a typeahead.
Summary: Fixes T11513. Previously the selector was just a giant dropdown which was just... just too much. Now there's a handy typeahead. Test Plan: Happy Path: Go to `Settings -> Home Page -> Pin Application`, start typing in the form then select one of the options. Click on "Pin Application". The application should now be in the list. Other paths: - Type nothing into the box and submit, nothing should happen. - Choose an application that is already pinned. The list should stay the same. - Type nonsense into the box and submit, nothing should happen. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: chad, Korvin, epriestley, yelirekim Maniphest Tasks: T11513 Differential Revision: https://secure.phabricator.com/D16459
This commit is contained in:
parent
90294713e8
commit
067d12d716
2 changed files with 20 additions and 6 deletions
|
@ -38,7 +38,9 @@ final class PhabricatorApplicationDatasource
|
||||||
->setDisplayType($application->getShortDescription())
|
->setDisplayType($application->getShortDescription())
|
||||||
->setImageuRI($application->getIconURI())
|
->setImageuRI($application->getIconURI())
|
||||||
->setPriorityType('apps')
|
->setPriorityType('apps')
|
||||||
->setImageSprite('phabricator-search-icon '.$img);
|
->setImageSprite('phabricator-search-icon '.$img)
|
||||||
|
->setIcon($application->getIcon())
|
||||||
|
->addAttribute($application->getShortDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->filterResultsAgainstTokens($results);
|
return $this->filterResultsAgainstTokens($results);
|
||||||
|
|
|
@ -67,7 +67,19 @@ final class PhabricatorHomePreferencesSettingsPanel
|
||||||
unset($options['PhabricatorApplicationsApplication']);
|
unset($options['PhabricatorApplicationsApplication']);
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$pin = $request->getStr('pin');
|
$pins = $request->getArr('pin');
|
||||||
|
$phid = head($pins);
|
||||||
|
$app = id(new PhabricatorApplicationQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withPHIDs(array($phid))
|
||||||
|
->executeOne();
|
||||||
|
if ($app) {
|
||||||
|
$pin = get_class($app);
|
||||||
|
} else {
|
||||||
|
// This likely means the user submitted an empty form
|
||||||
|
// which will cause nothing to happen.
|
||||||
|
$pin = '';
|
||||||
|
}
|
||||||
if (isset($options[$pin]) && !in_array($pin, $pinned)) {
|
if (isset($options[$pin]) && !in_array($pin, $pinned)) {
|
||||||
$pinned[] = $pin;
|
$pinned[] = $pin;
|
||||||
|
|
||||||
|
@ -78,18 +90,18 @@ final class PhabricatorHomePreferencesSettingsPanel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$options_control = id(new AphrontFormSelectControl())
|
$options_control = id(new AphrontFormTokenizerControl())
|
||||||
->setName('pin')
|
->setName('pin')
|
||||||
->setLabel(pht('Application'))
|
->setLabel(pht('Application'))
|
||||||
->setOptions($options)
|
->setDatasource(new PhabricatorApplicationDatasource())
|
||||||
->setDisabledOptions(array_keys($app_list));
|
->setLimit(1);
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->addHiddenInput('add', 'true')
|
->addHiddenInput('add', 'true')
|
||||||
->appendRemarkupInstructions(
|
->appendRemarkupInstructions(
|
||||||
pht('Choose an application to pin to your home page.'))
|
pht('Choose an application to pin to your home page.'))
|
||||||
->appendChild($options_control);
|
->appendControl($options_control);
|
||||||
|
|
||||||
return $this->newDialog()
|
return $this->newDialog()
|
||||||
->setWidth(AphrontDialogView::WIDTH_FORM)
|
->setWidth(AphrontDialogView::WIDTH_FORM)
|
||||||
|
|
Loading…
Reference in a new issue