@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.

Make event detail view more user-friendly for imported events

Summary:
Ref T10747. When viewing an imported event:

- Make it more clear that it is imported and where it is from.
- Add some explicit "this is imported" help.

Test Plan: Viewed imported and normal events.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

Differential Revision: https://secure.phabricator.com/D16727

+96 -6
+19
src/applications/calendar/controller/PhabricatorCalendarController.php
··· 18 18 ->setContent($ics_data); 19 19 } 20 20 21 + protected function newImportedEventResponse(PhabricatorCalendarEvent $event) { 22 + if (!$event->isImportedEvent()) { 23 + return null; 24 + } 25 + 26 + // Give the user a specific, detailed message if they try to edit an 27 + // imported event via common web paths. Other edits (including those via 28 + // the API) are blocked by the normal policy system, but this makes it more 29 + // clear exactly why the event can't be edited. 30 + 31 + return $this->newDialog() 32 + ->setTitle(pht('Can Not Edit Imported Event')) 33 + ->appendParagraph( 34 + pht( 35 + 'This event has been imported from an external source and '. 36 + 'can not be edited.')) 37 + ->addCancelButton($event->getURI(), pht('Done')); 38 + } 39 + 21 40 }
+13 -5
src/applications/calendar/controller/PhabricatorCalendarEventCancelController.php
··· 7 7 $viewer = $request->getViewer(); 8 8 $id = $request->getURIData('id'); 9 9 10 + // Just check CAN_VIEW first. Then we'll check if this is an import so 11 + // we can raise a better error. 10 12 $event = id(new PhabricatorCalendarEventQuery()) 11 13 ->setViewer($viewer) 12 14 ->withIDs(array($id)) 13 - ->requireCapabilities( 14 - array( 15 - PhabricatorPolicyCapability::CAN_VIEW, 16 - PhabricatorPolicyCapability::CAN_EDIT, 17 - )) 18 15 ->executeOne(); 19 16 if (!$event) { 20 17 return new Aphront404Response(); 21 18 } 19 + 20 + $response = $this->newImportedEventResponse($event); 21 + if ($response) { 22 + return $response; 23 + } 24 + 25 + // Now that we've done the import check, check for CAN_EDIT. 26 + PhabricatorPolicyFilter::requireCapability( 27 + $viewer, 28 + $event, 29 + PhabricatorPolicyCapability::CAN_EDIT); 22 30 23 31 $cancel_uri = $event->getURI(); 24 32
+14
src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
··· 4 4 extends PhabricatorCalendarController { 5 5 6 6 public function handleRequest(AphrontRequest $request) { 7 + $viewer = $this->getViewer(); 8 + 9 + $id = $request->getURIData('id'); 10 + if ($id) { 11 + $event = id(new PhabricatorCalendarEventQuery()) 12 + ->setViewer($viewer) 13 + ->withIDs(array($id)) 14 + ->executeOne(); 15 + $response = $this->newImportedEventResponse($event); 16 + if ($response) { 17 + return $response; 18 + } 19 + } 20 + 7 21 return id(new PhabricatorCalendarEventEditEngine()) 8 22 ->setController($this) 9 23 ->buildResponse();
+5
src/applications/calendar/controller/PhabricatorCalendarEventJoinController.php
··· 15 15 return new Aphront404Response(); 16 16 } 17 17 18 + $response = $this->newImportedEventResponse($event); 19 + if ($response) { 20 + return $response; 21 + } 22 + 18 23 $cancel_uri = $event->getURI(); 19 24 20 25 $action = $request->getURIData('action');
+36
src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
··· 63 63 ->setHeader(pht('Details')); 64 64 $recurring_header = $this->buildRecurringHeader($event); 65 65 66 + // NOTE: This is a bit hacky: for imported events, we're just hiding the 67 + // comment form without actually preventing comments. Users could still 68 + // submit a request to add comments to these events. This isn't really a 69 + // major problem since they can't do anything truly bad and there isn't an 70 + // easy way to selectively disable this or some other similar behaviors 71 + // today, but it would probably be nice to fully disable these 72 + // "pseudo-edits" (like commenting and probably subscribing and awarding 73 + // tokens) at some point. 74 + if ($event->isImportedEvent()) { 75 + $comment_view = null; 76 + $timeline->setShouldTerminate(true); 77 + } 78 + 66 79 $view = id(new PHUITwoColumnView()) 67 80 ->setHeader($header) 68 81 ->setSubheader($subheader) ··· 105 118 ->setPolicyObject($event) 106 119 ->setHeaderIcon($event->getIcon()); 107 120 121 + if ($event->isImportedEvent()) { 122 + $header->addTag( 123 + id(new PHUITagView()) 124 + ->setType(PHUITagView::TYPE_SHADE) 125 + ->setName(pht('Imported')) 126 + ->setIcon('fa-download') 127 + ->setHref($event->getImportSource()->getURI()) 128 + ->setShade('orange')); 129 + } 130 + 108 131 foreach ($this->buildRSVPActions($event) as $action) { 109 132 $header->addActionLink($action); 110 133 } ··· 141 164 ->setWorkflow(!$can_edit)); 142 165 } 143 166 167 + $can_attend = !$event->isImportedEvent(); 168 + 144 169 if ($is_attending) { 145 170 $curtain->addAction( 146 171 id(new PhabricatorActionView()) 147 172 ->setName(pht('Decline Event')) 148 173 ->setIcon('fa-user-times') 149 174 ->setHref($this->getApplicationURI("event/join/{$id}/")) 175 + ->setDisabled(!$can_attend) 150 176 ->setWorkflow(true)); 151 177 } else { 152 178 $curtain->addAction( ··· 154 180 ->setName(pht('Join Event')) 155 181 ->setIcon('fa-user-plus') 156 182 ->setHref($this->getApplicationURI("event/join/{$id}/")) 183 + ->setDisabled(!$can_attend) 157 184 ->setWorkflow(true)); 158 185 } 159 186 ··· 259 286 'em', 260 287 array(), 261 288 pht('None')); 289 + } 290 + 291 + if ($event->isImportedEvent()) { 292 + $properties->addProperty( 293 + pht('Imported By'), 294 + pht( 295 + '%s from %s', 296 + $viewer->renderHandle($event->getImportAuthorPHID()), 297 + $viewer->renderHandle($event->getImportSourcePHID()))); 262 298 } 263 299 264 300 $properties->addProperty(
+1 -1
src/applications/calendar/phid/PhabricatorCalendarImportPHIDType.php
··· 33 33 $import = $objects[$phid]; 34 34 35 35 $id = $import->getID(); 36 - $name = $import->getName(); 36 + $name = $import->getDisplayName(); 37 37 $uri = $import->getURI(); 38 38 39 39 $handle
+8
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 576 576 } 577 577 } 578 578 579 + if ($this->isImportedEvent()) { 580 + return 'fa-download'; 581 + } 582 + 579 583 return $this->getIcon(); 580 584 } 581 585 582 586 public function getDisplayIconColor(PhabricatorUser $viewer) { 583 587 if ($this->isCancelledEvent()) { 584 588 return 'red'; 589 + } 590 + 591 + if ($this->isImportedEvent()) { 592 + return 'orange'; 585 593 } 586 594 587 595 if ($viewer->isLoggedIn()) {