Page MenuHomePhabricator

D17036.id40990.diff
No OneTemporary

D17036.id40990.diff

diff --git a/resources/sql/autopatches/20161212.dashboardpanel.01.author.sql b/resources/sql/autopatches/20161212.dashboardpanel.01.author.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161212.dashboardpanel.01.author.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_dashboard.dashboard_panel
+ ADD authorPHID VARBINARY(64) NOT NULL;
diff --git a/resources/sql/autopatches/20161212.dashboardpanel.02.author.php b/resources/sql/autopatches/20161212.dashboardpanel.02.author.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161212.dashboardpanel.02.author.php
@@ -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");
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
@@ -400,7 +400,7 @@
$viewer = $request->getUser();
$copy = PhabricatorDashboardPanel::initializeNewPanel($viewer);
- $copy = PhabricatorDashboardPanel::copyPanel($copy, $panel);
+ $copy = PhabricatorDashboardPanel::copyPanel($copy, $panel, $viewer);
$copy->openTransaction();
$copy->save();
diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
--- a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
@@ -7,6 +7,7 @@
private $phids;
private $archived;
private $panelTypes;
+ private $authorPHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -28,6 +29,11 @@
return $this;
}
+ public function withAuthorPHIDs(array $authors) {
+ $this->authorPHIDs = $authors;
+ return $this;
+ }
+
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
@@ -75,6 +81,13 @@
$this->panelTypes);
}
+ if ($this->authorPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'authorPHID IN (%Ls)',
+ $this->authorPHIDs);
+ }
+
return $where;
}
diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
--- a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
@@ -34,12 +34,20 @@
$query->withPanelTypes(array($map['paneltype']));
}
+ if ($map['authorPHIDs']) {
+ $query->withAuthorPHIDs($map['authorPHIDs']);
+ }
+
return $query;
}
protected function buildCustomSearchFields() {
return array(
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Authored By'))
+ ->setKey('authorPHIDs')
+ ->setDatasource(new PhabricatorPeopleUserFunctionDatasource()),
id(new PhabricatorSearchSelectField())
->setKey('status')
->setLabel(pht('Status'))
@@ -60,19 +68,32 @@
}
protected function getBuiltinQueryNames() {
- return array(
- 'active' => pht('Active Panels'),
- 'all' => pht('All Panels'),
- );
+ $names = array();
+
+ 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) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
+ $viewer = $this->requireViewer();
switch ($query_key) {
case 'active':
return $query->setParameter('status', 'active');
+ case 'authored':
+ return $query->setParameter(
+ 'authorPHIDs',
+ array(
+ $viewer->getPHID(),
+ ));
case 'all':
return $query;
}
diff --git a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
--- a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
@@ -56,7 +56,7 @@
return $query;
case 'authored':
return $query->setParameter(
- 'authored',
+ 'authorPHIDs',
array(
$viewer->getPHID(),
));
diff --git a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
--- a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
@@ -16,6 +16,7 @@
protected $panelType;
protected $viewPolicy;
protected $editPolicy;
+ protected $authorPHID;
protected $isArchived = 0;
protected $properties = array();
@@ -24,17 +25,20 @@
public static function initializeNewPanel(PhabricatorUser $actor) {
return id(new PhabricatorDashboardPanel())
->setName('')
+ ->setAuthorPHID($actor->getPHID())
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy($actor->getPHID());
}
public static function copyPanel(
PhabricatorDashboardPanel $dst,
- PhabricatorDashboardPanel $src) {
+ PhabricatorDashboardPanel $src,
+ PhabricatorUser $user) {
$dst->name = $src->name;
$dst->panelType = $src->panelType;
$dst->properties = $src->properties;
+ $dst->authorPHID = $user->getPHID();
return $dst;
}
@@ -48,6 +52,7 @@
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'panelType' => 'text64',
+ 'authorPHID' => 'phid',
'isArchived' => 'bool',
),
) + parent::getConfiguration();

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 29, 4:14 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704978
Default Alt Text
D17036.id40990.diff (6 KB)

Event Timeline