mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-29 08:50:58 +01:00
Add PasteArchiveController
Summary: Makes this more consistent. Also clean up spacing. Ref T9414 Test Plan: Archive/Activate Paste, Edit Paste Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9414 Differential Revision: https://secure.phabricator.com/D14724
This commit is contained in:
parent
23bb1eeec0
commit
02cd235b3d
7 changed files with 99 additions and 17 deletions
|
@ -80,7 +80,7 @@ return array(
|
||||||
'rsrc/css/application/maniphest/task-summary.css' => '11cc5344',
|
'rsrc/css/application/maniphest/task-summary.css' => '11cc5344',
|
||||||
'rsrc/css/application/objectselector/object-selector.css' => '85ee8ce6',
|
'rsrc/css/application/objectselector/object-selector.css' => '85ee8ce6',
|
||||||
'rsrc/css/application/owners/owners-path-editor.css' => '2f00933b',
|
'rsrc/css/application/owners/owners-path-editor.css' => '2f00933b',
|
||||||
'rsrc/css/application/paste/paste.css' => 'b2f5a543',
|
'rsrc/css/application/paste/paste.css' => 'a5157c48',
|
||||||
'rsrc/css/application/people/people-profile.css' => '25970776',
|
'rsrc/css/application/people/people-profile.css' => '25970776',
|
||||||
'rsrc/css/application/phame/phame.css' => 'cea3c9e1',
|
'rsrc/css/application/phame/phame.css' => 'cea3c9e1',
|
||||||
'rsrc/css/application/pholio/pholio-edit.css' => '3ad9d1ee',
|
'rsrc/css/application/pholio/pholio-edit.css' => '3ad9d1ee',
|
||||||
|
@ -730,7 +730,7 @@ return array(
|
||||||
'multirow-row-manager' => 'b5d57730',
|
'multirow-row-manager' => 'b5d57730',
|
||||||
'owners-path-editor' => 'aa1733d0',
|
'owners-path-editor' => 'aa1733d0',
|
||||||
'owners-path-editor-css' => '2f00933b',
|
'owners-path-editor-css' => '2f00933b',
|
||||||
'paste-css' => 'b2f5a543',
|
'paste-css' => 'a5157c48',
|
||||||
'path-typeahead' => 'f7fc67ec',
|
'path-typeahead' => 'f7fc67ec',
|
||||||
'people-profile-css' => '25970776',
|
'people-profile-css' => '25970776',
|
||||||
'phabricator-action-list-view-css' => 'c5eba19d',
|
'phabricator-action-list-view-css' => 'c5eba19d',
|
||||||
|
|
|
@ -2616,6 +2616,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPasswordSettingsPanel' => 'applications/settings/panel/PhabricatorPasswordSettingsPanel.php',
|
'PhabricatorPasswordSettingsPanel' => 'applications/settings/panel/PhabricatorPasswordSettingsPanel.php',
|
||||||
'PhabricatorPaste' => 'applications/paste/storage/PhabricatorPaste.php',
|
'PhabricatorPaste' => 'applications/paste/storage/PhabricatorPaste.php',
|
||||||
'PhabricatorPasteApplication' => 'applications/paste/application/PhabricatorPasteApplication.php',
|
'PhabricatorPasteApplication' => 'applications/paste/application/PhabricatorPasteApplication.php',
|
||||||
|
'PhabricatorPasteArchiveController' => 'applications/paste/controller/PhabricatorPasteArchiveController.php',
|
||||||
'PhabricatorPasteConfigOptions' => 'applications/paste/config/PhabricatorPasteConfigOptions.php',
|
'PhabricatorPasteConfigOptions' => 'applications/paste/config/PhabricatorPasteConfigOptions.php',
|
||||||
'PhabricatorPasteController' => 'applications/paste/controller/PhabricatorPasteController.php',
|
'PhabricatorPasteController' => 'applications/paste/controller/PhabricatorPasteController.php',
|
||||||
'PhabricatorPasteDAO' => 'applications/paste/storage/PhabricatorPasteDAO.php',
|
'PhabricatorPasteDAO' => 'applications/paste/storage/PhabricatorPasteDAO.php',
|
||||||
|
@ -6824,6 +6825,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSpacesInterface',
|
'PhabricatorSpacesInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorPasteApplication' => 'PhabricatorApplication',
|
'PhabricatorPasteApplication' => 'PhabricatorApplication',
|
||||||
|
'PhabricatorPasteArchiveController' => 'PhabricatorPasteController',
|
||||||
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
'PhabricatorPasteController' => 'PhabricatorController',
|
'PhabricatorPasteController' => 'PhabricatorController',
|
||||||
'PhabricatorPasteDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorPasteDAO' => 'PhabricatorLiskDAO',
|
||||||
|
|
|
@ -41,6 +41,7 @@ final class PhabricatorPasteApplication extends PhabricatorApplication {
|
||||||
'create/' => 'PhabricatorPasteEditController',
|
'create/' => 'PhabricatorPasteEditController',
|
||||||
$this->getEditRoutePattern('edit/') => 'PhabricatorPasteEditController',
|
$this->getEditRoutePattern('edit/') => 'PhabricatorPasteEditController',
|
||||||
'raw/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteRawController',
|
'raw/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteRawController',
|
||||||
|
'archive/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteArchiveController',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPasteArchiveController
|
||||||
|
extends PhabricatorPasteController {
|
||||||
|
|
||||||
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $request->getViewer();
|
||||||
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
|
$paste = id(new PhabricatorPasteQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($id))
|
||||||
|
->requireCapabilities(
|
||||||
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
|
))
|
||||||
|
->executeOne();
|
||||||
|
if (!$paste) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$view_uri = '/P'.$paste->getID();
|
||||||
|
|
||||||
|
if ($request->isFormPost()) {
|
||||||
|
if ($paste->isArchived()) {
|
||||||
|
$new_status = PhabricatorPaste::STATUS_ACTIVE;
|
||||||
|
} else {
|
||||||
|
$new_status = PhabricatorPaste::STATUS_ARCHIVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
$xactions = array();
|
||||||
|
|
||||||
|
$xactions[] = id(new PhabricatorPasteTransaction())
|
||||||
|
->setTransactionType(PhabricatorPasteTransaction::TYPE_STATUS)
|
||||||
|
->setNewValue($new_status);
|
||||||
|
|
||||||
|
id(new PhabricatorPasteEditor())
|
||||||
|
->setActor($viewer)
|
||||||
|
->setContentSourceFromRequest($request)
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContinueOnMissingFields(true)
|
||||||
|
->applyTransactions($paste, $xactions);
|
||||||
|
|
||||||
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($paste->isArchived()) {
|
||||||
|
$title = pht('Activate Paste');
|
||||||
|
$body = pht('This paste will become consumable again.');
|
||||||
|
$button = pht('Activate Paste');
|
||||||
|
} else {
|
||||||
|
$title = pht('Archive Paste');
|
||||||
|
$body = pht('This paste will be marked as expired.');
|
||||||
|
$button = pht('Archive Paste');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->newDialog()
|
||||||
|
->setTitle($title)
|
||||||
|
->appendChild($body)
|
||||||
|
->addCancelButton($view_uri)
|
||||||
|
->addSubmitButton($button);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -129,22 +129,43 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||||
|
|
||||||
$id = $paste->getID();
|
$id = $paste->getID();
|
||||||
|
|
||||||
return id(new PhabricatorActionListView())
|
$action_list = id(new PhabricatorActionListView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setObject($paste)
|
->setObject($paste)
|
||||||
->setObjectURI($this->getRequest()->getRequestURI())
|
->setObjectURI($this->getRequest()->getRequestURI());
|
||||||
->addAction(
|
|
||||||
|
$action_list->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Paste'))
|
->setName(pht('Edit Paste'))
|
||||||
->setIcon('fa-pencil')
|
->setIcon('fa-pencil')
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(!$can_edit)
|
->setHref($this->getApplicationURI("edit/{$id}/")));
|
||||||
->setHref($this->getApplicationURI("edit/{$id}/")))
|
|
||||||
->addAction(
|
if ($paste->isArchived()) {
|
||||||
|
$action_list->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Activate Paste'))
|
||||||
|
->setIcon('fa-check')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow($can_edit)
|
||||||
|
->setHref($this->getApplicationURI("archive/{$id}/")));
|
||||||
|
} else {
|
||||||
|
$action_list->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Archive Paste'))
|
||||||
|
->setIcon('fa-ban')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow($can_edit)
|
||||||
|
->setHref($this->getApplicationURI("archive/{$id}/")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$action_list->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('View Raw File'))
|
->setName(pht('View Raw File'))
|
||||||
->setIcon('fa-file-text-o')
|
->setIcon('fa-file-text-o')
|
||||||
->setHref($this->getApplicationURI("raw/{$id}/")));
|
->setHref($this->getApplicationURI("raw/{$id}/")));
|
||||||
|
|
||||||
|
return $action_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildPropertyView(
|
private function buildPropertyView(
|
||||||
|
|
|
@ -76,13 +76,6 @@ final class PhabricatorPasteEditEngine
|
||||||
->setIsCopyable(true)
|
->setIsCopyable(true)
|
||||||
->setValue($object->getLanguage())
|
->setValue($object->getLanguage())
|
||||||
->setOptions($langs),
|
->setOptions($langs),
|
||||||
id(new PhabricatorSelectEditField())
|
|
||||||
->setKey('status')
|
|
||||||
->setLabel(pht('Status'))
|
|
||||||
->setDescription(pht('Archive the paste.'))
|
|
||||||
->setTransactionType(PhabricatorPasteTransaction::TYPE_STATUS)
|
|
||||||
->setValue($object->getStatus())
|
|
||||||
->setOptions(PhabricatorPaste::getStatusNameMap()),
|
|
||||||
id(new PhabricatorTextAreaEditField())
|
id(new PhabricatorTextAreaEditField())
|
||||||
->setKey('text')
|
->setKey('text')
|
||||||
->setLabel(pht('Text'))
|
->setLabel(pht('Text'))
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.container-of-paste {
|
.container-of-paste {
|
||||||
margin: 16px;
|
margin: 16px 16px 0 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.device .container-of-paste {
|
.device .container-of-paste {
|
||||||
margin: 8px;
|
margin: 8px 8px 0 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.paste-embed {
|
.paste-embed {
|
||||||
|
|
Loading…
Reference in a new issue