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

Avoid PhabricatorApplicationTransactionStructureException on editors not supporting Mute Notifications

Summary:
Do not expose the "Mute Notifications" sidebar menu entry when the underlying Editor for that object type does not support muting notifications (means: creating a transaction of type "core:edge") at all.
This avoids a disappointing `PhabricatorApplicationTransactionStructureException` after two clicks.

Disabling the menu entry while still exposing it makes no sense here as the user could never get it enabled anyway.

```
EXCEPTION: (PhabricatorApplicationTransactionStructureException) Attempting to apply a transaction (of class "PhabricatorFileTransaction", with type "core:edge") which has not been constructed correctly: Transaction has type "core:edge", but that transaction type is not supported by this editor (PhabricatorFileEditor). at [<phorge>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:1830]
```

```
EXCEPTION: (PhabricatorApplicationTransactionStructureException) Attempting to apply a transaction (of class "LegalpadTransaction", with type "core:edge") which has not been constructed correctly: Transaction has type "core:edge", but that transaction type is not supported by this editor (LegalpadDocumentEditor). at [<phorge>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:1830]
```

Closes T15378

Test Plan:
* Open various different object types:
** Files: http://phorge.localhost/F1 (not implemented)
** Legalpad: http://phorge.localhost/legalpad/view/1/ (not implemented)
** Maniphest: http://phorge.localhost/T1 (implemented)
* Click "Subscribe" on these various types of objects.
* Click "Mute Notifications" on these various types of objects, remember which objects throw an exception.
* Apply this patch.
* Check that "Mute Notifications" is not exposed for those types of objects that threw an exception.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15378

Differential Revision: https://we.phorge.it/D25730

+24 -17
+24 -17
src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
··· 94 94 } 95 95 } 96 96 97 - $mute_action = id(new PhabricatorActionView()) 98 - ->setWorkflow(true) 99 - ->setHref('/subscriptions/mute/'.$object->getPHID().'/') 100 - ->setDisabled(!$user_phid); 97 + $actions = $event->getValue('actions'); 98 + $actions[] = $sub_action; 99 + 100 + // Hide "Mute Notifications" in sidebar if not supported by Editor - T15378 101 + $supported_editor_transaction_types = 102 + array_fill_keys($object->getApplicationTransactionEditor() 103 + ->getTransactionTypesForObject($object), true); 104 + if (array_key_exists(PhabricatorTransactions::TYPE_EDGE, 105 + $supported_editor_transaction_types)) { 106 + $mute_action = id(new PhabricatorActionView()) 107 + ->setWorkflow(true) 108 + ->setHref('/subscriptions/mute/'.$object->getPHID().'/') 109 + ->setDisabled(!$user_phid); 101 110 102 - if (!$is_muted) { 103 - $mute_action 104 - ->setName(pht('Mute Notifications')) 105 - ->setIcon('fa-volume-up'); 106 - } else { 107 - $mute_action 108 - ->setName(pht('Unmute Notifications')) 109 - ->setIcon('fa-volume-off') 110 - ->setColor(PhabricatorActionView::RED); 111 + if (!$is_muted) { 112 + $mute_action 113 + ->setName(pht('Mute Notifications')) 114 + ->setIcon('fa-volume-up'); 115 + } else { 116 + $mute_action 117 + ->setName(pht('Unmute Notifications')) 118 + ->setIcon('fa-volume-off') 119 + ->setColor(PhabricatorActionView::RED); 120 + } 121 + $actions[] = $mute_action; 111 122 } 112 123 113 - 114 - $actions = $event->getValue('actions'); 115 - $actions[] = $sub_action; 116 - $actions[] = $mute_action; 117 124 $event->setValue('actions', $actions); 118 125 } 119 126