Track a "Done" state on inline comments
Summary:
Ref T1460. This just barely works, but throwing it up in case any of it sounds mechanically crazy before we build integrations/UI/etc.
Specifically, these are the behaviors:
- You can mark your own draft comments as "done" before you submit them. The intent is to let reviewers mark their stuff advisory/minor/not-important before they submit it, to hint to authors that they don't expect the feedback to necessarily be addressed (maybe it's a joke, maybe it's just discussion, maybe it's "consider..").
- You can mark others' published comments as "done" if you're the revision/commit author. The intent is to keep this lightweight by not requiring an audit trail of who marked what done when. If anyone could mark anything done, we'd have to have some way to show who marked stuff.
- When you mark stuff done (or unmark it), it goes into a "draft" state, where you see the change but others don't see it yet. The intent is twofold:
- Be consistent with how inlines work.
- Allow us to publish a "epriestley updated this revision + epriestley marked 15 inlines as done" story later if we want. This seems more useful than publishing 15 "epriestley marked one thing as done" stories.
- The actual bit where done-ness publishes isn't implemented.
- UI is bare bones.
- No integration with the rest of the UI yet.
Test Plan: Clicked some checkboxes.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: paulshen, chasemp, epriestley
Maniphest Tasks: T1460
Differential Revision: https://secure.phabricator.com/D12033
This commit is contained in:
@@ -8,8 +8,9 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$author_phid = $request->getUser()->getPHID();
|
||||
$author_phid = $viewer->getPHID();
|
||||
|
||||
$rendering_reference = $request->getStr('ref');
|
||||
$parts = explode('/', $rendering_reference);
|
||||
@@ -29,7 +30,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||
}
|
||||
|
||||
$changesets = id(new DifferentialChangesetQuery())
|
||||
->setViewer($request->getUser())
|
||||
->setViewer($viewer)
|
||||
->withIDs($load_ids)
|
||||
->needHunks(true)
|
||||
->execute();
|
||||
@@ -191,7 +192,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||
$parser->setHandles($handles);
|
||||
|
||||
$engine = new PhabricatorMarkupEngine();
|
||||
$engine->setViewer($request->getUser());
|
||||
$engine->setViewer($viewer);
|
||||
|
||||
foreach ($inlines as $inline) {
|
||||
$engine->addObject(
|
||||
@@ -201,10 +202,25 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||
|
||||
$engine->process();
|
||||
|
||||
$diff = $changeset->getDiff();
|
||||
$revision_id = $diff->getRevisionID();
|
||||
|
||||
$can_mark = false;
|
||||
if ($revision_id) {
|
||||
$revision = id(new DifferentialRevisionQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($revision_id))
|
||||
->executeOne();
|
||||
if ($revision) {
|
||||
$can_mark = ($revision->getAuthorPHID() == $viewer->getPHID());
|
||||
}
|
||||
}
|
||||
|
||||
$parser
|
||||
->setUser($request->getUser())
|
||||
->setUser($viewer)
|
||||
->setMarkupEngine($engine)
|
||||
->setShowEditAndReplyLinks(true)
|
||||
->setCanMarkDone($can_mark)
|
||||
->setRange($range_s, $range_e)
|
||||
->setMask($mask);
|
||||
|
||||
@@ -221,8 +237,6 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||
->setUndoTemplates($parser->getRenderer()->renderUndoTemplates());
|
||||
}
|
||||
|
||||
$diff = $changeset->getDiff();
|
||||
|
||||
$detail = id(new DifferentialChangesetListView())
|
||||
->setUser($this->getViewer())
|
||||
->setChangesets(array($changeset))
|
||||
@@ -233,7 +247,6 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||
->setTitle(pht('Standalone View'))
|
||||
->setParser($parser);
|
||||
|
||||
$revision_id = $diff->getRevisionID();
|
||||
if ($revision_id) {
|
||||
$detail->setInlineCommentControllerURI(
|
||||
'/differential/comment/inline/edit/'.$revision_id.'/');
|
||||
@@ -280,7 +293,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
||||
DifferentialChangeset $changeset,
|
||||
$is_new) {
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
if ($is_new) {
|
||||
$key = 'raw:new:phid';
|
||||
|
||||
@@ -57,6 +57,46 @@ final class DifferentialInlineCommentEditController
|
||||
return $inline;
|
||||
}
|
||||
|
||||
protected function loadCommentForDone($id) {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$inline = $this->loadComment($id);
|
||||
if (!$inline) {
|
||||
throw new Exception(pht('Unable to load inline "%d".', $id));
|
||||
}
|
||||
|
||||
$changeset = id(new DifferentialChangesetQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($inline->getChangesetID()))
|
||||
->executeOne();
|
||||
if (!$changeset) {
|
||||
throw new Exception(pht('Unable to load changeset.'));
|
||||
}
|
||||
|
||||
$diff = id(new DifferentialDiffQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($changeset->getDiffID()))
|
||||
->executeOne();
|
||||
if (!$diff) {
|
||||
throw new Exception(pht('Unable to load diff.'));
|
||||
}
|
||||
|
||||
$revision = id(new DifferentialRevisionQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($diff->getRevisionID()))
|
||||
->executeOne();
|
||||
if (!$revision) {
|
||||
throw new Exception(pht('Unable to load revision.'));
|
||||
}
|
||||
|
||||
if ($revision->getAuthorPHID() !== $viewer->getPHID()) {
|
||||
throw new Exception(pht('You are not the revision owner.'));
|
||||
}
|
||||
|
||||
return $inline;
|
||||
}
|
||||
|
||||
private function canEditInlineComment(
|
||||
PhabricatorUser $user,
|
||||
DifferentialInlineComment $inline) {
|
||||
|
||||
Reference in New Issue
Block a user