mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Distinguish between "Assigned" and "Effective" identity PHIDs more clearly and consistently
Summary: Ref T13444. You can currently explicitly unassign an identity (useful if the matching algorithm is misfiring). However, this populates the "currentEffectiveUserPHID" with the "unassigned()" token, which mostly makes things more difficult. When an identity is explicitly unassigned, convert that into an explicit `null` in the effective user PHID. Then, realign "assigned" / "effective" language a bit. Previously, `withAssigneePHIDs(...)` actualy queried effective users, which was misleading. Finally, bulk up the list view a little bit to make testing slightly easier. Test Plan: - Unassigned an identity, ran migration, saw `currentEffectiveUserPHID` become `NULL` for the identity. - Unassigned a fresh identity, saw NULL. - Queried for various identities under the modified constraints. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13444 Differential Revision: https://secure.phabricator.com/D20908
This commit is contained in:
parent
df0f5c6cee
commit
a2b2c391a1
5 changed files with 100 additions and 17 deletions
|
@ -0,0 +1,3 @@
|
|||
UPDATE {$NAMESPACE}_repository.repository_identity
|
||||
SET currentEffectiveUserPHID = NULL
|
||||
WHERE currentEffectiveUserPHID = 'unassigned()';
|
|
@ -25,6 +25,9 @@ final class DiffusionIdentityViewController
|
|||
->setHeaderIcon('fa-globe');
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(
|
||||
pht('Identities'),
|
||||
$this->getApplicationURI('identity/'));
|
||||
$crumbs->addTextCrumb($identity->getObjectName());
|
||||
$crumbs->setBorder(true);
|
||||
|
||||
|
|
|
@ -17,21 +17,35 @@ final class DiffusionRepositoryIdentitySearchEngine
|
|||
|
||||
protected function buildCustomSearchFields() {
|
||||
return array(
|
||||
id(new PhabricatorUsersSearchField())
|
||||
->setLabel(pht('Matching Users'))
|
||||
->setKey('effectivePHIDs')
|
||||
->setAliases(
|
||||
array(
|
||||
'effective',
|
||||
'effectivePHID',
|
||||
))
|
||||
->setDescription(pht('Search for identities by effective user.')),
|
||||
id(new DiffusionIdentityAssigneeSearchField())
|
||||
->setLabel(pht('Assigned To'))
|
||||
->setKey('assignee')
|
||||
->setDescription(pht('Search for identities by assignee.')),
|
||||
->setKey('assignedPHIDs')
|
||||
->setAliases(
|
||||
array(
|
||||
'assigned',
|
||||
'assignedPHID',
|
||||
))
|
||||
->setDescription(pht('Search for identities by explicit assignee.')),
|
||||
id(new PhabricatorSearchTextField())
|
||||
->setLabel(pht('Identity Contains'))
|
||||
->setKey('match')
|
||||
->setDescription(pht('Search for identities by substring.')),
|
||||
id(new PhabricatorSearchThreeStateField())
|
||||
->setLabel(pht('Is Assigned'))
|
||||
->setLabel(pht('Has Matching User'))
|
||||
->setKey('hasEffectivePHID')
|
||||
->setOptions(
|
||||
pht('(Show All)'),
|
||||
pht('Show Only Assigned Identities'),
|
||||
pht('Show Only Unassigned Identities')),
|
||||
pht('Show Identities With Matching Users'),
|
||||
pht('Show Identities Without Matching Users')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -46,8 +60,12 @@ final class DiffusionRepositoryIdentitySearchEngine
|
|||
$query->withIdentityNameLike($map['match']);
|
||||
}
|
||||
|
||||
if ($map['assignee']) {
|
||||
$query->withAssigneePHIDs($map['assignee']);
|
||||
if ($map['assignedPHIDs']) {
|
||||
$query->withAssignedPHIDs($map['assignedPHIDs']);
|
||||
}
|
||||
|
||||
if ($map['effectivePHIDs']) {
|
||||
$query->withEffectivePHIDs($map['effectivePHIDs']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
@ -86,15 +104,54 @@ final class DiffusionRepositoryIdentitySearchEngine
|
|||
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$list = new PHUIObjectItemListView();
|
||||
$list->setUser($viewer);
|
||||
$list = id(new PHUIObjectItemListView())
|
||||
->setViewer($viewer);
|
||||
|
||||
$phids = array();
|
||||
foreach ($identities as $identity) {
|
||||
$phids[] = $identity->getCurrentEffectiveUserPHID();
|
||||
$phids[] = $identity->getManuallySetUserPHID();
|
||||
}
|
||||
|
||||
$handles = $viewer->loadHandles($phids);
|
||||
|
||||
$unassigned = DiffusionIdentityUnassignedDatasource::FUNCTION_TOKEN;
|
||||
|
||||
foreach ($identities as $identity) {
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObjectName(pht('Identity %d', $identity->getID()))
|
||||
->setObjectName($identity->getObjectName())
|
||||
->setHeader($identity->getIdentityShortName())
|
||||
->setHref($identity->getURI())
|
||||
->setObject($identity);
|
||||
|
||||
$status_icon = 'fa-circle-o grey';
|
||||
|
||||
$effective_phid = $identity->getCurrentEffectiveUserPHID();
|
||||
if ($effective_phid) {
|
||||
$item->addIcon(
|
||||
'fa-id-badge',
|
||||
pht('Matches User: %s', $handles[$effective_phid]->getName()));
|
||||
|
||||
$status_icon = 'fa-id-badge';
|
||||
}
|
||||
|
||||
$assigned_phid = $identity->getManuallySetUserPHID();
|
||||
if ($assigned_phid) {
|
||||
if ($assigned_phid === $unassigned) {
|
||||
$item->addIcon(
|
||||
'fa-ban',
|
||||
pht('Explicitly Unassigned'));
|
||||
$status_icon = 'fa-ban';
|
||||
} else {
|
||||
$item->addIcon(
|
||||
'fa-user',
|
||||
pht('Assigned To: %s', $handles[$assigned_phid]->getName()));
|
||||
$status_icon = 'fa-user';
|
||||
}
|
||||
}
|
||||
|
||||
$item->setStatusIcon($status_icon);
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@ final class PhabricatorRepositoryIdentityQuery
|
|||
private $phids;
|
||||
private $identityNames;
|
||||
private $emailAddresses;
|
||||
private $assigneePHIDs;
|
||||
private $assignedPHIDs;
|
||||
private $effectivePHIDs;
|
||||
private $identityNameLike;
|
||||
private $hasEffectivePHID;
|
||||
|
||||
|
@ -36,8 +37,13 @@ final class PhabricatorRepositoryIdentityQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withAssigneePHIDs(array $assignees) {
|
||||
$this->assigneePHIDs = $assignees;
|
||||
public function withAssignedPHIDs(array $assigned) {
|
||||
$this->assignedPHIDs = $assigned;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withEffectivePHIDs(array $effective) {
|
||||
$this->effectivePHIDs = $effective;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -75,11 +81,18 @@ final class PhabricatorRepositoryIdentityQuery
|
|||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->assigneePHIDs !== null) {
|
||||
if ($this->assignedPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'repository_identity.manuallySetUserPHID IN (%Ls)',
|
||||
$this->assignedPHIDs);
|
||||
}
|
||||
|
||||
if ($this->effectivePHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'repository_identity.currentEffectiveUserPHID IN (%Ls)',
|
||||
$this->assigneePHIDs);
|
||||
$this->effectivePHIDs);
|
||||
}
|
||||
|
||||
if ($this->hasEffectivePHID !== null) {
|
||||
|
|
|
@ -96,10 +96,17 @@ final class PhabricatorRepositoryIdentity
|
|||
|
||||
public function save() {
|
||||
if ($this->manuallySetUserPHID) {
|
||||
$this->currentEffectiveUserPHID = $this->manuallySetUserPHID;
|
||||
$unassigned = DiffusionIdentityUnassignedDatasource::FUNCTION_TOKEN;
|
||||
if ($this->manuallySetUserPHID === $unassigned) {
|
||||
$effective_phid = null;
|
||||
} else {
|
||||
$this->currentEffectiveUserPHID = $this->automaticGuessedUserPHID;
|
||||
$effective_phid = $this->manuallySetUserPHID;
|
||||
}
|
||||
} else {
|
||||
$effective_phid = $this->automaticGuessedUserPHID;
|
||||
}
|
||||
|
||||
$this->setCurrentEffectiveUserPHID($effective_phid);
|
||||
|
||||
$email_address = $this->getIdentityEmailAddress();
|
||||
|
||||
|
|
Loading…
Reference in a new issue