Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15407173
D21144.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D21144.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3251,6 +3251,7 @@
'PhabricatorEditEngineMFAInterface' => 'applications/transactions/editengine/PhabricatorEditEngineMFAInterface.php',
'PhabricatorEditEngineNameTransaction' => 'applications/transactions/xaction/PhabricatorEditEngineNameTransaction.php',
'PhabricatorEditEngineOrderTransaction' => 'applications/transactions/xaction/PhabricatorEditEngineOrderTransaction.php',
+ 'PhabricatorEditEnginePageState' => 'applications/transactions/editengine/PhabricatorEditEnginePageState.php',
'PhabricatorEditEnginePointsCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEnginePointsCommentAction.php',
'PhabricatorEditEnginePreambleTransaction' => 'applications/transactions/xaction/PhabricatorEditEnginePreambleTransaction.php',
'PhabricatorEditEngineProfileMenuItem' => 'applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php',
@@ -9714,6 +9715,7 @@
'PhabricatorEditEngineMFAEngine' => 'Phobject',
'PhabricatorEditEngineNameTransaction' => 'PhabricatorEditEngineTransactionType',
'PhabricatorEditEngineOrderTransaction' => 'PhabricatorEditEngineTransactionType',
+ 'PhabricatorEditEnginePageState' => 'Phobject',
'PhabricatorEditEnginePointsCommentAction' => 'PhabricatorEditEngineCommentAction',
'PhabricatorEditEnginePreambleTransaction' => 'PhabricatorEditEngineTransactionType',
'PhabricatorEditEngineProfileMenuItem' => 'PhabricatorProfileMenuItem',
diff --git a/src/aphront/AphrontRequest.php b/src/aphront/AphrontRequest.php
--- a/src/aphront/AphrontRequest.php
+++ b/src/aphront/AphrontRequest.php
@@ -30,6 +30,7 @@
private $controller;
private $uriData = array();
private $cookiePrefix;
+ private $submitKey;
public function __construct($host, $path) {
$this->host = $host;
@@ -914,5 +915,19 @@
return $future;
}
+ public function updateEphemeralCookies() {
+ $submit_cookie = PhabricatorCookies::COOKIE_SUBMIT;
+
+ $submit_key = $this->getCookie($submit_cookie);
+ if (strlen($submit_key)) {
+ $this->clearCookie($submit_cookie);
+ $this->submitKey = $submit_key;
+ }
+
+ }
+
+ public function getSubmitKey() {
+ return $this->submitKey;
+ }
}
diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php
--- a/src/aphront/configuration/AphrontApplicationConfiguration.php
+++ b/src/aphront/configuration/AphrontApplicationConfiguration.php
@@ -27,6 +27,8 @@
$request->setApplicationConfiguration($this);
$request->setCookiePrefix($cookie_prefix);
+ $request->updateEphemeralCookies();
+
return $request;
}
diff --git a/src/applications/auth/application/PhabricatorAuthApplication.php b/src/applications/auth/application/PhabricatorAuthApplication.php
--- a/src/applications/auth/application/PhabricatorAuthApplication.php
+++ b/src/applications/auth/application/PhabricatorAuthApplication.php
@@ -73,7 +73,7 @@
'session/downgrade/'
=> 'PhabricatorAuthDowngradeSessionController',
'enroll/' => array(
- '(?:(?P<pageKey>[^/]+)/)?(?:(?P<formSaved>saved)/)?'
+ '(?:(?P<pageKey>[^/]+)/)?'
=> 'PhabricatorAuthNeedsMultiFactorController',
),
'sshkey/' => array(
diff --git a/src/applications/auth/constants/PhabricatorCookies.php b/src/applications/auth/constants/PhabricatorCookies.php
--- a/src/applications/auth/constants/PhabricatorCookies.php
+++ b/src/applications/auth/constants/PhabricatorCookies.php
@@ -63,6 +63,13 @@
const COOKIE_INVITE = 'invite';
+ /**
+ * Stores a workflow completion across a redirect-after-POST following a
+ * form submission. This can be used to show "Changes Saved" messages.
+ */
+ const COOKIE_SUBMIT = 'phfrm';
+
+
/* -( Client ID Cookie )--------------------------------------------------- */
diff --git a/src/applications/settings/application/PhabricatorSettingsApplication.php b/src/applications/settings/application/PhabricatorSettingsApplication.php
--- a/src/applications/settings/application/PhabricatorSettingsApplication.php
+++ b/src/applications/settings/application/PhabricatorSettingsApplication.php
@@ -23,7 +23,7 @@
}
public function getRoutes() {
- $panel_pattern = '(?:page/(?P<pageKey>[^/]+)/(?:(?P<formSaved>saved)/)?)?';
+ $panel_pattern = '(?:page/(?P<pageKey>[^/]+)/)?';
return array(
'/settings/' => array(
diff --git a/src/applications/settings/editor/PhabricatorSettingsEditEngine.php b/src/applications/settings/editor/PhabricatorSettingsEditEngine.php
--- a/src/applications/settings/editor/PhabricatorSettingsEditEngine.php
+++ b/src/applications/settings/editor/PhabricatorSettingsEditEngine.php
@@ -128,10 +128,6 @@
return PhabricatorPolicies::POLICY_ADMIN;
}
- public function getEffectiveObjectEditDoneURI($object) {
- return parent::getEffectiveObjectViewURI($object).'saved/';
- }
-
public function getEffectiveObjectEditCancelURI($object) {
if (!$object->getUser()) {
return '/settings/';
@@ -253,4 +249,16 @@
return parent::getValidationExceptionShortMessage($ex, $field);
}
+ protected function newEditFormHeadContent(
+ PhabricatorEditEnginePageState $state) {
+
+ if ($state->getIsSave()) {
+ return id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
+ ->appendChild(pht('Changes saved.'));
+ }
+
+ return null;
+ }
+
}
diff --git a/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php b/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php
@@ -138,7 +138,6 @@
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Email Preferences'))
- ->setFormSaved($request->getStr('saved'))
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::WHITE_CONFIG)
->setForm($form);
diff --git a/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php b/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php
@@ -206,7 +206,6 @@
$algo_box = $this->newBox(pht('Password Algorithms'), $properties);
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Change Password'))
- ->setFormSaved($request->getStr('saved'))
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::WHITE_CONFIG)
->setForm($form);
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -1036,9 +1036,13 @@
$fields = $this->buildEditFields($object);
$template = $object->getApplicationTransactionTemplate();
+ $page_state = new PhabricatorEditEnginePageState();
+
if ($this->getIsCreate()) {
$cancel_uri = $this->getObjectCreateCancelURI($object);
$submit_button = $this->getObjectCreateButtonText($object);
+
+ $page_state->setIsCreate(true);
} else {
$cancel_uri = $this->getEffectiveObjectEditCancelURI($object);
$submit_button = $this->getObjectEditButtonText($object);
@@ -1069,6 +1073,8 @@
$validation_exception = null;
if ($request->isFormOrHisecPost() && $request->getBool('editEngine')) {
+ $page_state->setIsSubmit(true);
+
$submit_fields = $fields;
foreach ($submit_fields as $key => $field) {
@@ -1154,6 +1160,8 @@
$field->setControlError($message);
}
+
+ $page_state->setIsError(true);
}
} else {
if ($this->getIsCreate()) {
@@ -1252,6 +1260,17 @@
$box_header->addActionLink($action_button);
}
+ $request_submit_key = $request->getSubmitKey();
+ $engine_submit_key = $this->getEditEngineSubmitKey();
+
+ if ($request_submit_key === $engine_submit_key) {
+ $page_state->setIsSubmit(true);
+ $page_state->setIsSave(true);
+ }
+
+ $head = $this->newEditFormHeadContent($page_state);
+ $tail = $this->newEditFormTailContent($page_state);
+
$box = id(new PHUIObjectBoxView())
->setUser($viewer)
->setHeader($box_header)
@@ -1259,14 +1278,11 @@
->setBackground(PHUIObjectBoxView::WHITE_CONFIG)
->appendChild($form);
- // This is fairly questionable, but in use by Settings.
- if ($request->getURIData('formSaved')) {
- $box->setFormSaved(true);
- }
-
$content = array(
+ $head,
$box,
$previews,
+ $tail,
);
$view = new PHUITwoColumnView();
@@ -1291,14 +1307,34 @@
return $page;
}
+ protected function newEditFormHeadContent(
+ PhabricatorEditEnginePageState $state) {
+ return null;
+ }
+
+ protected function newEditFormTailContent(
+ PhabricatorEditEnginePageState $state) {
+ return null;
+ }
+
protected function newEditResponse(
AphrontRequest $request,
$object,
array $xactions) {
+
+ $submit_cookie = PhabricatorCookies::COOKIE_SUBMIT;
+ $submit_key = $this->getEditEngineSubmitKey();
+
+ $request->setTemporaryCookie($submit_cookie, $submit_key);
+
return id(new AphrontRedirectResponse())
->setURI($this->getEffectiveObjectEditDoneURI($object));
}
+ private function getEditEngineSubmitKey() {
+ return 'edit-engine/'.$this->getEngineKey();
+ }
+
private function buildEditForm($object, array $fields) {
$viewer = $this->getViewer();
$controller = $this->getController();
diff --git a/src/applications/transactions/editengine/PhabricatorEditEnginePageState.php b/src/applications/transactions/editengine/PhabricatorEditEnginePageState.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/editengine/PhabricatorEditEnginePageState.php
@@ -0,0 +1,47 @@
+<?php
+
+final class PhabricatorEditEnginePageState
+ extends Phobject {
+
+ private $isCreate;
+ private $isSubmit;
+ private $isError;
+ private $isSave;
+
+ public function setIsCreate($is_create) {
+ $this->isCreate = $is_create;
+ return $this;
+ }
+
+ public function getIsCreate() {
+ return $this->isCreate;
+ }
+
+ public function setIsSubmit($is_submit) {
+ $this->isSubmit = $is_submit;
+ return $this;
+ }
+
+ public function getIsSubmit() {
+ return $this->isSubmit;
+ }
+
+ public function setIsError($is_error) {
+ $this->isError = $is_error;
+ return $this;
+ }
+
+ public function getIsError() {
+ return $this->isError;
+ }
+
+ public function setIsSave($is_save) {
+ $this->isSave = $is_save;
+ return $this;
+ }
+
+ public function getIsSave() {
+ return $this->isSave;
+ }
+
+}
diff --git a/src/view/phui/PHUIObjectBoxView.php b/src/view/phui/PHUIObjectBoxView.php
--- a/src/view/phui/PHUIObjectBoxView.php
+++ b/src/view/phui/PHUIObjectBoxView.php
@@ -7,7 +7,6 @@
private $background;
private $tabGroups = array();
private $formErrors = null;
- private $formSaved = false;
private $infoView;
private $form;
private $validationException;
@@ -75,19 +74,6 @@
return $this;
}
- public function setFormSaved($saved, $text = null) {
- if (!$text) {
- $text = pht('Changes saved.');
- }
- if ($saved) {
- $save = id(new PHUIInfoView())
- ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
- ->appendChild($text);
- $this->formSaved = $save;
- }
- return $this;
- }
-
public function addTabGroup(PHUITabGroupView $view) {
$this->tabGroups[] = $view;
return $this;
@@ -324,7 +310,6 @@
$header,
$this->infoView,
$this->formErrors,
- $this->formSaved,
$exception_errors,
$this->form,
$this->tabGroups,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 4:13 PM (2 w, 8 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7341803
Default Alt Text
D21144.diff (11 KB)
Attached To
Mode
D21144: Replace old hard-coded URI-based "changes saved" jank with new overgeneralized cookie-based "changes saved" jank
Attached
Detach File
Event Timeline
Log In to Comment