1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Combine the "View", "Arrange", and "Manage" modes of Dashboards into a single mode

Summary:
Depends on D20361. Ref T13272. Currently, Dashboards have three separate modes: view, arrange, manage.

With the advent of Portals, I think we can simplify this, and make the dashboard view a combined view/edit/manage page. To view it in a cleaner standalone way, you can add it to a portal/home/project. I'll also improve the "Install" workflow.

Test Plan:
Viewed a dashboard page, clicked through all the actions, grepped for affected URIs.

{F6327027}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13272

Differential Revision: https://secure.phabricator.com/D20362
This commit is contained in:
epriestley 2019-04-01 08:34:34 -07:00
parent 7e1743a959
commit eea093bec8
13 changed files with 43 additions and 270 deletions

View file

@ -2905,21 +2905,19 @@ phutil_register_library_map(array(
'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php',
'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php',
'PhabricatorDashboardApplication' => 'applications/dashboard/application/PhabricatorDashboardApplication.php',
'PhabricatorDashboardArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardArchiveController.php',
'PhabricatorDashboardArrangeController' => 'applications/dashboard/controller/PhabricatorDashboardArrangeController.php',
'PhabricatorDashboardArchiveController' => 'applications/dashboard/controller/dashboard/PhabricatorDashboardArchiveController.php',
'PhabricatorDashboardConsoleController' => 'applications/dashboard/controller/PhabricatorDashboardConsoleController.php',
'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php',
'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php',
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php',
'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php',
'PhabricatorDashboardDatasource' => 'applications/dashboard/typeahead/PhabricatorDashboardDatasource.php',
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php',
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/dashboard/PhabricatorDashboardEditController.php',
'PhabricatorDashboardIconSet' => 'applications/dashboard/icon/PhabricatorDashboardIconSet.php',
'PhabricatorDashboardInstall' => 'applications/dashboard/storage/PhabricatorDashboardInstall.php',
'PhabricatorDashboardInstallController' => 'applications/dashboard/controller/PhabricatorDashboardInstallController.php',
'PhabricatorDashboardInstallController' => 'applications/dashboard/controller/dashboard/PhabricatorDashboardInstallController.php',
'PhabricatorDashboardLayoutConfig' => 'applications/dashboard/layoutconfig/PhabricatorDashboardLayoutConfig.php',
'PhabricatorDashboardListController' => 'applications/dashboard/controller/PhabricatorDashboardListController.php',
'PhabricatorDashboardManageController' => 'applications/dashboard/controller/PhabricatorDashboardManageController.php',
'PhabricatorDashboardMovePanelController' => 'applications/dashboard/controller/PhabricatorDashboardMovePanelController.php',
'PhabricatorDashboardNgrams' => 'applications/dashboard/storage/PhabricatorDashboardNgrams.php',
'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php',
@ -2981,7 +2979,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardTransaction' => 'applications/dashboard/storage/PhabricatorDashboardTransaction.php',
'PhabricatorDashboardTransactionEditor' => 'applications/dashboard/editor/PhabricatorDashboardTransactionEditor.php',
'PhabricatorDashboardTransactionQuery' => 'applications/dashboard/query/PhabricatorDashboardTransactionQuery.php',
'PhabricatorDashboardViewController' => 'applications/dashboard/controller/PhabricatorDashboardViewController.php',
'PhabricatorDashboardViewController' => 'applications/dashboard/controller/dashboard/PhabricatorDashboardViewController.php',
'PhabricatorDataCacheSpec' => 'applications/cache/spec/PhabricatorDataCacheSpec.php',
'PhabricatorDataNotAttachedException' => 'infrastructure/storage/lisk/PhabricatorDataNotAttachedException.php',
'PhabricatorDatabaseRef' => 'infrastructure/cluster/PhabricatorDatabaseRef.php',
@ -8868,7 +8866,6 @@ phutil_register_library_map(array(
'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController',
'PhabricatorDashboardApplication' => 'PhabricatorApplication',
'PhabricatorDashboardArchiveController' => 'PhabricatorDashboardController',
'PhabricatorDashboardArrangeController' => 'PhabricatorDashboardProfileController',
'PhabricatorDashboardConsoleController' => 'PhabricatorDashboardController',
'PhabricatorDashboardController' => 'PhabricatorController',
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
@ -8881,7 +8878,6 @@ phutil_register_library_map(array(
'PhabricatorDashboardInstallController' => 'PhabricatorDashboardController',
'PhabricatorDashboardLayoutConfig' => 'Phobject',
'PhabricatorDashboardListController' => 'PhabricatorDashboardController',
'PhabricatorDashboardManageController' => 'PhabricatorDashboardProfileController',
'PhabricatorDashboardMovePanelController' => 'PhabricatorDashboardController',
'PhabricatorDashboardNgrams' => 'PhabricatorSearchNgrams',
'PhabricatorDashboardPanel' => array(

View file

@ -41,8 +41,6 @@ final class PhabricatorDashboardApplication extends PhabricatorApplication {
=> 'PhabricatorDashboardListController',
'view/(?P<id>\d+)/' => 'PhabricatorDashboardViewController',
'archive/(?P<id>\d+)/' => 'PhabricatorDashboardArchiveController',
'manage/(?P<id>\d+)/' => 'PhabricatorDashboardManageController',
'arrange/(?P<id>\d+)/' => 'PhabricatorDashboardArrangeController',
'create/' => 'PhabricatorDashboardEditController',
'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardEditController',
'install/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardInstallController',

View file

@ -1,79 +0,0 @@
<?php
final class PhabricatorDashboardArrangeController
extends PhabricatorDashboardProfileController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($id))
->needPanels(true)
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$this->setDashboard($dashboard);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$dashboard,
PhabricatorPolicyCapability::CAN_EDIT);
$title = $dashboard->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Arrange'));
$header = $this->buildHeaderView();
$info_view = null;
if (!$can_edit) {
$no_edit = pht(
'You do not have permission to edit this dashboard.');
$info_view = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setErrors(array($no_edit));
}
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
->setViewer($viewer)
->setDashboard($dashboard)
->setArrangeMode($can_edit)
->renderDashboard();
$dashboard_box = id(new PHUIBoxView())
->addClass('dashboard-preview-box')
->appendChild($rendered_dashboard);
$install_button = id(new PHUIButtonView())
->setTag('a')
->setText('Install Dashboard')
->setIcon('fa-plus')
->setWorkflow(true)
->setHref($this->getApplicationURI("/install/{$id}/"));
$header->addActionLink($install_button);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$info_view,
$dashboard_box,
));
$navigation = $this->buildSideNavView('arrange');
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setNavigation($navigation)
->appendChild($view);
}
}

View file

@ -14,10 +14,6 @@ abstract class PhabricatorDashboardProfileController
return $this->dashboard;
}
public function buildApplicationMenu() {
return $this->buildSideNavView()->getMenu();
}
protected function buildHeaderView() {
$viewer = $this->getViewer();
$dashboard = $this->getDashboard();
@ -49,50 +45,10 @@ abstract class PhabricatorDashboardProfileController
$dashboard = $this->getDashboard();
if ($dashboard) {
$id = $dashboard->getID();
$dashboard_uri = $this->getApplicationURI("/view/{$id}/");
$crumbs->addTextCrumb($dashboard->getName(), $dashboard_uri);
$crumbs->addTextCrumb($dashboard->getName(), $dashboard->getURI());
}
return $crumbs;
}
protected function buildSideNavView($filter = null) {
$viewer = $this->getViewer();
$dashboard = $this->getDashboard();
$id = $dashboard->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$dashboard,
PhabricatorPolicyCapability::CAN_EDIT);
$nav = id(new AphrontSideNavFilterView())
->setBaseURI(new PhutilURI($this->getApplicationURI()));
$nav->addLabel(pht('Dashboard'));
$nav->addFilter(
'view',
pht('View Dashboard'),
$this->getApplicationURI("/view/{$id}/"),
'fa-dashboard');
$nav->addFilter(
'arrange',
pht('Arrange Panels'),
$this->getApplicationURI("/arrange/{$id}/"),
'fa-columns');
$nav->addFilter(
'manage',
pht('Manage Dashboard'),
$this->getApplicationURI("/manage/{$id}/"),
'fa-gears');
$nav->selectFilter($filter);
return $nav;
}
}

