Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php b/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
index 2077160b7c..3d43d972f6 100644
--- a/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
+++ b/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
@@ -1,153 +1,160 @@
<?php
final class PhabricatorSubscriptionsUIEventListener
extends PhabricatorEventListener {
public function register() {
$this->listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS);
$this->listen(PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES);
}
public function handleEvent(PhutilEvent $event) {
$object = $event->getValue('object');
switch ($event->getType()) {
case PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS:
$this->handleActionEvent($event);
break;
case PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES:
// Hacky solution so that property list view on Diffusion
// commits shows build status, but not Projects, Subscriptions,
// or Tokens.
if ($object instanceof PhabricatorRepositoryCommit) {
return;
}
$this->handlePropertyEvent($event);
break;
}
}
private function handleActionEvent($event) {
$user = $event->getUser();
$user_phid = $user->getPHID();
$object = $event->getValue('object');
if (!$object || !$object->getPHID()) {
// No object, or the object has no PHID yet. No way to subscribe.
return;
}
if (!($object instanceof PhabricatorSubscribableInterface)) {
// This object isn't subscribable.
return;
}
$src_phid = $object->getPHID();
$subscribed_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
$muted_type = PhabricatorMutedByEdgeType::EDGECONST;
$edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array($src_phid))
->withEdgeTypes(
array(
$subscribed_type,
$muted_type,
))
->withDestinationPHIDs(array($user_phid))
->execute();
if ($user_phid) {
$is_subscribed = isset($edges[$src_phid][$subscribed_type][$user_phid]);
$is_muted = isset($edges[$src_phid][$muted_type][$user_phid]);
} else {
$is_subscribed = false;
$is_muted = false;
}
if ($user_phid && $object->isAutomaticallySubscribed($user_phid)) {
$sub_action = id(new PhabricatorActionView())
->setWorkflow(true)
->setDisabled(true)
->setRenderAsForm(true)
->setHref('/subscriptions/add/'.$object->getPHID().'/')
->setName(pht('Automatically Subscribed'))
->setIcon('fa-check-circle lightgreytext');
} else {
if ($is_subscribed) {
$sub_action = id(new PhabricatorActionView())
->setWorkflow(true)
->setRenderAsForm(true)
->setHref('/subscriptions/delete/'.$object->getPHID().'/')
->setName(pht('Unsubscribe'))
->setIcon('fa-minus-circle');
} else {
$sub_action = id(new PhabricatorActionView())
->setWorkflow(true)
->setRenderAsForm(true)
->setHref('/subscriptions/add/'.$object->getPHID().'/')
->setName(pht('Subscribe'))
->setIcon('fa-plus-circle');
}
if (!$user->isLoggedIn()) {
$sub_action->setDisabled(true);
}
}
- $mute_action = id(new PhabricatorActionView())
- ->setWorkflow(true)
- ->setHref('/subscriptions/mute/'.$object->getPHID().'/')
- ->setDisabled(!$user_phid);
-
- if (!$is_muted) {
- $mute_action
- ->setName(pht('Mute Notifications'))
- ->setIcon('fa-volume-up');
- } else {
- $mute_action
- ->setName(pht('Unmute Notifications'))
- ->setIcon('fa-volume-off')
- ->setColor(PhabricatorActionView::RED);
- }
-
-
$actions = $event->getValue('actions');
$actions[] = $sub_action;
- $actions[] = $mute_action;
+
+ // Hide "Mute Notifications" in sidebar if not supported by Editor - T15378
+ $supported_editor_transaction_types =
+ array_fill_keys($object->getApplicationTransactionEditor()
+ ->getTransactionTypesForObject($object), true);
+ if (array_key_exists(PhabricatorTransactions::TYPE_EDGE,
+ $supported_editor_transaction_types)) {
+ $mute_action = id(new PhabricatorActionView())
+ ->setWorkflow(true)
+ ->setHref('/subscriptions/mute/'.$object->getPHID().'/')
+ ->setDisabled(!$user_phid);
+
+ if (!$is_muted) {
+ $mute_action
+ ->setName(pht('Mute Notifications'))
+ ->setIcon('fa-volume-up');
+ } else {
+ $mute_action
+ ->setName(pht('Unmute Notifications'))
+ ->setIcon('fa-volume-off')
+ ->setColor(PhabricatorActionView::RED);
+ }
+ $actions[] = $mute_action;
+ }
+
$event->setValue('actions', $actions);
}
private function handlePropertyEvent($event) {
$user = $event->getUser();
$object = $event->getValue('object');
if (!$object || !$object->getPHID()) {
// No object, or the object has no PHID yet..
return;
}
if (!($object instanceof PhabricatorSubscribableInterface)) {
// This object isn't subscribable.
return;
}
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$object->getPHID());
if ($subscribers) {
$handles = id(new PhabricatorHandleQuery())
->setViewer($user)
->withPHIDs($subscribers)
->execute();
} else {
$handles = array();
}
$sub_view = id(new SubscriptionListStringBuilder())
->setObjectPHID($object->getPHID())
->setHandles($handles)
->buildPropertyString();
$view = $event->getValue('view');
$view->addProperty(pht('Subscribers'), $sub_view);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 1:11 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1137
Default Alt Text
(5 KB)

Event Timeline