Add authorPHID to Dashboard Panels
Summary: Adds authorPHID to panels so we can default to the panels you made. Test Plan: Run upgrade, visit manage panels, see my panels. Create a new panel. Edit a panel. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17036
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE {$NAMESPACE}_dashboard.dashboard_panel
|
||||||
|
ADD authorPHID VARBINARY(64) NOT NULL;
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Set authorPHID on Dashboard Panels
|
||||||
|
//
|
||||||
|
$table = new PhabricatorDashboardPanel();
|
||||||
|
$conn_w = $table->establishConnection('w');
|
||||||
|
|
||||||
|
$txn_table = new PhabricatorDashboardPanelTransaction();
|
||||||
|
$txn_conn = $table->establishConnection('r');
|
||||||
|
|
||||||
|
echo pht("Building Dashboard Panel authorPHIDs...\n");
|
||||||
|
|
||||||
|
foreach (new LiskMigrationIterator($table) as $panel) {
|
||||||
|
|
||||||
|
if ($panel->getAuthorPHID()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$panel_row = queryfx_one(
|
||||||
|
$txn_conn,
|
||||||
|
'SELECT authorPHID FROM %T WHERE objectPHID = %s ORDER BY id ASC LIMIT 1',
|
||||||
|
$txn_table->getTableName(),
|
||||||
|
$panel->getPHID());
|
||||||
|
|
||||||
|
if (!$panel_row) {
|
||||||
|
$author_phid = id(new PhabricatorDashboardApplication())->getPHID();
|
||||||
|
} else {
|
||||||
|
$author_phid = $panel_row['authorPHID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn_w,
|
||||||
|
'UPDATE %T SET authorPHID = %s WHERE id = %d',
|
||||||
|
$table->getTableName(),
|
||||||
|
$author_phid,
|
||||||
|
$panel->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
echo pht("Done\n");
|
||||||
@@ -400,7 +400,7 @@ final class PhabricatorDashboardPanelEditController
|
|||||||
$viewer = $request->getUser();
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
$copy = PhabricatorDashboardPanel::initializeNewPanel($viewer);
|
$copy = PhabricatorDashboardPanel::initializeNewPanel($viewer);
|
||||||
$copy = PhabricatorDashboardPanel::copyPanel($copy, $panel);
|
$copy = PhabricatorDashboardPanel::copyPanel($copy, $panel, $viewer);
|
||||||
|
|
||||||
$copy->openTransaction();
|
$copy->openTransaction();
|
||||||
$copy->save();
|
$copy->save();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ final class PhabricatorDashboardPanelQuery
|
|||||||
private $phids;
|
private $phids;
|
||||||
private $archived;
|
private $archived;
|
||||||
private $panelTypes;
|
private $panelTypes;
|
||||||
|
private $authorPHIDs;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
@@ -28,6 +29,11 @@ final class PhabricatorDashboardPanelQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withAuthorPHIDs(array $authors) {
|
||||||
|
$this->authorPHIDs = $authors;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadPage() {
|
protected function loadPage() {
|
||||||
return $this->loadStandardPage($this->newResultObject());
|
return $this->loadStandardPage($this->newResultObject());
|
||||||
}
|
}
|
||||||
@@ -75,6 +81,13 @@ final class PhabricatorDashboardPanelQuery
|
|||||||
$this->panelTypes);
|
$this->panelTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->authorPHIDs !== null) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn,
|
||||||
|
'authorPHID IN (%Ls)',
|
||||||
|
$this->authorPHIDs);
|
||||||
|
}
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,20 @@ final class PhabricatorDashboardPanelSearchEngine
|
|||||||
$query->withPanelTypes(array($map['paneltype']));
|
$query->withPanelTypes(array($map['paneltype']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($map['authorPHIDs']) {
|
||||||
|
$query->withAuthorPHIDs($map['authorPHIDs']);
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildCustomSearchFields() {
|
protected function buildCustomSearchFields() {
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
id(new PhabricatorSearchDatasourceField())
|
||||||
|
->setLabel(pht('Authored By'))
|
||||||
|
->setKey('authorPHIDs')
|
||||||
|
->setDatasource(new PhabricatorPeopleUserFunctionDatasource()),
|
||||||
id(new PhabricatorSearchSelectField())
|
id(new PhabricatorSearchSelectField())
|
||||||
->setKey('status')
|
->setKey('status')
|
||||||
->setLabel(pht('Status'))
|
->setLabel(pht('Status'))
|
||||||
@@ -60,19 +68,32 @@ final class PhabricatorDashboardPanelSearchEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function getBuiltinQueryNames() {
|
protected function getBuiltinQueryNames() {
|
||||||
return array(
|
$names = array();
|
||||||
'active' => pht('Active Panels'),
|
|
||||||
'all' => pht('All Panels'),
|
if ($this->requireViewer()->isLoggedIn()) {
|
||||||
);
|
$names['authored'] = pht('Authored');
|
||||||
|
}
|
||||||
|
|
||||||
|
$names['active'] = pht('Active Panels');
|
||||||
|
$names['all'] = pht('All Panels');
|
||||||
|
|
||||||
|
return $names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromBuiltin($query_key) {
|
public function buildSavedQueryFromBuiltin($query_key) {
|
||||||
$query = $this->newSavedQuery();
|
$query = $this->newSavedQuery();
|
||||||
$query->setQueryKey($query_key);
|
$query->setQueryKey($query_key);
|
||||||
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
switch ($query_key) {
|
switch ($query_key) {
|
||||||
case 'active':
|
case 'active':
|
||||||
return $query->setParameter('status', 'active');
|
return $query->setParameter('status', 'active');
|
||||||
|
case 'authored':
|
||||||
|
return $query->setParameter(
|
||||||
|
'authorPHIDs',
|
||||||
|
array(
|
||||||
|
$viewer->getPHID(),
|
||||||
|
));
|
||||||
case 'all':
|
case 'all':
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ final class PhabricatorDashboardSearchEngine
|
|||||||
return $query;
|
return $query;
|
||||||
case 'authored':
|
case 'authored':
|
||||||
return $query->setParameter(
|
return $query->setParameter(
|
||||||
'authored',
|
'authorPHIDs',
|
||||||
array(
|
array(
|
||||||
$viewer->getPHID(),
|
$viewer->getPHID(),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ final class PhabricatorDashboardPanel
|
|||||||
protected $panelType;
|
protected $panelType;
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $editPolicy;
|
protected $editPolicy;
|
||||||
|
protected $authorPHID;
|
||||||
protected $isArchived = 0;
|
protected $isArchived = 0;
|
||||||
protected $properties = array();
|
protected $properties = array();
|
||||||
|
|
||||||
@@ -24,17 +25,20 @@ final class PhabricatorDashboardPanel
|
|||||||
public static function initializeNewPanel(PhabricatorUser $actor) {
|
public static function initializeNewPanel(PhabricatorUser $actor) {
|
||||||
return id(new PhabricatorDashboardPanel())
|
return id(new PhabricatorDashboardPanel())
|
||||||
->setName('')
|
->setName('')
|
||||||
|
->setAuthorPHID($actor->getPHID())
|
||||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
||||||
->setEditPolicy($actor->getPHID());
|
->setEditPolicy($actor->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function copyPanel(
|
public static function copyPanel(
|
||||||
PhabricatorDashboardPanel $dst,
|
PhabricatorDashboardPanel $dst,
|
||||||
PhabricatorDashboardPanel $src) {
|
PhabricatorDashboardPanel $src,
|
||||||
|
PhabricatorUser $user) {
|
||||||
|
|
||||||
$dst->name = $src->name;
|
$dst->name = $src->name;
|
||||||
$dst->panelType = $src->panelType;
|
$dst->panelType = $src->panelType;
|
||||||
$dst->properties = $src->properties;
|
$dst->properties = $src->properties;
|
||||||
|
$dst->authorPHID = $user->getPHID();
|
||||||
|
|
||||||
return $dst;
|
return $dst;
|
||||||
}
|
}
|
||||||
@@ -48,6 +52,7 @@ final class PhabricatorDashboardPanel
|
|||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'name' => 'text255',
|
'name' => 'text255',
|
||||||
'panelType' => 'text64',
|
'panelType' => 'text64',
|
||||||
|
'authorPHID' => 'phid',
|
||||||
'isArchived' => 'bool',
|
'isArchived' => 'bool',
|
||||||
),
|
),
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
|
|||||||
Reference in New Issue
Block a user