diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8d31e0fa2d..4461c91d0d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -756,6 +756,7 @@ phutil_register_library_map(array( 'PhabricatorWorkerTask' => 'infrastructure/daemon/workers/storage/task', 'PhabricatorWorkerTaskData' => 'infrastructure/daemon/workers/storage/taskdata', 'PhabricatorWorkerTaskDetailController' => 'applications/daemon/controller/workertaskdetail', + 'PhabricatorWorkerTaskUpdateController' => 'applications/daemon/controller/workertaskupdate', 'PhabricatorXHPASTViewController' => 'applications/xhpastview/controller/base', 'PhabricatorXHPASTViewDAO' => 'applications/xhpastview/storage/base', 'PhabricatorXHPASTViewFrameController' => 'applications/xhpastview/controller/viewframe', @@ -1421,6 +1422,7 @@ phutil_register_library_map(array( 'PhabricatorWorkerTask' => 'PhabricatorWorkerDAO', 'PhabricatorWorkerTaskData' => 'PhabricatorWorkerDAO', 'PhabricatorWorkerTaskDetailController' => 'PhabricatorDaemonController', + 'PhabricatorWorkerTaskUpdateController' => 'PhabricatorDaemonController', 'PhabricatorXHPASTViewController' => 'PhabricatorController', 'PhabricatorXHPASTViewDAO' => 'PhabricatorLiskDAO', 'PhabricatorXHPASTViewFrameController' => 'PhabricatorXHPASTViewController', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index ffec94c76e..6636fc274d 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -259,6 +259,8 @@ class AphrontDefaultApplicationConfiguration '/daemon/' => array( 'task/(?P\d+)/$' => 'PhabricatorWorkerTaskDetailController', + 'task/(?P\d+)/(?P[^/]+)/$' + => 'PhabricatorWorkerTaskUpdateController', 'log/' => array( '$' => 'PhabricatorDaemonLogListController', 'combined/$' => 'PhabricatorDaemonCombinedLogController', diff --git a/src/applications/daemon/controller/workertaskdetail/PhabricatorWorkerTaskDetailController.php b/src/applications/daemon/controller/workertaskdetail/PhabricatorWorkerTaskDetailController.php index 3eb9d24d1e..02198e5e74 100644 --- a/src/applications/daemon/controller/workertaskdetail/PhabricatorWorkerTaskDetailController.php +++ b/src/applications/daemon/controller/workertaskdetail/PhabricatorWorkerTaskDetailController.php @@ -1,7 +1,7 @@ appendChild( id(new AphrontFormSubmitControl()) - ->addCancelButton('/daemon/')); + ->addCancelButton('/daemon/', 'Back')); $panel = new AphrontPanelView(); $panel->setHeader('Task Detail'); $panel->setWidth(AphrontPanelView::WIDTH_WIDE); $panel->appendChild($form); + $panel->addButton( + javelin_render_tag( + 'a', + array( + 'href' => '/daemon/task/'.$task->getID().'/delete/', + 'class' => 'button grey', + 'sigil' => 'workflow', + ), + 'Delete Task')); + + $panel->addButton( + javelin_render_tag( + 'a', + array( + 'href' => '/daemon/task/'.$task->getID().'/release/', + 'class' => 'button grey', + 'sigil' => 'workflow', + ), + 'Free Lease')); + return $this->buildStandardPageResponse( $panel, array( diff --git a/src/applications/daemon/controller/workertaskdetail/__init__.php b/src/applications/daemon/controller/workertaskdetail/__init__.php index 66839c4cf7..6289238337 100644 --- a/src/applications/daemon/controller/workertaskdetail/__init__.php +++ b/src/applications/daemon/controller/workertaskdetail/__init__.php @@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/repository/storage/commit'); phutil_require_module('phabricator', 'applications/repository/storage/repository'); phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task'); phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/taskdata'); +phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/control/markup'); phutil_require_module('phabricator', 'view/form/control/static'); diff --git a/src/applications/daemon/controller/workertaskupdate/PhabricatorWorkerTaskUpdateController.php b/src/applications/daemon/controller/workertaskupdate/PhabricatorWorkerTaskUpdateController.php new file mode 100644 index 0000000000..34c570de91 --- /dev/null +++ b/src/applications/daemon/controller/workertaskupdate/PhabricatorWorkerTaskUpdateController.php @@ -0,0 +1,82 @@ +id = $data['id']; + $this->action = $data['action']; + } + + public function processRequest() { + $request = $this->getRequest(); + $user = $request->getUser(); + + $task = id(new PhabricatorWorkerTask())->load($this->id); + if (!$task) { + return new Aphront404Response(); + } + + if ($request->isFormPost()) { + switch ($this->action) { + case 'delete': + $task->delete(); + break; + case 'release': + $task->setLeaseOwner(null); + $task->setLeaseExpires(time()); + $task->save(); + break; + } + return id(new AphrontRedirectResponse())->setURI('/daemon/'); + } + + $dialog = new AphrontDialogView(); + $dialog->setUser($user); + + switch ($this->action) { + case 'delete': + $dialog->setTitle('Really delete task?'); + $dialog->appendChild( + '

The work this task represents will never be performed if you '. + 'delete it. Are you sure you want to delete it?

'); + $dialog->addSubmitButton('Delete Task'); + break; + case 'release': + $dialog->setTitle('Really free task lease?'); + $dialog->appendChild( + '

If the process which owns the task lease is still doing work '. + 'on it, the work may be performed twice. Are you sure you '. + 'want to free the lease?

'); + $dialog->addSubmitButton('Free Lease'); + break; + default: + return new Aphront404Response(); + } + + + $dialog->addCancelButton('/daemon/'); + + return id(new AphrontDialogResponse())->setDialog($dialog); + } + +} diff --git a/src/applications/daemon/controller/workertaskupdate/__init__.php b/src/applications/daemon/controller/workertaskupdate/__init__.php new file mode 100644 index 0000000000..de6e295a20 --- /dev/null +++ b/src/applications/daemon/controller/workertaskupdate/__init__.php @@ -0,0 +1,19 @@ +