Give "Auth Messages" a view/detail state before users customize them
Summary:
Depends on D20663. Ref T13343. Currently, if an Auth message hasn't been customized yet, clicking the message type takes you straight to an edit screen to create a message.
If an auth message has already been customized, you go to a detail screen instead.
Since there's no detail screen on the "create for the first time" flow, we don't have anywhere to put a more detailed description or a preview of a default value.
Add a view screen that works if a message is "empty" so we can add this stuff.
(The only reason we don't already have this is that it took a little work to build; this also generally improves the consistency and predictability of this interface.)
Test Plan: {F6607665}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13343
Differential Revision: https://secure.phabricator.com/D20664
This commit is contained in:
@@ -108,7 +108,7 @@ final class PhabricatorAuthApplication extends PhabricatorApplication {
|
|||||||
'PhabricatorAuthMessageListController',
|
'PhabricatorAuthMessageListController',
|
||||||
$this->getEditRoutePattern('edit/') =>
|
$this->getEditRoutePattern('edit/') =>
|
||||||
'PhabricatorAuthMessageEditController',
|
'PhabricatorAuthMessageEditController',
|
||||||
'(?P<id>[1-9]\d*)/' =>
|
'(?P<id>[^/]+)/' =>
|
||||||
'PhabricatorAuthMessageViewController',
|
'PhabricatorAuthMessageViewController',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,14 @@ final class PhabricatorAuthMessageListController
|
|||||||
$list = new PHUIObjectItemListView();
|
$list = new PHUIObjectItemListView();
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$message = idx($messages, $type->getMessageTypeKey());
|
$message = idx($messages, $type->getMessageTypeKey());
|
||||||
|
|
||||||
if ($message) {
|
if ($message) {
|
||||||
$href = $message->getURI();
|
$href = $message->getURI();
|
||||||
$name = $message->getMessageTypeDisplayName();
|
$name = $message->getMessageTypeDisplayName();
|
||||||
} else {
|
} else {
|
||||||
$href = '/auth/message/edit/?messageKey='.$type->getMessageTypeKey();
|
$href = urisprintf(
|
||||||
|
'/auth/message/%s/',
|
||||||
|
$type->getMessageTypeKey());
|
||||||
$name = $type->getDisplayName();
|
$name = $type->getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,26 +9,61 @@ final class PhabricatorAuthMessageViewController
|
|||||||
$this->requireApplicationCapability(
|
$this->requireApplicationCapability(
|
||||||
AuthManageProvidersCapability::CAPABILITY);
|
AuthManageProvidersCapability::CAPABILITY);
|
||||||
|
|
||||||
|
// The "id" in the URI may either be an actual storage record ID (if a
|
||||||
|
// message has already been created) or a message type key (for a message
|
||||||
|
// type which does not have a record yet).
|
||||||
|
|
||||||
|
// This flow allows messages which have not been set yet to have a detail
|
||||||
|
// page (so users can get detailed information about the message and see
|
||||||
|
// any default value).
|
||||||
|
|
||||||
|
$id = $request->getURIData('id');
|
||||||
|
if (ctype_digit($id)) {
|
||||||
$message = id(new PhabricatorAuthMessageQuery())
|
$message = id(new PhabricatorAuthMessageQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($request->getURIData('id')))
|
->withIDs(array($id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$message) {
|
if (!$message) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$types = PhabricatorAuthMessageType::getAllMessageTypes();
|
||||||
|
if (!isset($types[$id])) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this message type already has a storage record, redirect to the
|
||||||
|
// canonical page for the record.
|
||||||
|
$message = id(new PhabricatorAuthMessageQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withMessageKeys(array($id))
|
||||||
|
->executeOne();
|
||||||
|
if ($message) {
|
||||||
|
$message_uri = $message->getURI();
|
||||||
|
return id(new AphrontRedirectResponse())->setURI($message_uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, create an empty placeholder message object with the
|
||||||
|
// appropriate message type.
|
||||||
|
$message = PhabricatorAuthMessage::initializeNewMessage($types[$id]);
|
||||||
|
}
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs()
|
$crumbs = $this->buildApplicationCrumbs()
|
||||||
->addTextCrumb($message->getObjectName())
|
->addTextCrumb($message->getMessageType()->getDisplayName())
|
||||||
->setBorder(true);
|
->setBorder(true);
|
||||||
|
|
||||||
$header = $this->buildHeaderView($message);
|
$header = $this->buildHeaderView($message);
|
||||||
$properties = $this->buildPropertiesView($message);
|
$properties = $this->buildPropertiesView($message);
|
||||||
$curtain = $this->buildCurtain($message);
|
$curtain = $this->buildCurtain($message);
|
||||||
|
|
||||||
|
if ($message->getID()) {
|
||||||
$timeline = $this->buildTransactionTimeline(
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$message,
|
$message,
|
||||||
new PhabricatorAuthMessageTransactionQuery());
|
new PhabricatorAuthMessageTransactionQuery());
|
||||||
$timeline->setShouldTerminate(true);
|
$timeline->setShouldTerminate(true);
|
||||||
|
} else {
|
||||||
|
$timeline = null;
|
||||||
|
}
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
@@ -69,12 +104,14 @@ final class PhabricatorAuthMessageViewController
|
|||||||
pht('Description'),
|
pht('Description'),
|
||||||
$message->getMessageType()->getShortDescription());
|
$message->getMessageType()->getShortDescription());
|
||||||
|
|
||||||
|
if (strlen($message->getMessageText())) {
|
||||||
$view->addSectionHeader(
|
$view->addSectionHeader(
|
||||||
pht('Message Preview'),
|
pht('Message Preview'),
|
||||||
PHUIPropertyListView::ICON_SUMMARY);
|
PHUIPropertyListView::ICON_SUMMARY);
|
||||||
|
|
||||||
$view->addTextContent(
|
$view->addTextContent(
|
||||||
new PHUIRemarkupView($viewer, $message->getMessageText()));
|
new PHUIRemarkupView($viewer, $message->getMessageText()));
|
||||||
|
}
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
@@ -88,13 +125,27 @@ final class PhabricatorAuthMessageViewController
|
|||||||
$message,
|
$message,
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
if ($id) {
|
||||||
|
$edit_uri = urisprintf('message/edit/%s/', $id);
|
||||||
|
$edit_name = pht('Edit Message');
|
||||||
|
} else {
|
||||||
|
$edit_uri = urisprintf('message/edit/');
|
||||||
|
$params = array(
|
||||||
|
'messageKey' => $message->getMessageKey(),
|
||||||
|
);
|
||||||
|
$edit_uri = new PhutilURI($edit_uri, $params);
|
||||||
|
|
||||||
|
$edit_name = pht('Customize Message');
|
||||||
|
}
|
||||||
|
$edit_uri = $this->getApplicationURI($edit_uri);
|
||||||
|
|
||||||
$curtain = $this->newCurtainView($message);
|
$curtain = $this->newCurtainView($message);
|
||||||
|
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Message'))
|
->setName($edit_name)
|
||||||
->setIcon('fa-pencil')
|
->setIcon('fa-pencil')
|
||||||
->setHref($this->getApplicationURI("message/edit/{$id}/"))
|
->setHref($edit_uri)
|
||||||
->setDisabled(!$can_edit)
|
->setDisabled(!$can_edit)
|
||||||
->setWorkflow(!$can_edit));
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user