View file

@ -75,7 +75,7 @@ final class PhabricatorDashboardQueryPanelInstallController
}
if (!$errors) {
$redirect_uri = "/dashboard/arrange/{$v_dashboard}/";
$redirect_uri = "/dashboard/view/{$v_dashboard}/";
$panel_type = id(new PhabricatorDashboardQueryPanelType())
->getPanelTypeKey();

View file

@ -1,68 +0,0 @@
<?php
final class PhabricatorDashboardViewController
extends PhabricatorDashboardProfileController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($id))
->needPanels(true)
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$this->setDashboard($dashboard);
$dashboard_uri = $this->getApplicationURI("view/{$id}/");
$title = $dashboard->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('View'));
if ($dashboard->getPanelPHIDs()) {
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
->setViewer($viewer)
->setDashboard($dashboard)
->renderDashboard();
$content = id(new PHUIBoxView())
->addClass('dashboard-preview-box')
->appendChild($rendered_dashboard);
} else {
$content = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->appendChild(pht('This dashboard has no panels yet.'));
}
$navigation = $this->buildSideNavView('view');
$header = $this->buildHeaderView();
$install_button = id(new PHUIButtonView())
->setTag('a')
->setText('Install Dashboard')
->setIcon('fa-plus')
->setColor(PHUIButtonView::GREEN)
->setWorkflow(true)
->setHref($this->getApplicationURI("/install/{$id}/"));
$header->addActionLink($install_button);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$content,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setNavigation($navigation)
->appendChild($view);
}
}

