Page MenuHomePhabricator

D17036.id40982.diff
No OneTemporary

D17036.id40982.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/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
@@ -40,6 +40,10 @@
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 +64,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(
+ 'authored',
+ array(
+ $viewer->getPHID(),
+ ));
case 'all':
return $query;
}
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,6 +25,7 @@
public static function initializeNewPanel(PhabricatorUser $actor) {
return id(new PhabricatorDashboardPanel())
->setName('')
+ ->setAuthorPHID($actor->getPHID())
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy($actor->getPHID());
}
@@ -48,6 +50,7 @@
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'panelType' => 'text64',
+ 'authorPHID' => 'phid',
'isArchived' => 'bool',
),
) + parent::getConfiguration();

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 18, 5:58 PM (11 h, 22 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7007203
Default Alt Text
D17036.id40982.diff (5 KB)

Event Timeline