2011-01-30 21:08:40 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DifferentialCommentSaveController extends DifferentialController {
|
2011-01-30 21:08:40 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
if (!$request->isFormPost()) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$revision_id = $request->getInt('revision_id');
|
|
|
|
$revision = id(new DifferentialRevision())->load($revision_id);
|
|
|
|
if (!$revision) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$comment = $request->getStr('comment');
|
|
|
|
$action = $request->getStr('action');
|
2011-02-01 05:03:43 +01:00
|
|
|
$reviewers = $request->getArr('reviewers');
|
2011-06-24 21:21:48 +02:00
|
|
|
$ccs = $request->getArr('ccs');
|
2011-01-30 21:08:40 +01:00
|
|
|
|
|
|
|
$editor = new DifferentialCommentEditor(
|
|
|
|
$revision,
|
|
|
|
$action);
|
|
|
|
|
Track content sources (email, web, conduit, mobile) for replies
Summary:
When an object is updated, record the content source for the update. This mostly
isn't terribly useful but one concrete thing I want to do with it is let admins
audit via-email replies more easily since there are a bunch of options which let
you do hyjinx if you intentionally configure them insecurely. I think having a
little more auditability around this feature is generally good. At some point
I'm going to turn this into a link admins can click to see details.
It also allows us to see how frequently different mechanisms are used, and lets
you see if someone is at their desk or on a mobile or whatever, at least
indirectly.
The "tablet" and "mobile" sources are currently unused but I figured I'd throw
them in anyway. SMS support should definitely happen at some point.
Not 100% sure about the design for this, I might change it to plain text at some
point.
Test Plan: Updated objects and saw update sources rendered.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, epriestley, jungejason
Differential Revision: 844
2011-08-22 19:25:45 +02:00
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorContentSource::SOURCE_WEB,
|
|
|
|
array(
|
|
|
|
'ip' => $request->getRemoteAddr(),
|
|
|
|
));
|
|
|
|
|
Improve behavior when user submits a no-op action in Differential
Summary:
See T730 and the slightly-less-pretty version of this in D1398.
When a user takes an action in Differential that has no effect (for instance,
accepting an already-accepted revision), prompt them:
Action Has No Effect
You can not accept this revision because it has already been accepted.
Do you want to post the feedback anyway, as a normal comment?
[Cancel] [Post as Comment]
If they have no comment text, the dialog only says "Cancel".
I think this is probably the best way to balance all the concerns here -- it
might occasionally be a little annoying, but that should be rare, and it should
never be confusing (the current workflow is extremely confusing).
This also fixes the issue where you can add all sorts of CCs who are already
part of the revision, either explicitly or via mentions.
Test Plan:
Posted some has-effect and has-no-effect comments, made different
choices in the dialog, everything seems to work OK?
Reviewers: vrana, btrahan, jungejason
Reviewed By: vrana
CC: aran, vrana
Maniphest Tasks: T730
Differential Revision: https://secure.phabricator.com/D1403
2012-01-14 20:39:22 +01:00
|
|
|
try {
|
|
|
|
$editor
|
2012-10-10 19:18:23 +02:00
|
|
|
->setActor($request->getUser())
|
Improve behavior when user submits a no-op action in Differential
Summary:
See T730 and the slightly-less-pretty version of this in D1398.
When a user takes an action in Differential that has no effect (for instance,
accepting an already-accepted revision), prompt them:
Action Has No Effect
You can not accept this revision because it has already been accepted.
Do you want to post the feedback anyway, as a normal comment?
[Cancel] [Post as Comment]
If they have no comment text, the dialog only says "Cancel".
I think this is probably the best way to balance all the concerns here -- it
might occasionally be a little annoying, but that should be rare, and it should
never be confusing (the current workflow is extremely confusing).
This also fixes the issue where you can add all sorts of CCs who are already
part of the revision, either explicitly or via mentions.
Test Plan:
Posted some has-effect and has-no-effect comments, made different
choices in the dialog, everything seems to work OK?
Reviewers: vrana, btrahan, jungejason
Reviewed By: vrana
CC: aran, vrana
Maniphest Tasks: T730
Differential Revision: https://secure.phabricator.com/D1403
2012-01-14 20:39:22 +01:00
|
|
|
->setMessage($comment)
|
|
|
|
->setContentSource($content_source)
|
|
|
|
->setAttachInlineComments(true)
|
|
|
|
->setAddedReviewers($reviewers)
|
|
|
|
->setAddedCCs($ccs)
|
|
|
|
->save();
|
|
|
|
} catch (DifferentialActionHasNoEffectException $no_effect) {
|
|
|
|
$has_inlines = id(new DifferentialInlineComment())->loadAllWhere(
|
|
|
|
'authorPHID = %s AND revisionID = %d AND commentID IS NULL',
|
|
|
|
$request->getUser()->getPHID(),
|
|
|
|
$revision->getID());
|
|
|
|
|
|
|
|
$dialog = new AphrontDialogView();
|
|
|
|
$dialog->setUser($request->getUser());
|
|
|
|
$dialog->addCancelButton('/D'.$revision_id);
|
|
|
|
|
|
|
|
$dialog->addHiddenInput('revision_id', $revision_id);
|
|
|
|
$dialog->addHiddenInput('action', 'none');
|
|
|
|
$dialog->addHiddenInput('reviewers', $reviewers);
|
|
|
|
$dialog->addHiddenInput('ccs', $ccs);
|
|
|
|
$dialog->addHiddenInput('comment', $comment);
|
|
|
|
|
2013-01-24 19:46:47 +01:00
|
|
|
$dialog->setTitle(pht('Action Has No Effect'));
|
Improve behavior when user submits a no-op action in Differential
Summary:
See T730 and the slightly-less-pretty version of this in D1398.
When a user takes an action in Differential that has no effect (for instance,
accepting an already-accepted revision), prompt them:
Action Has No Effect
You can not accept this revision because it has already been accepted.
Do you want to post the feedback anyway, as a normal comment?
[Cancel] [Post as Comment]
If they have no comment text, the dialog only says "Cancel".
I think this is probably the best way to balance all the concerns here -- it
might occasionally be a little annoying, but that should be rare, and it should
never be confusing (the current workflow is extremely confusing).
This also fixes the issue where you can add all sorts of CCs who are already
part of the revision, either explicitly or via mentions.
Test Plan:
Posted some has-effect and has-no-effect comments, made different
choices in the dialog, everything seems to work OK?
Reviewers: vrana, btrahan, jungejason
Reviewed By: vrana
CC: aran, vrana
Maniphest Tasks: T730
Differential Revision: https://secure.phabricator.com/D1403
2012-01-14 20:39:22 +01:00
|
|
|
$dialog->appendChild(
|
|
|
|
'<p>'.phutil_escape_html($no_effect->getMessage()).'</p>');
|
|
|
|
|
|
|
|
if (strlen($comment) || $has_inlines) {
|
2013-01-24 19:46:47 +01:00
|
|
|
$dialog->addSubmitButton(pht('Post as Comment'));
|
Improve behavior when user submits a no-op action in Differential
Summary:
See T730 and the slightly-less-pretty version of this in D1398.
When a user takes an action in Differential that has no effect (for instance,
accepting an already-accepted revision), prompt them:
Action Has No Effect
You can not accept this revision because it has already been accepted.
Do you want to post the feedback anyway, as a normal comment?
[Cancel] [Post as Comment]
If they have no comment text, the dialog only says "Cancel".
I think this is probably the best way to balance all the concerns here -- it
might occasionally be a little annoying, but that should be rare, and it should
never be confusing (the current workflow is extremely confusing).
This also fixes the issue where you can add all sorts of CCs who are already
part of the revision, either explicitly or via mentions.
Test Plan:
Posted some has-effect and has-no-effect comments, made different
choices in the dialog, everything seems to work OK?
Reviewers: vrana, btrahan, jungejason
Reviewed By: vrana
CC: aran, vrana
Maniphest Tasks: T730
Differential Revision: https://secure.phabricator.com/D1403
2012-01-14 20:39:22 +01:00
|
|
|
$dialog->appendChild('<br />');
|
|
|
|
$dialog->appendChild(
|
2013-01-24 19:46:47 +01:00
|
|
|
'<p>'.pht('Do you want to post your feedback anyway, as a normal '.
|
|
|
|
'comment?').'</p>');
|
Improve behavior when user submits a no-op action in Differential
Summary:
See T730 and the slightly-less-pretty version of this in D1398.
When a user takes an action in Differential that has no effect (for instance,
accepting an already-accepted revision), prompt them:
Action Has No Effect
You can not accept this revision because it has already been accepted.
Do you want to post the feedback anyway, as a normal comment?
[Cancel] [Post as Comment]
If they have no comment text, the dialog only says "Cancel".
I think this is probably the best way to balance all the concerns here -- it
might occasionally be a little annoying, but that should be rare, and it should
never be confusing (the current workflow is extremely confusing).
This also fixes the issue where you can add all sorts of CCs who are already
part of the revision, either explicitly or via mentions.
Test Plan:
Posted some has-effect and has-no-effect comments, made different
choices in the dialog, everything seems to work OK?
Reviewers: vrana, btrahan, jungejason
Reviewed By: vrana
CC: aran, vrana
Maniphest Tasks: T730
Differential Revision: https://secure.phabricator.com/D1403
2012-01-14 20:39:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
2011-01-30 21:08:40 +01:00
|
|
|
|
|
|
|
// TODO: Diff change detection?
|
2011-02-06 01:57:21 +01:00
|
|
|
|
|
|
|
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
|
|
|
'authorPHID = %s AND draftKey = %s',
|
|
|
|
$request->getUser()->getPHID(),
|
|
|
|
'differential-comment-'.$revision->getID());
|
|
|
|
if ($draft) {
|
|
|
|
$draft->delete();
|
|
|
|
}
|
2011-01-30 21:08:40 +01:00
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI('/D'.$revision->getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|