Page MenuHomePhabricator

D14725.diff
No OneTemporary

D14725.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2042,6 +2042,7 @@
'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php',
'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php',
'PhabricatorDashboardApplication' => 'applications/dashboard/application/PhabricatorDashboardApplication.php',
+ 'PhabricatorDashboardArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardArchiveController.php',
'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php',
'PhabricatorDashboardCopyController' => 'applications/dashboard/controller/PhabricatorDashboardCopyController.php',
'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php',
@@ -6157,6 +6158,7 @@
),
'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController',
'PhabricatorDashboardApplication' => 'PhabricatorApplication',
+ 'PhabricatorDashboardArchiveController' => 'PhabricatorDashboardController',
'PhabricatorDashboardController' => 'PhabricatorController',
'PhabricatorDashboardCopyController' => 'PhabricatorDashboardController',
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
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
@@ -25,6 +25,7 @@
'(?:query/(?P<queryKey>[^/]+)/)?'
=> 'PhabricatorDashboardListController',
'view/(?P<id>\d+)/' => 'PhabricatorDashboardViewController',
+ 'archive/(?P<id>\d+)/' => 'PhabricatorDashboardArchiveController',
'manage/(?P<id>\d+)/' => 'PhabricatorDashboardManageController',
'history/(?P<id>\d+)/' => 'PhabricatorDashboardHistoryController',
'create/' => 'PhabricatorDashboardEditController',
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardArchiveController.php b/src/applications/dashboard/controller/PhabricatorDashboardArchiveController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/controller/PhabricatorDashboardArchiveController.php
@@ -0,0 +1,65 @@
+<?php
+
+final class PhabricatorDashboardArchiveController
+ extends PhabricatorDashboardController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
+
+ $dashboard = id(new PhabricatorDashboardQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$dashboard) {
+ return new Aphront404Response();
+ }
+
+ $view_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/');
+
+ if ($request->isFormPost()) {
+ if ($dashboard->isArchived()) {
+ $new_status = PhabricatorDashboard::STATUS_ACTIVE;
+ } else {
+ $new_status = PhabricatorDashboard::STATUS_ARCHIVED;
+ }
+
+ $xactions = array();
+
+ $xactions[] = id(new PhabricatorDashboardTransaction())
+ ->setTransactionType(PhabricatorDashboardTransaction::TYPE_STATUS)
+ ->setNewValue($new_status);
+
+ id(new PhabricatorDashboardTransactionEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($dashboard, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($view_uri);
+ }
+
+ if ($dashboard->isArchived()) {
+ $title = pht('Activate Dashboard');
+ $body = pht('This dashboard will become active again.');
+ $button = pht('Activate Dashboard');
+ } else {
+ $title = pht('Archive Dashboard');
+ $body = pht('This dashboard will be marked as archived.');
+ $button = pht('Archive Dashboard');
+ }
+
+ return $this->newDialog()
+ ->setTitle($title)
+ ->appendChild($body)
+ ->addCancelButton($view_uri)
+ ->addSubmitButton($button);
+ }
+
+}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
@@ -67,7 +67,6 @@
}
$v_name = $dashboard->getName();
- $v_stat = $dashboard->getStatus();
$v_layout_mode = $dashboard->getLayoutConfigObject()->getLayoutMode();
$e_name = true;
@@ -78,13 +77,11 @@
$v_view_policy = $request->getStr('viewPolicy');
$v_edit_policy = $request->getStr('editPolicy');
$v_projects = $request->getArr('projects');
- $v_stat = $request->getStr('status');
$xactions = array();
$type_name = PhabricatorDashboardTransaction::TYPE_NAME;
$type_layout_mode = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE;
- $type_stat = PhabricatorDashboardTransaction::TYPE_STATUS;
$type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -100,9 +97,6 @@
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_edit_policy)
->setNewValue($v_edit_policy);
- $xactions[] = id(new PhabricatorDashboardTransaction())
- ->setTransactionType($type_stat)
- ->setNewValue($v_stat);
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$xactions[] = id(new PhabricatorDashboardTransaction())
@@ -163,13 +157,7 @@
->setLabel(pht('Layout Mode'))
->setName('layout_mode')
->setValue($v_layout_mode)
- ->setOptions($layout_mode_options))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Status'))
- ->setName('status')
- ->setValue($v_stat)
- ->setOptions($dashboard->getStatusNameMap()));
+ ->setOptions($layout_mode_options));
$form->appendControl(
id(new AphrontFormTokenizerControl())
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardManageController.php b/src/applications/dashboard/controller/PhabricatorDashboardManageController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardManageController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardManageController.php
@@ -75,7 +75,7 @@
private function buildHeaderView(PhabricatorDashboard $dashboard) {
$viewer = $this->getRequest()->getUser();
- if ($dashboard->isClosed()) {
+ if ($dashboard->isArchived()) {
$status_icon = 'fa-ban';
$status_color = 'dark';
} else {
@@ -119,8 +119,25 @@
->setName(pht('Edit Dashboard'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI("edit/{$id}/"))
- ->setDisabled(!$can_edit)
- ->setWorkflow(!$can_edit));
+ ->setDisabled(!$can_edit));
+
+ if ($dashboard->isArchived()) {
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Activate Dashboard'))
+ ->setIcon('fa-check')
+ ->setHref($this->getApplicationURI("archive/{$id}/"))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow($can_edit));
+ } else {
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Archive Dashboard'))
+ ->setIcon('fa-ban')
+ ->setHref($this->getApplicationURI("archive/{$id}/"))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow($can_edit));
+ }
$actions->addAction(
id(new PhabricatorActionView())
diff --git a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
--- a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
@@ -140,7 +140,7 @@
->setSlim(true)
->setHandles($project_handles));
- if ($dashboard->isClosed()) {
+ if ($dashboard->isArchived()) {
$item->setDisabled(true);
}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboard.php b/src/applications/dashboard/storage/PhabricatorDashboard.php
--- a/src/applications/dashboard/storage/PhabricatorDashboard.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboard.php
@@ -109,7 +109,7 @@
return $this->assertAttached($this->panels);
}
- public function isClosed() {
+ public function isArchived() {
return ($this->getStatus() == self::STATUS_ARCHIVED);
}

File Metadata

Mime Type
text/plain
Expires
Oct 19 2024, 7:26 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6712214
Default Alt Text
D14725.diff (9 KB)

Event Timeline