mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +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:
parent
2ad501873a
commit
3c8d88deb4
2 changed files with 13 additions and 7 deletions
|
@ -14,10 +14,12 @@ final class PhrictionEditController
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
|
$current_version = null;
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
$document = id(new PhrictionDocumentQuery())
|
$document = id(new PhrictionDocumentQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($this->id))
|
||||||
|
->needContent(true)
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
@ -28,6 +30,8 @@ final class PhrictionEditController
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$current_version = $document->getContent()->getVersion();
|
||||||
|
|
||||||
$revert = $request->getInt('revert');
|
$revert = $request->getInt('revert');
|
||||||
if ($revert) {
|
if ($revert) {
|
||||||
$content = id(new PhrictionContent())->loadOneWhere(
|
$content = id(new PhrictionContent())->loadOneWhere(
|
||||||
|
@ -38,7 +42,7 @@ final class PhrictionEditController
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$content = id(new PhrictionContent())->load($document->getContentID());
|
$content = $document->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,6 +60,7 @@ final class PhrictionEditController
|
||||||
|
|
||||||
if ($document) {
|
if ($document) {
|
||||||
$content = $document->getContent();
|
$content = $document->getContent();
|
||||||
|
$current_version = $content->getVersion();
|
||||||
} else {
|
} else {
|
||||||
if (PhrictionDocument::isProjectSlug($slug)) {
|
if (PhrictionDocument::isProjectSlug($slug)) {
|
||||||
$project = id(new PhabricatorProjectQuery())
|
$project = id(new PhabricatorProjectQuery())
|
||||||
|
@ -104,7 +109,6 @@ final class PhrictionEditController
|
||||||
$overwrite = $request->getBool('overwrite');
|
$overwrite = $request->getBool('overwrite');
|
||||||
if (!$overwrite) {
|
if (!$overwrite) {
|
||||||
$edit_version = $request->getStr('contentVersion');
|
$edit_version = $request->getStr('contentVersion');
|
||||||
$current_version = $content->getVersion();
|
|
||||||
if ($edit_version != $current_version) {
|
if ($edit_version != $current_version) {
|
||||||
$dialog = $this->newDialog()
|
$dialog = $this->newDialog()
|
||||||
->setTitle(pht('Edit Conflict!'))
|
->setTitle(pht('Edit Conflict!'))
|
||||||
|
@ -229,7 +233,7 @@ final class PhrictionEditController
|
||||||
->setAction($request->getRequestURI()->getPath())
|
->setAction($request->getRequestURI()->getPath())
|
||||||
->addHiddenInput('slug', $document->getSlug())
|
->addHiddenInput('slug', $document->getSlug())
|
||||||
->addHiddenInput('nodraft', $request->getBool('nodraft'))
|
->addHiddenInput('nodraft', $request->getBool('nodraft'))
|
||||||
->addHiddenInput('contentVersion', $content->getVersion())
|
->addHiddenInput('contentVersion', $current_version)
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextControl())
|
id(new AphrontFormTextControl())
|
||||||
->setLabel(pht('Title'))
|
->setLabel(pht('Title'))
|
||||||
|
|
|
@ -108,25 +108,27 @@ final class PhrictionHistoryController
|
||||||
|
|
||||||
if ($vs_previous) {
|
if ($vs_previous) {
|
||||||
$item->addIcon(
|
$item->addIcon(
|
||||||
'arrow_left',
|
'fa-reply',
|
||||||
pht('Show Change'),
|
pht('Show Change'),
|
||||||
array(
|
array(
|
||||||
'href' => $vs_previous,
|
'href' => $vs_previous,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$item->addIcon('arrow_left-grey',
|
$item->addIcon(
|
||||||
|
'fa-reply grey',
|
||||||
phutil_tag('em', array(), pht('No previous change')));
|
phutil_tag('em', array(), pht('No previous change')));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($vs_head) {
|
if ($vs_head) {
|
||||||
$item->addIcon(
|
$item->addIcon(
|
||||||
'merge',
|
'fa-reply-all',
|
||||||
pht('Show Later Changes'),
|
pht('Show Later Changes'),
|
||||||
array(
|
array(
|
||||||
'href' => $vs_head,
|
'href' => $vs_head,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$item->addIcon('merge-grey',
|
$item->addIcon(
|
||||||
|
'fa-reply-all grey',
|
||||||
phutil_tag('em', array(), pht('No later changes')));
|
phutil_tag('em', array(), pht('No later changes')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue