Commit 3c8d88de authored by epriestley's avatar epriestley
Browse files

Don't warn about conflicts when reverting Phriction documents

Summary:
Fixes T5144. This was incorrectly checking the //content// version, not the //head// version, so reverts would raise the "conflict" warning.

Also fix a couple of FontAwesome icons.

Test Plan:
  - Edited a document.
  - Reverted a document.
  - Opened two edit tabs. Edited one, tried to edit #2, got a warning.
  - Opened two revert tabs. Reverted in one, tried to revert in #2, got a warning.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5144

Differential Revision: https://secure.phabricator.com/D9249
parent 2ad50187
......@@ -14,10 +14,12 @@ final class PhrictionEditController
$request = $this->getRequest();
$user = $request->getUser();
$current_version = null;
if ($this->id) {
$document = id(new PhrictionDocumentQuery())
->setViewer($user)
->withIDs(array($this->id))
->needContent(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
......@@ -28,6 +30,8 @@ final class PhrictionEditController
return new Aphront404Response();
}
$current_version = $document->getContent()->getVersion();
$revert = $request->getInt('revert');
if ($revert) {
$content = id(new PhrictionContent())->loadOneWhere(
......@@ -38,7 +42,7 @@ final class PhrictionEditController
return new Aphront404Response();
}
} else {
$content = id(new PhrictionContent())->load($document->getContentID());
$content = $document->getContent();
}
} else {
......@@ -56,6 +60,7 @@ final class PhrictionEditController
if ($document) {
$content = $document->getContent();
$current_version = $content->getVersion();
} else {
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProjectQuery())
......@@ -104,7 +109,6 @@ final class PhrictionEditController
$overwrite = $request->getBool('overwrite');
if (!$overwrite) {
$edit_version = $request->getStr('contentVersion');
$current_version = $content->getVersion();
if ($edit_version != $current_version) {
$dialog = $this->newDialog()
->setTitle(pht('Edit Conflict!'))
......@@ -229,7 +233,7 @@ final class PhrictionEditController
->setAction($request->getRequestURI()->getPath())
->addHiddenInput('slug', $document->getSlug())
->addHiddenInput('nodraft', $request->getBool('nodraft'))
->addHiddenInput('contentVersion', $content->getVersion())
->addHiddenInput('contentVersion', $current_version)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Title'))
......
......@@ -108,25 +108,27 @@ final class PhrictionHistoryController
if ($vs_previous) {
$item->addIcon(
'arrow_left',
'fa-reply',
pht('Show Change'),
array(
'href' => $vs_previous,
));
} else {
$item->addIcon('arrow_left-grey',
$item->addIcon(
'fa-reply grey',
phutil_tag('em', array(), pht('No previous change')));
}
if ($vs_head) {
$item->addIcon(
'merge',
'fa-reply-all',
pht('Show Later Changes'),
array(
'href' => $vs_head,
));
} else {
$item->addIcon('merge-grey',
$item->addIcon(
'fa-reply-all grey',
phutil_tag('em', array(), pht('No later changes')));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment