Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard] add pagination to admin search #13161

Merged
merged 1 commit into from
Sep 22, 2022

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented Sep 21, 2022

Description

This change adds pagination support for the various admin dashboard list views.

Related Issue(s)

Fixes #8983

How to test

Release Notes

Admin dashboard now has pagination

Documentation

Werft options:

  • /werft with-preview
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-sefftinge-populate-admin-dashboard-8983.1 because the annotations in the pull request description changed
(with .werft/ from main)

@svenefftinge
Copy link
Member Author

svenefftinge commented Sep 21, 2022

/werft run

👍 started the job as gitpod-build-sefftinge-populate-admin-dashboard-8983.2
(with .werft/ from main)

@svenefftinge
Copy link
Member Author

svenefftinge commented Sep 21, 2022

/werft run with-preview

👍 started the job as gitpod-build-sefftinge-populate-admin-dashboard-8983.5
(with .werft/ from main)

@svenefftinge svenefftinge changed the title [dashboard] add pagination to user search [dashboard] add pagination to admin search Sep 21, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/populate-admin-dashboard-8983 branch from e31d0b8 to f247773 Compare September 21, 2022 11:58
@svenefftinge svenefftinge marked this pull request as ready for review September 21, 2022 11:58
@svenefftinge svenefftinge requested a review from a team September 21, 2022 11:58
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Sep 21, 2022
orderBy: "creationDate",
offset: 0,
offset: (currentPage - 1) * pageLength,
Copy link
Member

Choose a reason for hiding this comment

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

currentPage starts at value of 0, wouldn't this cause the offset to be negative?

Copy link
Member Author

Choose a reason for hiding this comment

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

currentPage should start at 1.

Copy link
Member

Choose a reason for hiding this comment

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

Now it does, but before it was definitely initialized to 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes on 3 out of 4 occasions 😬 (the four search pages are a bit copy and paste and of course I only tested on one of them, which also explains why the limit was set to 2 only on one of them)

Comment on lines 81 to 84
// Disables empty search on the workspace search page
if (!props.user && queryTerm.length === 0) {
return;
}
// if (!props.user && queryTerm.length === 0) {
// return;
// }
Copy link
Member

Choose a reason for hiding this comment

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

I believe this was the cause of an incident when we originally added the WS search - it would cause too many queries (but may be okay now)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, was this maybe before we introduced limits? cc @geropl Do you remember?
It's for sure a SaaS hack that makes the view less useful in smaller self-hosted installations. If we need to protect us we better do that on the server based on a saas-specific configuration.

Copy link
Member

Choose a reason for hiding this comment

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

AFAIR the problem was we executed an unlimited query with an empty query term, multiple times on page load.

If we do proper limits (and maybe just once on page load) this should be fine (did not check the code).

@@ -43,6 +44,11 @@ export function WorkspaceSearch(props: Props) {
const [queryTerm, setQueryTerm] = useState("");
const [searching, setSearching] = useState(false);
const [currentWorkspace, setCurrentWorkspaceState] = useState<WorkspaceAndInstance | undefined>(undefined);
const pageLength = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Why so low? Originally this was set to 100

Copy link
Member Author

Choose a reason for hiding this comment

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

For testing. But I have updated it 50 again.

Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why is it needed to commit test code? I'm asking because I'm trying to understand the problem and because this is something worth digging into to eliminate. Committing it risks we actually land it (and we have done so in past and caused incidents).

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, it was just an overlook by myself.
It could have been a conscious decision to allow others testing the changes more easily. In that case I would have added a 'hold' and a comment.

@svenefftinge svenefftinge force-pushed the sefftinge/populate-admin-dashboard-8983 branch from f247773 to e6df4f6 Compare September 21, 2022 12:13
@roboquat roboquat merged commit 29c88a7 into main Sep 22, 2022
@roboquat roboquat deleted the sefftinge/populate-admin-dashboard-8983 branch September 22, 2022 09:11
@roboquat roboquat added the deployed: webapp Meta team change is running in production label Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Populate Admin dashboard list views without first requiring a search
4 participants