View file

@ -20,7 +20,7 @@ final class PhabricatorDashboardArchiveController
return new Aphront404Response();
}
$view_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/');
$view_uri = $dashboard->getURI();
if ($request->isFormPost()) {
if ($dashboard->isArchived()) {

View file

@ -55,8 +55,7 @@ final class PhabricatorDashboardEditController
$crumbs->addTextCrumb(pht('Create Dashboard'));
} else {
$id = $dashboard->getID();
$cancel_uri = $this->getApplicationURI('manage/'.$id.'/');
$cancel_uri = $dashboard->getURI();
$title = pht('Edit Dashboard: %s', $dashboard->getName());
$header_icon = 'fa-pencil';
@ -117,9 +116,7 @@ final class PhabricatorDashboardEditController
->setContentSourceFromRequest($request)
->applyTransactions($dashboard, $xactions);
$uri = $this->getApplicationURI('arrange/'.$dashboard->getID().'/');
return id(new AphrontRedirectResponse())->setURI($uri);
return id(new AphrontRedirectResponse())->setURI($dashboard->getURI());
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
@ -346,10 +343,8 @@ final class PhabricatorDashboardEditController
->setContentSourceFromRequest($request)
->applyTransactions($dashboard, $xactions);
$manage_uri = $this->getApplicationURI('arrange/'.$dashboard->getID().'/');
return id(new AphrontRedirectResponse())
->setURI($manage_uri);
->setURI($dashboard->getURI());
}
private function newPanel(

View file

@ -15,8 +15,7 @@ final class PhabricatorDashboardInstallController
return new Aphront404Response();
}
$cancel_uri = $this->getApplicationURI(
'view/'.$dashboard->getID().'/');
$cancel_uri = $dashboard->getURI();
$home_app = new PhabricatorHomeApplication();

View file

@ -1,6 +1,6 @@
<?php
final class PhabricatorDashboardManageController
final class PhabricatorDashboardViewController
extends PhabricatorDashboardProfileController {
public function shouldAllowPublic() {
@ -11,10 +11,6 @@ final class PhabricatorDashboardManageController
$viewer = $request->getViewer();
$id = $request->getURIData('id');
// TODO: This UI should drop a lot of capabilities if the user can't
// edit the dashboard, but we should still let them in for "Install" and
// "View History".
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($id))
@ -31,44 +27,38 @@ final class PhabricatorDashboardManageController
PhabricatorPolicyCapability::CAN_EDIT);
$title = $dashboard->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Manage'));
$header = $this->buildHeaderView();
$curtain = $this->buildCurtainView($dashboard);
$properties = $this->buildPropertyView($dashboard);
$timeline = $this->buildTransactionTimeline(
$dashboard,
new PhabricatorDashboardTransactionQuery());
$timeline->setShouldTerminate(true);
$info_view = null;
if (!$can_edit) {
$no_edit = pht(
'You do not have permission to edit this dashboard.');
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
->setViewer($viewer)
->setDashboard($dashboard)
->setArrangeMode($can_edit)
->renderDashboard();
$info_view = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setErrors(array($no_edit));
}
$dashboard_box = id(new PHUIBoxView())
->addClass('dashboard-preview-box')
->appendChild($rendered_dashboard);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$info_view,
$properties,
$timeline,
));
$navigation = $this->buildSideNavView('manage');
->setMainColumn(
array(
$dashboard_box,
$timeline,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setNavigation($navigation)
->appendChild($view);
}
@ -91,6 +81,13 @@ final class PhabricatorDashboardManageController
->setHref($this->getApplicationURI("edit/{$id}/"))
->setDisabled(!$can_edit));
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Install Dashboard'))
->setIcon('fa-wrench')
->setHref($this->getApplicationURI("/install/{$id}/"))
->setWorkflow(true));
if ($dashboard->isArchived()) {
$curtain->addAction(
id(new PhabricatorActionView())
@ -112,28 +109,5 @@ final class PhabricatorDashboardManageController
return $curtain;
}
private function buildPropertyView(PhabricatorDashboard $dashboard) {
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView())
->setUser($viewer);
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
$viewer,
$dashboard);
$properties->addProperty(
pht('Editable By'),
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$properties->addProperty(
pht('Panels'),
$viewer->renderHandleList($dashboard->getPanelPHIDs()));
return id(new PHUIObjectBoxView())
->setHeaderText(pht('Details'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->addPropertyList($properties);
}
}

View file

@ -123,15 +123,14 @@ final class PhabricatorDashboardSearchEngine
$handles = $viewer->loadHandles($phids);
$list = id(new PHUIObjectItemListView())
->setUser($viewer);
->setViewer($viewer);
foreach ($dashboards as $dashboard) {
$id = $dashboard->getID();
$item = id(new PHUIObjectItemView())
->setUser($viewer)
->setViewer($viewer)
->setObjectName($dashboard->getObjectName())
->setHeader($dashboard->getName())
->setHref($this->getApplicationURI("view/{$id}/"))
->setHref($dashboard->getURI())
->setObject($dashboard);
$bg_color = 'bg-dark';

View file

@ -118,10 +118,13 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
return ($this->getStatus() == self::STATUS_ARCHIVED);
}
public function getViewURI() {
return '/dashboard/view/'.$this->getID().'/';
public function getURI() {
return urisprintf('/dashboard/view/%d/', $this->getID());
}
public function getObjectName() {
return pht('Dashboard %d', $this->getID());
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -153,7 +153,7 @@ final class PhabricatorDashboardProfileMenuItem
$icon = $dashboard->getIcon();
$name = $this->getDisplayName($config);
$is_disabled = false;
$action_uri = '/dashboard/arrange/'.$dashboard->getID().'/';
$action_uri = $dashboard->getURI();
}
} else {
$icon = 'fa-ban';