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())
|
|
|
|
->needProjects(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
|
|
|
}
|
|
|
|
|
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()),
|
|
|
|
);
|
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']);
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
|
2014-08-07 23:31:02 +02:00
|
|
|
$dashboards = mpull($dashboards, null, 'getPHID');
|
2014-05-08 18:31:33 +02:00
|
|
|
$viewer = $this->requireViewer();
|
2014-08-10 04:08:16 +02:00
|
|
|
|
|
|
|
if ($dashboards) {
|
|
|
|
$installs = id(new PhabricatorDashboardInstall())
|
|
|
|
->loadAllWhere(
|
|
|
|
'objectPHID IN (%Ls) AND dashboardPHID IN (%Ls)',
|
2014-10-07 15:01:04 +02:00
|
|
|
array(
|
|
|
|
PhabricatorHomeApplication::DASHBOARD_DEFAULT,
|
|
|
|
$viewer->getPHID(),
|
|
|
|
),
|
2014-08-10 04:08:16 +02:00
|
|
|
array_keys($dashboards));
|
|
|
|
$installs = mpull($installs, null, 'getDashboardPHID');
|
|
|
|
} else {
|
|
|
|
$installs = array();
|
|
|
|
}
|
2014-05-08 18:31:33 +02:00
|
|
|
|
2015-07-21 21:01:19 +02:00
|
|
|
$proj_phids = array();
|
|
|
|
foreach ($dashboards as $dashboard) {
|
|
|
|
foreach ($dashboard->getProjectPHIDs() as $project_phid) {
|
|
|
|
$proj_phids[] = $project_phid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$proj_handles = id(new PhabricatorHandleQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs($proj_phids)
|
|
|
|
->execute();
|
|
|
|
|
2014-05-08 18:31:33 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
$list->setUser($viewer);
|
2014-08-07 23:31:02 +02:00
|
|
|
$list->initBehavior('phabricator-tooltips', array());
|
|
|
|
$list->requireResource('aphront-tooltip-css');
|
|
|
|
|
|
|
|
foreach ($dashboards as $dashboard_phid => $dashboard) {
|
2014-05-08 18:31:33 +02:00
|
|
|
$id = $dashboard->getID();
|
|
|
|
|
|
|
|
$item = id(new PHUIObjectItemView())
|
|
|
|
->setObjectName(pht('Dashboard %d', $id))
|
|
|
|
->setHeader($dashboard->getName())
|
|
|
|
->setHref($this->getApplicationURI("view/{$id}/"))
|
|
|
|
->setObject($dashboard);
|
|
|
|
|
2014-08-07 23:31:02 +02:00
|
|
|
if (isset($installs[$dashboard_phid])) {
|
|
|
|
$install = $installs[$dashboard_phid];
|
|
|
|
if ($install->getObjectPHID() == $viewer->getPHID()) {
|
|
|
|
$attrs = array(
|
|
|
|
'tip' => pht(
|
2014-10-07 15:01:04 +02:00
|
|
|
'This dashboard is installed to your personal homepage.'),
|
|
|
|
);
|
2014-08-07 23:31:02 +02:00
|
|
|
$item->addIcon('fa-user', pht('Installed'), $attrs);
|
|
|
|
} else {
|
|
|
|
$attrs = array(
|
|
|
|
'tip' => pht(
|
2014-10-07 15:01:04 +02:00
|
|
|
'This dashboard is the default homepage for all users.'),
|
|
|
|
);
|
2014-08-07 23:31:02 +02:00
|
|
|
$item->addIcon('fa-globe', pht('Installed'), $attrs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 21:01:19 +02:00
|
|
|
$project_handles = array_select_keys(
|
|
|
|
$proj_handles,
|
|
|
|
$dashboard->getProjectPHIDs());
|
|
|
|
|
|
|
|
$item->addAttribute(
|
|
|
|
id(new PHUIHandleTagListView())
|
|
|
|
->setLimit(4)
|
|
|
|
->setNoDataString(pht('No Projects'))
|
|
|
|
->setSlim(true)
|
|
|
|
->setHandles($project_handles));
|
|
|
|
|
2015-12-09 21:17:03 +01:00
|
|
|
if ($dashboard->isArchived()) {
|
2015-07-23 23:22:56 +02:00
|
|
|
$item->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$dashboard,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$href_view = $this->getApplicationURI("manage/{$id}/");
|
|
|
|
$item->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setName(pht('Manage'))
|
|
|
|
->setIcon('fa-th')
|
|
|
|
->setHref($href_view));
|
|
|
|
|
|
|
|
$href_edit = $this->getApplicationURI("edit/{$id}/");
|
|
|
|
$item->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setName(pht('Edit'))
|
|
|
|
->setIcon('fa-pencil')
|
|
|
|
->setHref($href_edit)
|
|
|
|
->setDisabled(!$can_edit));
|
|
|
|
|
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
|
|
|
}
|