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:
parent
1182bbcae7
commit
7d4c0f002f
2 changed files with 26 additions and 1 deletions
|
@ -7,6 +7,7 @@ final class PhabricatorDashboardQuery
|
|||
private $phids;
|
||||
private $statuses;
|
||||
private $authorPHIDs;
|
||||
private $canEdit;
|
||||
|
||||
private $needPanels;
|
||||
private $needProjects;
|
||||
|
@ -41,6 +42,11 @@ final class PhabricatorDashboardQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withCanEdit($can_edit) {
|
||||
$this->canEdit = $can_edit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withNameNgrams($ngrams) {
|
||||
return $this->withNgramsConstraint(
|
||||
id(new PhabricatorDashboardNgrams()),
|
||||
|
@ -59,6 +65,15 @@ final class PhabricatorDashboardQuery
|
|||
|
||||
$phids = mpull($dashboards, 'getPHID');
|
||||
|
||||
if ($this->canEdit) {
|
||||
$dashboards = id(new PhabricatorPolicyFilter())
|
||||
->setViewer($this->getViewer())
|
||||
->requireCapabilities(array(
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->apply($dashboards);
|
||||
}
|
||||
|
||||
if ($this->needPanels) {
|
||||
$edge_query = id(new PhabricatorEdgeQuery())
|
||||
->withSourcePHIDs($phids)
|
||||
|
|
|
@ -34,6 +34,10 @@ final class PhabricatorDashboardSearchEngine
|
|||
->setKey('statuses')
|
||||
->setLabel(pht('Status'))
|
||||
->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']);
|
||||
}
|
||||
|
||||
if ($map['editable'] !== null) {
|
||||
$query->withCanEdit($map['editable']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -126,8 +134,10 @@ final class PhabricatorDashboardSearchEngine
|
|||
->setHref($this->getApplicationURI("view/{$id}/"))
|
||||
->setObject($dashboard);
|
||||
|
||||
$bg_color = 'bg-dark';
|
||||
if ($dashboard->isArchived()) {
|
||||
$item->setDisabled(true);
|
||||
$bg_color = 'bg-grey';
|
||||
}
|
||||
|
||||
$panels = $dashboard->getPanels();
|
||||
|
@ -142,7 +152,7 @@ final class PhabricatorDashboardSearchEngine
|
|||
|
||||
$icon = id(new PHUIIconView())
|
||||
->setIcon($dashboard->getIcon())
|
||||
->setBackground('bg-dark');
|
||||
->setBackground($bg_color);
|
||||
$item->setImageIcon($icon);
|
||||
$item->setEpoch($dashboard->getDateModified());
|
||||
|
||||
|
|
Loading…
Reference in a new issue