mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Update Phlux for handleRequest
Summary: Ref T8628. Updates Phlux Test Plan: New var, list vars, edit vars Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T8628 Differential Revision: https://secure.phabricator.com/D14267
This commit is contained in:
parent
a8e9da4a56
commit
057d62d570
3 changed files with 24 additions and 37 deletions
|
@ -2,35 +2,29 @@
|
|||
|
||||
final class PhluxEditController extends PhluxController {
|
||||
|
||||
private $key;
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$key = $request->getURIData('key');
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->key = idx($data, 'key');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$is_new = ($this->key === null);
|
||||
$is_new = ($key === null);
|
||||
if ($is_new) {
|
||||
$var = new PhluxVariable();
|
||||
$var->setViewPolicy(PhabricatorPolicies::POLICY_USER);
|
||||
$var->setEditPolicy(PhabricatorPolicies::POLICY_USER);
|
||||
} else {
|
||||
$var = id(new PhluxVariableQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->withKeys(array($this->key))
|
||||
->withKeys(array($key))
|
||||
->executeOne();
|
||||
if (!$var) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
$view_uri = $this->getApplicationURI('/view/'.$this->key.'/');
|
||||
$view_uri = $this->getApplicationURI('/view/'.$key.'/');
|
||||
}
|
||||
|
||||
$e_key = ($is_new ? true : null);
|
||||
|
@ -67,7 +61,7 @@ final class PhluxEditController extends PhluxController {
|
|||
|
||||
if (!$errors) {
|
||||
$editor = id(new PhluxVariableEditor())
|
||||
->setActor($user)
|
||||
->setActor($viewer)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
|
@ -110,12 +104,12 @@ final class PhluxEditController extends PhluxController {
|
|||
}
|
||||
|
||||
$policies = id(new PhabricatorPolicyQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->setObject($var)
|
||||
->execute();
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setValue($var->getVariableKey())
|
||||
|
@ -161,7 +155,7 @@ final class PhluxEditController extends PhluxController {
|
|||
$title = pht('Create Variable');
|
||||
$crumbs->addTextCrumb($title, $request->getRequestURI());
|
||||
} else {
|
||||
$title = pht('Edit %s', $this->key);
|
||||
$title = pht('Edit %s', $key);
|
||||
$crumbs->addTextCrumb($title, $request->getRequestURI());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
final class PhluxListController extends PhluxController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$pager = new AphrontCursorPagerView();
|
||||
$pager->readFromRequest($request);
|
||||
$query = id(new PhluxVariableQuery())
|
||||
->setViewer($user);
|
||||
->setViewer($viewer);
|
||||
|
||||
$vars = $query->executeWithCursorPager($pager);
|
||||
|
||||
|
@ -22,7 +21,7 @@ final class PhluxListController extends PhluxController {
|
|||
$item->setHref($this->getApplicationURI('/view/'.$key.'/'));
|
||||
$item->addIcon(
|
||||
'none',
|
||||
phabricator_datetime($var->getDateModified(), $user));
|
||||
phabricator_datetime($var->getDateModified(), $viewer));
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
|
|
@ -2,19 +2,13 @@
|
|||
|
||||
final class PhluxViewController extends PhluxController {
|
||||
|
||||
private $key;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->key = $data['key'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$key = $request->getURIData('key');
|
||||
|
||||
$var = id(new PhluxVariableQuery())
|
||||
->setViewer($user)
|
||||
->withKeys(array($this->key))
|
||||
->setViewer($viewer)
|
||||
->withKeys(array($key))
|
||||
->executeOne();
|
||||
|
||||
if (!$var) {
|
||||
|
@ -29,16 +23,16 @@ final class PhluxViewController extends PhluxController {
|
|||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($title)
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($var);
|
||||
|
||||
$actions = id(new PhabricatorActionListView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setObjectURI($request->getRequestURI())
|
||||
->setObject($var);
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$user,
|
||||
$viewer,
|
||||
$var,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
|
@ -53,7 +47,7 @@ final class PhluxViewController extends PhluxController {
|
|||
$display_value = json_encode($var->getVariableValue());
|
||||
|
||||
$properties = id(new PHUIPropertyListView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setObject($var)
|
||||
->setActionList($actions)
|
||||
->addProperty(pht('Value'), $display_value);
|
||||
|
|
Loading…
Reference in a new issue