mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +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
|
@ -54,6 +54,8 @@ class DifferentialRevisionEditController extends DifferentialController {
|
||||||
$e_testplan = true;
|
$e_testplan = true;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
|
$revision->loadRelationships();
|
||||||
|
|
||||||
if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
|
if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
|
||||||
$revision->setTitle($request->getStr('title'));
|
$revision->setTitle($request->getStr('title'));
|
||||||
$revision->setSummary($request->getStr('summary'));
|
$revision->setSummary($request->getStr('summary'));
|
||||||
|
@ -93,12 +95,20 @@ class DifferentialRevisionEditController extends DifferentialController {
|
||||||
$reviewer_phids = $request->getArr('reviewers');
|
$reviewer_phids = $request->getArr('reviewers');
|
||||||
$cc_phids = $request->getArr('cc');
|
$cc_phids = $request->getArr('cc');
|
||||||
} else {
|
} else {
|
||||||
// $reviewer_phids = $revision->getReviewers();
|
$reviewer_phids = $revision->getReviewers();
|
||||||
// $cc_phids = $revision->getCCPHIDs();
|
$cc_phids = $revision->getCCPHIDs();
|
||||||
$reviewer_phids = array();
|
|
||||||
$cc_phids = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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 = new AphrontFormView();
|
||||||
$form->setUser($request->getUser());
|
$form->setUser($request->getUser());
|
||||||
if ($diff) {
|
if ($diff) {
|
||||||
|
@ -148,7 +158,7 @@ class DifferentialRevisionEditController extends DifferentialController {
|
||||||
->setLabel('CC')
|
->setLabel('CC')
|
||||||
->setName('cc')
|
->setName('cc')
|
||||||
->setDatasource('/typeahead/common/mailable/')
|
->setDatasource('/typeahead/common/mailable/')
|
||||||
->setValue($reviewer_map))
|
->setValue($cc_map))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextControl())
|
id(new AphrontFormTextControl())
|
||||||
->setLabel('Blame Revision')
|
->setLabel('Blame Revision')
|
||||||
|
|
|
@ -515,7 +515,7 @@ class DifferentialRevisionEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
$raw = $revision->getRawRelations(DifferentialRevision::RELATION_REVIEWER);
|
$raw = $revision->getRawRelations(DifferentialRevision::RELATION_REVIEWER);
|
||||||
$raw = ipull($raw, 'objectPHID');
|
$raw = ipull($raw, null, 'objectPHID');
|
||||||
|
|
||||||
$sequence = count($seq_map);
|
$sequence = count($seq_map);
|
||||||
foreach ($raw as $phid => $relation) {
|
foreach ($raw as $phid => $relation) {
|
||||||
|
@ -529,18 +529,13 @@ class DifferentialRevisionEditor {
|
||||||
|
|
||||||
foreach ($raw as $phid => $relation) {
|
foreach ($raw as $phid => $relation) {
|
||||||
if (isset($rem_map[$phid])) {
|
if (isset($rem_map[$phid])) {
|
||||||
$relation['forbidden'] = true;
|
unset($raw[$phid]);
|
||||||
$relation['reasonPHID'] = $reason_phid;
|
|
||||||
} else if (isset($add_map[$phid])) {
|
|
||||||
$relation['forbidden'] = false;
|
|
||||||
$relation['reasonPHID'] = $reason_phid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($add_phids as $add) {
|
foreach ($add_phids as $add) {
|
||||||
$raw[] = array(
|
$raw[$add] = array(
|
||||||
'objectPHID' => $add,
|
'objectPHID' => $add,
|
||||||
'forbidden' => false,
|
|
||||||
'sequence' => idx($seq_map, $add, $sequence++),
|
'sequence' => idx($seq_map, $add, $sequence++),
|
||||||
'reasonPHID' => $reason_phid,
|
'reasonPHID' => $reason_phid,
|
||||||
);
|
);
|
||||||
|
@ -552,11 +547,10 @@ class DifferentialRevisionEditor {
|
||||||
foreach ($raw as $relation) {
|
foreach ($raw as $relation) {
|
||||||
$sql[] = qsprintf(
|
$sql[] = qsprintf(
|
||||||
$conn_w,
|
$conn_w,
|
||||||
'(%d, %s, %s, %d, %d, %s)',
|
'(%d, %s, %s, %d, %s)',
|
||||||
$revision->getID(),
|
$revision->getID(),
|
||||||
DifferentialRevision::RELATION_REVIEWER,
|
DifferentialRevision::RELATION_REVIEWER,
|
||||||
$relation['objectPHID'],
|
$relation['objectPHID'],
|
||||||
$relation['forbidden'],
|
|
||||||
$relation['sequence'],
|
$relation['sequence'],
|
||||||
$relation['reasonPHID']);
|
$relation['reasonPHID']);
|
||||||
}
|
}
|
||||||
|
@ -572,7 +566,7 @@ class DifferentialRevisionEditor {
|
||||||
queryfx(
|
queryfx(
|
||||||
$conn_w,
|
$conn_w,
|
||||||
'INSERT INTO %T
|
'INSERT INTO %T
|
||||||
(revisionID, relation, objectPHID, forbidden, sequence, reasonPHID)
|
(revisionID, relation, objectPHID, sequence, reasonPHID)
|
||||||
VALUES %Q',
|
VALUES %Q',
|
||||||
DifferentialRevision::RELATIONSHIP_TABLE,
|
DifferentialRevision::RELATIONSHIP_TABLE,
|
||||||
implode(', ', $sql));
|
implode(', ', $sql));
|
||||||
|
|
|
@ -33,13 +33,13 @@ class DifferentialRevision extends DifferentialDAO {
|
||||||
|
|
||||||
protected $lineCount;
|
protected $lineCount;
|
||||||
|
|
||||||
private $related;
|
private $relationships;
|
||||||
private $forbidden;
|
|
||||||
|
|
||||||
const RELATIONSHIP_TABLE = 'differential_relationship';
|
const RELATIONSHIP_TABLE = 'differential_relationship';
|
||||||
|
|
||||||
const RELATION_REVIEWER = 'revw';
|
const RELATION_REVIEWER = 'revw';
|
||||||
const RELATION_SUBSCRIBED = 'subd';
|
const RELATION_SUBSCRIBED = 'subd';
|
||||||
|
const RELATION_UNSUBSCRIBED = 'usub';
|
||||||
|
|
||||||
public function getConfiguration() {
|
public function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -78,8 +78,6 @@ class DifferentialRevision extends DifferentialDAO {
|
||||||
public function loadRelationships() {
|
public function loadRelationships() {
|
||||||
if (!$this->getID()) {
|
if (!$this->getID()) {
|
||||||
$this->relationships = array();
|
$this->relationships = array();
|
||||||
$this->related = array();
|
|
||||||
$this->forbidden = array();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,19 +87,6 @@ class DifferentialRevision extends DifferentialDAO {
|
||||||
self::RELATIONSHIP_TABLE,
|
self::RELATIONSHIP_TABLE,
|
||||||
$this->getID());
|
$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');
|
$this->relationships = igroup($data, 'relation');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -116,60 +101,14 @@ class DifferentialRevision extends DifferentialDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRelatedPHIDs($relation) {
|
private function getRelatedPHIDs($relation) {
|
||||||
if ($this->related === null) {
|
if ($this->relationships === null) {
|
||||||
throw new Exception("Must load relationships!");
|
throw new Exception("Must load relationships!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$related = idx($this->related, $relation, array());
|
return ipull($this->getRawRelations($relation), 'objectPHID');
|
||||||
|
|
||||||
return ipull($related, 'objectPHID');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRawRelations($relation) {
|
public function getRawRelations($relation) {
|
||||||
return idx($this->relationships, $relation, array());
|
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 $type;
|
||||||
private $name;
|
private $name;
|
||||||
private $email;
|
private $email;
|
||||||
|
private $fullName;
|
||||||
private $imageURI;
|
private $imageURI;
|
||||||
|
|
||||||
public function setURI($uri) {
|
public function setURI($uri) {
|
||||||
|
@ -52,6 +53,15 @@ class PhabricatorObjectHandle {
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFullName($full_name) {
|
||||||
|
$this->fullName = $full_name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFullName() {
|
||||||
|
return $this->fullName;
|
||||||
|
}
|
||||||
|
|
||||||
public function setType($type) {
|
public function setType($type) {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -58,6 +58,8 @@ class PhabricatorObjectHandleData {
|
||||||
$handle->setName($user->getUsername());
|
$handle->setName($user->getUsername());
|
||||||
$handle->setURI('/p/'.$user->getUsername().'/');
|
$handle->setURI('/p/'.$user->getUsername().'/');
|
||||||
$handle->setEmail($user->getEmail());
|
$handle->setEmail($user->getEmail());
|
||||||
|
$handle->setFullName(
|
||||||
|
$user->getUsername().' ('.$user->getRealName().')');
|
||||||
|
|
||||||
$img_phid = $user->getProfileImagePHID();
|
$img_phid = $user->getProfileImagePHID();
|
||||||
if ($img_phid) {
|
if ($img_phid) {
|
||||||
|
@ -89,6 +91,7 @@ class PhabricatorObjectHandleData {
|
||||||
$handle->setEmail($list->getEmail());
|
$handle->setEmail($list->getEmail());
|
||||||
$handle->setName($list->getName());
|
$handle->setName($list->getName());
|
||||||
$handle->setURI($list->getURI());
|
$handle->setURI($list->getURI());
|
||||||
|
$handle->setFullName($list->getName());
|
||||||
}
|
}
|
||||||
$handles[$phid] = $handle;
|
$handles[$phid] = $handle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2693,9 +2693,13 @@ JX.install('DOM', {
|
||||||
listen : function(node, type, path, callback) {
|
listen : function(node, type, path, callback) {
|
||||||
var id = ['id:' + JX.DOM.uniqID(node)];
|
var id = ['id:' + JX.DOM.uniqID(node)];
|
||||||
path = JX.$AX(path || []);
|
path = JX.$AX(path || []);
|
||||||
|
if (!path.length) {
|
||||||
|
path = id;
|
||||||
|
} else {
|
||||||
for (var ii = 0; ii < path.length; ii++) {
|
for (var ii = 0; ii < path.length; ii++) {
|
||||||
path[ii] = id.concat(JX.$AX(path[ii]));
|
path[ii] = id.concat(JX.$AX(path[ii]));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return JX.Stratcom.listen(type, path, callback);
|
return JX.Stratcom.listen(type, path, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue