@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+74 -20
+1 -1
src/applications/auth/application/PhabricatorAuthApplication.php
··· 108 108 'PhabricatorAuthMessageListController', 109 109 $this->getEditRoutePattern('edit/') => 110 110 'PhabricatorAuthMessageEditController', 111 - '(?P<id>[1-9]\d*)/' => 111 + '(?P<id>[^/]+)/' => 112 112 'PhabricatorAuthMessageViewController', 113 113 ), 114 114
+4 -1
src/applications/auth/controller/message/PhabricatorAuthMessageListController.php
··· 19 19 $list = new PHUIObjectItemListView(); 20 20 foreach ($types as $type) { 21 21 $message = idx($messages, $type->getMessageTypeKey()); 22 + 22 23 if ($message) { 23 24 $href = $message->getURI(); 24 25 $name = $message->getMessageTypeDisplayName(); 25 26 } else { 26 - $href = '/auth/message/edit/?messageKey='.$type->getMessageTypeKey(); 27 + $href = urisprintf( 28 + '/auth/message/%s/', 29 + $type->getMessageTypeKey()); 27 30 $name = $type->getDisplayName(); 28 31 } 29 32
+69 -18
src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php
··· 9 9 $this->requireApplicationCapability( 10 10 AuthManageProvidersCapability::CAPABILITY); 11 11 12 - $message = id(new PhabricatorAuthMessageQuery()) 13 - ->setViewer($viewer) 14 - ->withIDs(array($request->getURIData('id'))) 15 - ->executeOne(); 16 - if (!$message) { 17 - return new Aphront404Response(); 12 + // The "id" in the URI may either be an actual storage record ID (if a 13 + // message has already been created) or a message type key (for a message 14 + // type which does not have a record yet). 15 + 16 + // This flow allows messages which have not been set yet to have a detail 17 + // page (so users can get detailed information about the message and see 18 + // any default value). 19 + 20 + $id = $request->getURIData('id'); 21 + if (ctype_digit($id)) { 22 + $message = id(new PhabricatorAuthMessageQuery()) 23 + ->setViewer($viewer) 24 + ->withIDs(array($id)) 25 + ->executeOne(); 26 + if (!$message) { 27 + return new Aphront404Response(); 28 + } 29 + } else { 30 + $types = PhabricatorAuthMessageType::getAllMessageTypes(); 31 + if (!isset($types[$id])) { 32 + return new Aphront404Response(); 33 + } 34 + 35 + // If this message type already has a storage record, redirect to the 36 + // canonical page for the record. 37 + $message = id(new PhabricatorAuthMessageQuery()) 38 + ->setViewer($viewer) 39 + ->withMessageKeys(array($id)) 40 + ->executeOne(); 41 + if ($message) { 42 + $message_uri = $message->getURI(); 43 + return id(new AphrontRedirectResponse())->setURI($message_uri); 44 + } 45 + 46 + // Otherwise, create an empty placeholder message object with the 47 + // appropriate message type. 48 + $message = PhabricatorAuthMessage::initializeNewMessage($types[$id]); 18 49 } 19 50 20 51 $crumbs = $this->buildApplicationCrumbs() 21 - ->addTextCrumb($message->getObjectName()) 52 + ->addTextCrumb($message->getMessageType()->getDisplayName()) 22 53 ->setBorder(true); 23 54 24 55 $header = $this->buildHeaderView($message); 25 56 $properties = $this->buildPropertiesView($message); 26 57 $curtain = $this->buildCurtain($message); 27 58 28 - $timeline = $this->buildTransactionTimeline( 29 - $message, 30 - new PhabricatorAuthMessageTransactionQuery()); 31 - $timeline->setShouldTerminate(true); 59 + if ($message->getID()) { 60 + $timeline = $this->buildTransactionTimeline( 61 + $message, 62 + new PhabricatorAuthMessageTransactionQuery()); 63 + $timeline->setShouldTerminate(true); 64 + } else { 65 + $timeline = null; 66 + } 32 67 33 68 $view = id(new PHUITwoColumnView()) 34 69 ->setHeader($header) ··· 69 104 pht('Description'), 70 105 $message->getMessageType()->getShortDescription()); 71 106 72 - $view->addSectionHeader( 73 - pht('Message Preview'), 74 - PHUIPropertyListView::ICON_SUMMARY); 107 + if (strlen($message->getMessageText())) { 108 + $view->addSectionHeader( 109 + pht('Message Preview'), 110 + PHUIPropertyListView::ICON_SUMMARY); 75 111 76 - $view->addTextContent( 77 - new PHUIRemarkupView($viewer, $message->getMessageText())); 112 + $view->addTextContent( 113 + new PHUIRemarkupView($viewer, $message->getMessageText())); 114 + } 78 115 79 116 return $view; 80 117 } ··· 88 125 $message, 89 126 PhabricatorPolicyCapability::CAN_EDIT); 90 127 128 + if ($id) { 129 + $edit_uri = urisprintf('message/edit/%s/', $id); 130 + $edit_name = pht('Edit Message'); 131 + } else { 132 + $edit_uri = urisprintf('message/edit/'); 133 + $params = array( 134 + 'messageKey' => $message->getMessageKey(), 135 + ); 136 + $edit_uri = new PhutilURI($edit_uri, $params); 137 + 138 + $edit_name = pht('Customize Message'); 139 + } 140 + $edit_uri = $this->getApplicationURI($edit_uri); 141 + 91 142 $curtain = $this->newCurtainView($message); 92 143 93 144 $curtain->addAction( 94 145 id(new PhabricatorActionView()) 95 - ->setName(pht('Edit Message')) 146 + ->setName($edit_name) 96 147 ->setIcon('fa-pencil') 97 - ->setHref($this->getApplicationURI("message/edit/{$id}/")) 148 + ->setHref($edit_uri) 98 149 ->setDisabled(!$can_edit) 99 150 ->setWorkflow(!$can_edit)); 100 151