Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: paginate workspaces page#4647

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
presleyp merged 44 commits intomainfrompaginate-ws/presleyp
Oct 20, 2022
Merged

feat: paginate workspaces page#4647

presleyp merged 44 commits intomainfrompaginate-ws/presleyp
Oct 20, 2022

Conversation

presleyp
Copy link
Contributor

  • add count endpoint to backend
  • add count call to frontend
  • put pagination widget in workspaces page
  • made pagination widget mobile friendly (shows only the current page button)

The frontend test is not ideal but I wanted to get reviews before demo time!

@presleyppresleyp requested a review froma team as acode ownerOctober 19, 2022 03:45
@presleyppresleyp removed the request for review froma teamOctober 19, 2022 03:45
severity={
workspaceRefs !== undefined && workspaceRefs.length > 0
? "warning"
: "error"
Copy link
Member

Choose a reason for hiding this comment

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

What does theAlertBanner look like with the error prop passed through, but also a severity ofwarning? JC because I only ever tested the warning case with the text prop, as opposed to the error prop.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Just added a story for this!

@@ -206,160 +206,255 @@ interface WorkspacesContext {
workspaceRefs?: WorkspaceItemMachineRef[]
filter: string
getWorkspacesError?: Error | unknown
getCountError?: Error | unknown
Copy link
Member

Choose a reason for hiding this comment

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

Could these additions be pulled out into a separate machine for pagination? Not sure if there's a way to call a machine state from another machine.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe viaspawn? I saw that being used below.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah, that's the idea I mentioned!

One way would be for the pagination widget to have its own machine. I believe both machines would need to be aware of the other, so we'd have to hard-code in their machine ids. I wasn't sure I liked that. I think someday XState will make stuff like that easier.

Another way would be to have a pagination machine that doesn't operate on its own, but the workspaces page invokes it. I didn't go that route only because the pagination machine would have no states, and I didn't think people would want an extra machine for something simple.

But if you're in favor, I can reconsider.

Kira-Pilot reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see! I forgot about the machine IDs.

I do like the idea of a pagination machine. Otherwise, I think we'll have to duplicate the logic you've written here to each page machine.

getWorkspacesError: (_, event) => event.data,
}),
clearGetWorkspacesError: (context) =>
assign({ ...context, getWorkspacesError: undefined }),
Copy link
Member

Choose a reason for hiding this comment

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

curious why we overwrite the the whole context here instead of just updating thegetWorkspaceError to be undefined.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Oh so something not great about this diff is that I used the XState editor and it rearranged some code, so some stuff looks new that isn't. This is just an old pattern that we found a better way of writing since then.

Kira-Pilot reacted with thumbs up emoji
@Kira-Pilot
Copy link
Member

Kira-Pilot commentedOct 19, 2022
edited
Loading

The empty state is a bit off - neither buttons are disabled, and when clicked, I get this error:
Screen Shot 2022-10-19 at 10 18 36 AM

Also, I'm surprised to see the widget for 0 entries, but if there are less than 25 entries, I don't see it.

Copy link
Member

@Kira-PilotKira-Pilot left a comment

Choose a reason for hiding this comment

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

Great job! I do think we should make a pagination machine and also explore showing the pagination widget at all times, even if there is only 1 page.

But not gonna block this sweet PR over it! 🥳

@presleyp
Copy link
ContributorAuthor

@Kira-Pilot some of the weirdness is because I got rid of conditions in the page that block the widget, but I didn't change the conditions in the widget. Partly I'm trying to leave it for that other ticket and partly I'm afraid to change the widget before testing the audit log page. I think the widget enables the page turning buttons when count is undefined, so it's usable without a count, but doesn't distinguish between 0 and undefined, so in the meantime I'm not rendering it when count is 0.

Kira-Pilot reacted with thumbs up emoji

q.mutex.RLock()
defer q.mutex.RUnlock()

workspaces := make([]database.Workspace, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

You could probably save some code by just converting this fromdatabase.GetWorkspaceCountParams todatabase.GetWorkspaceParams and then callingq.GetAuthorizedWorkspace but completely optional.

kylecarbs reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I agree with this!

@presleyppresleyp merged commit7c238f1 intomainOct 20, 2022
@presleyppresleyp deleted the paginate-ws/presleyp branchOctober 20, 2022 17:23
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 20, 2022
Copy link
Member

@kylecarbskylecarbs left a comment

Choose a reason for hiding this comment

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

Sorry for the late review!

q.mutex.RLock()
defer q.mutex.RUnlock()

workspaces := make([]database.Workspace, 0)
Copy link
Member

Choose a reason for hiding this comment

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

I agree with this!

Comment on lines +148 to +149
-- this duplicates the filtering in GetWorkspaces
-- name: GetWorkspaceCount :one
Copy link
Member

Choose a reason for hiding this comment

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

I left an ad-hoc comment on the commit, but I think this is quite bug-prone.

It's not extremely obvious that youhave to change this when introducing a new filter type, which could lead to a mismatch with the workspaces and count.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah, Colin thought this was the best thing for now but we have an issue to clean it up#4604

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@kylecarbskylecarbskylecarbs left review comments

@Kira-PilotKira-PilotKira-Pilot approved these changes

@f0sself0sself0ssel approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@presleyp@Kira-Pilot@kylecarbs@f0ssel

[8]ページ先頭

©2009-2025 Movatter.jp