1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Dashboard Panel: fix first tab sometime not opened anymore

Summary:
After this change the first Tab ID is always selected, so we don't risk
to have no tabs opened by default under some corner cases.

This is vaguely better than the original logic that relied on the fact that
(0=="0") is true. Besides being a vaguely weird emoticon as well, now that
I look at it better.

Original logic:

https://we.phorge.it/source/phorge/browse/master/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php;c43618a3a8bb021936fad687f04cb1a95faa23e4$289

This fixes a regression that appeared in the cute Wikimedia Phabricator
(that now is really Wikimedia Phorge). Their homepage should be gorgeous again,
without blank space due to unopened silly tabs.

Closes T15651

Test Plan:
- Have a Tab Panel (/dashboard/panel/).
- Be sure that the first Tab is automatically selected (again?)

Reviewers: aklapper, O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15651

Differential Revision: https://we.phorge.it/D25447
This commit is contained in:
Valerio Bozzolan 2023-10-16 08:40:23 +02:00
parent 94aefaa31d
commit 2d635fb76e

View file

@ -85,10 +85,12 @@ final class PhabricatorDashboardTabsPanelType
$rename_uri = id(new PhutilURI($rename_uri))
->replaceQueryParam('contextPHID', $context_phid);
$selected = 0;
$key_list = array_keys($config);
// In the future we may persist which panel was selected.
// At the moment we have always selected the first one.
$selected = (string)head($key_list);
$next_keys = array();
$prev_keys = array();
for ($ii = 0; $ii < count($key_list); $ii++) {
@ -111,7 +113,8 @@ final class PhabricatorDashboardTabsPanelType
$name = pht('Unnamed Tab');
}
$is_selected = (string)$idx === (string)$selected;
// The $idx can be something like "0", "1" or "asdasd98".
$is_selected = (string)$idx === $selected;
$tab_view = id(new PHUIListItemView())
->setHref('#')
@ -282,7 +285,8 @@ final class PhabricatorDashboardTabsPanelType
$panel_content = pht('(Invalid Panel)');
}
$is_selected = (string)$idx === (string)$selected;
// Note that $idx can be something like "0", "1" or "asdasd98".
$is_selected = (string)$idx === $selected;
$content_id = celerity_generate_unique_node_id();