mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
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
This commit is contained in:
parent
5039b9ca28
commit
d860008b6a
7 changed files with 96 additions and 6 deletions
|
@ -18,4 +18,23 @@ abstract class PhabricatorCalendarController extends PhabricatorController {
|
||||||
->setContent($ics_data);
|
->setContent($ics_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function newImportedEventResponse(PhabricatorCalendarEvent $event) {
|
||||||
|
if (!$event->isImportedEvent()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give the user a specific, detailed message if they try to edit an
|
||||||
|
// imported event via common web paths. Other edits (including those via
|
||||||
|
// the API) are blocked by the normal policy system, but this makes it more
|
||||||
|
// clear exactly why the event can't be edited.
|
||||||
|
|
||||||
|
return $this->newDialog()
|
||||||
|
->setTitle(pht('Can Not Edit Imported Event'))
|
||||||
|
->appendParagraph(
|
||||||
|
pht(
|
||||||
|
'This event has been imported from an external source and '.
|
||||||
|
'can not be edited.'))
|
||||||
|
->addCancelButton($event->getURI(), pht('Done'));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,27 @@ final class PhabricatorCalendarEventCancelController
|
||||||
$viewer = $request->getViewer();
|
$viewer = $request->getViewer();
|
||||||
$id = $request->getURIData('id');
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
|
// Just check CAN_VIEW first. Then we'll check if this is an import so
|
||||||
|
// we can raise a better error.
|
||||||
$event = id(new PhabricatorCalendarEventQuery())
|
$event = id(new PhabricatorCalendarEventQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($id))
|
->withIDs(array($id))
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
|
||||||
))
|
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$event) {
|
if (!$event) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = $this->newImportedEventResponse($event);
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we've done the import check, check for CAN_EDIT.
|
||||||
|
PhabricatorPolicyFilter::requireCapability(
|
||||||
|
$viewer,
|
||||||
|
$event,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
$cancel_uri = $event->getURI();
|
$cancel_uri = $event->getURI();
|
||||||
|
|
||||||
$is_parent = $event->isParentEvent();
|
$is_parent = $event->isParentEvent();
|
||||||
|
|
|
@ -4,6 +4,20 @@ final class PhabricatorCalendarEventEditController
|
||||||
extends PhabricatorCalendarController {
|
extends PhabricatorCalendarController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$id = $request->getURIData('id');
|
||||||
|
if ($id) {
|
||||||
|
$event = id(new PhabricatorCalendarEventQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($id))
|
||||||
|
->executeOne();
|
||||||
|
$response = $this->newImportedEventResponse($event);
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return id(new PhabricatorCalendarEventEditEngine())
|
return id(new PhabricatorCalendarEventEditEngine())
|
||||||
->setController($this)
|
->setController($this)
|
||||||
->buildResponse();
|
->buildResponse();
|
||||||
|
|
|
@ -15,6 +15,11 @@ final class PhabricatorCalendarEventJoinController
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = $this->newImportedEventResponse($event);
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
$cancel_uri = $event->getURI();
|
$cancel_uri = $event->getURI();
|
||||||
|
|
||||||
$action = $request->getURIData('action');
|
$action = $request->getURIData('action');
|
||||||
|
|
|
@ -63,6 +63,19 @@ final class PhabricatorCalendarEventViewController
|
||||||
->setHeader(pht('Details'));
|
->setHeader(pht('Details'));
|
||||||
$recurring_header = $this->buildRecurringHeader($event);
|
$recurring_header = $this->buildRecurringHeader($event);
|
||||||
|
|
||||||
|
// NOTE: This is a bit hacky: for imported events, we're just hiding the
|
||||||
|
// comment form without actually preventing comments. Users could still
|
||||||
|
// submit a request to add comments to these events. This isn't really a
|
||||||
|
// major problem since they can't do anything truly bad and there isn't an
|
||||||
|
// easy way to selectively disable this or some other similar behaviors
|
||||||
|
// today, but it would probably be nice to fully disable these
|
||||||
|
// "pseudo-edits" (like commenting and probably subscribing and awarding
|
||||||
|
// tokens) at some point.
|
||||||
|
if ($event->isImportedEvent()) {
|
||||||
|
$comment_view = null;
|
||||||
|
$timeline->setShouldTerminate(true);
|
||||||
|
}
|
||||||
|
|
||||||
$view = id(new PHUITwoColumnView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->setSubheader($subheader)
|
->setSubheader($subheader)
|
||||||
|
@ -105,6 +118,16 @@ final class PhabricatorCalendarEventViewController
|
||||||
->setPolicyObject($event)
|
->setPolicyObject($event)
|
||||||
->setHeaderIcon($event->getIcon());
|
->setHeaderIcon($event->getIcon());
|
||||||
|
|
||||||
|
if ($event->isImportedEvent()) {
|
||||||
|
$header->addTag(
|
||||||
|
id(new PHUITagView())
|
||||||
|
->setType(PHUITagView::TYPE_SHADE)
|
||||||
|
->setName(pht('Imported'))
|
||||||
|
->setIcon('fa-download')
|
||||||
|
->setHref($event->getImportSource()->getURI())
|
||||||
|
->setShade('orange'));
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->buildRSVPActions($event) as $action) {
|
foreach ($this->buildRSVPActions($event) as $action) {
|
||||||
$header->addActionLink($action);
|
$header->addActionLink($action);
|
||||||
}
|
}
|
||||||
|
@ -141,12 +164,15 @@ final class PhabricatorCalendarEventViewController
|
||||||
->setWorkflow(!$can_edit));
|
->setWorkflow(!$can_edit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$can_attend = !$event->isImportedEvent();
|
||||||
|
|
||||||
if ($is_attending) {
|
if ($is_attending) {
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Decline Event'))
|
->setName(pht('Decline Event'))
|
||||||
->setIcon('fa-user-times')
|
->setIcon('fa-user-times')
|
||||||
->setHref($this->getApplicationURI("event/join/{$id}/"))
|
->setHref($this->getApplicationURI("event/join/{$id}/"))
|
||||||
|
->setDisabled(!$can_attend)
|
||||||
->setWorkflow(true));
|
->setWorkflow(true));
|
||||||
} else {
|
} else {
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
|
@ -154,6 +180,7 @@ final class PhabricatorCalendarEventViewController
|
||||||
->setName(pht('Join Event'))
|
->setName(pht('Join Event'))
|
||||||
->setIcon('fa-user-plus')
|
->setIcon('fa-user-plus')
|
||||||
->setHref($this->getApplicationURI("event/join/{$id}/"))
|
->setHref($this->getApplicationURI("event/join/{$id}/"))
|
||||||
|
->setDisabled(!$can_attend)
|
||||||
->setWorkflow(true));
|
->setWorkflow(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +288,15 @@ final class PhabricatorCalendarEventViewController
|
||||||
pht('None'));
|
pht('None'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($event->isImportedEvent()) {
|
||||||
|
$properties->addProperty(
|
||||||
|
pht('Imported By'),
|
||||||
|
pht(
|
||||||
|
'%s from %s',
|
||||||
|
$viewer->renderHandle($event->getImportAuthorPHID()),
|
||||||
|
$viewer->renderHandle($event->getImportSourcePHID())));
|
||||||
|
}
|
||||||
|
|
||||||
$properties->addProperty(
|
$properties->addProperty(
|
||||||
pht('Invitees'),
|
pht('Invitees'),
|
||||||
$invitee_list);
|
$invitee_list);
|
||||||
|
|
|
@ -33,7 +33,7 @@ final class PhabricatorCalendarImportPHIDType extends PhabricatorPHIDType {
|
||||||
$import = $objects[$phid];
|
$import = $objects[$phid];
|
||||||
|
|
||||||
$id = $import->getID();
|
$id = $import->getID();
|
||||||
$name = $import->getName();
|
$name = $import->getDisplayName();
|
||||||
$uri = $import->getURI();
|
$uri = $import->getURI();
|
||||||
|
|
||||||
$handle
|
$handle
|
||||||
|
|
|
@ -576,6 +576,10 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->isImportedEvent()) {
|
||||||
|
return 'fa-download';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->getIcon();
|
return $this->getIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,6 +588,10 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
return 'red';
|
return 'red';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->isImportedEvent()) {
|
||||||
|
return 'orange';
|
||||||
|
}
|
||||||
|
|
||||||
if ($viewer->isLoggedIn()) {
|
if ($viewer->isLoggedIn()) {
|
||||||
$status = $this->getUserInviteStatus($viewer->getPHID());
|
$status = $this->getUserInviteStatus($viewer->getPHID());
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
|
|
Loading…
Reference in a new issue