@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove Copy Dashboard

Summary: Ref T10390. This removes the "Copy Dashboard" feature, which was more of a crutch to assist in the complexity of building and maintaining dashboards. I think we're close enough now that removing this and adding in some simpler edit dialogs should negate any benefit to keeping this around. Also removed an un-used "Uninstall Dashboard" dialog.

Test Plan: Visit manage, edit, no longer see option to copy dashboard. grep /dashboards/ for "copy" and remove all traces. Add some panels to a dashboard I own.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10390

Differential Revision: https://secure.phabricator.com/D17338

+2 -326
-4
src/__phutil_library_map__.php
··· 2466 2466 'PhabricatorDashboardArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardArchiveController.php', 2467 2467 'PhabricatorDashboardArrangeController' => 'applications/dashboard/controller/PhabricatorDashboardArrangeController.php', 2468 2468 'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php', 2469 - 'PhabricatorDashboardCopyController' => 'applications/dashboard/controller/PhabricatorDashboardCopyController.php', 2470 2469 'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php', 2471 2470 'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php', 2472 2471 'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php', ··· 2518 2517 'PhabricatorDashboardTransaction' => 'applications/dashboard/storage/PhabricatorDashboardTransaction.php', 2519 2518 'PhabricatorDashboardTransactionEditor' => 'applications/dashboard/editor/PhabricatorDashboardTransactionEditor.php', 2520 2519 'PhabricatorDashboardTransactionQuery' => 'applications/dashboard/query/PhabricatorDashboardTransactionQuery.php', 2521 - 'PhabricatorDashboardUninstallController' => 'applications/dashboard/controller/PhabricatorDashboardUninstallController.php', 2522 2520 'PhabricatorDashboardViewController' => 'applications/dashboard/controller/PhabricatorDashboardViewController.php', 2523 2521 'PhabricatorDataCacheSpec' => 'applications/cache/spec/PhabricatorDataCacheSpec.php', 2524 2522 'PhabricatorDataNotAttachedException' => 'infrastructure/storage/lisk/PhabricatorDataNotAttachedException.php', ··· 7476 7474 'PhabricatorDashboardArchiveController' => 'PhabricatorDashboardController', 7477 7475 'PhabricatorDashboardArrangeController' => 'PhabricatorDashboardProfileController', 7478 7476 'PhabricatorDashboardController' => 'PhabricatorController', 7479 - 'PhabricatorDashboardCopyController' => 'PhabricatorDashboardController', 7480 7477 'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO', 7481 7478 'PhabricatorDashboardDashboardHasPanelEdgeType' => 'PhabricatorEdgeType', 7482 7479 'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType', ··· 7539 7536 'PhabricatorDashboardTransaction' => 'PhabricatorApplicationTransaction', 7540 7537 'PhabricatorDashboardTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 7541 7538 'PhabricatorDashboardTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 7542 - 'PhabricatorDashboardUninstallController' => 'PhabricatorDashboardController', 7543 7539 'PhabricatorDashboardViewController' => 'PhabricatorDashboardProfileController', 7544 7540 'PhabricatorDataCacheSpec' => 'PhabricatorCacheSpec', 7545 7541 'PhabricatorDataNotAttachedException' => 'Exception',
-2
src/applications/dashboard/application/PhabricatorDashboardApplication.php
··· 29 29 'manage/(?P<id>\d+)/' => 'PhabricatorDashboardManageController', 30 30 'arrange/(?P<id>\d+)/' => 'PhabricatorDashboardArrangeController', 31 31 'create/' => 'PhabricatorDashboardEditController', 32 - 'copy/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardCopyController', 33 32 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardEditController', 34 - 'uninstall/(?P<id>\d+)/' => 'PhabricatorDashboardUninstallController', 35 33 'addpanel/(?P<id>\d+)/' => 'PhabricatorDashboardAddPanelController', 36 34 'movepanel/(?P<id>\d+)/' => 'PhabricatorDashboardMovePanelController', 37 35 'removepanel/(?P<id>\d+)/'
+1 -2
src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php
··· 34 34 $info_view = null; 35 35 if (!$can_edit) { 36 36 $no_edit = pht( 37 - 'You do not have permission to edit this dashboard. If you want to '. 38 - 'make changes, make a copy first.'); 37 + 'You do not have permission to edit this dashboard.'); 39 38 40 39 $info_view = id(new PHUIInfoView()) 41 40 ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
-62
src/applications/dashboard/controller/PhabricatorDashboardCopyController.php
··· 1 - <?php 2 - 3 - final class PhabricatorDashboardCopyController 4 - extends PhabricatorDashboardController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $viewer = $request->getViewer(); 8 - $id = $request->getURIData('id'); 9 - 10 - $dashboard = id(new PhabricatorDashboardQuery()) 11 - ->setViewer($viewer) 12 - ->withIDs(array($id)) 13 - ->needPanels(true) 14 - ->executeOne(); 15 - if (!$dashboard) { 16 - return new Aphront404Response(); 17 - } 18 - 19 - $cancel_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/'); 20 - 21 - if ($request->isFormPost()) { 22 - 23 - $copy = PhabricatorDashboard::initializeNewDashboard($viewer); 24 - $copy = PhabricatorDashboard::copyDashboard($copy, $dashboard); 25 - 26 - $copy->setName(pht('Copy of %s', $copy->getName())); 27 - 28 - // Set up all the edges for the new dashboard. 29 - 30 - $xactions = array(); 31 - $xactions[] = id(new PhabricatorDashboardTransaction()) 32 - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 33 - ->setMetadataValue( 34 - 'edge:type', 35 - PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST) 36 - ->setNewValue( 37 - array( 38 - '=' => array_fuse($dashboard->getPanelPHIDs()), 39 - )); 40 - 41 - $editor = id(new PhabricatorDashboardTransactionEditor()) 42 - ->setActor($viewer) 43 - ->setContentSourceFromRequest($request) 44 - ->setContinueOnMissingFields(true) 45 - ->setContinueOnNoEffect(true) 46 - ->applyTransactions($copy, $xactions); 47 - 48 - $cancel_uri = $this->getApplicationURI('edit/'.$copy->getID().'/'); 49 - return id(new AphrontRedirectResponse())->setURI($cancel_uri); 50 - } 51 - 52 - return $this->newDialog() 53 - ->setTitle(pht('Copy Dashboard')) 54 - ->appendParagraph( 55 - pht( 56 - 'Create a copy of the dashboard "%s"?', 57 - phutil_tag('strong', array(), $dashboard->getName()))) 58 - ->addCancelButton($cancel_uri) 59 - ->addSubmitButton(pht('Create Copy')); 60 - } 61 - 62 - }
+1 -9
src/applications/dashboard/controller/PhabricatorDashboardManageController.php
··· 47 47 $info_view = null; 48 48 if (!$can_edit) { 49 49 $no_edit = pht( 50 - 'You do not have permission to edit this dashboard. If you want to '. 51 - 'make changes, make a copy first.'); 50 + 'You do not have permission to edit this dashboard.'); 52 51 53 52 $info_view = id(new PHUIInfoView()) 54 53 ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) ··· 109 108 ->setDisabled(!$can_edit) 110 109 ->setWorkflow($can_edit)); 111 110 } 112 - 113 - $curtain->addAction( 114 - id(new PhabricatorActionView()) 115 - ->setName(pht('Copy Dashboard')) 116 - ->setIcon('fa-files-o') 117 - ->setHref($this->getApplicationURI("copy/{$id}/")) 118 - ->setWorkflow(true)); 119 111 120 112 return $curtain; 121 113 }
-93
src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
··· 52 52 return new Aphront404Response(); 53 53 } 54 54 55 - if ($dashboard) { 56 - $can_edit = PhabricatorPolicyFilter::hasCapability( 57 - $viewer, 58 - $panel, 59 - PhabricatorPolicyCapability::CAN_EDIT); 60 - if (!$can_edit) { 61 - if ($request->isFormPost() && $request->getBool('copy')) { 62 - $panel = $this->copyPanel( 63 - $request, 64 - $dashboard, 65 - $panel); 66 - } else { 67 - return $this->processPanelCloneRequest( 68 - $request, 69 - $dashboard, 70 - $panel); 71 - } 72 - } 73 - } 74 55 } else { 75 56 $is_create = true; 76 57 ··· 363 344 ->setTitle($title) 364 345 ->setCrumbs($crumbs) 365 346 ->appendChild($view); 366 - } 367 - 368 - private function processPanelCloneRequest( 369 - AphrontRequest $request, 370 - PhabricatorDashboard $dashboard, 371 - PhabricatorDashboardPanel $panel) { 372 - 373 - $viewer = $request->getUser(); 374 - 375 - $manage_uri = $this->getApplicationURI('arrange/'.$dashboard->getID().'/'); 376 - 377 - return $this->newDialog() 378 - ->setTitle(pht('Copy Panel?')) 379 - ->addHiddenInput('copy', true) 380 - ->addHiddenInput('dashboardID', $request->getInt('dashboardID')) 381 - ->addHiddenInput('column', $request->getInt('column')) 382 - ->appendParagraph( 383 - pht( 384 - 'You do not have permission to edit this dashboard panel, but you '. 385 - 'can make a copy and edit that instead. If you choose to copy the '. 386 - 'panel, the original will be replaced with the new copy on this '. 387 - 'dashboard.')) 388 - ->appendParagraph( 389 - pht( 390 - 'Do you want to make a copy of this panel?')) 391 - ->addCancelButton($manage_uri) 392 - ->addSubmitButton(pht('Copy Panel')); 393 - } 394 - 395 - private function copyPanel( 396 - AphrontRequest $request, 397 - PhabricatorDashboard $dashboard, 398 - PhabricatorDashboardPanel $panel) { 399 - 400 - $viewer = $request->getUser(); 401 - 402 - $copy = PhabricatorDashboardPanel::initializeNewPanel($viewer); 403 - $copy = PhabricatorDashboardPanel::copyPanel($copy, $panel, $viewer); 404 - 405 - $copy->openTransaction(); 406 - $copy->save(); 407 - 408 - // TODO: This should record a transaction on the panel copy, too. 409 - 410 - $xactions = array(); 411 - $xactions[] = id(new PhabricatorDashboardTransaction()) 412 - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 413 - ->setMetadataValue( 414 - 'edge:type', 415 - PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST) 416 - ->setNewValue( 417 - array( 418 - '+' => array( 419 - $copy->getPHID() => $copy->getPHID(), 420 - ), 421 - '-' => array( 422 - $panel->getPHID() => $panel->getPHID(), 423 - ), 424 - )); 425 - 426 - $layout_config = $dashboard->getLayoutConfigObject(); 427 - $layout_config->replacePanel($panel->getPHID(), $copy->getPHID()); 428 - $dashboard->setLayoutConfigFromObject($layout_config); 429 - $dashboard->save(); 430 - 431 - $editor = id(new PhabricatorDashboardTransactionEditor()) 432 - ->setActor($viewer) 433 - ->setContentSourceFromRequest($request) 434 - ->setContinueOnMissingFields(true) 435 - ->setContinueOnNoEffect(true) 436 - ->applyTransactions($dashboard, $xactions); 437 - $copy->saveTransaction(); 438 - 439 - return $copy; 440 347 } 441 348 442 349
-131
src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php
··· 1 - <?php 2 - 3 - final class PhabricatorDashboardUninstallController 4 - extends PhabricatorDashboardController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $viewer = $request->getViewer(); 8 - $id = $request->getURIData('id'); 9 - 10 - $dashboard = id(new PhabricatorDashboardQuery()) 11 - ->setViewer($viewer) 12 - ->withIDs(array($id)) 13 - ->executeOne(); 14 - if (!$dashboard) { 15 - return new Aphront404Response(); 16 - } 17 - $dashboard_phid = $dashboard->getPHID(); 18 - 19 - $object_phid = $request->getStr('objectPHID', $viewer->getPHID()); 20 - $object = id(new PhabricatorObjectQuery()) 21 - ->setViewer($viewer) 22 - ->requireCapabilities( 23 - array( 24 - PhabricatorPolicyCapability::CAN_VIEW, 25 - PhabricatorPolicyCapability::CAN_EDIT, 26 - )) 27 - ->withPHIDs(array($object_phid)) 28 - ->executeOne(); 29 - if (!$object) { 30 - return new Aphront404Response(); 31 - } 32 - 33 - $application_class = $request->getStr( 34 - 'applicationClass', 35 - 'PhabricatorHomeApplication'); 36 - 37 - $dashboard_install = id(new PhabricatorDashboardInstall()) 38 - ->loadOneWhere( 39 - 'objectPHID = %s AND applicationClass = %s', 40 - $object_phid, 41 - $application_class); 42 - if (!$dashboard_install) { 43 - return new Aphront404Response(); 44 - } 45 - if ($dashboard_install->getDashboardPHID() != $dashboard_phid) { 46 - return new Aphront404Response(); 47 - } 48 - 49 - $installer_phid = $viewer->getPHID(); 50 - 51 - if ($request->isFormPost()) { 52 - $dashboard_install->delete(); 53 - return id(new AphrontRedirectResponse()) 54 - ->setURI($this->getRedirectURI($application_class, $object_phid)); 55 - } 56 - 57 - $body = $this->getBodyContent( 58 - $application_class, 59 - $object_phid, 60 - $installer_phid); 61 - 62 - $form = id(new AphrontFormView()) 63 - ->setUser($viewer) 64 - ->appendChild($body); 65 - 66 - return $this->newDialog() 67 - ->setTitle(pht('Uninstall Dashboard')) 68 - ->appendChild($form->buildLayoutView()) 69 - ->addCancelButton($this->getCancelURI( 70 - $application_class, $object_phid, $id)) 71 - ->addSubmitButton(pht('Uninstall Dashboard')); 72 - } 73 - 74 - private function getBodyContent( 75 - $application_class, 76 - $object_phid, 77 - $installer_phid) { 78 - 79 - $viewer = $this->getViewer(); 80 - 81 - $body = array(); 82 - switch ($application_class) { 83 - case 'PhabricatorHomeApplication': 84 - if ($installer_phid == $object_phid) { 85 - $body[] = phutil_tag( 86 - 'p', 87 - array(), 88 - pht( 89 - 'Are you sure you want to uninstall this dashboard as your '. 90 - 'home page?')); 91 - $body[] = phutil_tag( 92 - 'p', 93 - array(), 94 - pht( 95 - 'You will be re-directed to your bland, default home page if '. 96 - 'you choose to uninstall this dashboard.')); 97 - } else { 98 - $body[] = phutil_tag( 99 - 'p', 100 - array(), 101 - pht( 102 - 'Are you sure you want to uninstall this dashboard as the home '. 103 - 'page for %s?', 104 - $viewer->renderHandle($object_phid))); 105 - } 106 - break; 107 - } 108 - return $body; 109 - } 110 - 111 - private function getCancelURI($application_class, $object_phid, $id) { 112 - $uri = null; 113 - switch ($application_class) { 114 - case 'PhabricatorHomeApplication': 115 - $uri = '/dashboard/view/'.$id.'/'; 116 - break; 117 - } 118 - return $uri; 119 - } 120 - 121 - private function getRedirectURI($application_class, $object_phid) { 122 - $uri = null; 123 - switch ($application_class) { 124 - case 'PhabricatorHomeApplication': 125 - $uri = '/'; 126 - break; 127 - } 128 - return $uri; 129 - } 130 - 131 - }
-10
src/applications/dashboard/storage/PhabricatorDashboard.php
··· 47 47 ); 48 48 } 49 49 50 - public static function copyDashboard( 51 - PhabricatorDashboard $dst, 52 - PhabricatorDashboard $src) { 53 - 54 - $dst->name = $src->name; 55 - $dst->layoutConfig = $src->layoutConfig; 56 - 57 - return $dst; 58 - } 59 - 60 50 protected function getConfiguration() { 61 51 return array( 62 52 self::CONFIG_AUX_PHID => true,
-13
src/applications/dashboard/storage/PhabricatorDashboardPanel.php
··· 31 31 ->setEditPolicy($actor->getPHID()); 32 32 } 33 33 34 - public static function copyPanel( 35 - PhabricatorDashboardPanel $dst, 36 - PhabricatorDashboardPanel $src, 37 - PhabricatorUser $user) { 38 - 39 - $dst->name = $src->name; 40 - $dst->panelType = $src->panelType; 41 - $dst->properties = $src->properties; 42 - $dst->authorPHID = $user->getPHID(); 43 - 44 - return $dst; 45 - } 46 - 47 34 protected function getConfiguration() { 48 35 return array( 49 36 self::CONFIG_AUX_PHID => true,