2011-01-25 13:26:09 -08:00
|
|
|
<?php
|
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
final class DifferentialRevisionEditController
|
|
|
|
extends DifferentialController {
|
2011-01-25 13:26:09 -08:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = idx($data, 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
2011-02-03 15:41:58 -08:00
|
|
|
$request = $this->getRequest();
|
2013-07-01 12:38:42 -07:00
|
|
|
$viewer = $request->getUser();
|
2011-02-03 15:41:58 -08:00
|
|
|
|
|
|
|
if (!$this->id) {
|
|
|
|
$this->id = $request->getInt('revisionID');
|
|
|
|
}
|
|
|
|
|
2011-01-25 13:26:09 -08:00
|
|
|
if ($this->id) {
|
2013-07-01 12:38:42 -07:00
|
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($this->id))
|
2013-07-15 16:01:31 -07:00
|
|
|
->needRelationships(true)
|
|
|
|
->needReviewerStatus(true)
|
2014-02-28 16:49:30 -08:00
|
|
|
->needActiveDiffs(true)
|
2013-09-26 12:37:19 -07:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
2013-07-01 12:38:42 -07:00
|
|
|
->executeOne();
|
2011-01-25 13:26:09 -08:00
|
|
|
if (!$revision) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
} else {
|
2013-10-09 13:58:00 -07:00
|
|
|
$revision = DifferentialRevision::initializeNewRevision($viewer);
|
2014-02-28 16:49:30 -08:00
|
|
|
$revision->attachReviewerStatus(array());
|
2011-01-25 13:26:09 -08:00
|
|
|
}
|
|
|
|
|
2011-01-25 17:17:19 -08:00
|
|
|
$diff_id = $request->getInt('diffID');
|
|
|
|
if ($diff_id) {
|
2013-07-01 12:38:42 -07:00
|
|
|
$diff = id(new DifferentialDiffQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($diff_id))
|
|
|
|
->executeOne();
|
2011-01-25 17:17:19 -08:00
|
|
|
if (!$diff) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
if ($diff->getRevisionID()) {
|
|
|
|
// TODO: Redirect?
|
2015-05-22 17:27:56 +10:00
|
|
|
throw new Exception(
|
|
|
|
pht('This diff is already attached to a revision!'));
|
2011-01-25 17:17:19 -08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$diff = null;
|
|
|
|
}
|
|
|
|
|
2014-02-28 16:49:30 -08: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-02 19:38:43 -08:00
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
$field_list = PhabricatorCustomField::getObjectFields(
|
|
|
|
$revision,
|
|
|
|
PhabricatorCustomField::ROLE_EDIT);
|
|
|
|
$field_list
|
|
|
|
->setViewer($viewer)
|
|
|
|
->readFieldsFromStorage($revision);
|
2011-01-25 13:26:09 -08:00
|
|
|
|
Differential - refine selecting a repository diff --> revision workflow
Summary: Fixes T6200. Ref T6237. When creating a diff from the web view, allow the user to select the repository at that time. When viewing a diff that has no associated revision and then creating a revision, pass along the repository phid to the create revision controller. Within the create revision controller, default the repository selector to this repository phid. Finally, in the editor, stop aggressively resetting the repository phid for every TYPE_UPDATE; rather, do so if its not a new object -- the diff should reign supreme in that case -- or if there's no repository -- let the diff be the guide.
Test Plan:
- made a diff with an associated repo, made a revision from the diff, saw the associated repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo to nothing and it stuck on save!
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T6237, T6200
Differential Revision: https://secure.phabricator.com/D10872
2014-11-19 11:11:09 -08:00
|
|
|
if ($request->getStr('viaDiffView') && $diff) {
|
|
|
|
$repo_key = id(new DifferentialRepositoryField())->getFieldKey();
|
|
|
|
$repository_field = idx(
|
|
|
|
$field_list->getFields(),
|
|
|
|
$repo_key);
|
|
|
|
if ($repository_field) {
|
|
|
|
$repository_field->setValue($request->getStr($repo_key));
|
|
|
|
}
|
2014-11-19 12:16:07 -08:00
|
|
|
$view_policy_key = id(new DifferentialViewPolicyField())->getFieldKey();
|
|
|
|
$view_policy_field = idx(
|
|
|
|
$field_list->getFields(),
|
|
|
|
$view_policy_key);
|
|
|
|
if ($view_policy_field) {
|
|
|
|
$view_policy_field->setValue($diff->getViewPolicy());
|
|
|
|
}
|
Differential - refine selecting a repository diff --> revision workflow
Summary: Fixes T6200. Ref T6237. When creating a diff from the web view, allow the user to select the repository at that time. When viewing a diff that has no associated revision and then creating a revision, pass along the repository phid to the create revision controller. Within the create revision controller, default the repository selector to this repository phid. Finally, in the editor, stop aggressively resetting the repository phid for every TYPE_UPDATE; rather, do so if its not a new object -- the diff should reign supreme in that case -- or if there's no repository -- let the diff be the guide.
Test Plan:
- made a diff with an associated repo, made a revision from the diff, saw the associated repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo to nothing and it stuck on save!
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T6237, T6200
Differential Revision: https://secure.phabricator.com/D10872
2014-11-19 11:11:09 -08:00
|
|
|
}
|
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
$validation_exception = null;
|
2011-02-02 19:38:43 -08:00
|
|
|
if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
|
Differential - refine selecting a repository diff --> revision workflow
Summary: Fixes T6200. Ref T6237. When creating a diff from the web view, allow the user to select the repository at that time. When viewing a diff that has no associated revision and then creating a revision, pass along the repository phid to the create revision controller. Within the create revision controller, default the repository selector to this repository phid. Finally, in the editor, stop aggressively resetting the repository phid for every TYPE_UPDATE; rather, do so if its not a new object -- the diff should reign supreme in that case -- or if there's no repository -- let the diff be the guide.
Test Plan:
- made a diff with an associated repo, made a revision from the diff, saw the associated repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo to nothing and it stuck on save!
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T6237, T6200
Differential Revision: https://secure.phabricator.com/D10872
2014-11-19 11:11:09 -08:00
|
|
|
|
|
|
|
$editor = id(new DifferentialTransactionEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnNoEffect(true);
|
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
$xactions = $field_list->buildFieldTransactionsFromRequest(
|
|
|
|
new DifferentialTransaction(),
|
|
|
|
$request);
|
|
|
|
|
|
|
|
if ($diff) {
|
Differential - refine selecting a repository diff --> revision workflow
Summary: Fixes T6200. Ref T6237. When creating a diff from the web view, allow the user to select the repository at that time. When viewing a diff that has no associated revision and then creating a revision, pass along the repository phid to the create revision controller. Within the create revision controller, default the repository selector to this repository phid. Finally, in the editor, stop aggressively resetting the repository phid for every TYPE_UPDATE; rather, do so if its not a new object -- the diff should reign supreme in that case -- or if there's no repository -- let the diff be the guide.
Test Plan:
- made a diff with an associated repo, made a revision from the diff, saw the associated repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo to nothing and it stuck on save!
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T6237, T6200
Differential Revision: https://secure.phabricator.com/D10872
2014-11-19 11:11:09 -08:00
|
|
|
$repository_phid = null;
|
|
|
|
$repository_tokenizer = $request->getArr(
|
|
|
|
id(new DifferentialRepositoryField())->getFieldKey());
|
|
|
|
if ($repository_tokenizer) {
|
|
|
|
$repository_phid = reset($repository_tokenizer);
|
|
|
|
}
|
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
$xactions[] = id(new DifferentialTransaction())
|
|
|
|
->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
|
|
|
|
->setNewValue($diff->getPHID());
|
Differential - refine selecting a repository diff --> revision workflow
Summary: Fixes T6200. Ref T6237. When creating a diff from the web view, allow the user to select the repository at that time. When viewing a diff that has no associated revision and then creating a revision, pass along the repository phid to the create revision controller. Within the create revision controller, default the repository selector to this repository phid. Finally, in the editor, stop aggressively resetting the repository phid for every TYPE_UPDATE; rather, do so if its not a new object -- the diff should reign supreme in that case -- or if there's no repository -- let the diff be the guide.
Test Plan:
- made a diff with an associated repo, made a revision from the diff, saw the associated repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo and it stuck on save!
- made a diff with an associated repo, made a revision from the diff but changed the repo to nothing and it stuck on save!
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T6237, T6200
Differential Revision: https://secure.phabricator.com/D10872
2014-11-19 11:11:09 -08:00
|
|
|
|
|
|
|
$editor->setRepositoryPHIDOverride($repository_phid);
|
2011-08-10 13:46:01 -07:00
|
|
|
}
|
|
|
|
|
2014-02-28 16:49:30 -08: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 13:26:09 -08:00
|
|
|
}
|
2011-02-02 19:38:43 -08:00
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
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 14:28:08 -07:00
|
|
|
}
|
2011-01-25 13:26:09 -08:00
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
|
2011-01-25 13:26:09 -08:00
|
|
|
$form = new AphrontFormView();
|
2011-01-30 18:52:29 -08:00
|
|
|
$form->setUser($request->getUser());
|
2011-01-25 17:17:19 -08:00
|
|
|
if ($diff) {
|
|
|
|
$form->addHiddenInput('diffID', $diff->getID());
|
|
|
|
}
|
|
|
|
|
2011-01-25 13:26:09 -08:00
|
|
|
if ($revision->getID()) {
|
2011-01-25 13:48:05 -08:00
|
|
|
$form->setAction('/differential/revision/edit/'.$revision->getID().'/');
|
2011-01-25 13:26:09 -08:00
|
|
|
} else {
|
|
|
|
$form->setAction('/differential/revision/edit/');
|
|
|
|
}
|
|
|
|
|
2011-02-04 17:53:14 -08:00
|
|
|
if ($diff && $revision->getID()) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
2013-01-24 10:46:47 -08:00
|
|
|
->setLabel(pht('Comments'))
|
2011-02-04 17:53:14 -08:00
|
|
|
->setName('comments')
|
2013-01-24 10:46:47 -08:00
|
|
|
->setCaption(pht("Explain what's new in this diff."))
|
2011-02-04 17:53:14 -08:00
|
|
|
->setValue($request->getStr('comments')))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-01-24 10:46:47 -08:00
|
|
|
->setValue(pht('Save')))
|
2011-02-04 17:53:14 -08:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormDividerControl()));
|
|
|
|
}
|
|
|
|
|
2014-02-28 16:49:30 -08:00
|
|
|
$field_list->appendFieldsToForm($form);
|
2011-01-25 17:17:19 -08: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 13:26:09 -08: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 14:07:06 -07:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2011-01-25 13:26:09 -08:00
|
|
|
if ($revision->getID()) {
|
2011-02-04 17:53:14 -08: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 14:07:06 -07:00
|
|
|
$title = pht('Update Differential Revision');
|
2013-12-18 17:47:34 -08:00
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
'D'.$revision->getID(),
|
|
|
|
'/differential/diff/'.$diff->getID().'/');
|
2011-02-04 17:53:14 -08: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 14:07:06 -07:00
|
|
|
$title = pht('Edit Differential Revision');
|
2013-12-18 17:47:34 -08:00
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
'D'.$revision->getID(),
|
|
|
|
'/D'.$revision->getID());
|
2011-02-04 17:53:14 -08:00
|
|
|
}
|
2011-01-25 13:26:09 -08: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 14:07:06 -07:00
|
|
|
$title = pht('Create New Differential Revision');
|
2011-01-25 13:26:09 -08:00
|
|
|
}
|
|
|
|
|
2013-09-25 11:23:29 -07:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 15:45:58 -07:00
|
|
|
->setHeaderText($title)
|
2014-02-28 16:49:30 -08:00
|
|
|
->setValidationException($validation_exception)
|
2013-08-26 15:45:58 -07:00
|
|
|
->setForm($form);
|
|
|
|
|
2013-12-18 17:47:34 -08:00
|
|
|
$crumbs->addTextCrumb($title);
|
2011-01-25 13:26:09 -08: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 14:07:06 -07:00
|
|
|
return $this->buildApplicationPage(
|
2011-01-25 13:26:09 -08: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 14:07:06 -07:00
|
|
|
$crumbs,
|
2013-08-26 15:45:58 -07:00
|
|
|
$form_box,
|
2014-02-28 16:49:30 -08: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 14:07:06 -07:00
|
|
|
array(
|
|
|
|
'title' => $title,
|
2011-01-25 13:26:09 -08:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|