mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Workboard Trigger Rule: allow to Add/Remove Subscribers
Summary: This is a natural expansion of the Workboard Trigger system to support actions about Subscribers. Context: even before this change - Workboard users were already able to move Tasks to Columns with nice automatisms. For instance, you can already: - Play a nice Sound - Change Task Priority - Change Task Status - Add or Remove a Task Owner - Add or Remove a Task Project Tag With this change, you can also: - Add or Remove Task Subscribers If you need inspiration, this feature is useful for adding more eyes on a given work area; lighten the notifications of certain people after certain workflows have already been done, to increase happiness and mitigate Burnout. If your goal is to oppress yourself or your coworkers - of course you can also use this feature to increase the Burnout of yourself or your coworkers, adding random people as Subscriber. Note: every trigger action can be confusing in general, but it is the fault of Triggers in general and not related to this specific feature - that is totally loveable, just like you. Closes T15162 Test Plan: - Workboard > Column > Create Trigger - Add Action > Add Subscriber > (your best friend who hates NodeJS) - Add Action > Remove Subscriber > (your antagonist who hates PHP) - Move some Tasks there and here, and note that Add/Remove works Reviewers: O1 Blessed Committers, Cigaryno, aklapper Reviewed By: O1 Blessed Committers, Cigaryno, aklapper Subscribers: aklapper, speck, tobiaswiese, Matthew, Cigaryno Tags: #workboard Maniphest Tasks: T15162 Differential Revision: https://we.phorge.it/D25080
This commit is contained in:
parent
f4d9d6920b
commit
b8a03bc145
3 changed files with 258 additions and 0 deletions
|
@ -4491,6 +4491,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectTransactionType' => 'applications/project/xaction/PhabricatorProjectTransactionType.php',
|
'PhabricatorProjectTransactionType' => 'applications/project/xaction/PhabricatorProjectTransactionType.php',
|
||||||
'PhabricatorProjectTrigger' => 'applications/project/storage/PhabricatorProjectTrigger.php',
|
'PhabricatorProjectTrigger' => 'applications/project/storage/PhabricatorProjectTrigger.php',
|
||||||
'PhabricatorProjectTriggerAddProjectsRule' => 'applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php',
|
'PhabricatorProjectTriggerAddProjectsRule' => 'applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php',
|
||||||
|
'PhabricatorProjectTriggerAddSubscribersRule' => 'applications/project/trigger/PhabricatorProjectTriggerAddSubscribersRule.php',
|
||||||
'PhabricatorProjectTriggerController' => 'applications/project/controller/trigger/PhabricatorProjectTriggerController.php',
|
'PhabricatorProjectTriggerController' => 'applications/project/controller/trigger/PhabricatorProjectTriggerController.php',
|
||||||
'PhabricatorProjectTriggerCorruptionException' => 'applications/project/exception/PhabricatorProjectTriggerCorruptionException.php',
|
'PhabricatorProjectTriggerCorruptionException' => 'applications/project/exception/PhabricatorProjectTriggerCorruptionException.php',
|
||||||
'PhabricatorProjectTriggerEditController' => 'applications/project/controller/trigger/PhabricatorProjectTriggerEditController.php',
|
'PhabricatorProjectTriggerEditController' => 'applications/project/controller/trigger/PhabricatorProjectTriggerEditController.php',
|
||||||
|
@ -4505,6 +4506,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectTriggerPlaySoundRule' => 'applications/project/trigger/PhabricatorProjectTriggerPlaySoundRule.php',
|
'PhabricatorProjectTriggerPlaySoundRule' => 'applications/project/trigger/PhabricatorProjectTriggerPlaySoundRule.php',
|
||||||
'PhabricatorProjectTriggerQuery' => 'applications/project/query/PhabricatorProjectTriggerQuery.php',
|
'PhabricatorProjectTriggerQuery' => 'applications/project/query/PhabricatorProjectTriggerQuery.php',
|
||||||
'PhabricatorProjectTriggerRemoveProjectsRule' => 'applications/project/trigger/PhabricatorProjectTriggerRemoveProjectsRule.php',
|
'PhabricatorProjectTriggerRemoveProjectsRule' => 'applications/project/trigger/PhabricatorProjectTriggerRemoveProjectsRule.php',
|
||||||
|
'PhabricatorProjectTriggerRemoveSubscribersRule' => 'applications/project/trigger/PhabricatorProjectTriggerRemoveSubscribersRule.php',
|
||||||
'PhabricatorProjectTriggerRule' => 'applications/project/trigger/PhabricatorProjectTriggerRule.php',
|
'PhabricatorProjectTriggerRule' => 'applications/project/trigger/PhabricatorProjectTriggerRule.php',
|
||||||
'PhabricatorProjectTriggerRuleRecord' => 'applications/project/trigger/PhabricatorProjectTriggerRuleRecord.php',
|
'PhabricatorProjectTriggerRuleRecord' => 'applications/project/trigger/PhabricatorProjectTriggerRuleRecord.php',
|
||||||
'PhabricatorProjectTriggerRulesetTransaction' => 'applications/project/xaction/trigger/PhabricatorProjectTriggerRulesetTransaction.php',
|
'PhabricatorProjectTriggerRulesetTransaction' => 'applications/project/xaction/trigger/PhabricatorProjectTriggerRulesetTransaction.php',
|
||||||
|
@ -11129,6 +11131,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorProjectTriggerAddProjectsRule' => 'PhabricatorProjectTriggerRule',
|
'PhabricatorProjectTriggerAddProjectsRule' => 'PhabricatorProjectTriggerRule',
|
||||||
|
'PhabricatorProjectTriggerAddSubscribersRule' => 'PhabricatorProjectTriggerRule',
|
||||||
'PhabricatorProjectTriggerController' => 'PhabricatorProjectController',
|
'PhabricatorProjectTriggerController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectTriggerCorruptionException' => 'Exception',
|
'PhabricatorProjectTriggerCorruptionException' => 'Exception',
|
||||||
'PhabricatorProjectTriggerEditController' => 'PhabricatorProjectTriggerController',
|
'PhabricatorProjectTriggerEditController' => 'PhabricatorProjectTriggerController',
|
||||||
|
@ -11143,6 +11146,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectTriggerPlaySoundRule' => 'PhabricatorProjectTriggerRule',
|
'PhabricatorProjectTriggerPlaySoundRule' => 'PhabricatorProjectTriggerRule',
|
||||||
'PhabricatorProjectTriggerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhabricatorProjectTriggerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhabricatorProjectTriggerRemoveProjectsRule' => 'PhabricatorProjectTriggerRule',
|
'PhabricatorProjectTriggerRemoveProjectsRule' => 'PhabricatorProjectTriggerRule',
|
||||||
|
'PhabricatorProjectTriggerRemoveSubscribersRule' => 'PhabricatorProjectTriggerRule',
|
||||||
'PhabricatorProjectTriggerRule' => 'Phobject',
|
'PhabricatorProjectTriggerRule' => 'Phobject',
|
||||||
'PhabricatorProjectTriggerRuleRecord' => 'Phobject',
|
'PhabricatorProjectTriggerRuleRecord' => 'Phobject',
|
||||||
'PhabricatorProjectTriggerRulesetTransaction' => 'PhabricatorProjectTriggerTransactionType',
|
'PhabricatorProjectTriggerRulesetTransaction' => 'PhabricatorProjectTriggerTransactionType',
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger Rule that Adds Subscribers
|
||||||
|
*
|
||||||
|
* This may be useful to automatically engage some
|
||||||
|
* Users or Project Tags on certain Workboard areas.
|
||||||
|
*
|
||||||
|
* This class was adapted from these classes:
|
||||||
|
* - PhabricatorProjectTriggerAddProjectsRule
|
||||||
|
* - PhabricatorProjectTriggerManiphestOwnerRule
|
||||||
|
*
|
||||||
|
* https://we.phorge.it/T15162
|
||||||
|
*/
|
||||||
|
final class PhabricatorProjectTriggerAddSubscribersRule
|
||||||
|
extends PhabricatorProjectTriggerRule {
|
||||||
|
|
||||||
|
const TRIGGERTYPE = 'task.subscriber.add';
|
||||||
|
|
||||||
|
public function getSelectControlName() {
|
||||||
|
return pht('Add subscribers');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getValueForEditorField() {
|
||||||
|
return $this->getDatasource()->getWireTokens($this->getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertValidRuleRecordFormat($value) {
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Add subscribers rule value should be a list, but is not '.
|
||||||
|
'(value is "%s").',
|
||||||
|
phutil_describe_type($value)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertValidRuleRecordValue($value) {
|
||||||
|
if (!$value) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You must select at least one user or project tag to add.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newDropTransactions($object, $value) {
|
||||||
|
$subscriber_edge_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
|
||||||
|
|
||||||
|
$xaction = $object->getApplicationTransactionTemplate()
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $subscriber_edge_type)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'+' => array_fuse($value),
|
||||||
|
));
|
||||||
|
|
||||||
|
return array($xaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newDropEffects($value) {
|
||||||
|
return array(
|
||||||
|
$this->newEffect()
|
||||||
|
->setIcon('fa-briefcase')
|
||||||
|
->setContent($this->getRuleViewDescription($value)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getDefaultValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPHUIXControlType() {
|
||||||
|
return 'tokenizer';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDatasource() {
|
||||||
|
$datasource = new PhabricatorProjectOrUserDatasource();
|
||||||
|
|
||||||
|
if ($this->getViewer()) {
|
||||||
|
$datasource->setViewer($this->getViewer());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $datasource;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPHUIXControlSpecification() {
|
||||||
|
$template = id(new AphrontTokenizerTemplateView())
|
||||||
|
->setViewer($this->getViewer());
|
||||||
|
|
||||||
|
$template_markup = $template->render();
|
||||||
|
$datasource = $this->getDatasource();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'markup' => (string)hsprintf('%s', $template_markup),
|
||||||
|
'config' => array(
|
||||||
|
'src' => $datasource->getDatasourceURI(),
|
||||||
|
'browseURI' => $datasource->getBrowseURI(),
|
||||||
|
'placeholder' => $datasource->getPlaceholderText(),
|
||||||
|
'limit' => $datasource->getLimit(),
|
||||||
|
),
|
||||||
|
'value' => null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRuleViewLabel() {
|
||||||
|
return pht('Add subscribers');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRuleViewDescription($value) {
|
||||||
|
return pht(
|
||||||
|
'Add subscribers: %s.',
|
||||||
|
phutil_tag(
|
||||||
|
'strong',
|
||||||
|
array(),
|
||||||
|
$this->getViewer()
|
||||||
|
->renderHandleList($value)
|
||||||
|
->setAsInline(true)
|
||||||
|
->render()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRuleViewIcon($value) {
|
||||||
|
return id(new PHUIIconView())
|
||||||
|
->setIcon('fa-users', 'green');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger Rule that Removes Subscribers
|
||||||
|
*
|
||||||
|
* This may be useful to have a column that simplify
|
||||||
|
* Task handovers. You can remove both Users or Project Tags
|
||||||
|
* from the list of Task Subscribers.
|
||||||
|
*
|
||||||
|
* This class was adapted from these classes:
|
||||||
|
* - PhabricatorProjectTriggerRemoveProjectsRule
|
||||||
|
* - PhabricatorProjectTriggerManiphestOwnerRule
|
||||||
|
*
|
||||||
|
* https://we.phorge.it/T15162
|
||||||
|
*/
|
||||||
|
final class PhabricatorProjectTriggerRemoveSubscribersRule
|
||||||
|
extends PhabricatorProjectTriggerRule {
|
||||||
|
|
||||||
|
const TRIGGERTYPE = 'task.subscriber.remove';
|
||||||
|
|
||||||
|
public function getSelectControlName() {
|
||||||
|
return pht('Remove subscribers');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getValueForEditorField() {
|
||||||
|
return $this->getDatasource()->getWireTokens($this->getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertValidRuleRecordFormat($value) {
|
||||||
|
if (!is_array($value)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Remove subscribers rule value should be a list, but is not '.
|
||||||
|
'(value is "%s").',
|
||||||
|
phutil_describe_type($value)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertValidRuleRecordValue($value) {
|
||||||
|
if (!$value) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You must select at least one user or project tag to remove.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newDropTransactions($object, $value) {
|
||||||
|
$subscriber_edge_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
|
||||||
|
|
||||||
|
$xaction = $object->getApplicationTransactionTemplate()
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $subscriber_edge_type)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'-' => array_fuse($value),
|
||||||
|
));
|
||||||
|
|
||||||
|
return array($xaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newDropEffects($value) {
|
||||||
|
return array(
|
||||||
|
$this->newEffect()
|
||||||
|
->setIcon('fa-briefcase')
|
||||||
|
->setContent($this->getRuleViewDescription($value)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getDefaultValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPHUIXControlType() {
|
||||||
|
return 'tokenizer';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDatasource() {
|
||||||
|
$datasource = new PhabricatorProjectOrUserDatasource();
|
||||||
|
|
||||||
|
if ($this->getViewer()) {
|
||||||
|
$datasource->setViewer($this->getViewer());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $datasource;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPHUIXControlSpecification() {
|
||||||
|
$template = id(new AphrontTokenizerTemplateView())
|
||||||
|
->setViewer($this->getViewer());
|
||||||
|
|
||||||
|
$template_markup = $template->render();
|
||||||
|
$datasource = $this->getDatasource();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'markup' => (string)hsprintf('%s', $template_markup),
|
||||||
|
'config' => array(
|
||||||
|
'src' => $datasource->getDatasourceURI(),
|
||||||
|
'browseURI' => $datasource->getBrowseURI(),
|
||||||
|
'placeholder' => $datasource->getPlaceholderText(),
|
||||||
|
'limit' => $datasource->getLimit(),
|
||||||
|
),
|
||||||
|
'value' => null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRuleViewLabel() {
|
||||||
|
return pht('Remove subscribers');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRuleViewDescription($value) {
|
||||||
|
return pht(
|
||||||
|
'Remove subscribers: %s.',
|
||||||
|
phutil_tag(
|
||||||
|
'strong',
|
||||||
|
array(),
|
||||||
|
$this->getViewer()
|
||||||
|
->renderHandleList($value)
|
||||||
|
->setAsInline(true)
|
||||||
|
->render()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRuleViewIcon($value) {
|
||||||
|
return id(new PHUIIconView())
|
||||||
|
->setIcon('fa-users', 'red');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue