Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14357203
D13162.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D13162.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1144,9 +1144,11 @@
'NuanceSourceDefinition' => 'applications/nuance/source/NuanceSourceDefinition.php',
'NuanceSourceEditController' => 'applications/nuance/controller/NuanceSourceEditController.php',
'NuanceSourceEditor' => 'applications/nuance/editor/NuanceSourceEditor.php',
+ 'NuanceSourceListController' => 'applications/nuance/controller/NuanceSourceListController.php',
'NuanceSourceManageCapability' => 'applications/nuance/capability/NuanceSourceManageCapability.php',
'NuanceSourcePHIDType' => 'applications/nuance/phid/NuanceSourcePHIDType.php',
'NuanceSourceQuery' => 'applications/nuance/query/NuanceSourceQuery.php',
+ 'NuanceSourceSearchEngine' => 'applications/nuance/query/NuanceSourceSearchEngine.php',
'NuanceSourceTransaction' => 'applications/nuance/storage/NuanceSourceTransaction.php',
'NuanceSourceTransactionComment' => 'applications/nuance/storage/NuanceSourceTransactionComment.php',
'NuanceSourceTransactionQuery' => 'applications/nuance/query/NuanceSourceTransactionQuery.php',
@@ -4489,9 +4491,11 @@
'NuanceSourceDefinition' => 'Phobject',
'NuanceSourceEditController' => 'NuanceController',
'NuanceSourceEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'NuanceSourceListController' => 'NuanceController',
'NuanceSourceManageCapability' => 'PhabricatorPolicyCapability',
'NuanceSourcePHIDType' => 'PhabricatorPHIDType',
'NuanceSourceQuery' => 'NuanceQuery',
+ 'NuanceSourceSearchEngine' => 'PhabricatorApplicationSearchEngine',
'NuanceSourceTransaction' => 'NuanceTransaction',
'NuanceSourceTransactionComment' => 'PhabricatorApplicationTransactionComment',
'NuanceSourceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
diff --git a/src/applications/nuance/application/PhabricatorNuanceApplication.php b/src/applications/nuance/application/PhabricatorNuanceApplication.php
--- a/src/applications/nuance/application/PhabricatorNuanceApplication.php
+++ b/src/applications/nuance/application/PhabricatorNuanceApplication.php
@@ -44,6 +44,7 @@
'new/' => 'NuanceItemEditController',
),
'source/' => array(
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'NuanceSourceListController',
'view/(?P<id>[1-9]\d*)/' => 'NuanceSourceViewController',
'edit/(?P<id>[1-9]\d*)/' => 'NuanceSourceEditController',
'new/(?P<type>[^/]+)/' => 'NuanceSourceEditController',
diff --git a/src/applications/nuance/controller/NuanceSourceListController.php b/src/applications/nuance/controller/NuanceSourceListController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/nuance/controller/NuanceSourceListController.php
@@ -0,0 +1,48 @@
+<?php
+
+final class NuanceSourceListController
+ extends NuanceController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $request = $this->getRequest();
+ $controller = id(new PhabricatorApplicationSearchController($request))
+ ->setQueryKey($request->getURIData('queryKey'))
+ ->setSearchEngine(new NuanceSourceSearchEngine())
+ ->setNavigation($this->buildSideNavView());
+
+ return $this->delegateToController($controller);
+ }
+
+ public function buildSideNavView($for_app = false) {
+ $user = $this->getRequest()->getUser();
+
+ $nav = new AphrontSideNavFilterView();
+ $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
+
+ id(new NuanceSourceSearchEngine())
+ ->setViewer($user)
+ ->addNavigationItems($nav->getMenu());
+
+ $nav->selectFilter(null);
+
+ return $nav;
+ }
+
+ protected function buildApplicationCrumbs() {
+ $crumbs = parent::buildApplicationCrumbs();
+
+ $can_create = $this->hasApplicationCapability(
+ NuanceSourceManageCapability::CAPABILITY);
+
+ $crumbs->addAction(
+ id(new PHUIListItemView())
+ ->setName(pht('Create Source'))
+ ->setHref($this->getApplicationURI('source/create/'))
+ ->setIcon('fa-plus-square')
+ ->setDisabled(!$can_create)
+ ->setWorkflow(!$can_create));
+
+ return $crumbs;
+ }
+
+}
diff --git a/src/applications/nuance/query/NuanceSourceSearchEngine.php b/src/applications/nuance/query/NuanceSourceSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/nuance/query/NuanceSourceSearchEngine.php
@@ -0,0 +1,78 @@
+<?php
+
+final class NuanceSourceSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ public function getApplicationClassName() {
+ return 'PhabricatorNuanceApplication';
+ }
+
+ public function getResultTypeDescription() {
+ return pht('Nuance Sources');
+ }
+
+ public function buildSavedQueryFromRequest(AphrontRequest $request) {
+ $saved = new PhabricatorSavedQuery();
+
+ return $saved;
+ }
+
+ public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
+ $query = id(new NuanceSourceQuery());
+
+ return $query;
+ }
+
+ public function buildSearchForm(
+ AphrontFormView $form,
+ PhabricatorSavedQuery $saved_query) {}
+
+ protected function getURI($path) {
+ return '/nuance/source/'.$path;
+ }
+
+ protected function getBuiltinQueryNames() {
+ $names = array(
+ 'all' => pht('All Sources'),
+ );
+
+ return $names;
+ }
+
+ public function buildSavedQueryFromBuiltin($query_key) {
+ $query = $this->newSavedQuery();
+ $query->setQueryKey($query_key);
+
+ switch ($query_key) {
+ case 'all':
+ return $query;
+ }
+
+ return parent::buildSavedQueryFromBuiltin($query_key);
+ }
+
+ protected function renderResultList(
+ array $sources,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+ assert_instances_of($sources, 'NuanceSource');
+
+ $viewer = $this->requireViewer();
+
+ $list = new PHUIObjectItemListView();
+ $list->setUser($viewer);
+ foreach ($sources as $source) {
+ $item = id(new PHUIObjectItemView())
+ ->setObjectName(pht('Source %d', $source->getID()))
+ ->setHeader($source->getName())
+ ->setHref($source->getURI());
+
+ $item->addIcon('none', $source->getType());
+
+ $list->addItem($item);
+ }
+
+ return $list;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 3:16 AM (18 h, 11 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6912626
Default Alt Text
D13162.diff (6 KB)
Attached To
Mode
D13162: Add a list view for Nuance sources
Attached
Detach File
Event Timeline
Log In to Comment