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

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

+100 -17
+3
resources/sql/autopatches/20191113.identity.03.unassigned.sql
··· 1 + UPDATE {$NAMESPACE}_repository.repository_identity 2 + SET currentEffectiveUserPHID = NULL 3 + WHERE currentEffectiveUserPHID = 'unassigned()';
+3
src/applications/diffusion/controller/DiffusionIdentityViewController.php
··· 25 25 ->setHeaderIcon('fa-globe'); 26 26 27 27 $crumbs = $this->buildApplicationCrumbs(); 28 + $crumbs->addTextCrumb( 29 + pht('Identities'), 30 + $this->getApplicationURI('identity/')); 28 31 $crumbs->addTextCrumb($identity->getObjectName()); 29 32 $crumbs->setBorder(true); 30 33
+67 -10
src/applications/diffusion/query/DiffusionRepositoryIdentitySearchEngine.php
··· 17 17 18 18 protected function buildCustomSearchFields() { 19 19 return array( 20 + id(new PhabricatorUsersSearchField()) 21 + ->setLabel(pht('Matching Users')) 22 + ->setKey('effectivePHIDs') 23 + ->setAliases( 24 + array( 25 + 'effective', 26 + 'effectivePHID', 27 + )) 28 + ->setDescription(pht('Search for identities by effective user.')), 20 29 id(new DiffusionIdentityAssigneeSearchField()) 21 30 ->setLabel(pht('Assigned To')) 22 - ->setKey('assignee') 23 - ->setDescription(pht('Search for identities by assignee.')), 31 + ->setKey('assignedPHIDs') 32 + ->setAliases( 33 + array( 34 + 'assigned', 35 + 'assignedPHID', 36 + )) 37 + ->setDescription(pht('Search for identities by explicit assignee.')), 24 38 id(new PhabricatorSearchTextField()) 25 39 ->setLabel(pht('Identity Contains')) 26 40 ->setKey('match') 27 41 ->setDescription(pht('Search for identities by substring.')), 28 42 id(new PhabricatorSearchThreeStateField()) 29 - ->setLabel(pht('Is Assigned')) 43 + ->setLabel(pht('Has Matching User')) 30 44 ->setKey('hasEffectivePHID') 31 45 ->setOptions( 32 46 pht('(Show All)'), 33 - pht('Show Only Assigned Identities'), 34 - pht('Show Only Unassigned Identities')), 47 + pht('Show Identities With Matching Users'), 48 + pht('Show Identities Without Matching Users')), 35 49 ); 36 50 } 37 51 ··· 46 60 $query->withIdentityNameLike($map['match']); 47 61 } 48 62 49 - if ($map['assignee']) { 50 - $query->withAssigneePHIDs($map['assignee']); 63 + if ($map['assignedPHIDs']) { 64 + $query->withAssignedPHIDs($map['assignedPHIDs']); 65 + } 66 + 67 + if ($map['effectivePHIDs']) { 68 + $query->withEffectivePHIDs($map['effectivePHIDs']); 51 69 } 52 70 53 71 return $query; ··· 86 104 87 105 $viewer = $this->requireViewer(); 88 106 89 - $list = new PHUIObjectItemListView(); 90 - $list->setUser($viewer); 107 + $list = id(new PHUIObjectItemListView()) 108 + ->setViewer($viewer); 109 + 110 + $phids = array(); 111 + foreach ($identities as $identity) { 112 + $phids[] = $identity->getCurrentEffectiveUserPHID(); 113 + $phids[] = $identity->getManuallySetUserPHID(); 114 + } 115 + 116 + $handles = $viewer->loadHandles($phids); 117 + 118 + $unassigned = DiffusionIdentityUnassignedDatasource::FUNCTION_TOKEN; 119 + 91 120 foreach ($identities as $identity) { 92 121 $item = id(new PHUIObjectItemView()) 93 - ->setObjectName(pht('Identity %d', $identity->getID())) 122 + ->setObjectName($identity->getObjectName()) 94 123 ->setHeader($identity->getIdentityShortName()) 95 124 ->setHref($identity->getURI()) 96 125 ->setObject($identity); 126 + 127 + $status_icon = 'fa-circle-o grey'; 128 + 129 + $effective_phid = $identity->getCurrentEffectiveUserPHID(); 130 + if ($effective_phid) { 131 + $item->addIcon( 132 + 'fa-id-badge', 133 + pht('Matches User: %s', $handles[$effective_phid]->getName())); 134 + 135 + $status_icon = 'fa-id-badge'; 136 + } 137 + 138 + $assigned_phid = $identity->getManuallySetUserPHID(); 139 + if ($assigned_phid) { 140 + if ($assigned_phid === $unassigned) { 141 + $item->addIcon( 142 + 'fa-ban', 143 + pht('Explicitly Unassigned')); 144 + $status_icon = 'fa-ban'; 145 + } else { 146 + $item->addIcon( 147 + 'fa-user', 148 + pht('Assigned To: %s', $handles[$assigned_phid]->getName())); 149 + $status_icon = 'fa-user'; 150 + } 151 + } 152 + 153 + $item->setStatusIcon($status_icon); 97 154 98 155 $list->addItem($item); 99 156 }
+18 -5
src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php
··· 7 7 private $phids; 8 8 private $identityNames; 9 9 private $emailAddresses; 10 - private $assigneePHIDs; 10 + private $assignedPHIDs; 11 + private $effectivePHIDs; 11 12 private $identityNameLike; 12 13 private $hasEffectivePHID; 13 14 ··· 36 37 return $this; 37 38 } 38 39 39 - public function withAssigneePHIDs(array $assignees) { 40 - $this->assigneePHIDs = $assignees; 40 + public function withAssignedPHIDs(array $assigned) { 41 + $this->assignedPHIDs = $assigned; 42 + return $this; 43 + } 44 + 45 + public function withEffectivePHIDs(array $effective) { 46 + $this->effectivePHIDs = $effective; 41 47 return $this; 42 48 } 43 49 ··· 75 81 $this->phids); 76 82 } 77 83 78 - if ($this->assigneePHIDs !== null) { 84 + if ($this->assignedPHIDs !== null) { 85 + $where[] = qsprintf( 86 + $conn, 87 + 'repository_identity.manuallySetUserPHID IN (%Ls)', 88 + $this->assignedPHIDs); 89 + } 90 + 91 + if ($this->effectivePHIDs !== null) { 79 92 $where[] = qsprintf( 80 93 $conn, 81 94 'repository_identity.currentEffectiveUserPHID IN (%Ls)', 82 - $this->assigneePHIDs); 95 + $this->effectivePHIDs); 83 96 } 84 97 85 98 if ($this->hasEffectivePHID !== null) {
+9 -2
src/applications/repository/storage/PhabricatorRepositoryIdentity.php
··· 96 96 97 97 public function save() { 98 98 if ($this->manuallySetUserPHID) { 99 - $this->currentEffectiveUserPHID = $this->manuallySetUserPHID; 99 + $unassigned = DiffusionIdentityUnassignedDatasource::FUNCTION_TOKEN; 100 + if ($this->manuallySetUserPHID === $unassigned) { 101 + $effective_phid = null; 102 + } else { 103 + $effective_phid = $this->manuallySetUserPHID; 104 + } 100 105 } else { 101 - $this->currentEffectiveUserPHID = $this->automaticGuessedUserPHID; 106 + $effective_phid = $this->automaticGuessedUserPHID; 102 107 } 108 + 109 + $this->setCurrentEffectiveUserPHID($effective_phid); 103 110 104 111 $email_address = $this->getIdentityEmailAddress(); 105 112