2011-01-25 22:26:09 +01:00
|
|
|
<?php
|
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
final class DifferentialRevisionEditController
|
|
|
|
extends DifferentialController {
|
2011-01-25 22:26:09 +01:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = idx($data, 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
2011-02-04 00:41:58 +01:00
|
|
|
$request = $this->getRequest();
|
2013-07-01 21:38:42 +02:00
|
|
|
$viewer = $request->getUser();
|
2011-02-04 00:41:58 +01:00
|
|
|
|
|
|
|
if (!$this->id) {
|
|
|
|
$this->id = $request->getInt('revisionID');
|
|
|
|
}
|
|
|
|
|
2011-01-25 22:26:09 +01:00
|
|
|
if ($this->id) {
|
2013-07-01 21:38:42 +02:00
|
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($this->id))
|
2013-07-16 01:01:31 +02:00
|
|
|
->needRelationships(true)
|
|
|
|
->needReviewerStatus(true)
|
2014-03-01 01:49:30 +01:00
|
|
|
->needActiveDiffs(true)
|
2013-09-26 21:37:19 +02:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
2013-07-01 21:38:42 +02:00
|
|
|
->executeOne();
|
2011-01-25 22:26:09 +01:00
|
|
|
if (!$revision) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
} else {
|
2013-10-09 22:58:00 +02:00
|
|
|
$revision = DifferentialRevision::initializeNewRevision($viewer);
|
2014-03-01 01:49:30 +01:00
|
|
|
$revision->attachReviewerStatus(array());
|
2011-01-25 22:26:09 +01:00
|
|
|
}
|
|
|
|
|
2011-01-26 02:17:19 +01:00
|
|
|
$diff_id = $request->getInt('diffID');
|
|
|
|
if ($diff_id) {
|
2013-07-01 21:38:42 +02:00
|
|
|
$diff = id(new DifferentialDiffQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($diff_id))
|
|
|
|
->executeOne();
|
2011-01-26 02:17:19 +01:00
|
|
|
if (!$diff) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
if ($diff->getRevisionID()) {
|
|
|
|
// TODO: Redirect?
|
2014-06-09 20:36:49 +02:00
|
|
|
throw new Exception('This diff is already attached to a revision!');
|
2011-01-26 02:17:19 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$diff = null;
|
|
|
|
}
|
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
if (!$diff) {
|
|
|
|
if (!$revision->getID()) {
|
|
|
|
throw new Exception(
|
|
|
|
pht('You can not create a new revision without a diff!'));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// TODO: It would be nice to show the diff being attached in the UI.
|
|
|
|
}
|
2011-02-03 04:38:43 +01:00
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
$field_list = PhabricatorCustomField::getObjectFields(
|
|
|
|
$revision,
|
|
|
|
PhabricatorCustomField::ROLE_EDIT);
|
|
|
|
$field_list
|
|
|
|
->setViewer($viewer)
|
|
|
|
->readFieldsFromStorage($revision);
|
2011-01-25 22:26:09 +01:00
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
$validation_exception = null;
|
2011-02-03 04:38:43 +01:00
|
|
|
if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
|
2014-03-01 01:49:30 +01:00
|
|
|
$xactions = $field_list->buildFieldTransactionsFromRequest(
|
|
|
|
new DifferentialTransaction(),
|
|
|
|
$request);
|
|
|
|
|
|
|
|
if ($diff) {
|
|
|
|
$xactions[] = id(new DifferentialTransaction())
|
|
|
|
->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
|
|
|
|
->setNewValue($diff->getPHID());
|
2011-08-10 22:46:01 +02:00
|
|
|
}
|
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
$comments = $request->getStr('comments');
|
|
|
|
if (strlen($comments)) {
|
|
|
|
$xactions[] = id(new DifferentialTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
|
|
->attachComment(
|
|
|
|
id(new DifferentialTransactionComment())
|
|
|
|
->setContent($comments));
|
2011-01-25 22:26:09 +01:00
|
|
|
}
|
2011-02-03 04:38:43 +01:00
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
$editor = id(new DifferentialTransactionEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnNoEffect(true);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$editor->applyTransactions($revision, $xactions);
|
|
|
|
$revision_uri = '/D'.$revision->getID();
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($revision_uri);
|
|
|
|
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
|
|
|
$validation_exception = $ex;
|
|
|
|
}
|
2011-08-14 23:28:08 +02:00
|
|
|
}
|
2011-01-25 22:26:09 +01:00
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
|
2011-01-25 22:26:09 +01:00
|
|
|
$form = new AphrontFormView();
|
2011-01-31 03:52:29 +01:00
|
|
|
$form->setUser($request->getUser());
|
2011-01-26 02:17:19 +01:00
|
|
|
if ($diff) {
|
|
|
|
$form->addHiddenInput('diffID', $diff->getID());
|
|
|
|
}
|
|
|
|
|
2011-01-25 22:26:09 +01:00
|
|
|
if ($revision->getID()) {
|
2011-01-25 22:48:05 +01:00
|
|
|
$form->setAction('/differential/revision/edit/'.$revision->getID().'/');
|
2011-01-25 22:26:09 +01:00
|
|
|
} else {
|
|
|
|
$form->setAction('/differential/revision/edit/');
|
|
|
|
}
|
|
|
|
|
2011-02-05 02:53:14 +01:00
|
|
|
if ($diff && $revision->getID()) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
2013-01-24 19:46:47 +01:00
|
|
|
->setLabel(pht('Comments'))
|
2011-02-05 02:53:14 +01:00
|
|
|
->setName('comments')
|
2013-01-24 19:46:47 +01:00
|
|
|
->setCaption(pht("Explain what's new in this diff."))
|
2011-02-05 02:53:14 +01:00
|
|
|
->setValue($request->getStr('comments')))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-01-24 19:46:47 +01:00
|
|
|
->setValue(pht('Save')))
|
2011-02-05 02:53:14 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormDividerControl()));
|
|
|
|
}
|
|
|
|
|
2014-03-01 01:49:30 +01:00
|
|
|
$field_list->appendFieldsToForm($form);
|
2011-01-26 02:17:19 +01:00
|
|
|
|
|
|
|
$submit = id(new AphrontFormSubmitControl())
|
|
|
|
->setValue('Save');
|
|
|
|
if ($diff) {
|
|
|
|
$submit->addCancelButton('/differential/diff/'.$diff->getID().'/');
|
|
|
|
} else {
|
|
|
|
$submit->addCancelButton('/D'.$revision->getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
$form->appendChild($submit);
|
2011-01-25 22:26:09 +01:00
|
|
|
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2011-01-25 22:26:09 +01:00
|
|
|
if ($revision->getID()) {
|
2011-02-05 02:53:14 +01:00
|
|
|
if ($diff) {
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
$title = pht('Update Differential Revision');
|
2013-12-19 02:47:34 +01:00
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
'D'.$revision->getID(),
|
|
|
|
'/differential/diff/'.$diff->getID().'/');
|
2011-02-05 02:53:14 +01:00
|
|
|
} else {
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
$title = pht('Edit Differential Revision');
|
2013-12-19 02:47:34 +01:00
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
'D'.$revision->getID(),
|
|
|
|
'/D'.$revision->getID());
|
2011-02-05 02:53:14 +01:00
|
|
|
}
|
2011-01-25 22:26:09 +01:00
|
|
|
} else {
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
$title = pht('Create New Differential Revision');
|
2011-01-25 22:26:09 +01:00
|
|
|
}
|
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-27 00:45:58 +02:00
|
|
|
->setHeaderText($title)
|
2014-03-01 01:49:30 +01:00
|
|
|
->setValidationException($validation_exception)
|
2013-08-27 00:45:58 +02:00
|
|
|
->setForm($form);
|
|
|
|
|
2013-12-19 02:47:34 +01:00
|
|
|
$crumbs->addTextCrumb($title);
|
2011-01-25 22:26:09 +01:00
|
|
|
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
return $this->buildApplicationPage(
|
2011-01-25 22:26:09 +01:00
|
|
|
array(
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
$crumbs,
|
2013-08-27 00:45:58 +02:00
|
|
|
$form_box,
|
2014-03-01 01:49:30 +01:00
|
|
|
),
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
array(
|
|
|
|
'title' => $title,
|
2011-01-25 22:26:09 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|