1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

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
This commit is contained in:
epriestley 2014-05-21 16:05:59 -07:00
parent 2ad501873a
commit 3c8d88deb4
2 changed files with 13 additions and 7 deletions

View file

@ -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'))

View file

@ -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')));
}