Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15386027
D17022.id40976.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D17022.id40976.diff
View Options
diff --git a/resources/sql/autopatches/20161210.dashboards.01.author.sql b/resources/sql/autopatches/20161210.dashboards.01.author.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161210.dashboards.01.author.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_dashboard.dashboard
+ ADD authorPHID VARBINARY(64);
diff --git a/resources/sql/autopatches/21061210.dashboards.01.author.php b/resources/sql/autopatches/21061210.dashboards.01.author.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/21061210.dashboards.01.author.php
@@ -0,0 +1,33 @@
+<?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) {
+
+ $author_phid = queryfx_one(
+ $txn_conn,
+ 'SELECT authorPHID FROM %T WHERE objectPHID = %s ORDER BY id ASC LIMIT 1',
+ $txn_table->getTableName(),
+ $dashboard->getPHID());
+
+ if (!$author_phid) {
+ $author_phid = id(new PhabricatorDashboardApplication())->getPHID();
+ }
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET authorPHID = %s WHERE id = %d',
+ $table->getTableName(),
+ $author_phid['authorPHID'],
+ $dashboard->getID());
+}
+
+echo pht("Done\n");
diff --git a/src/applications/dashboard/query/PhabricatorDashboardQuery.php b/src/applications/dashboard/query/PhabricatorDashboardQuery.php
--- a/src/applications/dashboard/query/PhabricatorDashboardQuery.php
+++ b/src/applications/dashboard/query/PhabricatorDashboardQuery.php
@@ -6,6 +6,7 @@
private $ids;
private $phids;
private $statuses;
+ private $authorPHIDs;
private $needPanels;
private $needProjects;
@@ -25,6 +26,11 @@
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 @@
$this->statuses);
}
+ if ($this->authorPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'authorPHID IN (%Ls)',
+ $this->authorPHIDs);
+ }
+
return $where;
}
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
@@ -18,6 +18,10 @@
protected function buildCustomSearchFields() {
return array(
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Authored By'))
+ ->setKey('authorPHIDs')
+ ->setDatasource(new PhabricatorPeopleDatasource()),
id(new PhabricatorSearchCheckboxesField())
->setKey('statuses')
->setLabel(pht('Status'))
@@ -30,19 +34,32 @@
}
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 @@
$query->withStatuses($map['statuses']);
}
+ if ($map['authorPHIDs']) {
+ $query->withAuthorPHIDs($map['authorPHIDs']);
+ }
+
return $query;
}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboard.php b/src/applications/dashboard/storage/PhabricatorDashboard.php
--- a/src/applications/dashboard/storage/PhabricatorDashboard.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboard.php
@@ -12,6 +12,7 @@
PhabricatorProjectInterface {
protected $name;
+ protected $authorPHID;
protected $viewPolicy;
protected $editPolicy;
protected $status;
@@ -31,6 +32,7 @@
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy($actor->getPHID())
->setStatus(self::STATUS_ACTIVE)
+ ->setAuthorPHID($actor->getPHID())
->attachPanels(array())
->attachPanelPHIDs(array());
}
@@ -61,6 +63,7 @@
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'status' => 'text32',
+ 'authorPHID' => 'phid?',
),
) + parent::getConfiguration();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 15 2025, 11:53 PM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704543
Default Alt Text
D17022.id40976.diff (4 KB)
Attached To
Mode
D17022: Add authorPHID to Dashboards
Attached
Detach File
Event Timeline
Log In to Comment