mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Straighten out some reviewer-realtd horribleness.
This commit is contained in:
parent
ba26f67687
commit
223ac18287
6 changed files with 48 additions and 88 deletions
|
@ -53,8 +53,10 @@ class DifferentialRevisionEditController extends DifferentialController {
|
|||
$e_title = true;
|
||||
$e_testplan = true;
|
||||
$errors = array();
|
||||
|
||||
$revision->loadRelationships();
|
||||
|
||||
if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
|
||||
if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
|
||||
$revision->setTitle($request->getStr('title'));
|
||||
$revision->setSummary($request->getStr('summary'));
|
||||
$revision->setTestPlan($request->getStr('testplan'));
|
||||
|
@ -93,11 +95,19 @@ class DifferentialRevisionEditController extends DifferentialController {
|
|||
$reviewer_phids = $request->getArr('reviewers');
|
||||
$cc_phids = $request->getArr('cc');
|
||||
} else {
|
||||
// $reviewer_phids = $revision->getReviewers();
|
||||
// $cc_phids = $revision->getCCPHIDs();
|
||||
$reviewer_phids = array();
|
||||
$cc_phids = array();
|
||||
$reviewer_phids = $revision->getReviewers();
|
||||
$cc_phids = $revision->getCCPHIDs();
|
||||
}
|
||||
|
||||
$phids = array_merge($reviewer_phids, $cc_phids);
|
||||
$phids = array_unique($phids);
|
||||
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))
|
||||
->loadHandles();
|
||||
$handles = mpull($handles, 'getFullName', 'getPHID');
|
||||
|
||||
$reviewer_map = array_select_keys($handles, $reviewer_phids);
|
||||
$cc_map = array_select_keys($handles, $cc_phids);
|
||||
|
||||
$form = new AphrontFormView();
|
||||
$form->setUser($request->getUser());
|
||||
|
@ -148,7 +158,7 @@ class DifferentialRevisionEditController extends DifferentialController {
|
|||
->setLabel('CC')
|
||||
->setName('cc')
|
||||
->setDatasource('/typeahead/common/mailable/')
|
||||
->setValue($reviewer_map))
|
||||
->setValue($cc_map))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Blame Revision')
|
||||
|
|
|
@ -497,7 +497,7 @@ class DifferentialRevisionEditor {
|
|||
array $rem_phids,
|
||||
array $add_phids,
|
||||
$reason_phid) {
|
||||
|
||||
|
||||
$rem_map = array_fill_keys($rem_phids, true);
|
||||
$add_map = array_fill_keys($add_phids, true);
|
||||
|
||||
|
@ -515,8 +515,8 @@ class DifferentialRevisionEditor {
|
|||
}
|
||||
|
||||
$raw = $revision->getRawRelations(DifferentialRevision::RELATION_REVIEWER);
|
||||
$raw = ipull($raw, 'objectPHID');
|
||||
|
||||
$raw = ipull($raw, null, 'objectPHID');
|
||||
|
||||
$sequence = count($seq_map);
|
||||
foreach ($raw as $phid => $relation) {
|
||||
if (isset($seq_map[$phid])) {
|
||||
|
@ -529,34 +529,28 @@ class DifferentialRevisionEditor {
|
|||
|
||||
foreach ($raw as $phid => $relation) {
|
||||
if (isset($rem_map[$phid])) {
|
||||
$relation['forbidden'] = true;
|
||||
$relation['reasonPHID'] = $reason_phid;
|
||||
} else if (isset($add_map[$phid])) {
|
||||
$relation['forbidden'] = false;
|
||||
$relation['reasonPHID'] = $reason_phid;
|
||||
unset($raw[$phid]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($add_phids as $add) {
|
||||
$raw[] = array(
|
||||
$raw[$add] = array(
|
||||
'objectPHID' => $add,
|
||||
'forbidden' => false,
|
||||
'sequence' => idx($seq_map, $add, $sequence++),
|
||||
'reasonPHID' => $reason_phid,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$conn_w = $revision->establishConnection('w');
|
||||
|
||||
$sql = array();
|
||||
foreach ($raw as $relation) {
|
||||
$sql[] = qsprintf(
|
||||
$conn_w,
|
||||
'(%d, %s, %s, %d, %d, %s)',
|
||||
'(%d, %s, %s, %d, %s)',
|
||||
$revision->getID(),
|
||||
DifferentialRevision::RELATION_REVIEWER,
|
||||
$relation['objectPHID'],
|
||||
$relation['forbidden'],
|
||||
$relation['sequence'],
|
||||
$relation['reasonPHID']);
|
||||
}
|
||||
|
@ -572,7 +566,7 @@ class DifferentialRevisionEditor {
|
|||
queryfx(
|
||||
$conn_w,
|
||||
'INSERT INTO %T
|
||||
(revisionID, relation, objectPHID, forbidden, sequence, reasonPHID)
|
||||
(revisionID, relation, objectPHID, sequence, reasonPHID)
|
||||
VALUES %Q',
|
||||
DifferentialRevision::RELATIONSHIP_TABLE,
|
||||
implode(', ', $sql));
|
||||
|
|
|
@ -33,13 +33,13 @@ class DifferentialRevision extends DifferentialDAO {
|
|||
|
||||
protected $lineCount;
|
||||
|
||||
private $related;
|
||||
private $forbidden;
|
||||
private $relationships;
|
||||
|
||||
const RELATIONSHIP_TABLE = 'differential_relationship';
|
||||
|
||||
const RELATION_REVIEWER = 'revw';
|
||||
const RELATION_SUBSCRIBED = 'subd';
|
||||
const RELATION_UNSUBSCRIBED = 'usub';
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
|
@ -78,8 +78,6 @@ class DifferentialRevision extends DifferentialDAO {
|
|||
public function loadRelationships() {
|
||||
if (!$this->getID()) {
|
||||
$this->relationships = array();
|
||||
$this->related = array();
|
||||
$this->forbidden = array();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -89,19 +87,6 @@ class DifferentialRevision extends DifferentialDAO {
|
|||
self::RELATIONSHIP_TABLE,
|
||||
$this->getID());
|
||||
|
||||
$related = array();
|
||||
$forbidden = array();
|
||||
|
||||
foreach ($data as $row) {
|
||||
if ($row['forbidden']) {
|
||||
$forbidden[] = $row;
|
||||
} else {
|
||||
$related[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->related = igroup($related, 'relation');
|
||||
$this->forbidden = igroup($related, 'relation');
|
||||
$this->relationships = igroup($data, 'relation');
|
||||
|
||||
return $this;
|
||||
|
@ -116,60 +101,14 @@ class DifferentialRevision extends DifferentialDAO {
|
|||
}
|
||||
|
||||
private function getRelatedPHIDs($relation) {
|
||||
if ($this->related === null) {
|
||||
if ($this->relationships === null) {
|
||||
throw new Exception("Must load relationships!");
|
||||
}
|
||||
|
||||
$related = idx($this->related, $relation, array());
|
||||
|
||||
return ipull($related, 'objectPHID');
|
||||
|
||||
return ipull($this->getRawRelations($relation), 'objectPHID');
|
||||
}
|
||||
|
||||
public function getRawRelations($relation) {
|
||||
return idx($this->relationships, $relation, array());
|
||||
}
|
||||
|
||||
public function writeRelatedPHIDs(
|
||||
$relation,
|
||||
$phids,
|
||||
$reason_phid,
|
||||
$forbidden) {
|
||||
|
||||
$conn_w = $this->establishConnection('w');
|
||||
|
||||
$sql = array();
|
||||
$phids = array_values($phids);
|
||||
foreach ($phids as $key => $phid) {
|
||||
$sql[] = qsprintf(
|
||||
$conn_w,
|
||||
'(%d, %s, %d, %s, %d)',
|
||||
$this->getRevisionID(),
|
||||
$phid,
|
||||
$key,
|
||||
$reason_phid,
|
||||
$forbidden);
|
||||
}
|
||||
|
||||
$conn_w->openTransaction();
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'DELETE FROM %T WHERE revisionID = %d AND relation = %s
|
||||
AND forbidden = %d
|
||||
AND relatedPHID NOT IN (%Ls)',
|
||||
self::RELATIONSHIP_TABLE,
|
||||
$this->getID(),
|
||||
$relation,
|
||||
$forbidden,
|
||||
$phids);
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'INSERT INTO %T
|
||||
(revisionID, relatedPHID, sequence, reason_phid, forbidden)
|
||||
VALUES %Q
|
||||
ON DUPLICATE KEY UPDATE sequence = VALUES(sequence)',
|
||||
self::RELATIONSHIP_TABLE,
|
||||
implode(', ', $sql));
|
||||
$conn_w->saveTransaction();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class PhabricatorObjectHandle {
|
|||
private $type;
|
||||
private $name;
|
||||
private $email;
|
||||
private $fullName;
|
||||
private $imageURI;
|
||||
|
||||
public function setURI($uri) {
|
||||
|
@ -52,6 +53,15 @@ class PhabricatorObjectHandle {
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
public function setFullName($full_name) {
|
||||
$this->fullName = $full_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFullName() {
|
||||
return $this->fullName;
|
||||
}
|
||||
|
||||
public function setType($type) {
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
|
|
|
@ -58,6 +58,8 @@ class PhabricatorObjectHandleData {
|
|||
$handle->setName($user->getUsername());
|
||||
$handle->setURI('/p/'.$user->getUsername().'/');
|
||||
$handle->setEmail($user->getEmail());
|
||||
$handle->setFullName(
|
||||
$user->getUsername().' ('.$user->getRealName().')');
|
||||
|
||||
$img_phid = $user->getProfileImagePHID();
|
||||
if ($img_phid) {
|
||||
|
@ -89,6 +91,7 @@ class PhabricatorObjectHandleData {
|
|||
$handle->setEmail($list->getEmail());
|
||||
$handle->setName($list->getName());
|
||||
$handle->setURI($list->getURI());
|
||||
$handle->setFullName($list->getName());
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
|
|
|
@ -2693,8 +2693,12 @@ JX.install('DOM', {
|
|||
listen : function(node, type, path, callback) {
|
||||
var id = ['id:' + JX.DOM.uniqID(node)];
|
||||
path = JX.$AX(path || []);
|
||||
for (var ii = 0; ii < path.length; ii++) {
|
||||
path[ii] = id.concat(JX.$AX(path[ii]));
|
||||
if (!path.length) {
|
||||
path = id;
|
||||
} else {
|
||||
for (var ii = 0; ii < path.length; ii++) {
|
||||
path[ii] = id.concat(JX.$AX(path[ii]));
|
||||
}
|
||||
}
|
||||
return JX.Stratcom.listen(type, path, callback);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue