mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 03:20:59 +01:00
Add authorPHID to Dashboards
Summary: Adds an authorPHIDs, populates olds ones. Test Plan: Make a new Dashboard, see that I created it. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17022
This commit is contained in:
parent
39b618039f
commit
59f3b5125d
5 changed files with 82 additions and 4 deletions
39
resources/sql/autopatches/20161210.dashboards.01.author.php
Normal file
39
resources/sql/autopatches/20161210.dashboards.01.author.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
// Set authorPHID on Dashboards
|
||||
//
|
||||
$table = new PhabricatorDashboard();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
$txn_table = new PhabricatorDashboardTransaction();
|
||||
$txn_conn = $table->establishConnection('r');
|
||||
|
||||
echo pht("Building Dashboard authorPHIDs...\n");
|
||||
|
||||
foreach (new LiskMigrationIterator($table) as $dashboard) {
|
||||
|
||||
if ($dashboard->getAuthorPHID()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$author_row = queryfx_one(
|
||||
$txn_conn,
|
||||
'SELECT authorPHID FROM %T WHERE objectPHID = %s ORDER BY id ASC LIMIT 1',
|
||||
$txn_table->getTableName(),
|
||||
$dashboard->getPHID());
|
||||
|
||||
if (!$author_row) {
|
||||
$author_phid = id(new PhabricatorDashboardApplication())->getPHID();
|
||||
} else {
|
||||
$author_phid = $author_row['authorPHID'];
|
||||
}
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'UPDATE %T SET authorPHID = %s WHERE id = %d',
|
||||
$table->getTableName(),
|
||||
$author_phid,
|
||||
$dashboard->getID());
|
||||
}
|
||||
|
||||
echo pht("Done\n");
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_dashboard.dashboard
|
||||
ADD authorPHID VARBINARY(64) NOT NULL;
|
|
@ -6,6 +6,7 @@ final class PhabricatorDashboardQuery
|
|||
private $ids;
|
||||
private $phids;
|
||||
private $statuses;
|
||||
private $authorPHIDs;
|
||||
|
||||
private $needPanels;
|
||||
private $needProjects;
|
||||
|
@ -25,6 +26,11 @@ final class PhabricatorDashboardQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withAuthorPHIDs(array $authors) {
|
||||
$this->authorPHIDs = $authors;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needPanels($need_panels) {
|
||||
$this->needPanels = $need_panels;
|
||||
return $this;
|
||||
|
@ -121,6 +127,13 @@ final class PhabricatorDashboardQuery
|
|||
$this->statuses);
|
||||
}
|
||||
|
||||
if ($this->authorPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'authorPHID IN (%Ls)',
|
||||
$this->authorPHIDs);
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@ final class PhabricatorDashboardSearchEngine
|
|||
|
||||
protected function buildCustomSearchFields() {
|
||||
return array(
|
||||
id(new PhabricatorSearchDatasourceField())
|
||||
->setLabel(pht('Authored By'))
|
||||
->setKey('authorPHIDs')
|
||||
->setDatasource(new PhabricatorPeopleUserFunctionDatasource()),
|
||||
id(new PhabricatorSearchCheckboxesField())
|
||||
->setKey('statuses')
|
||||
->setLabel(pht('Status'))
|
||||
|
@ -30,19 +34,32 @@ final class PhabricatorDashboardSearchEngine
|
|||
}
|
||||
|
||||
protected function getBuiltinQueryNames() {
|
||||
return array(
|
||||
'open' => pht('Active Dashboards'),
|
||||
'all' => pht('All Dashboards'),
|
||||
);
|
||||
$names = array();
|
||||
|
||||
if ($this->requireViewer()->isLoggedIn()) {
|
||||
$names['authored'] = pht('Authored');
|
||||
}
|
||||
|
||||
$names['open'] = pht('Active Dashboards');
|
||||
$names['all'] = pht('All Dashboards');
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromBuiltin($query_key) {
|
||||
$query = $this->newSavedQuery();
|
||||
$query->setQueryKey($query_key);
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
switch ($query_key) {
|
||||
case 'all':
|
||||
return $query;
|
||||
case 'authored':
|
||||
return $query->setParameter(
|
||||
'authored',
|
||||
array(
|
||||
$viewer->getPHID(),
|
||||
));
|
||||
case 'open':
|
||||
return $query->setParameter(
|
||||
'statuses',
|
||||
|
@ -61,6 +78,10 @@ final class PhabricatorDashboardSearchEngine
|
|||
$query->withStatuses($map['statuses']);
|
||||
}
|
||||
|
||||
if ($map['authorPHIDs']) {
|
||||
$query->withAuthorPHIDs($map['authorPHIDs']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
|
|||
PhabricatorProjectInterface {
|
||||
|
||||
protected $name;
|
||||
protected $authorPHID;
|
||||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
protected $status;
|
||||
|
@ -31,6 +32,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
|
|||
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
||||
->setEditPolicy($actor->getPHID())
|
||||
->setStatus(self::STATUS_ACTIVE)
|
||||
->setAuthorPHID($actor->getPHID())
|
||||
->attachPanels(array())
|
||||
->attachPanelPHIDs(array());
|
||||
}
|
||||
|
@ -61,6 +63,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
|
|||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'name' => 'text255',
|
||||
'status' => 'text32',
|
||||
'authorPHID' => 'phid',
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue