mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 20:10:55 +01:00
Add DashboardArchiveController
Summary: So Fancy, Much JavaScript. Ref T9414 Test Plan: Archive a Dashboard, Activate a Dashboard, Edit a Dashboard Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9414 Differential Revision: https://secure.phabricator.com/D14725
This commit is contained in:
parent
02cd235b3d
commit
2e6c69e07e
7 changed files with 91 additions and 18 deletions
|
@ -2042,6 +2042,7 @@ phutil_register_library_map(array(
|
|||
'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 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardApplication' => 'PhabricatorApplication',
|
||||
'PhabricatorDashboardArchiveController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardController' => 'PhabricatorController',
|
||||
'PhabricatorDashboardCopyController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
|
||||
|
|
|
@ -25,6 +25,7 @@ final class PhabricatorDashboardApplication extends PhabricatorApplication {
|
|||
'(?: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',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -67,7 +67,6 @@ final class PhabricatorDashboardEditController
|
|||
}
|
||||
|
||||
$v_name = $dashboard->getName();
|
||||
$v_stat = $dashboard->getStatus();
|
||||
$v_layout_mode = $dashboard->getLayoutConfigObject()->getLayoutMode();
|
||||
$e_name = true;
|
||||
|
||||
|
@ -78,13 +77,11 @@ final class PhabricatorDashboardEditController
|
|||
$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 @@ final class PhabricatorDashboardEditController
|
|||
$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 @@ final class PhabricatorDashboardEditController
|
|||
->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())
|
||||
|
|
|
@ -75,7 +75,7 @@ final class PhabricatorDashboardManageController
|
|||
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 @@ final class PhabricatorDashboardManageController
|
|||
->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())
|
||||
|
|
|
@ -140,7 +140,7 @@ final class PhabricatorDashboardSearchEngine
|
|||
->setSlim(true)
|
||||
->setHandles($project_handles));
|
||||
|
||||
if ($dashboard->isClosed()) {
|
||||
if ($dashboard->isArchived()) {
|
||||
$item->setDisabled(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
|
|||
return $this->assertAttached($this->panels);
|
||||
}
|
||||
|
||||
public function isClosed() {
|
||||
public function isArchived() {
|
||||
return ($this->getStatus() == self::STATUS_ARCHIVED);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue