@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.

Basic "Install Dashboard" workflow

Summary: Ref T12264. This allows users to install a dashboard they are viewing to their personal home menu or as a global home menu item. Has some basic ability to be extended later for maybe projects.

Test Plan:
Build a dashboard, click "Install Dashboard".

- As user only get personal option
- As HomeApp edit person, see both options
- Try installation as either, with and without label set
- Fake "global" form as user, get error
- Don't set anything, get error

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12264

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

+169 -10
+5 -5
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '32f2c040', 11 11 'conpherence.pkg.js' => '6249a1cf', 12 - 'core.pkg.css' => '35645dec', 12 + 'core.pkg.css' => 'c0c87dac', 13 13 'core.pkg.js' => '1fa7c0c5', 14 14 'darkconsole.pkg.js' => 'e7393ebb', 15 15 'differential.pkg.css' => '90b30783', ··· 21 21 'maniphest.pkg.js' => '5ab2753f', 22 22 'rsrc/css/aphront/aphront-bars.css' => '231ac33c', 23 23 'rsrc/css/aphront/dark-console.css' => 'f54bf286', 24 - 'rsrc/css/aphront/dialog-view.css' => '5e5aa60b', 24 + 'rsrc/css/aphront/dialog-view.css' => '685c7e2d', 25 25 'rsrc/css/aphront/list-filter-view.css' => '5d6f0526', 26 26 'rsrc/css/aphront/multi-column.css' => '84cc6640', 27 27 'rsrc/css/aphront/notification.css' => '3f6c89c9', ··· 146 146 'rsrc/css/phui/phui-document.css' => 'c32e8dec', 147 147 'rsrc/css/phui/phui-feed-story.css' => '44a9c8e9', 148 148 'rsrc/css/phui/phui-fontkit.css' => 'b78a0059', 149 - 'rsrc/css/phui/phui-form-view.css' => 'adca31ce', 149 + 'rsrc/css/phui/phui-form-view.css' => 'cf198e10', 150 150 'rsrc/css/phui/phui-form.css' => 'b62c01d8', 151 151 'rsrc/css/phui/phui-head-thing.css' => 'fd311e5f', 152 152 'rsrc/css/phui/phui-header-view.css' => 'fef6a54e', ··· 548 548 'almanac-css' => 'dbb9b3af', 549 549 'aphront-bars' => '231ac33c', 550 550 'aphront-dark-console-css' => 'f54bf286', 551 - 'aphront-dialog-view-css' => '5e5aa60b', 551 + 'aphront-dialog-view-css' => '685c7e2d', 552 552 'aphront-list-filter-view-css' => '5d6f0526', 553 553 'aphront-multi-column-view-css' => '84cc6640', 554 554 'aphront-panel-view-css' => '8427b78d', ··· 859 859 'phui-font-icon-base-css' => '870a7360', 860 860 'phui-fontkit-css' => 'b78a0059', 861 861 'phui-form-css' => 'b62c01d8', 862 - 'phui-form-view-css' => 'adca31ce', 862 + 'phui-form-view-css' => 'cf198e10', 863 863 'phui-head-thing-view-css' => 'fd311e5f', 864 864 'phui-header-view-css' => 'fef6a54e', 865 865 'phui-hovercard' => '1bd28176',
+2
src/__phutil_library_map__.php
··· 2496 2496 'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php', 2497 2497 'PhabricatorDashboardIconSet' => 'applications/dashboard/icon/PhabricatorDashboardIconSet.php', 2498 2498 'PhabricatorDashboardInstall' => 'applications/dashboard/storage/PhabricatorDashboardInstall.php', 2499 + 'PhabricatorDashboardInstallController' => 'applications/dashboard/controller/PhabricatorDashboardInstallController.php', 2499 2500 'PhabricatorDashboardLayoutConfig' => 'applications/dashboard/layoutconfig/PhabricatorDashboardLayoutConfig.php', 2500 2501 'PhabricatorDashboardListController' => 'applications/dashboard/controller/PhabricatorDashboardListController.php', 2501 2502 'PhabricatorDashboardManageController' => 'applications/dashboard/controller/PhabricatorDashboardManageController.php', ··· 7562 7563 'PhabricatorDashboardEditController' => 'PhabricatorDashboardController', 7563 7564 'PhabricatorDashboardIconSet' => 'PhabricatorIconSet', 7564 7565 'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO', 7566 + 'PhabricatorDashboardInstallController' => 'PhabricatorDashboardController', 7565 7567 'PhabricatorDashboardLayoutConfig' => 'Phobject', 7566 7568 'PhabricatorDashboardListController' => 'PhabricatorDashboardController', 7567 7569 'PhabricatorDashboardManageController' => 'PhabricatorDashboardProfileController',
+1
src/applications/dashboard/application/PhabricatorDashboardApplication.php
··· 30 30 'arrange/(?P<id>\d+)/' => 'PhabricatorDashboardArrangeController', 31 31 'create/' => 'PhabricatorDashboardEditController', 32 32 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardEditController', 33 + 'install/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardInstallController', 33 34 'addpanel/(?P<id>\d+)/' => 'PhabricatorDashboardAddPanelController', 34 35 'movepanel/(?P<id>\d+)/' => 'PhabricatorDashboardMovePanelController', 35 36 'removepanel/(?P<id>\d+)/'
+8
src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php
··· 51 51 ->addClass('dashboard-preview-box') 52 52 ->appendChild($rendered_dashboard); 53 53 54 + $install_button = id(new PHUIButtonView()) 55 + ->setTag('a') 56 + ->setText('Install Dashboard') 57 + ->setIcon('fa-plus') 58 + ->setWorkflow(true) 59 + ->setHref($this->getApplicationURI("/install/{$id}/")); 60 + $header->addActionLink($install_button); 61 + 54 62 $view = id(new PHUITwoColumnView()) 55 63 ->setHeader($header) 56 64 ->setFooter(array(
+141
src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardInstallController 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 + 18 + $cancel_uri = $this->getApplicationURI( 19 + 'view/'.$dashboard->getID().'/'); 20 + 21 + $home_app = new PhabricatorHomeApplication(); 22 + 23 + $options = array(); 24 + $options['home'] = array( 25 + 'personal' => 26 + array( 27 + 'capability' => PhabricatorPolicyCapability::CAN_VIEW, 28 + 'application' => $home_app, 29 + 'name' => pht('Personal Dashboard'), 30 + 'value' => 'personal', 31 + 'description' => pht('Places this dashboard as a menu item on home '. 32 + 'as a personal menu item. It will only be on your personal '. 33 + 'home.'), 34 + ), 35 + 'global' => 36 + array( 37 + 'capability' => PhabricatorPolicyCapability::CAN_EDIT, 38 + 'application' => $home_app, 39 + 'name' => pht('Global Dashboard'), 40 + 'value' => 'global', 41 + 'description' => pht('Places this dashboard as a menu item on home '. 42 + 'as a global menu item. It will be available to all users.'), 43 + ), 44 + ); 45 + 46 + 47 + $errors = array(); 48 + $v_name = null; 49 + if ($request->isFormPost()) { 50 + $menuitem = new PhabricatorDashboardProfileMenuItem(); 51 + $dashboard_phid = $dashboard->getPHID(); 52 + $home = new PhabricatorHomeApplication(); 53 + $v_name = $request->getStr('name'); 54 + $v_home = $request->getStr('home'); 55 + 56 + if ($v_home) { 57 + $application = $options['home'][$v_home]['application']; 58 + $capability = $options['home'][$v_home]['capability']; 59 + 60 + $can_edit_home = PhabricatorPolicyFilter::hasCapability( 61 + $viewer, 62 + $application, 63 + $capability); 64 + 65 + if (!$can_edit_home) { 66 + $errors[] = pht( 67 + 'You do not have permission to install a dashboard on home.'); 68 + } 69 + } else { 70 + $errors[] = pht( 71 + 'You must select a destination to install this dashboard.'); 72 + } 73 + 74 + $v_phid = $viewer->getPHID(); 75 + if ($v_home == 'global') { 76 + $v_phid = null; 77 + } 78 + 79 + if (!$errors) { 80 + $install = PhabricatorProfileMenuItemConfiguration::initializeNewItem( 81 + $home, 82 + $menuitem, 83 + $v_phid); 84 + 85 + $install->setMenuItemProperty('dashboardPHID', $dashboard_phid); 86 + $install->setMenuItemProperty('name', $v_name); 87 + $install->setMenuItemOrder(1); 88 + 89 + $xactions = array(); 90 + 91 + $editor = id(new PhabricatorProfileMenuEditor()) 92 + ->setActor($viewer) 93 + ->setContinueOnNoEffect(true) 94 + ->setContinueOnMissingFields(true) 95 + ->setContentSourceFromRequest($request); 96 + 97 + $editor->applyTransactions($install, $xactions); 98 + 99 + $view_uri = '/home/menu/view/'.$install->getID().'/'; 100 + 101 + return id(new AphrontRedirectResponse())->setURI($view_uri); 102 + } 103 + } 104 + 105 + $form = id(new AphrontFormView()) 106 + ->setUser($viewer) 107 + ->appendChild( 108 + id(new AphrontFormTextControl()) 109 + ->setLabel(pht('Menu Label')) 110 + ->setName('name') 111 + ->setValue($v_name)); 112 + 113 + $radio = id(new AphrontFormRadioButtonControl()) 114 + ->setLabel(pht('Home Menu')) 115 + ->setName('home'); 116 + 117 + foreach ($options['home'] as $type => $option) { 118 + $can_edit = PhabricatorPolicyFilter::hasCapability( 119 + $viewer, 120 + $option['application'], 121 + $option['capability']); 122 + if ($can_edit) { 123 + $radio->addButton( 124 + $option['value'], 125 + $option['name'], 126 + $option['description']); 127 + } 128 + } 129 + 130 + $form->appendChild($radio); 131 + 132 + return $this->newDialog() 133 + ->setTitle(pht('Install Dashboard')) 134 + ->setErrors($errors) 135 + ->setWidth(AphrontDialogView::WIDTH_FORM) 136 + ->appendChild($form->buildLayoutView()) 137 + ->addCancelButton($cancel_uri) 138 + ->addSubmitButton(pht('Install Dashboard')); 139 + } 140 + 141 + }
+8
src/applications/dashboard/controller/PhabricatorDashboardViewController.php
··· 43 43 $navigation = $this->buildSideNavView('view'); 44 44 $header = $this->buildHeaderView(); 45 45 46 + $install_button = id(new PHUIButtonView()) 47 + ->setTag('a') 48 + ->setText('Install Dashboard') 49 + ->setIcon('fa-plus') 50 + ->setWorkflow(true) 51 + ->setHref($this->getApplicationURI("/install/{$id}/")); 52 + $header->addActionLink($install_button); 53 + 46 54 $view = id(new PHUITwoColumnView()) 47 55 ->setHeader($header) 48 56 ->setFooter(array(
+2 -2
webroot/rsrc/css/aphront/dialog-view.css
··· 3 3 */ 4 4 5 5 .aphront-dialog-view { 6 - width: 540px; 6 + width: 560px; 7 7 margin: 32px auto 16px; 8 8 border: 1px solid {$lightblueborder}; 9 9 border-radius: 3px; ··· 32 32 } 33 33 34 34 .aphront-dialog-view-width-form { 35 - width: 600px; 35 + width: 640px; 36 36 } 37 37 38 38 .aphront-dialog-view-width-full {
+2 -3
webroot/rsrc/css/phui/phui-form-view.css
··· 208 208 209 209 table.aphront-form-control-radio-layout, 210 210 table.aphront-form-control-checkbox-layout { 211 - margin-top: 3px; 211 + margin-top: 4px !important; 212 212 font-size: {$normalfontsize}; 213 213 } 214 214 215 215 table.aphront-form-control-radio-layout th { 216 - padding-top: 3px; 217 216 padding-left: 8px; 218 - padding-bottom: 4px; 217 + padding-bottom: 8px; 219 218 font-weight: bold; 220 219 color: {$darkgreytext}; 221 220 }