diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 65dc31d9da..8d30e65d5e 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1463,7 +1463,6 @@ phutil_register_library_map(array( 'PhabricatorDaemonTaskGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php', 'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php', 'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php', - 'PhabricatorDashboardArrangeController' => 'applications/dashboard/controller/PhabricatorDashboardArrangeController.php', 'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php', 'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php', 'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php', @@ -1471,6 +1470,7 @@ phutil_register_library_map(array( 'PhabricatorDashboardInstallController' => 'applications/dashboard/controller/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', 'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php', 'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php', @@ -4258,13 +4258,13 @@ phutil_register_library_map(array( 1 => 'PhabricatorPolicyInterface', ), 'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController', - 'PhabricatorDashboardArrangeController' => 'PhabricatorDashboardController', 'PhabricatorDashboardController' => 'PhabricatorController', 'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO', 'PhabricatorDashboardEditController' => 'PhabricatorDashboardController', 'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO', 'PhabricatorDashboardInstallController' => 'PhabricatorDashboardController', 'PhabricatorDashboardListController' => 'PhabricatorDashboardController', + 'PhabricatorDashboardManageController' => 'PhabricatorDashboardController', 'PhabricatorDashboardMovePanelController' => 'PhabricatorDashboardController', 'PhabricatorDashboardPHIDTypeDashboard' => 'PhabricatorPHIDType', 'PhabricatorDashboardPHIDTypePanel' => 'PhabricatorPHIDType', diff --git a/src/applications/dashboard/application/PhabricatorApplicationDashboard.php b/src/applications/dashboard/application/PhabricatorApplicationDashboard.php index f4989c7806..c453d9a4b3 100644 --- a/src/applications/dashboard/application/PhabricatorApplicationDashboard.php +++ b/src/applications/dashboard/application/PhabricatorApplicationDashboard.php @@ -21,7 +21,7 @@ final class PhabricatorApplicationDashboard extends PhabricatorApplication { '(?:query/(?P[^/]+)/)?' => 'PhabricatorDashboardListController', 'view/(?P\d+)/' => 'PhabricatorDashboardViewController', - 'arrange/(?P\d+)/' => 'PhabricatorDashboardArrangeController', + 'manage/(?P\d+)/' => 'PhabricatorDashboardManageController', 'create/' => 'PhabricatorDashboardEditController', 'edit/(?:(?P\d+)/)?' => 'PhabricatorDashboardEditController', 'install/(?P\d+)/' => 'PhabricatorDashboardInstallController', diff --git a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php index c6081c7702..44c0f3dc80 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php @@ -26,13 +26,8 @@ final class PhabricatorDashboardAddPanelController return new Aphront404Response(); } - if ($request->getStr('src', 'edit') == 'edit') { - $redirect_uri = $this->getApplicationURI( - 'view/'.$dashboard->getID().'/'); - } else { - $redirect_uri = $this->getApplicationURI( - 'arrange/'.$dashboard->getID().'/'); - } + $redirect_uri = $this->getApplicationURI( + 'manage/'.$dashboard->getID().'/'); $layout_config = $dashboard->getLayoutConfigObject(); $v_panel = $request->getStr('panel'); diff --git a/src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php b/src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php deleted file mode 100644 index fbbe9db239..0000000000 --- a/src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php +++ /dev/null @@ -1,54 +0,0 @@ -id = $data['id']; - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $dashboard = id(new PhabricatorDashboardQuery()) - ->setViewer($viewer) - ->withIDs(array($this->id)) - ->needPanels(true) - ->requireCapabilities( - array( - PhabricatorPolicyCapability::CAN_VIEW, - PhabricatorPolicyCapability::CAN_EDIT, - )) - ->executeOne(); - if (!$dashboard) { - return new Aphront404Response(); - } - - $title = $dashboard->getName(); - $crumbs = $this->buildApplicationCrumbs(); - $crumbs->addTextCrumb( - pht('Dashboard %d', $dashboard->getID()), - $this->getApplicationURI('view/'.$dashboard->getID().'/')); - $crumbs->addTextCrumb(pht('Arrange')); - - $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) - ->setViewer($viewer) - ->setDashboard($dashboard) - ->setArrangeMode(true) - ->renderDashboard(); - - return $this->buildApplicationPage( - array( - $crumbs, - $rendered_dashboard, - ), - array( - 'title' => $title, - 'device' => true, - )); - } - -} diff --git a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php index 46f7dda13d..e2dcd5f3da 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php @@ -46,7 +46,7 @@ final class PhabricatorDashboardEditController $crumbs->addTextCrumb('Create Dashboard'); } else { $id = $dashboard->getID(); - $cancel_uri = $this->getApplicationURI('view/'.$id.'/'); + $cancel_uri = $this->getApplicationURI('manage/'.$id.'/'); $title = pht('Edit Dashboard %d', $dashboard->getID()); $header = pht('Edit Dashboard "%s"', $dashboard->getName()); @@ -94,11 +94,8 @@ final class PhabricatorDashboardEditController ->setContentSourceFromRequest($request) ->applyTransactions($dashboard, $xactions); - if ($is_new) { - $uri = $this->getApplicationURI('arrange/'.$dashboard->getID().'/'); - } else { - $uri = $this->getApplicationURI('view/'.$dashboard->getID().'/'); - } + $uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/'); + return id(new AphrontRedirectResponse())->setURI($uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; diff --git a/src/applications/dashboard/controller/PhabricatorDashboardManageController.php b/src/applications/dashboard/controller/PhabricatorDashboardManageController.php new file mode 100644 index 0000000000..d82e8f78a1 --- /dev/null +++ b/src/applications/dashboard/controller/PhabricatorDashboardManageController.php @@ -0,0 +1,161 @@ +id = $data['id']; + } + + public function processRequest() { + $request = $this->getRequest(); + $viewer = $request->getUser(); + $id = $this->id; + $dashboard_uri = $this->getApplicationURI('view/'.$id.'/'); + + $dashboard = id(new PhabricatorDashboardQuery()) + ->setViewer($viewer) + ->withIDs(array($this->id)) + ->needPanels(true) + ->executeOne(); + if (!$dashboard) { + return new Aphront404Response(); + } + + $title = $dashboard->getName(); + + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addTextCrumb( + pht('Dashboard %d', $dashboard->getID()), + $dashboard_uri); + $crumbs->addTextCrumb(pht('Manage')); + + $header = $this->buildHeaderView($dashboard); + $actions = $this->buildActionView($dashboard); + $properties = $this->buildPropertyView($dashboard); + $timeline = $this->buildTransactions($dashboard); + + $properties->setActionList($actions); + $box = id(new PHUIObjectBoxView()) + ->setHeader($header) + ->addPropertyList($properties); + + $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) + ->setViewer($viewer) + ->setDashboard($dashboard) + ->setArrangeMode(true) + ->renderDashboard(); + + return $this->buildApplicationPage( + array( + $crumbs, + $box, + $timeline, + $rendered_dashboard, + ), + array( + 'title' => $title, + 'device' => true, + )); + } + + private function buildHeaderView(PhabricatorDashboard $dashboard) { + $viewer = $this->getRequest()->getUser(); + + return id(new PHUIHeaderView()) + ->setUser($viewer) + ->setHeader($dashboard->getName()) + ->setPolicyObject($dashboard); + } + + private function buildActionView(PhabricatorDashboard $dashboard) { + $viewer = $this->getRequest()->getUser(); + $id = $dashboard->getID(); + + $actions = id(new PhabricatorActionListView()) + ->setObjectURI($this->getApplicationURI('view/'.$dashboard->getID().'/')) + ->setUser($viewer); + + $can_edit = PhabricatorPolicyFilter::hasCapability( + $viewer, + $dashboard, + PhabricatorPolicyCapability::CAN_EDIT); + + $actions->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Edit Dashboard')) + ->setIcon('fa-pencil') + ->setHref($this->getApplicationURI("edit/{$id}/")) + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit)); + + $installed_dashboard = id(new PhabricatorDashboardInstall()) + ->loadOneWhere( + 'objectPHID = %s AND applicationClass = %s', + $viewer->getPHID(), + 'PhabricatorApplicationHome'); + if ($installed_dashboard && + $installed_dashboard->getDashboardPHID() == $dashboard->getPHID()) { + $title_install = pht('Uninstall Dashboard'); + $href_install = "uninstall/{$id}/"; + } else { + $title_install = pht('Install Dashboard'); + $href_install = "install/{$id}/"; + } + $actions->addAction( + id(new PhabricatorActionView()) + ->setName($title_install) + ->setIcon('fa-wrench') + ->setHref($this->getApplicationURI($href_install)) + ->setWorkflow(true)); + + return $actions; + } + + private function buildPropertyView(PhabricatorDashboard $dashboard) { + $viewer = $this->getRequest()->getUser(); + + $properties = id(new PHUIPropertyListView()) + ->setUser($viewer) + ->setObject($dashboard); + + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( + $viewer, + $dashboard); + + $properties->addProperty( + pht('Editable By'), + $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); + + $panel_phids = $dashboard->getPanelPHIDs(); + $this->loadHandles($panel_phids); + + $properties->addProperty( + pht('Panels'), + $this->renderHandlesForPHIDs($panel_phids)); + + return $properties; + } + + private function buildTransactions(PhabricatorDashboard $dashboard) { + $viewer = $this->getRequest()->getUser(); + + $xactions = id(new PhabricatorDashboardTransactionQuery()) + ->setViewer($viewer) + ->withObjectPHIDs(array($dashboard->getPHID())) + ->execute(); + + $engine = id(new PhabricatorMarkupEngine()) + ->setViewer($viewer); + + $timeline = id(new PhabricatorApplicationTransactionView()) + ->setUser($viewer) + ->setObjectPHID($dashboard->getPHID()) + ->setTransactions($xactions); + + return $timeline; + } + +} diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php index 1458cde0ad..c8d42f6629 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php @@ -182,7 +182,7 @@ final class PhabricatorDashboardPanelEditController $request = $this->getRequest(); $dashboard_id = $request->getInt('dashboardID'); if ($dashboard_id) { - $uri = $this->getApplicationURI('arrange/'.$dashboard_id.'/'); + $uri = $this->getApplicationURI('manage/'.$dashboard_id.'/'); } else { $uri = '/'.$panel->getMonogram(); } diff --git a/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php b/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php index 191d691343..3fed036f50 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php @@ -36,7 +36,7 @@ final class PhabricatorDashboardRemovePanelController } $redirect_uri = $this->getApplicationURI( - 'arrange/'.$dashboard->getID().'/'); + 'manage/'.$dashboard->getID().'/'); $layout_config = $dashboard->getLayoutConfigObject(); if ($request->isFormPost()) { diff --git a/src/applications/dashboard/controller/PhabricatorDashboardViewController.php b/src/applications/dashboard/controller/PhabricatorDashboardViewController.php index 59fe51ae4a..5fded53dab 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardViewController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardViewController.php @@ -26,16 +26,6 @@ final class PhabricatorDashboardViewController $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Dashboard %d', $dashboard->getID())); - $header = $this->buildHeaderView($dashboard); - $actions = $this->buildActionView($dashboard); - $properties = $this->buildPropertyView($dashboard); - $timeline = $this->buildTransactions($dashboard); - - $properties->setActionList($actions); - $box = id(new PHUIObjectBoxView()) - ->setHeader($header) - ->addPropertyList($properties); - $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) ->setViewer($viewer) ->setDashboard($dashboard) @@ -44,8 +34,6 @@ final class PhabricatorDashboardViewController return $this->buildApplicationPage( array( $crumbs, - $box, - $timeline, $rendered_dashboard, ), array( @@ -54,117 +42,17 @@ final class PhabricatorDashboardViewController )); } - private function buildHeaderView(PhabricatorDashboard $dashboard) { - $viewer = $this->getRequest()->getUser(); + public function buildApplicationCrumbs() { + $crumbs = parent::buildApplicationCrumbs(); + $id = $this->id; - return id(new PHUIHeaderView()) - ->setUser($viewer) - ->setHeader($dashboard->getName()) - ->setPolicyObject($dashboard); - } + $crumbs->addAction( + id(new PHUIListItemView()) + ->setIcon('fa-th') + ->setName(pht('Manage Dashboard')) + ->setHref($this->getApplicationURI()."manage/{$id}/")); - private function buildActionView(PhabricatorDashboard $dashboard) { - $viewer = $this->getRequest()->getUser(); - $id = $dashboard->getID(); - - $actions = id(new PhabricatorActionListView()) - ->setObjectURI($this->getApplicationURI('view/'.$dashboard->getID().'/')) - ->setUser($viewer); - - $can_edit = PhabricatorPolicyFilter::hasCapability( - $viewer, - $dashboard, - PhabricatorPolicyCapability::CAN_EDIT); - - $actions->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Edit Dashboard')) - ->setIcon('fa-pencil') - ->setHref($this->getApplicationURI("edit/{$id}/")) - ->setDisabled(!$can_edit) - ->setWorkflow(!$can_edit)); - - $actions->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Arrange Dashboard')) - ->setIcon('fa-arrows') - ->setHref($this->getApplicationURI("arrange/{$id}/")) - ->setDisabled(!$can_edit) - ->setWorkflow(!$can_edit)); - - $installed_dashboard = id(new PhabricatorDashboardInstall()) - ->loadOneWhere( - 'objectPHID = %s AND applicationClass = %s', - $viewer->getPHID(), - 'PhabricatorApplicationHome'); - if ($installed_dashboard && - $installed_dashboard->getDashboardPHID() == $dashboard->getPHID()) { - $title_install = pht('Uninstall Dashboard'); - $href_install = "uninstall/{$id}/"; - } else { - $title_install = pht('Install Dashboard'); - $href_install = "install/{$id}/"; - } - $actions->addAction( - id(new PhabricatorActionView()) - ->setName($title_install) - ->setIcon('fa-wrench') - ->setHref($this->getApplicationURI($href_install)) - ->setWorkflow(true)); - - $actions->addAction( - id(new PhabricatorActionView()) - ->setName(pht('Add Panel')) - ->setIcon('fa-plus') - ->setHref($this->getApplicationURI("addpanel/{$id}/")) - ->setDisabled(!$can_edit) - ->setWorkflow(true)); - - return $actions; - } - - private function buildPropertyView(PhabricatorDashboard $dashboard) { - $viewer = $this->getRequest()->getUser(); - - $properties = id(new PHUIPropertyListView()) - ->setUser($viewer) - ->setObject($dashboard); - - $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( - $viewer, - $dashboard); - - $properties->addProperty( - pht('Editable By'), - $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); - - $panel_phids = $dashboard->getPanelPHIDs(); - $this->loadHandles($panel_phids); - - $properties->addProperty( - pht('Panels'), - $this->renderHandlesForPHIDs($panel_phids)); - - return $properties; - } - - private function buildTransactions(PhabricatorDashboard $dashboard) { - $viewer = $this->getRequest()->getUser(); - - $xactions = id(new PhabricatorDashboardTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($dashboard->getPHID())) - ->execute(); - - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($viewer); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($dashboard->getPHID()) - ->setTransactions($xactions); - - return $timeline; + return $crumbs; } }