Skip to content

Commit 8fd97f4

Browse files
author
epriestley
committed
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
1 parent 23f2ffb commit 8fd97f4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/applications/phriction/controller/PhrictionEditController.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ public function processRequest() {
103103
require_celerity_resource('phriction-document-css');
104104

105105
$e_title = true;
106+
$notes = null;
106107
$errors = array();
107108

108109
if ($request->isFormPost()) {
109110
$title = $request->getStr('title');
111+
$notes = $request->getStr('description');
110112

111113
if (!strlen($title)) {
112114
$e_title = 'Required';
@@ -115,12 +117,27 @@ public function processRequest() {
115117
$e_title = null;
116118
}
117119

120+
if ($document->getID()) {
121+
if ($content->getTitle() == $title &&
122+
$content->getContent() == $request->getStr('content')) {
123+
124+
$dialog = new AphrontDialogView();
125+
$dialog->setUser($user);
126+
$dialog->setTitle('No Edits');
127+
$dialog->appendChild(
128+
'<p>You did not make any changes to the document.</p>');
129+
$dialog->addCancelButton($request->getRequestURI());
130+
131+
return id(new AphrontDialogResponse())->setDialog($dialog);
132+
}
133+
}
134+
118135
if (!count($errors)) {
119136
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
120137
->setUser($user)
121138
->setTitle($title)
122139
->setContent($request->getStr('content'))
123-
->setDescription($request->getStr('description'));
140+
->setDescription($notes);
124141

125142
$editor->save();
126143

@@ -195,6 +212,7 @@ public function processRequest() {
195212

196213
$form = id(new AphrontFormView())
197214
->setUser($user)
215+
->setWorkflow(true)
198216
->setAction($request->getRequestURI()->getPath())
199217
->addHiddenInput('slug', $document->getSlug())
200218
->addHiddenInput('nodraft', $request->getBool('nodraft'))
@@ -220,7 +238,7 @@ public function processRequest() {
220238
->appendChild(
221239
id(new AphrontFormTextControl())
222240
->setLabel('Edit Notes')
223-
->setValue($content->getDescription())
241+
->setValue($notes)
224242
->setError(null)
225243
->setName('description'))
226244
->appendChild(

0 commit comments

Comments
 (0)