mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 19:31:02 +01:00
Add very basic conflict detection to Phriction
Summary: Ref T4768. This is extremely basic, but will stop conflicts from going silently unnoticed. Test Plan: {F156219} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4768 Differential Revision: https://secure.phabricator.com/D9167
This commit is contained in:
parent
cc9ee66ef3
commit
b1ec4a9a21
1 changed files with 31 additions and 0 deletions
|
@ -93,6 +93,36 @@ final class PhrictionEditController
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
|
|
||||||
|
$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!'))
|
||||||
|
->appendParagraph(
|
||||||
|
pht(
|
||||||
|
'Another user made changes to this document after you began '.
|
||||||
|
'editing it. Do you want to overwrite their changes?'))
|
||||||
|
->appendParagraph(
|
||||||
|
pht(
|
||||||
|
'If you choose to overwrite their changes, you should review '.
|
||||||
|
'the document edit history to see what you overwrote, and '.
|
||||||
|
'then make another edit to merge the changes if necessary.'))
|
||||||
|
->addSubmitButton(pht('Overwrite Changes'))
|
||||||
|
->addCancelButton($request->getRequestURI());
|
||||||
|
|
||||||
|
$dialog->addHiddenInput('overwrite', 'true');
|
||||||
|
foreach ($request->getPassthroughRequestData() as $key => $value) {
|
||||||
|
$dialog->addHiddenInput($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$title = $request->getStr('title');
|
$title = $request->getStr('title');
|
||||||
$notes = $request->getStr('description');
|
$notes = $request->getStr('description');
|
||||||
|
|
||||||
|
@ -192,6 +222,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())
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextControl())
|
id(new AphrontFormTextControl())
|
||||||
->setLabel(pht('Title'))
|
->setLabel(pht('Title'))
|
||||||
|
|
Loading…
Reference in a new issue