Skip to content

Conversation

DominikB2014
Copy link
Contributor

@DominikB2014 DominikB2014 commented Dec 12, 2024

closes #82035

Basically, in superuser, sometimes pageFilters.selection.projects returns [] when all projects are selected. However the code assumes empty array is "my projects".

@DominikB2014 DominikB2014 requested a review from a team as a code owner December 12, 2024 20:49
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 12, 2024
@@ -52,6 +53,9 @@ export function useHasFirstSpan(module: ModuleName, projects?: Project[]): boole
// - [] empty list represents "My Projects"
// - [-1] represents "All Projects"
// - [.., ..] otherwise, represents a list of project IDs
if (pageFilters.selection.projects.length === 0 && isActiveSuperuser()) {
selectedProjects = allProjects; // when superuser is enabled, My Projects isn't applicable, and in reality all projects are selected when projects.length === 0
}
if (pageFilters.selection.projects.length === 0) {
selectedProjects = allProjects.filter(p => p.isMember);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
selectedProjects = allProjects.filter(p => p.isMember);
selectedProjects = allProjects.filter(p => p.isMember || isActiveSuperuser());

same thing but shorter, maybe less obvious what it does though 🤷

Copy link
Contributor Author

@DominikB2014 DominikB2014 Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good call out, thanks! I accidentally merged this, but I can make this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I thought it wasn't obvious, but it makes sense actually as they are both conditions on the user (isMemeber or isSuperusuer).
It is an unnecessary filter, but the performance of that is negligible

@DominikB2014 DominikB2014 merged commit 9b1ef04 into master Dec 12, 2024
44 checks passed
@DominikB2014 DominikB2014 deleted the DominikB2014/fix-no-data-bugs-admin branch December 12, 2024 22:53
evanh pushed a commit that referenced this pull request Dec 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix(insights) module hasData returns false always in admin
2 participants