1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

When users submit a no-op edit in Phriction, don't update the document

Summary:
See T1501. When users mash "save", stop them if they didn't change anything.

Also, don't default-fill the "edit notes" field with the previous notes. This is meant to be more like a commit message for your changes.

Test Plan: Edited a document with no changes, got a dialog. Edited a document with a title change only and a description change only, things worked. Edited a document with a previous "Edit notes", got a blank default fill.

Reviewers: alanh, btrahan, vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1501

Differential Revision: https://secure.phabricator.com/D2978
This commit is contained in:
epriestley 2012-07-16 09:40:10 -07:00
parent 23f2ffb81c
commit 8fd97f4352

View file

@ -103,10 +103,12 @@ final class PhrictionEditController
require_celerity_resource('phriction-document-css');
$e_title = true;
$notes = null;
$errors = array();
if ($request->isFormPost()) {
$title = $request->getStr('title');
$notes = $request->getStr('description');
if (!strlen($title)) {
$e_title = 'Required';
@ -115,12 +117,27 @@ final class PhrictionEditController
$e_title = null;
}
if ($document->getID()) {
if ($content->getTitle() == $title &&
$content->getContent() == $request->getStr('content')) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle('No Edits');
$dialog->appendChild(
'<p>You did not make any changes to the document.</p>');
$dialog->addCancelButton($request->getRequestURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
if (!count($errors)) {
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
->setUser($user)
->setTitle($title)
->setContent($request->getStr('content'))
->setDescription($request->getStr('description'));
->setDescription($notes);
$editor->save();
@ -195,6 +212,7 @@ final class PhrictionEditController
$form = id(new AphrontFormView())
->setUser($user)
->setWorkflow(true)
->setAction($request->getRequestURI()->getPath())
->addHiddenInput('slug', $document->getSlug())
->addHiddenInput('nodraft', $request->getBool('nodraft'))
@ -220,7 +238,7 @@ final class PhrictionEditController
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Edit Notes')
->setValue($content->getDescription())
->setValue($notes)
->setError(null)
->setName('description'))
->appendChild(