1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Convert dashboard read/display pathways to the new panel storage format

Summary:
Depends on D20406. Ref T13272. This gets about half of Dashboards working with the new "duplicate panel friendly" storage format. Followups will fix the write pathways.

Collateral damage here includes:

  - Remove the old Dashboard/Panel edge type. We have a new, more general edge type for "container X uses panel Y", and we don't need this edge type for anything else.
  - Remove "attachPanels()" from Dashboard. Only rendering actually needs this, and it can just load the panels.
  - Remove "attachPanelPHIDs()" from Dashboard. We can look at the panel refs to figure this out.
  - Remove "attachProjects()" from Dashboard. Nothing uses this and it's not a very modern approach.
  - `getPanelPHIDs()` just looks at the config now.
  - Deleted some `LayoutConfig`-related code which is broken/obsolete.

Test Plan:
  - Viewed various dashboards which were created before the changes, saw them render correctly.
  - Viewed a dashboard with two of the same panel! AMAZING!

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13272

Differential Revision: https://secure.phabricator.com/D20407
This commit is contained in:
epriestley 2019-04-12 08:34:48 -07:00
parent 0381eed6e6
commit a3c43c473b
17 changed files with 190 additions and 425 deletions

View file

@ -2914,7 +2914,6 @@ phutil_register_library_map(array(
'PhabricatorDashboardConsoleController' => 'applications/dashboard/controller/PhabricatorDashboardConsoleController.php',
'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php',
'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php',
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php',
'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php',
'PhabricatorDashboardDatasource' => 'applications/dashboard/typeahead/PhabricatorDashboardDatasource.php',
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/dashboard/PhabricatorDashboardEditController.php',
@ -2945,13 +2944,14 @@ phutil_register_library_map(array(
'PhabricatorDashboardPanelEditConduitAPIMethod' => 'applications/dashboard/conduit/PhabricatorDashboardPanelEditConduitAPIMethod.php',
'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/panel/PhabricatorDashboardPanelEditController.php',
'PhabricatorDashboardPanelEditEngine' => 'applications/dashboard/editor/PhabricatorDashboardPanelEditEngine.php',
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardPanelHasDashboardEdgeType.php',
'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/panel/PhabricatorDashboardPanelListController.php',
'PhabricatorDashboardPanelNameTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardPanelNameTransaction.php',
'PhabricatorDashboardPanelNgrams' => 'applications/dashboard/storage/PhabricatorDashboardPanelNgrams.php',
'PhabricatorDashboardPanelPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardPanelPHIDType.php',
'PhabricatorDashboardPanelPropertyTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardPanelPropertyTransaction.php',
'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php',
'PhabricatorDashboardPanelRef' => 'applications/dashboard/layoutconfig/PhabricatorDashboardPanelRef.php',
'PhabricatorDashboardPanelRefList' => 'applications/dashboard/layoutconfig/PhabricatorDashboardPanelRefList.php',
'PhabricatorDashboardPanelRenderController' => 'applications/dashboard/controller/panel/PhabricatorDashboardPanelRenderController.php',
'PhabricatorDashboardPanelRenderingEngine' => 'applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php',
'PhabricatorDashboardPanelSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php',
@ -8914,7 +8914,6 @@ phutil_register_library_map(array(
'PhabricatorDashboardConsoleController' => 'PhabricatorDashboardController',
'PhabricatorDashboardController' => 'PhabricatorController',
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'PhabricatorEdgeType',
'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType',
'PhabricatorDashboardDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorDashboardEditController' => 'PhabricatorDashboardController',
@ -8952,13 +8951,14 @@ phutil_register_library_map(array(
'PhabricatorDashboardPanelEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelEditEngine' => 'PhabricatorEditEngine',
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'PhabricatorEdgeType',
'PhabricatorDashboardPanelListController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelNameTransaction' => 'PhabricatorDashboardPanelTransactionType',
'PhabricatorDashboardPanelNgrams' => 'PhabricatorSearchNgrams',
'PhabricatorDashboardPanelPHIDType' => 'PhabricatorPHIDType',
'PhabricatorDashboardPanelPropertyTransaction' => 'PhabricatorDashboardPanelTransactionType',
'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorDashboardPanelRef' => 'Phobject',
'PhabricatorDashboardPanelRefList' => 'Phobject',
'PhabricatorDashboardPanelRenderController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelRenderingEngine' => 'Phobject',
'PhabricatorDashboardPanelSearchEngine' => 'PhabricatorApplicationSearchEngine',

View file

@ -10,7 +10,6 @@ final class PhabricatorDashboardAddPanelController
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($id))
->needPanels(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -15,7 +15,6 @@ final class PhabricatorDashboardMovePanelController
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($id))
->needPanels(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -47,17 +47,6 @@ final class PhabricatorDashboardRemovePanelController
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
->setNewValue(
array(
'-' => array(
$v_panel => $v_panel,
),
));
$layout_config->removePanel($v_panel);
$dashboard->setLayoutConfigFromObject($layout_config);

View file

@ -14,7 +14,6 @@ final class PhabricatorDashboardViewController
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($id))
->needPanels(true)
->executeOne();
if (!$dashboard) {
return new Aphront404Response();

View file

@ -1,103 +0,0 @@
<?php
final class PhabricatorDashboardDashboardHasPanelEdgeType
extends PhabricatorEdgeType {
const EDGECONST = 45;
public function getInverseEdgeConstant() {
return PhabricatorDashboardPanelHasDashboardEdgeType::EDGECONST;
}
public function shouldWriteInverseTransactions() {
return true;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s panel(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s panel(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited panel(s), added %s: %s; removed %s: %s.',
$actor,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s panel(s) for %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s panel(s) for %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited panel(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -1,103 +0,0 @@
<?php
final class PhabricatorDashboardPanelHasDashboardEdgeType
extends PhabricatorEdgeType {
const EDGECONST = 46;
public function getInverseEdgeConstant() {
return PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST;
}
public function shouldWriteInverseTransactions() {
return true;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s dashboard(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s dashboard(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited dashboard(s), added %s: %s; removed %s: %s.',
$actor,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s dashboard(s) for %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s dashboard(s) for %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited dashboard(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -11,38 +11,6 @@ final class PhabricatorDashboardTransactionEditor
return pht('Dashboards');
}
public static function addPanelToDashboard(
PhabricatorUser $actor,
PhabricatorContentSource $content_source,
PhabricatorDashboardPanel $panel,
PhabricatorDashboard $dashboard,
$column) {
$xactions = array();
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
->setNewValue(
array(
'+' => array(
$panel->getPHID() => $panel->getPHID(),
),
));
$layout_config = $dashboard->getLayoutConfigObject();
$layout_config->setPanelLocation($column, $panel->getPHID());
$dashboard->setLayoutConfigFromObject($layout_config);
$editor = id(new PhabricatorDashboardTransactionEditor())
->setActor($actor)
->setContentSource($content_source)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true)
->applyTransactions($dashboard, $xactions);
}
public function getTransactionTypes() {
$types = parent::getTransactionTypes();

View file

@ -31,44 +31,46 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
public function renderDashboard() {
require_celerity_resource('phabricator-dashboard-css');
$dashboard = $this->dashboard;
$viewer = $this->viewer;
$dashboard = $this->getDashboard();
$viewer = $this->getViewer();
$is_editable = $this->arrangeMode;
$layout_config = $dashboard->getLayoutConfigObject();
$panel_grid_locations = $layout_config->getPanelLocations();
$panels = mpull($dashboard->getPanels(), null, 'getPHID');
$dashboard_id = celerity_generate_unique_node_id();
$result = id(new AphrontMultiColumnView())
->setID($dashboard_id)
->setFluidLayout(true)
->setGutter(AphrontMultiColumnView::GUTTER_LARGE);
if ($is_editable) {
$h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_EDIT;
} else {
$h_mode = PhabricatorDashboardPanelRenderingEngine::HEADER_MODE_NORMAL;
}
$panel_phids = array();
foreach ($panel_grid_locations as $panel_column_locations) {
foreach ($panel_column_locations as $panel_phid) {
$panel_phids[] = $panel_phid;
}
$panel_phids = $dashboard->getPanelPHIDs();
if ($panel_phids) {
$panels = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
->withPHIDs($panel_phids)
->execute();
$panels = mpull($panels, null, 'getPHID');
$handles = $viewer->loadHandles($panel_phids);
} else {
$panels = array();
$handles = array();
}
$handles = $viewer->loadHandles($panel_phids);
foreach ($panel_grid_locations as $column => $panel_column_locations) {
$panel_phids = $panel_column_locations;
$ref_list = $dashboard->getPanelRefList();
$columns = $ref_list->getColumns();
// TODO: This list may contain duplicates when the dashboard itself
// does not? Perhaps this is related to T10612. For now, just unique
// the list before moving on.
$panel_phids = array_unique($panel_phids);
$dashboard_id = celerity_generate_unique_node_id();
$result = id(new AphrontMultiColumnView())
->setID($dashboard_id)
->setFluidLayout(true)
->setGutter(AphrontMultiColumnView::GUTTER_LARGE);
foreach ($columns as $column) {
$column_views = array();
foreach ($column->getPanelRefs() as $panel_ref) {
$panel_phid = $panel_ref->getPanelPHID();
$column_result = array();
foreach ($panel_phids as $panel_phid) {
$panel_engine = id(new PhabricatorDashboardPanelRenderingEngine())
->setViewer($viewer)
->setDashboardID($dashboard->getID())
@ -85,18 +87,19 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
$panel_engine->setPanel($panel);
}
$column_result[] = $panel_engine->renderPanel();
$column_views[] = $panel_engine->renderPanel();
}
$column_class = $layout_config->getColumnClass(
$column,
$is_editable);
$column_classes = $column->getClasses();
if ($is_editable) {
$column_result[] = $this->renderAddPanelPlaceHolder($column);
$column_result[] = $this->renderAddPanelUI($column);
$column_views[] = $this->renderAddPanelPlaceHolder();
$column_views[] = $this->renderAddPanelUI($column->getColumnKey());
}
$result->addColumn(
$column_result,
$column_class,
$column_views,
implode(' ', $column_classes),
$sigil = 'dashboard-column',
$metadata = array('columnID' => $column));
}
@ -120,10 +123,7 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
return $view;
}
private function renderAddPanelPlaceHolder($column) {
$dashboard = $this->dashboard;
$panels = $dashboard->getPanels();
private function renderAddPanelPlaceHolder() {
return javelin_tag(
'span',
array(

View file

@ -5,6 +5,7 @@ final class PhabricatorDashboardColumn
private $columnKey;
private $classes = array();
private $refs = array();
public function setColumnKey($column_key) {
$this->columnKey = $column_key;
@ -24,4 +25,13 @@ final class PhabricatorDashboardColumn
return $this->classes;
}
public function addPanelRef(PhabricatorDashboardPanelRef $ref) {
$this->refs[] = $ref;
return $this;
}
public function getPanelRefs() {
return $this->refs;
}
}

View file

@ -0,0 +1,37 @@
<?php
final class PhabricatorDashboardPanelRef
extends Phobject {
private $panelPHID;
private $panelKey;
private $columnKey;
public function setPanelPHID($panel_phid) {
$this->panelPHID = $panel_phid;
return $this;
}
public function getPanelPHID() {
return $this->panelPHID;
}
public function setColumnKey($column_key) {
$this->columnKey = $column_key;
return $this;
}
public function getColumnKey() {
return $this->columnKey;
}
public function setPanelKey($panel_key) {
$this->panelKey = $panel_key;
return $this;
}
public function getPanelKey() {
return $this->panelKey;
}
}

View file

@ -0,0 +1,76 @@
<?php
final class PhabricatorDashboardPanelRefList
extends Phobject {
private $refs;
private $columns;
public static function newFromDictionary($config) {
if (!is_array($config)) {
$config = array();
}
$mode_map = PhabricatorDashboardLayoutMode::getAllLayoutModes();
$mode_key = idx($config, 'layoutMode');
if (!isset($mode_map[$mode_key])) {
$mode_key = head_key($mode_map);
}
$mode = $mode_map[$mode_key];
$columns = $mode->getLayoutModeColumns();
$columns = mpull($columns, null, 'getColumnKey');
$default_column = head($columns);
$panels = idx($config, 'panels');
if (!is_array($panels)) {
$panels = array();
}
$seen_panels = array();
$refs = array();
foreach ($panels as $panel) {
$panel_phid = idx($panel, 'panelPHID');
if (!strlen($panel_phid)) {
continue;
}
$panel_key = idx($panel, 'panelKey');
if (!strlen($panel_key)) {
continue;
}
if (isset($seen_panels[$panel_key])) {
continue;
}
$seen_panels[$panel_key] = true;
$column_key = idx($panel, 'columnKey');
$column = idx($columns, $column_key, $default_column);
$ref = id(new PhabricatorDashboardPanelRef())
->setPanelPHID($panel_phid)
->setPanelKey($panel_key)
->setColumnKey($column->getColumnKey());
$column->addPanelRef($ref);
$refs[] = $ref;
}
$list = new self();
$list->columns = $columns;
$list->refs = $refs;
return $list;
}
public function getColumns() {
return $this->columns;
}
public function getPanelRefs() {
return $this->refs;
}
}

View file

@ -9,9 +9,6 @@ final class PhabricatorDashboardQuery
private $authorPHIDs;
private $canEdit;
private $needPanels;
private $needProjects;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
@ -32,16 +29,6 @@ final class PhabricatorDashboardQuery
return $this;
}
public function needPanels($need_panels) {
$this->needPanels = $need_panels;
return $this;
}
public function needProjects($need_projects) {
$this->needProjects = $need_projects;
return $this;
}
public function withCanEdit($can_edit) {
$this->canEdit = $can_edit;
return $this;
@ -74,58 +61,6 @@ final class PhabricatorDashboardQuery
->apply($dashboards);
}
if ($this->needPanels) {
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($phids)
->withEdgeTypes(
array(
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST,
));
$edge_query->execute();
$panel_phids = $edge_query->getDestinationPHIDs();
if ($panel_phids) {
// NOTE: We explicitly disable policy exceptions when loading panels.
// If a particular panel is invalid or not visible to the viewer,
// we'll still render the dashboard, just not that panel.
$panels = id(new PhabricatorDashboardPanelQuery())
->setParentQuery($this)
->setRaisePolicyExceptions(false)
->setViewer($this->getViewer())
->withPHIDs($panel_phids)
->execute();
$panels = mpull($panels, null, 'getPHID');
} else {
$panels = array();
}
foreach ($dashboards as $dashboard) {
$dashboard_phids = $edge_query->getDestinationPHIDs(
array($dashboard->getPHID()));
$dashboard_panels = array_select_keys($panels, $dashboard_phids);
$dashboard->attachPanelPHIDs($dashboard_phids);
$dashboard->attachPanels($dashboard_panels);
}
}
if ($this->needProjects) {
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($phids)
->withEdgeTypes(
array(
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
));
$edge_query->execute();
foreach ($dashboards as $dashboard) {
$project_phids = $edge_query->getDestinationPHIDs(
array($dashboard->getPHID()));
$dashboard->attachProjectPHIDs($project_phids);
}
}
return $dashboards;
}

View file

@ -12,8 +12,7 @@ final class PhabricatorDashboardSearchEngine
}
public function newQuery() {
return id(new PhabricatorDashboardQuery())
->needPanels(true);
return id(new PhabricatorDashboardQuery());
}
public function canUseInPanelContext() {
@ -139,16 +138,6 @@ final class PhabricatorDashboardSearchEngine
$bg_color = 'bg-grey';
}
$panels = $dashboard->getPanels();
foreach ($panels as $panel) {
$item->addAttribute($panel->getName());
}
if (empty($panels)) {
$empty = phutil_tag('em', array(), pht('No panels.'));
$item->addAttribute($empty);
}
$icon = id(new PHUIIconView())
->setIcon($dashboard->getIcon())
->setBackground($bg_color);

View file

@ -24,10 +24,10 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
const STATUS_ACTIVE = 'active';
const STATUS_ARCHIVED = 'archived';
private $panelPHIDs = self::ATTACHABLE;
private $panels = self::ATTACHABLE;
private $edgeProjectPHIDs = self::ATTACHABLE;
private $panelRefList;
public static function initializeNewDashboard(PhabricatorUser $actor) {
return id(new PhabricatorDashboard())
@ -37,8 +37,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
->setEditPolicy($actor->getPHID())
->setStatus(self::STATUS_ACTIVE)
->setAuthorPHID($actor->getPHID())
->attachPanels(array())
->attachPanelPHIDs(array());
->attachPanels(array());
}
public static function getStatusNameMap() {
@ -76,6 +75,10 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
public function setRawLayoutMode($mode) {
$config = $this->getRawLayoutConfig();
$config['layoutMode'] = $mode;
// If a cached panel ref list exists, clear it.
$this->panelRefList = null;
return $this->setLayoutConfig($config);
}
@ -89,53 +92,6 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
return $config;
}
public function getLayoutConfigObject() {
return PhabricatorDashboardLayoutConfig::newFromDictionary(
$this->getLayoutConfig());
}
public function setLayoutConfigFromObject(
PhabricatorDashboardLayoutConfig $object) {
$this->setLayoutConfig($object->toDictionary());
// See PHI385. Dashboard panel mutations rely on changes to the Dashboard
// object persisting when transactions are applied, but this assumption is
// no longer valid after T13054. For now, just save the dashboard
// explicitly.
$this->save();
return $this;
}
public function getProjectPHIDs() {
return $this->assertAttached($this->edgeProjectPHIDs);
}
public function attachProjectPHIDs(array $phids) {
$this->edgeProjectPHIDs = $phids;
return $this;
}
public function attachPanelPHIDs(array $phids) {
$this->panelPHIDs = $phids;
return $this;
}
public function getPanelPHIDs() {
return $this->assertAttached($this->panelPHIDs);
}
public function attachPanels(array $panels) {
assert_instances_of($panels, 'PhabricatorDashboardPanel');
$this->panels = $panels;
return $this;
}
public function getPanels() {
return $this->assertAttached($this->panels);
}
public function isArchived() {
return ($this->getStatus() == self::STATUS_ARCHIVED);
}
@ -148,6 +104,24 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
return pht('Dashboard %d', $this->getID());
}
public function getPanelRefList() {
if (!$this->panelRefList) {
$this->panelRefList = $this->newPanelRefList();
}
return $this->panelRefList;
}
private function newPanelRefList() {
$raw_config = $this->getLayoutConfig();
return PhabricatorDashboardPanelRefList::newFromDictionary($raw_config);
}
public function getPanelPHIDs() {
$ref_list = $this->getPanelRefList();
$phids = mpull($ref_list->getPanelRefs(), 'getPanelPHID');
return array_unique($phids);
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
@ -216,9 +190,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
/* -( PhabricatorDashboardPanelContainerInterface )------------------------ */
public function getDashboardPanelContainerPanelPHIDs() {
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$this->getPHID(),
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST);
return $this->getPanelPHIDs();
}
}

View file

@ -43,7 +43,6 @@ final class PhabricatorDashboardInstall
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withPHIDs(array($dashboard_install->getDashboardPHID()))
->needPanels(true)
->executeOne();
}

View file

@ -54,7 +54,6 @@ final class PhabricatorDashboardProfileMenuItem
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withPHIDs(array($dashboard_phid))
->needPanels(true)
->executeOne();
if (!$dashboard) {
return $this->newEmptyView(