Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14006084
D17529.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D17529.id.diff
View Options
diff --git a/src/applications/dashboard/application/PhabricatorDashboardApplication.php b/src/applications/dashboard/application/PhabricatorDashboardApplication.php
--- a/src/applications/dashboard/application/PhabricatorDashboardApplication.php
+++ b/src/applications/dashboard/application/PhabricatorDashboardApplication.php
@@ -39,11 +39,11 @@
'create/' => 'PhabricatorDashboardEditController',
'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardEditController',
'install/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardInstallController',
- 'addpanel/(?P<id>\d+)/' => 'PhabricatorDashboardAddPanelController',
'movepanel/(?P<id>\d+)/' => 'PhabricatorDashboardMovePanelController',
'removepanel/(?P<id>\d+)/'
=> 'PhabricatorDashboardRemovePanelController',
'panel/' => array(
+ 'add/(?P<id>\d+)/' => 'PhabricatorDashboardAddPanelController',
'install/(?P<engineKey>[^/]+)/(?:(?P<queryKey>[^/]+)/)?' =>
'PhabricatorDashboardQueryPanelInstallController',
'(?:query/(?P<queryKey>[^/]+)/)?'
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
@@ -7,51 +7,48 @@
$viewer = $request->getViewer();
$id = $request->getURIData('id');
- $dashboard = id(new PhabricatorDashboardQuery())
+ $panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
->withIDs(array($id))
- ->needPanels(true)
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
->executeOne();
- if (!$dashboard) {
+ if (!$panel) {
return new Aphront404Response();
}
- $redirect_uri = $this->getApplicationURI(
- 'arrange/'.$dashboard->getID().'/');
+ $cancel_uri = $this->getApplicationURI($panel->getMonogram());
- $v_panel = head($request->getArr('panel'));
- $e_panel = true;
+ $v_dashboard = $request->getInt('dashboardID');
+ $v_column = 0;
+ $e_dashboard = true;
$errors = array();
if ($request->isFormPost()) {
- if (strlen($v_panel)) {
- $panel = id(new PhabricatorDashboardPanelQuery())
- ->setViewer($viewer)
- ->withIDs(array($v_panel))
- ->executeOne();
- if (!$panel) {
- $errors[] = pht('Not a valid panel.');
- $e_panel = pht('Invalid');
- }
-
- $on_dashboard = $dashboard->getPanels();
- $on_ids = mpull($on_dashboard, null, 'getID');
- if (array_key_exists($v_panel, $on_ids)) {
- $p_name = $panel->getName();
- $errors[] = pht('Panel "%s" already exists on dashboard.', $p_name);
- $e_panel = pht('Invalid');
- }
+ $dashboard = id(new PhabricatorDashboardQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($v_dashboard))
+ ->needPanels(true)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$dashboard) {
+ $errors[] = pht('Not a valid dashboard.');
+ $e_dashboard = pht('Invalid');
+ }
- } else {
- $errors[] = pht('Select a panel to add.');
- $e_panel = pht('Required');
+ $on_dashboard = $dashboard->getPanels();
+ $on_ids = mpull($on_dashboard, null, 'getID');
+ if (array_key_exists($id, $on_ids)) {
+ $p_name = $panel->getName();
+ $errors[] = pht('Panel "%s" already exists on dashboard.', $p_name);
+ $e_panel = pht('Invalid');
}
if (!$errors) {
+ $redirect_uri = $this->getApplicationURI(
+ 'arrange/'.$dashboard->getID().'/');
+
PhabricatorDashboardTransactionEditor::addPanelToDashboard(
$viewer,
PhabricatorContentSource::newFromRequest($request),
@@ -63,41 +60,50 @@
}
}
- $panels = id(new PhabricatorDashboardPanelQuery())
+ $dashboards = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withArchived(false)
+ ->withStatuses(array(
+ PhabricatorDashboard::STATUS_ACTIVE,
+ ))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
->execute();
+ $options = mpull($dashboards, 'getName', 'getID');
+ asort($options);
+
+ if (!$options) {
+ $notice = id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
+ ->appendChild(pht('You do not have access to any dashboards. To '.
+ 'continue, please create a dashboard first.'));
- if (!$panels) {
return $this->newDialog()
- ->setTitle(pht('No Panels Exist Yet'))
- ->appendParagraph(
- pht(
- 'You have not created any dashboard panels yet, so you can not '.
- 'add an existing panel.'))
- ->appendParagraph(
- pht('Instead, add a new panel.'))
- ->addCancelButton($redirect_uri);
+ ->setTitle(pht('No Dashboards'))
+ ->setWidth(AphrontDialogView::WIDTH_FORM)
+ ->appendChild($notice)
+ ->addCancelButton($cancel_uri);
}
$form = id(new AphrontFormView())
->setUser($viewer)
- ->addHiddenInput('column', $request->getInt('column'))
- ->appendRemarkupInstructions(
- pht('Choose a panel to add to this dashboard:'))
+ ->addHiddenInput('column', $v_column)
->appendChild(
- id(new AphrontFormTokenizerControl())
+ id(new AphrontFormSelectControl())
->setUser($this->getViewer())
- ->setDatasource(new PhabricatorDashboardPanelDatasource())
- ->setLimit(1)
- ->setName('panel')
- ->setLabel(pht('Panel')));
+ ->setValue($v_dashboard)
+ ->setName('dashboardID')
+ ->setOptions($options)
+ ->setLabel(pht('Dashboard')));
return $this->newDialog()
- ->setTitle(pht('Add Panel'))
+ ->setTitle(pht('Add Panel to Dashboard'))
->setErrors($errors)
+ ->setWidth(AphrontDialogView::WIDTH_FORM)
->appendChild($form->buildLayoutView())
- ->addCancelButton($redirect_uri)
+ ->addCancelButton($cancel_uri)
->addSubmitButton(pht('Add Panel'));
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
@@ -65,18 +65,26 @@
$viewer = $this->getViewer();
$id = $panel->getID();
- $button = id(new PHUIButtonView())
+ $view_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('View Panel'))
->setIcon('fa-columns')
->setHref($this->getApplicationURI("panel/render/{$id}/"));
+ $install_button = id(new PHUIButtonView())
+ ->setTag('a')
+ ->setText(pht('Install Panel'))
+ ->setIcon('fa-plus')
+ ->setWorkflow(true)
+ ->setHref($this->getApplicationURI("panel/add/{$id}/"));
+
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($panel->getName())
->setPolicyObject($panel)
->setHeaderIcon('fa-columns')
- ->addActionLink($button);
+ ->addActionLink($view_button)
+ ->addActionLink($install_button);
if (!$panel->getIsArchived()) {
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
diff --git a/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php b/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php
--- a/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php
+++ b/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php
@@ -116,9 +116,6 @@
->setQueryParam('dashboardID', $dashboard_id)
->setQueryParam('column', $column);
- $add_uri = id(new PhutilURI('/dashboard/addpanel/'.$dashboard_id.'/'))
- ->setQueryParam('column', $column);
-
$create_button = id(new PHUIButtonView())
->setTag('a')
->setHref($create_uri)
@@ -126,13 +123,6 @@
->setText(pht('Create Panel'))
->addClass(PHUI::MARGIN_MEDIUM);
- $add_button = id(new PHUIButtonView())
- ->setTag('a')
- ->setHref($add_uri)
- ->setWorkflow(true)
- ->setText(pht('Add Existing Panel'))
- ->addClass(PHUI::MARGIN_MEDIUM);
-
return phutil_tag(
'div',
array(
@@ -140,7 +130,6 @@
),
array(
$create_button,
- $add_button,
));
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 29, 12:46 AM (1 w, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720277
Default Alt Text
D17529.id.diff (8 KB)
Attached To
Mode
D17529: Remove "Add Existing Panel" from dashboard arrange view
Attached
Detach File
Event Timeline
Log In to Comment