1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-22 20:51:10 +01:00

Allow searching Dashboards by Editable

Summary: Ref T10390. I find myself wanting to find dashboards I can edit, even if I am not the author. I think this is useful for larger installs with multiple admins. Also make disabled Dashboards more grey in UI results.

Test Plan: Log in a test user, create a dashboard with I cannot edit. Log into my account, search for editable dashboards and only see mine. Set dashboard to all users, search under test account and see editable dashboards.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10390

Differential Revision: https://secure.phabricator.com/D17524
This commit is contained in:
Chad Little 2017-03-21 09:25:05 -07:00
parent 1182bbcae7
commit 7d4c0f002f
2 changed files with 26 additions and 1 deletions

View file

@ -7,6 +7,7 @@ final class PhabricatorDashboardQuery
private $phids; private $phids;
private $statuses; private $statuses;
private $authorPHIDs; private $authorPHIDs;
private $canEdit;
private $needPanels; private $needPanels;
private $needProjects; private $needProjects;
@ -41,6 +42,11 @@ final class PhabricatorDashboardQuery
return $this; return $this;
} }
public function withCanEdit($can_edit) {
$this->canEdit = $can_edit;
return $this;
}
public function withNameNgrams($ngrams) { public function withNameNgrams($ngrams) {
return $this->withNgramsConstraint( return $this->withNgramsConstraint(
id(new PhabricatorDashboardNgrams()), id(new PhabricatorDashboardNgrams()),
@ -59,6 +65,15 @@ final class PhabricatorDashboardQuery
$phids = mpull($dashboards, 'getPHID'); $phids = mpull($dashboards, 'getPHID');
if ($this->canEdit) {
$dashboards = id(new PhabricatorPolicyFilter())
->setViewer($this->getViewer())
->requireCapabilities(array(
PhabricatorPolicyCapability::CAN_EDIT,
))
->apply($dashboards);
}
if ($this->needPanels) { if ($this->needPanels) {
$edge_query = id(new PhabricatorEdgeQuery()) $edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($phids) ->withSourcePHIDs($phids)

View file

@ -34,6 +34,10 @@ final class PhabricatorDashboardSearchEngine
->setKey('statuses') ->setKey('statuses')
->setLabel(pht('Status')) ->setLabel(pht('Status'))
->setOptions(PhabricatorDashboard::getStatusNameMap()), ->setOptions(PhabricatorDashboard::getStatusNameMap()),
id(new PhabricatorSearchCheckboxesField())
->setKey('editable')
->setLabel(pht('Editable'))
->setOptions(array('editable' => null)),
); );
} }
@ -94,6 +98,10 @@ final class PhabricatorDashboardSearchEngine
$query->withNameNgrams($map['name']); $query->withNameNgrams($map['name']);
} }
if ($map['editable'] !== null) {
$query->withCanEdit($map['editable']);
}
return $query; return $query;
} }
@ -126,8 +134,10 @@ final class PhabricatorDashboardSearchEngine
->setHref($this->getApplicationURI("view/{$id}/")) ->setHref($this->getApplicationURI("view/{$id}/"))
->setObject($dashboard); ->setObject($dashboard);
$bg_color = 'bg-dark';
if ($dashboard->isArchived()) { if ($dashboard->isArchived()) {
$item->setDisabled(true); $item->setDisabled(true);
$bg_color = 'bg-grey';
} }
$panels = $dashboard->getPanels(); $panels = $dashboard->getPanels();
@ -142,7 +152,7 @@ final class PhabricatorDashboardSearchEngine
$icon = id(new PHUIIconView()) $icon = id(new PHUIIconView())
->setIcon($dashboard->getIcon()) ->setIcon($dashboard->getIcon())
->setBackground('bg-dark'); ->setBackground($bg_color);
$item->setImageIcon($icon); $item->setImageIcon($icon);
$item->setEpoch($dashboard->getDateModified()); $item->setEpoch($dashboard->getDateModified());