Skip to content

Commit a72d187

Browse files
author
Chad Little
committedMar 14, 2017
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
1 parent 251ee9b commit a72d187

8 files changed

+169
-10
lines changed
 

‎resources/celerity/map.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'names' => array(
1010
'conpherence.pkg.css' => '32f2c040',
1111
'conpherence.pkg.js' => '6249a1cf',
12-
'core.pkg.css' => '35645dec',
12+
'core.pkg.css' => 'c0c87dac',
1313
'core.pkg.js' => '1fa7c0c5',
1414
'darkconsole.pkg.js' => 'e7393ebb',
1515
'differential.pkg.css' => '90b30783',
@@ -21,7 +21,7 @@
2121
'maniphest.pkg.js' => '5ab2753f',
2222
'rsrc/css/aphront/aphront-bars.css' => '231ac33c',
2323
'rsrc/css/aphront/dark-console.css' => 'f54bf286',
24-
'rsrc/css/aphront/dialog-view.css' => '5e5aa60b',
24+
'rsrc/css/aphront/dialog-view.css' => '685c7e2d',
2525
'rsrc/css/aphront/list-filter-view.css' => '5d6f0526',
2626
'rsrc/css/aphront/multi-column.css' => '84cc6640',
2727
'rsrc/css/aphront/notification.css' => '3f6c89c9',
@@ -146,7 +146,7 @@
146146
'rsrc/css/phui/phui-document.css' => 'c32e8dec',
147147
'rsrc/css/phui/phui-feed-story.css' => '44a9c8e9',
148148
'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',
150150
'rsrc/css/phui/phui-form.css' => 'b62c01d8',
151151
'rsrc/css/phui/phui-head-thing.css' => 'fd311e5f',
152152
'rsrc/css/phui/phui-header-view.css' => 'fef6a54e',
@@ -548,7 +548,7 @@
548548
'almanac-css' => 'dbb9b3af',
549549
'aphront-bars' => '231ac33c',
550550
'aphront-dark-console-css' => 'f54bf286',
551-
'aphront-dialog-view-css' => '5e5aa60b',
551+
'aphront-dialog-view-css' => '685c7e2d',
552552
'aphront-list-filter-view-css' => '5d6f0526',
553553
'aphront-multi-column-view-css' => '84cc6640',
554554
'aphront-panel-view-css' => '8427b78d',
@@ -859,7 +859,7 @@
859859
'phui-font-icon-base-css' => '870a7360',
860860
'phui-fontkit-css' => 'b78a0059',
861861
'phui-form-css' => 'b62c01d8',
862-
'phui-form-view-css' => 'adca31ce',
862+
'phui-form-view-css' => 'cf198e10',
863863
'phui-head-thing-view-css' => 'fd311e5f',
864864
'phui-header-view-css' => 'fef6a54e',
865865
'phui-hovercard' => '1bd28176',

‎src/__phutil_library_map__.php

+2
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,7 @@
24962496
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php',
24972497
'PhabricatorDashboardIconSet' => 'applications/dashboard/icon/PhabricatorDashboardIconSet.php',
24982498
'PhabricatorDashboardInstall' => 'applications/dashboard/storage/PhabricatorDashboardInstall.php',
2499+
'PhabricatorDashboardInstallController' => 'applications/dashboard/controller/PhabricatorDashboardInstallController.php',
24992500
'PhabricatorDashboardLayoutConfig' => 'applications/dashboard/layoutconfig/PhabricatorDashboardLayoutConfig.php',
25002501
'PhabricatorDashboardListController' => 'applications/dashboard/controller/PhabricatorDashboardListController.php',
25012502
'PhabricatorDashboardManageController' => 'applications/dashboard/controller/PhabricatorDashboardManageController.php',
@@ -7562,6 +7563,7 @@
75627563
'PhabricatorDashboardEditController' => 'PhabricatorDashboardController',
75637564
'PhabricatorDashboardIconSet' => 'PhabricatorIconSet',
75647565
'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO',
7566+
'PhabricatorDashboardInstallController' => 'PhabricatorDashboardController',
75657567
'PhabricatorDashboardLayoutConfig' => 'Phobject',
75667568
'PhabricatorDashboardListController' => 'PhabricatorDashboardController',
75677569
'PhabricatorDashboardManageController' => 'PhabricatorDashboardProfileController',

‎src/applications/dashboard/application/PhabricatorDashboardApplication.php

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function getRoutes() {
3030
'arrange/(?P<id>\d+)/' => 'PhabricatorDashboardArrangeController',
3131
'create/' => 'PhabricatorDashboardEditController',
3232
'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardEditController',
33+
'install/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardInstallController',
3334
'addpanel/(?P<id>\d+)/' => 'PhabricatorDashboardAddPanelController',
3435
'movepanel/(?P<id>\d+)/' => 'PhabricatorDashboardMovePanelController',
3536
'removepanel/(?P<id>\d+)/'

‎src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ public function handleRequest(AphrontRequest $request) {
5151
->addClass('dashboard-preview-box')
5252
->appendChild($rendered_dashboard);
5353

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+
5462
$view = id(new PHUITwoColumnView())
5563
->setHeader($header)
5664
->setFooter(array(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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+
}

‎src/applications/dashboard/controller/PhabricatorDashboardViewController.php

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ public function handleRequest(AphrontRequest $request) {
4343
$navigation = $this->buildSideNavView('view');
4444
$header = $this->buildHeaderView();
4545

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+
4654
$view = id(new PHUITwoColumnView())
4755
->setHeader($header)
4856
->setFooter(array(

‎webroot/rsrc/css/aphront/dialog-view.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
.aphront-dialog-view {
6-
width: 540px;
6+
width: 560px;
77
margin: 32px auto 16px;
88
border: 1px solid {$lightblueborder};
99
border-radius: 3px;
@@ -32,7 +32,7 @@
3232
}
3333

3434
.aphront-dialog-view-width-form {
35-
width: 600px;
35+
width: 640px;
3636
}
3737

3838
.aphront-dialog-view-width-full {

‎webroot/rsrc/css/phui/phui-form-view.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,13 @@
208208

209209
table.aphront-form-control-radio-layout,
210210
table.aphront-form-control-checkbox-layout {
211-
margin-top: 3px;
211+
margin-top: 4px !important;
212212
font-size: {$normalfontsize};
213213
}
214214

215215
table.aphront-form-control-radio-layout th {
216-
padding-top: 3px;
217216
padding-left: 8px;
218-
padding-bottom: 4px;
217+
padding-bottom: 8px;
219218
font-weight: bold;
220219
color: {$darkgreytext};
221220
}

0 commit comments

Comments
 (0)
Failed to load comments.