mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 15:22:41 +01:00
Make Calendar query for indirect invites/RSVPs by default, like Differential
Summary: Ref T11816. Since the dashboard got updated, Differential now interprets "Responsible Users: epriestley" to mean "epriestley, or any project or package epriestley is part of". You can query for just "epriestley" with "exact(epriestley)". Give Calendar invites the same behavior: "epriestley" means "any event epriestley is invited to, or a project they are a member of is invited to". Individual invites can be queried with "exact(epriestley)". This is a little bit copy-pastey but I want to wait for a third use case to clean it up since I think I'm going to have to do a bunch of generalization around "how does an individual PHID get turned into a bunch of PHIDs". Test Plan: Queried for "Invited: dog", "invited: viewer", "invited; exact(dog)", etc. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11816 Differential Revision: https://secure.phabricator.com/D16870
This commit is contained in:
parent
015ead6e7b
commit
e713cc08e6
6 changed files with 168 additions and 2 deletions
|
@ -2160,6 +2160,9 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCalendarImportTriggerLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportTriggerLogType.php',
|
'PhabricatorCalendarImportTriggerLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportTriggerLogType.php',
|
||||||
'PhabricatorCalendarImportUpdateLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php',
|
'PhabricatorCalendarImportUpdateLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php',
|
||||||
'PhabricatorCalendarImportViewController' => 'applications/calendar/controller/PhabricatorCalendarImportViewController.php',
|
'PhabricatorCalendarImportViewController' => 'applications/calendar/controller/PhabricatorCalendarImportViewController.php',
|
||||||
|
'PhabricatorCalendarInviteeDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeDatasource.php',
|
||||||
|
'PhabricatorCalendarInviteeUserDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeUserDatasource.php',
|
||||||
|
'PhabricatorCalendarInviteeViewerFunctionDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeViewerFunctionDatasource.php',
|
||||||
'PhabricatorCalendarManagementNotifyWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementNotifyWorkflow.php',
|
'PhabricatorCalendarManagementNotifyWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementNotifyWorkflow.php',
|
||||||
'PhabricatorCalendarManagementReloadWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php',
|
'PhabricatorCalendarManagementReloadWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php',
|
||||||
'PhabricatorCalendarManagementWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementWorkflow.php',
|
'PhabricatorCalendarManagementWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementWorkflow.php',
|
||||||
|
@ -7041,6 +7044,9 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCalendarImportTriggerLogType' => 'PhabricatorCalendarImportLogType',
|
'PhabricatorCalendarImportTriggerLogType' => 'PhabricatorCalendarImportLogType',
|
||||||
'PhabricatorCalendarImportUpdateLogType' => 'PhabricatorCalendarImportLogType',
|
'PhabricatorCalendarImportUpdateLogType' => 'PhabricatorCalendarImportLogType',
|
||||||
'PhabricatorCalendarImportViewController' => 'PhabricatorCalendarController',
|
'PhabricatorCalendarImportViewController' => 'PhabricatorCalendarController',
|
||||||
|
'PhabricatorCalendarInviteeDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||||
|
'PhabricatorCalendarInviteeUserDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||||
|
'PhabricatorCalendarInviteeViewerFunctionDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'PhabricatorCalendarManagementNotifyWorkflow' => 'PhabricatorCalendarManagementWorkflow',
|
'PhabricatorCalendarManagementNotifyWorkflow' => 'PhabricatorCalendarManagementWorkflow',
|
||||||
'PhabricatorCalendarManagementReloadWorkflow' => 'PhabricatorCalendarManagementWorkflow',
|
'PhabricatorCalendarManagementReloadWorkflow' => 'PhabricatorCalendarManagementWorkflow',
|
||||||
'PhabricatorCalendarManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
'PhabricatorCalendarManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||||
|
|
|
@ -36,7 +36,7 @@ final class PhabricatorCalendarEventSearchEngine
|
||||||
id(new PhabricatorSearchDatasourceField())
|
id(new PhabricatorSearchDatasourceField())
|
||||||
->setLabel(pht('Invited'))
|
->setLabel(pht('Invited'))
|
||||||
->setKey('invitedPHIDs')
|
->setKey('invitedPHIDs')
|
||||||
->setDatasource(new PhabricatorPeopleUserFunctionDatasource()),
|
->setDatasource(new PhabricatorCalendarInviteeDatasource()),
|
||||||
id(new PhabricatorSearchDateControlField())
|
id(new PhabricatorSearchDateControlField())
|
||||||
->setLabel(pht('Occurs After'))
|
->setLabel(pht('Occurs After'))
|
||||||
->setKey('rangeStart'),
|
->setKey('rangeStart'),
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCalendarInviteeDatasource
|
||||||
|
extends PhabricatorTypeaheadCompositeDatasource {
|
||||||
|
|
||||||
|
public function getBrowseTitle() {
|
||||||
|
return pht('Browse Invitees');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlaceholderText() {
|
||||||
|
return pht('Type a user or project name, or function...');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatasourceApplicationClass() {
|
||||||
|
return 'PhabricatorCalendarApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComponentDatasources() {
|
||||||
|
return array(
|
||||||
|
new PhabricatorCalendarInviteeUserDatasource(),
|
||||||
|
new PhabricatorCalendarInviteeViewerFunctionDatasource(),
|
||||||
|
new DifferentialExactUserFunctionDatasource(),
|
||||||
|
new PhabricatorProjectDatasource(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function expandInvitees(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
array $values) {
|
||||||
|
|
||||||
|
$phids = array();
|
||||||
|
foreach ($values as $value) {
|
||||||
|
if (phid_get_type($value) == PhabricatorPeopleUserPHIDType::TYPECONST) {
|
||||||
|
$phids[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$phids) {
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
$projects = id(new PhabricatorProjectQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withMemberPHIDs($phids)
|
||||||
|
->execute();
|
||||||
|
foreach ($projects as $project) {
|
||||||
|
$values[] = $project->getPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCalendarInviteeUserDatasource
|
||||||
|
extends PhabricatorTypeaheadCompositeDatasource {
|
||||||
|
|
||||||
|
public function getBrowseTitle() {
|
||||||
|
return pht('Browse Users');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlaceholderText() {
|
||||||
|
return pht('Type a user name...');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatasourceApplicationClass() {
|
||||||
|
return 'PhabricatorCalendarApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComponentDatasources() {
|
||||||
|
return array(
|
||||||
|
new PhabricatorPeopleDatasource(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function evaluateValues(array $values) {
|
||||||
|
return PhabricatorCalendarInviteeDatasource::expandInvitees(
|
||||||
|
$this->getViewer(),
|
||||||
|
$values);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCalendarInviteeViewerFunctionDatasource
|
||||||
|
extends PhabricatorTypeaheadDatasource {
|
||||||
|
|
||||||
|
public function getBrowseTitle() {
|
||||||
|
return pht('Browse Viewer');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlaceholderText() {
|
||||||
|
return pht('Type viewer()...');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatasourceApplicationClass() {
|
||||||
|
return 'PhabricatorPeopleApplication';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatasourceFunctions() {
|
||||||
|
return array(
|
||||||
|
'viewer' => array(
|
||||||
|
'name' => pht('Current Viewer'),
|
||||||
|
'summary' => pht('Use the current viewing user.'),
|
||||||
|
'description' => pht(
|
||||||
|
'Show invites the current viewer is invited to. This function '.
|
||||||
|
'includes events the user is invited to because a project they '.
|
||||||
|
'are a member of is invited.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadResults() {
|
||||||
|
if ($this->getViewer()->getPHID()) {
|
||||||
|
$results = array($this->renderViewerFunctionToken());
|
||||||
|
} else {
|
||||||
|
$results = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->filterResultsAgainstTokens($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function canEvaluateFunction($function) {
|
||||||
|
if (!$this->getViewer()->getPHID()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::canEvaluateFunction($function);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function evaluateFunction($function, array $argv_list) {
|
||||||
|
$results = array();
|
||||||
|
foreach ($argv_list as $argv) {
|
||||||
|
$results[] = $this->getViewer()->getPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
return PhabricatorCalendarInviteeDatasource::expandInvitees(
|
||||||
|
$this->getViewer(),
|
||||||
|
$results);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderFunctionTokens($function, array $argv_list) {
|
||||||
|
$tokens = array();
|
||||||
|
foreach ($argv_list as $argv) {
|
||||||
|
$tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
|
||||||
|
$this->renderViewerFunctionToken());
|
||||||
|
}
|
||||||
|
return $tokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderViewerFunctionToken() {
|
||||||
|
return $this->newFunctionResult()
|
||||||
|
->setName(pht('Current Viewer'))
|
||||||
|
->setPHID('viewer()')
|
||||||
|
->setIcon('fa-user')
|
||||||
|
->setUnique(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ final class DifferentialExactUserFunctionDatasource
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDatasourceApplicationClass() {
|
public function getDatasourceApplicationClass() {
|
||||||
return 'PhabricatorDifferentialApplication';
|
return 'PhabricatorPeopleApplication';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getComponentDatasources() {
|
public function getComponentDatasources() {
|
||||||
|
|
Loading…
Reference in a new issue