Add initial skeleton for Dashboard application
Summary:
Ref T3583. General idea here is:
- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.
My plan is pretty much:
- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.
This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.
IMPORTANT: We need an icon bwahahahahaha
Test Plan:
omg si purrfect
{F106367}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3583
Differential Revision: https://secure.phabricator.com/D8109
2014-01-30 20:43:24 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorDashboardSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
2014-06-12 22:22:20 +02:00
|
|
|
public function getResultTypeDescription() {
|
|
|
|
return pht('Dashboards');
|
|
|
|
}
|
|
|
|
|
2015-02-05 00:47:48 +01:00
|
|
|
public function getApplicationClassName() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return 'PhabricatorDashboardApplication';
|
2014-05-08 18:31:33 +02:00
|
|
|
}
|
|
|
|
|
2015-07-21 21:01:19 +02:00
|
|
|
public function newQuery() {
|
|
|
|
return id(new PhabricatorDashboardQuery())
|
2017-02-12 04:47:21 +01:00
|
|
|
->needPanels(true);
|
Add initial skeleton for Dashboard application
Summary:
Ref T3583. General idea here is:
- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.
My plan is pretty much:
- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.
This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.
IMPORTANT: We need an icon bwahahahahaha
Test Plan:
omg si purrfect
{F106367}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3583
Differential Revision: https://secure.phabricator.com/D8109
2014-01-30 20:43:24 +01:00
|
|
|
}
|
|
|
|
|
2017-02-22 18:25:36 +01:00
|
|
|
public function canUseInPanelContext() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-21 21:01:19 +02:00
|
|
|
protected function buildCustomSearchFields() {
|
2015-07-23 23:22:56 +02:00
|
|
|
return array(
|
2016-12-16 21:08:43 +01:00
|
|
|
id(new PhabricatorSearchTextField())
|
|
|
|
->setLabel(pht('Name Contains'))
|
|
|
|
->setKey('name')
|
|
|
|
->setDescription(pht('Search for dashboards by name substring.')),
|
2016-12-13 00:15:05 +01:00
|
|
|
id(new PhabricatorSearchDatasourceField())
|
|
|
|
->setLabel(pht('Authored By'))
|
|
|
|
->setKey('authorPHIDs')
|
|
|
|
->setDatasource(new PhabricatorPeopleUserFunctionDatasource()),
|
2015-07-23 23:22:56 +02:00
|
|
|
id(new PhabricatorSearchCheckboxesField())
|
|
|
|
->setKey('statuses')
|
|
|
|
->setLabel(pht('Status'))
|
|
|
|
->setOptions(PhabricatorDashboard::getStatusNameMap()),
|
2017-03-21 17:25:05 +01:00
|
|
|
id(new PhabricatorSearchCheckboxesField())
|
|
|
|
->setKey('editable')
|
|
|
|
->setLabel(pht('Editable'))
|
|
|
|
->setOptions(array('editable' => null)),
|
2015-07-23 23:22:56 +02:00
|
|
|
);
|
Add initial skeleton for Dashboard application
Summary:
Ref T3583. General idea here is:
- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.
My plan is pretty much:
- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.
This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.
IMPORTANT: We need an icon bwahahahahaha
Test Plan:
omg si purrfect
{F106367}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3583
Differential Revision: https://secure.phabricator.com/D8109
2014-01-30 20:43:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
return '/dashboard/'.$path;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:34:51 +01:00
|
|
|
protected function getBuiltinQueryNames() {
|
2016-12-13 00:15:05 +01:00
|
|
|
$names = array();
|
|
|
|
|
|
|
|
if ($this->requireViewer()->isLoggedIn()) {
|
|
|
|
$names['authored'] = pht('Authored');
|
|
|
|
}
|
|
|
|
|
|
|
|
$names['open'] = pht('Active Dashboards');
|
|
|
|
$names['all'] = pht('All Dashboards');
|
|
|
|
|
|
|
|
return $names;
|
Add initial skeleton for Dashboard application
Summary:
Ref T3583. General idea here is:
- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.
My plan is pretty much:
- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.
This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.
IMPORTANT: We need an icon bwahahahahaha
Test Plan:
omg si purrfect
{F106367}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3583
Differential Revision: https://secure.phabricator.com/D8109
2014-01-30 20:43:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
$query->setQueryKey($query_key);
|
2016-12-13 00:15:05 +01:00
|
|
|
$viewer = $this->requireViewer();
|
Add initial skeleton for Dashboard application
Summary:
Ref T3583. General idea here is:
- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.
My plan is pretty much:
- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.
This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.
IMPORTANT: We need an icon bwahahahahaha
Test Plan:
omg si purrfect
{F106367}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3583
Differential Revision: https://secure.phabricator.com/D8109
2014-01-30 20:43:24 +01:00
|
|
|
|
|
|
|
switch ($query_key) {
|
|
|
|
case 'all':
|
|
|
|
return $query;
|
2016-12-13 00:15:05 +01:00
|
|
|
case 'authored':
|
|
|
|
return $query->setParameter(
|
2016-12-13 18:51:25 +01:00
|
|
|
'authorPHIDs',
|
2016-12-13 00:15:05 +01:00
|
|
|
array(
|
|
|
|
$viewer->getPHID(),
|
|
|
|
));
|
2015-07-23 23:22:56 +02:00
|
|
|
case 'open':
|
|
|
|
return $query->setParameter(
|
|
|
|
'statuses',
|
|
|
|
array(
|
|
|
|
PhabricatorDashboard::STATUS_ACTIVE,
|
|
|
|
));
|
Add initial skeleton for Dashboard application
Summary:
Ref T3583. General idea here is:
- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.
My plan is pretty much:
- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.
This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.
IMPORTANT: We need an icon bwahahahahaha
Test Plan:
omg si purrfect
{F106367}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3583
Differential Revision: https://secure.phabricator.com/D8109
2014-01-30 20:43:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
}
|
|
|
|
|
2015-07-21 21:01:19 +02:00
|
|
|
protected function buildQueryFromParameters(array $map) {
|
|
|
|
$query = $this->newQuery();
|
2015-07-23 23:22:56 +02:00
|
|
|
|
|
|
|
if ($map['statuses']) {
|
|
|
|
$query->withStatuses($map['statuses']);
|
|
|
|
}
|
|
|
|
|
2016-12-13 00:15:05 +01:00
|
|
|
if ($map['authorPHIDs']) {
|
|
|
|
$query->withAuthorPHIDs($map['authorPHIDs']);
|
|
|
|
}
|
|
|
|
|
2016-12-16 21:08:43 +01:00
|
|
|
if ($map['name'] !== null) {
|
|
|
|
$query->withNameNgrams($map['name']);
|
|
|
|
}
|
|
|
|
|
2017-03-21 17:25:05 +01:00
|
|
|
if ($map['editable'] !== null) {
|
|
|
|
$query->withCanEdit($map['editable']);
|
|
|
|
}
|
|
|
|
|
2015-07-21 21:01:19 +02:00
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
2014-05-08 18:31:33 +02:00
|
|
|
protected function renderResultList(
|
|
|
|
array $dashboards,
|
|
|
|
PhabricatorSavedQuery $query,
|
|
|
|
array $handles) {
|
|
|
|
|
|
|
|
$viewer = $this->requireViewer();
|
2014-08-10 04:08:16 +02:00
|
|
|
|
2017-02-12 04:47:21 +01:00
|
|
|
$phids = array();
|
2015-07-21 21:01:19 +02:00
|
|
|
foreach ($dashboards as $dashboard) {
|
2017-02-12 04:47:21 +01:00
|
|
|
$author_phid = $dashboard->getAuthorPHID();
|
|
|
|
if ($author_phid) {
|
|
|
|
$phids[] = $author_phid;
|
2015-07-21 21:01:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:47:21 +01:00
|
|
|
$handles = $viewer->loadHandles($phids);
|
2015-07-21 21:01:19 +02:00
|
|
|
|
2017-02-09 23:17:54 +01:00
|
|
|
$list = id(new PHUIObjectItemListView())
|
|
|
|
->setUser($viewer);
|
2014-08-07 23:31:02 +02:00
|
|
|
|
2017-02-12 04:47:21 +01:00
|
|
|
foreach ($dashboards as $dashboard) {
|
2014-05-08 18:31:33 +02:00
|
|
|
$id = $dashboard->getID();
|
|
|
|
|
|
|
|
$item = id(new PHUIObjectItemView())
|
2017-02-09 23:17:54 +01:00
|
|
|
->setUser($viewer)
|
2014-05-08 18:31:33 +02:00
|
|
|
->setHeader($dashboard->getName())
|
|
|
|
->setHref($this->getApplicationURI("view/{$id}/"))
|
|
|
|
->setObject($dashboard);
|
|
|
|
|
2017-03-21 17:25:05 +01:00
|
|
|
$bg_color = 'bg-dark';
|
2015-12-09 21:17:03 +01:00
|
|
|
if ($dashboard->isArchived()) {
|
2015-07-23 23:22:56 +02:00
|
|
|
$item->setDisabled(true);
|
2017-03-21 17:25:05 +01:00
|
|
|
$bg_color = 'bg-grey';
|
2015-07-23 23:22:56 +02:00
|
|
|
}
|
|
|
|
|
2017-02-12 04:47:21 +01:00
|
|
|
$panels = $dashboard->getPanels();
|
|
|
|
foreach ($panels as $panel) {
|
|
|
|
$item->addAttribute($panel->getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($panels)) {
|
|
|
|
$empty = phutil_tag('em', array(), pht('No panels.'));
|
|
|
|
$item->addAttribute($empty);
|
|
|
|
}
|
|
|
|
|
2017-02-09 23:17:54 +01:00
|
|
|
$icon = id(new PHUIIconView())
|
|
|
|
->setIcon($dashboard->getIcon())
|
2017-03-21 17:25:05 +01:00
|
|
|
->setBackground($bg_color);
|
2017-02-09 23:17:54 +01:00
|
|
|
$item->setImageIcon($icon);
|
|
|
|
$item->setEpoch($dashboard->getDateModified());
|
2015-07-23 23:22:56 +02:00
|
|
|
|
2017-02-12 04:47:21 +01:00
|
|
|
$author_phid = $dashboard->getAuthorPHID();
|
|
|
|
$author_name = $handles[$author_phid]->renderLink();
|
|
|
|
$item->addByline(pht('Author: %s', $author_name));
|
|
|
|
|
2014-05-08 18:31:33 +02:00
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
2015-06-19 12:46:20 +02:00
|
|
|
$result = new PhabricatorApplicationSearchResultView();
|
|
|
|
$result->setObjectList($list);
|
|
|
|
$result->setNoDataString(pht('No dashboards found.'));
|
|
|
|
|
|
|
|
return $result;
|
2014-05-08 18:31:33 +02:00
|
|
|
}
|
|
|
|
|
2015-12-21 20:15:44 +01:00
|
|
|
protected function getNewUserBody() {
|
|
|
|
$create_button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText(pht('Create a Dashboard'))
|
|
|
|
->setHref('/dashboard/create/')
|
|
|
|
->setColor(PHUIButtonView::GREEN);
|
|
|
|
|
2016-01-28 17:40:22 +01:00
|
|
|
$icon = $this->getApplication()->getIcon();
|
2015-12-21 20:15:44 +01:00
|
|
|
$app_name = $this->getApplication()->getName();
|
|
|
|
$view = id(new PHUIBigInfoView())
|
|
|
|
->setIcon($icon)
|
|
|
|
->setTitle(pht('Welcome to %s', $app_name))
|
|
|
|
->setDescription(
|
|
|
|
pht('Customize your homepage with different panels and '.
|
|
|
|
'search queries.'))
|
|
|
|
->addAction($create_button);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
Add initial skeleton for Dashboard application
Summary:
Ref T3583. General idea here is:
- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.
My plan is pretty much:
- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.
This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.
IMPORTANT: We need an icon bwahahahahaha
Test Plan:
omg si purrfect
{F106367}
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3583
Differential Revision: https://secure.phabricator.com/D8109
2014-01-30 20:43:24 +01:00
|
|
|
}
|