Summary: Depends on D20362. Ref T13272. Currently, Dashboards have an "Install Dashboard" flow which is pretty janky and only allows you to install things to the home page. Instead, allow users to install things to any valid target (home, favorites, portals, projects). This also provides URIs like `dashboard/install/1/home/personal/` which allow you to link users to an "install a dashboard" page; this may or may not get used. Test Plan: Installed dashboards on home, favorites, projects, and portals. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13272 Differential Revision: https://secure.phabricator.com/D20364
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
abstract class PhabricatorDashboardApplicationInstallWorkflow
 | 
						|
  extends PhabricatorDashboardInstallWorkflow {
 | 
						|
 | 
						|
  abstract protected function newApplication();
 | 
						|
 | 
						|
  protected function canInstallToGlobalMenu() {
 | 
						|
    return PhabricatorPolicyFilter::hasCapability(
 | 
						|
      $this->getViewer(),
 | 
						|
      $this->newApplication(),
 | 
						|
      PhabricatorPolicyCapability::CAN_EDIT);
 | 
						|
  }
 | 
						|
 | 
						|
  public function handleRequest(AphrontRequest $request) {
 | 
						|
    $viewer = $this->getViewer();
 | 
						|
    $application = $this->newApplication();
 | 
						|
    $can_global = $this->canInstallToGlobalMenu();
 | 
						|
 | 
						|
    switch ($this->getMode()) {
 | 
						|
      case 'global':
 | 
						|
        if (!$can_global) {
 | 
						|
          return $this->newGlobalPermissionDialog();
 | 
						|
        } else if ($request->isFormPost()) {
 | 
						|
          return $this->installDashboard($application, null);
 | 
						|
        } else {
 | 
						|
          return $this->newGlobalConfirmDialog();
 | 
						|
        }
 | 
						|
      case 'personal':
 | 
						|
        if ($request->isFormPost()) {
 | 
						|
          return $this->installDashboard($application, $viewer->getPHID());
 | 
						|
        } else {
 | 
						|
          return $this->newPersonalConfirmDialog();
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    $global_item = $this->newGlobalMenuItem()
 | 
						|
      ->setDisabled(!$can_global);
 | 
						|
 | 
						|
    $menu = $this->newMenuFromItemMap(
 | 
						|
      array(
 | 
						|
        'personal' => $this->newPersonalMenuItem(),
 | 
						|
        'global' => $global_item,
 | 
						|
      ));
 | 
						|
 | 
						|
    return $this->newApplicationModeDialog()
 | 
						|
      ->appendChild($menu);
 | 
						|
  }
 | 
						|
 | 
						|
  abstract protected function newGlobalPermissionDialog();
 | 
						|
  abstract protected function newGlobalConfirmDialog();
 | 
						|
  abstract protected function newPersonalConfirmDialog();
 | 
						|
 | 
						|
  abstract protected function newPersonalMenuItem();
 | 
						|
  abstract protected function newGlobalMenuItem();
 | 
						|
  abstract protected function newApplicationModeDialog();
 | 
						|
 | 
						|
}
 |