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

Add a "start with a template" option when creating dashboards

Summary: Ref T5317. This primarily makes it easier for new administrators to build a dashboard for the first time, without going too crazy on technical complexity.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5317

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

+189 -1
+183 -1
src/applications/dashboard/controller/PhabricatorDashboardEditController.php
··· 30 30 31 31 $is_new = false; 32 32 } else { 33 + if (!$request->getStr('edit')) { 34 + if ($request->isFormPost()) { 35 + switch ($request->getStr('template')) { 36 + case 'empty': 37 + break; 38 + default: 39 + return $this->processBuildTemplateRequest($request); 40 + } 41 + } else { 42 + return $this->processTemplateRequest($request); 43 + } 44 + } 45 + 33 46 $dashboard = PhabricatorDashboard::initializeNewDashboard($viewer); 34 47 35 48 $is_new = true; ··· 61 74 $e_name = true; 62 75 63 76 $validation_exception = null; 64 - if ($request->isFormPost()) { 77 + if ($request->isFormPost() && $request->getStr('edit')) { 65 78 $v_name = $request->getStr('name'); 66 79 $v_layout_mode = $request->getStr('layout_mode'); 67 80 $v_view_policy = $request->getStr('viewPolicy'); ··· 116 129 PhabricatorDashboardLayoutConfig::getLayoutModeSelectOptions(); 117 130 $form = id(new AphrontFormView()) 118 131 ->setUser($viewer) 132 + ->addHiddenInput('edit', true) 119 133 ->appendChild( 120 134 id(new AphrontFormTextControl()) 121 135 ->setLabel(pht('Name')) ··· 160 174 'device' => true, 161 175 )); 162 176 } 177 + 178 + private function processTemplateRequest(AphrontRequest $request) { 179 + $viewer = $request->getUser(); 180 + 181 + $template_control = id(new AphrontFormRadioButtonControl()) 182 + ->setName(pht('template')) 183 + ->setValue($request->getStr('template', 'empty')) 184 + ->addButton( 185 + 'empty', 186 + pht('Empty'), 187 + pht('Start with a blank canvas.')) 188 + ->addButton( 189 + 'simple', 190 + pht('Simple Template'), 191 + pht( 192 + 'Start with a simple dashboard with a welcome message, a feed of '. 193 + 'recent events, and a few starter panels.')); 194 + 195 + $form = id(new AphrontFormView()) 196 + ->setUser($viewer) 197 + ->appendRemarkupInstructions( 198 + pht('Choose a dashboard template to start with.')) 199 + ->appendChild($template_control); 200 + 201 + return $this->newDialog() 202 + ->setTitle(pht('Create Dashboard')) 203 + ->setWidth(AphrontDialogView::WIDTH_FORM) 204 + ->appendChild($form->buildLayoutView()) 205 + ->addCancelButton('/dashboard/') 206 + ->addSubmitButton(pht('Continue')); 207 + } 208 + 209 + private function processBuildTemplateRequest(AphrontRequest $request) { 210 + $viewer = $request->getUser(); 211 + $template = $request->getStr('template'); 212 + 213 + $bare_panel = PhabricatorDashboardPanel::initializeNewPanel($viewer); 214 + $panel_phids = array(); 215 + 216 + switch ($template) { 217 + case 'simple': 218 + $v_name = pht('New Simple Dashboard'); 219 + 220 + $welcome_panel = $this->newPanel( 221 + $request, 222 + $viewer, 223 + 'text', 224 + pht('Welcome'), 225 + array( 226 + 'text' => pht( 227 + "This is a simple template dashboard. You can edit this panel ". 228 + "to change this text and replace it with a welcome message, or ". 229 + "leave this placeholder text as-is to give your dashboard a ". 230 + "rustic, authentic feel.". 231 + "\n\n". 232 + "You can drag, remove, add, and edit panels to customize the ". 233 + "rest of this dashboard to show the information you want.". 234 + "\n\n". 235 + "To install this dashboard on the home page, use the ". 236 + "**Install Dashboard** action link above."), 237 + )); 238 + $panel_phids[] = $welcome_panel->getPHID(); 239 + 240 + $feed_panel = $this->newPanel( 241 + $request, 242 + $viewer, 243 + 'query', 244 + pht('Recent Activity'), 245 + array( 246 + 'class' => 'PhabricatorFeedSearchEngine', 247 + 'key' => 'all', 248 + )); 249 + $panel_phids[] = $feed_panel->getPHID(); 250 + 251 + $task_panel = $this->newPanel( 252 + $request, 253 + $viewer, 254 + 'query', 255 + pht('Recent Tasks'), 256 + array( 257 + 'class' => 'ManiphestTaskSearchEngine', 258 + 'key' => 'all', 259 + )); 260 + $panel_phids[] = $task_panel->getPHID(); 261 + 262 + $commit_panel = $this->newPanel( 263 + $request, 264 + $viewer, 265 + 'query', 266 + pht('Recent Commits'), 267 + array( 268 + 'class' => 'PhabricatorCommitSearchEngine', 269 + 'key' => 'all', 270 + )); 271 + $panel_phids[] = $commit_panel->getPHID(); 272 + 273 + $mode_2_and_1 = PhabricatorDashboardLayoutConfig::MODE_THIRDS_AND_THIRD; 274 + $layout = id(new PhabricatorDashboardLayoutConfig()) 275 + ->setLayoutMode($mode_2_and_1) 276 + ->setPanelLocation(0, $welcome_panel->getPHID()) 277 + ->setPanelLocation(0, $task_panel->getPHID()) 278 + ->setPanelLocation(0, $commit_panel->getPHID()) 279 + ->setPanelLocation(1, $feed_panel->getPHID()); 280 + 281 + break; 282 + default: 283 + throw new Exception(pht('Unknown dashboard template %s!', $template)); 284 + } 285 + 286 + // Create the dashboard. 287 + 288 + $dashboard = PhabricatorDashboard::initializeNewDashboard($viewer) 289 + ->setLayoutConfigFromObject($layout); 290 + 291 + $xactions = array(); 292 + 293 + $xactions[] = id(new PhabricatorDashboardTransaction()) 294 + ->setTransactionType(PhabricatorDashboardTransaction::TYPE_NAME) 295 + ->setNewValue($v_name); 296 + 297 + $xactions[] = id(new PhabricatorDashboardTransaction()) 298 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 299 + ->setMetadataValue( 300 + 'edge:type', 301 + PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL) 302 + ->setNewValue( 303 + array( 304 + '+' => array_fuse($panel_phids), 305 + )); 306 + 307 + $editor = id(new PhabricatorDashboardTransactionEditor()) 308 + ->setActor($viewer) 309 + ->setContinueOnNoEffect(true) 310 + ->setContentSourceFromRequest($request) 311 + ->applyTransactions($dashboard, $xactions); 312 + 313 + $manage_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/'); 314 + 315 + return id(new AphrontRedirectResponse()) 316 + ->setURI($manage_uri); 317 + } 318 + 319 + private function newPanel( 320 + AphrontRequest $request, 321 + PhabricatorUser $viewer, 322 + $type, 323 + $name, 324 + array $properties) { 325 + 326 + $panel = PhabricatorDashboardPanel::initializeNewPanel($viewer) 327 + ->setPanelType($type) 328 + ->setProperties($properties); 329 + 330 + $xactions = array(); 331 + 332 + $xactions[] = id(new PhabricatorDashboardPanelTransaction()) 333 + ->setTransactionType(PhabricatorDashboardPanelTransaction::TYPE_NAME) 334 + ->setNewValue($name); 335 + 336 + $editor = id(new PhabricatorDashboardPanelTransactionEditor()) 337 + ->setActor($viewer) 338 + ->setContinueOnNoEffect(true) 339 + ->setContentSourceFromRequest($request) 340 + ->applyTransactions($panel, $xactions); 341 + 342 + return $panel; 343 + } 344 + 163 345 164 346 }
+6
src/applications/dashboard/controller/PhabricatorDashboardManageController.php
··· 103 103 104 104 $actions->addAction( 105 105 id(new PhabricatorActionView()) 106 + ->setName(pht('View Dashboard')) 107 + ->setIcon('fa-columns') 108 + ->setHref($this->getApplicationURI("view/{$id}/"))); 109 + 110 + $actions->addAction( 111 + id(new PhabricatorActionView()) 106 112 ->setName(pht('Edit Dashboard')) 107 113 ->setIcon('fa-pencil') 108 114 ->setHref($this->getApplicationURI("edit/{$id}/"))