Page MenuHomePhabricator

D9281.id22320.diff
No OneTemporary

D9281.id22320.diff

diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
@@ -7,6 +7,29 @@
abstract public function getPanelTypeDescription();
abstract public function getFieldSpecifications();
+ abstract public function renderPanelContent(
+ PhabricatorUser $viewer,
+ PhabricatorDashboardPanel $panel,
+ PhabricatorDashboardPanelRenderingEngine $engine);
+
+ /**
+ * Should this panel pull content in over AJAX?
+ *
+ * Normally, panels use AJAX to render their content. This makes the page
+ * interactable sooner, allows panels to render in parallel, and prevents one
+ * slow panel from slowing everything down.
+ *
+ * However, some panels are very cheap to build (i.e., no expensive service
+ * calls or complicated rendering). In these cases overall performance can be
+ * improved by disabling async rendering so the panel rendering happens in the
+ * same process.
+ *
+ * @return bool True to enable asynchronous rendering when appropriate.
+ */
+ public function shouldRenderAsync() {
+ return true;
+ }
+
public static function getAllPanelTypes() {
static $types;
@@ -40,19 +63,4 @@
return $types;
}
-
-
- public function renderPanelContent(
- PhabricatorUser $viewer,
- PhabricatorDashboardPanel $panel,
- PhabricatorDashboardPanelRenderingEngine $engine) {
- return pht('TODO: Panel content goes here.');
- }
-
- public function shouldRenderAsync() {
- // TODO: For now, just make these things random so we can catch anything
- // that breaks.
- return (mt_rand(0, 1) == 1);
- }
-
}
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
@@ -25,6 +25,11 @@
);
}
+ public function shouldRenderAsync() {
+ // The actual tab panel itself is cheap to render.
+ return false;
+ }
+
public function renderPanelContent(
PhabricatorUser $viewer,
PhabricatorDashboardPanel $panel,
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php
@@ -26,6 +26,11 @@
);
}
+ public function shouldRenderAsync() {
+ // Rendering text panels is normally a cheap cache hit.
+ return false;
+ }
+
public function renderPanelContent(
PhabricatorUser $viewer,
PhabricatorDashboardPanel $panel,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 10:03 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6717626
Default Alt Text
D9281.id22320.diff (2 KB)

Event Timeline