这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@polRk
Copy link

@polRk polRk commented Feb 7, 2020

Description

Put a separate option in the settings tab.
Save pageSize default value in localStorage.
Load page Size default value in Browser Rows view

Affected components

  • Console

Related Issues

#3849

Solution and Design

@polRk polRk requested a review from beerose as a code owner February 7, 2020 11:00
@hasura-bot
Copy link
Contributor

Beep boop! 🤖

Hey @polRk, thanks for your PR!

One of my human friends will review this PR and get back to you as soon as possible.

Stay awesome! 😎

@hasura-bot
Copy link
Contributor

Review app for commit 7609d37 deployed to Heroku: https://hge-ci-pull-3850.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3850-7609d37f

@netlify
Copy link

netlify bot commented Feb 7, 2020

Deploy preview for hasura-docs ready!

Built with commit ecf083b

https://deploy-preview-3850--hasura-docs.netlify.com

@netlify
Copy link

netlify bot commented Feb 7, 2020

Deploy preview for hasura-docs ready!

Built with commit 10ee273

https://deploy-preview-3850--hasura-docs.netlify.com

@polRk
Copy link
Author

polRk commented Feb 8, 2020

@hasura-bot deploy

@rikinsk
Copy link
Member

rikinsk commented Feb 11, 2020

/heroku deploy

@hasura-bot
Copy link
Contributor

Review app for commit 5e5a2fc deployed to Heroku: https://hge-ci-pull-3850.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3850-5e5a2fcc

@rikinsk
Copy link
Member

rikinsk commented Feb 11, 2020

@polRk Thanks for taking this issue up and contributing.

I just had some feedback on the UX. Instead of adding a new page in the setting section to set the default pageSize value, it would just suffice to persist the page size value when the user updates the page size on the browse rows page itself. If user sets page value to 20, then we persist that value and show 20 results always from then on.

Screenshot from 2020-02-11 12-57-05

@polRk
Copy link
Author

polRk commented Feb 11, 2020

@rikinsk Looks pretty good. I'll try to finish it soon

@polRk
Copy link
Author

polRk commented Feb 11, 2020

/heroku deploy

@hasura-bot
Copy link
Contributor

@polRk you don't have enough permissions to execute this command

@hasura-bot
Copy link
Contributor

Review app for commit 324520f deployed to Heroku: https://hge-ci-pull-3850.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3850-324520fc

@polRk
Copy link
Author

polRk commented Feb 11, 2020

After update, i see 2 requests ( with limit 10, and limit from localStorage )
Снимок экрана 2020-02-11 в 3 38 34 PM

Снимок экрана 2020-02-11 в 3 38 24 PM

@hasura-bot
Copy link
Contributor

Review app for commit 1f914bf deployed to Heroku: https://hge-ci-pull-3850.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3850-1f914bfc

@polRk polRk changed the title WIP: save pageSize default value in localStorage Save limit value in localStorage Feb 11, 2020
@polRk
Copy link
Author

polRk commented Feb 11, 2020

@beerose Can you make a review ?

@beerose
Copy link
Contributor

beerose commented Feb 11, 2020 via email

Copy link
Contributor

@beerose beerose left a comment

Choose a reason for hiding this comment

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

Hi @polRk. Thank you for your contribution!

Your code is working fine, but I see some problems with the implementation.

The content of the DataState.js is a pure state of the app, where we don't want to introduce any side effects. Thus, it's not the place for accessing the local storage.

Instead, take a look at this file and componentDidMount method: https://github.com/polRk/graphql-engine/blob/master/console/src/components/Services/Data/TableBrowseRows/FilterQuery.js#L173
Here, we are setting the default values, so this is the proper place for taking the limit from localStorage and passing it as a default limit:

dispatch(setDefaultQuery({ where, order_by, limit }));

Another thing is how you access the Local Storage. We don't want to do it directly from the components or reducers. Instead, we rather create some abstractions for Local Storage. Take a look at this file: https://github.com/hasura/graphql-engine/pull/3753/files#diff-7d6f61aee8febe1d54e2e517ca909792R1 .

It would be ideal if you'd make this PR a part of #3753 (by changing the base), which adds similar functionality -- it also makes some settings persistent.

query: {
columns: [],
limit: 10,
limit: parseInt(localStorage.getItem('console:queryLimit') || 10, 10),
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
limit: parseInt(localStorage.getItem('console:queryLimit') || 10, 10),
limit: 10

const defaultCurFilter = {
where: { $and: [{ '': { '': '' } }] },
limit: 10,
limit: parseInt(localStorage.getItem('console:queryLimit') || 10, 10),
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
limit: parseInt(localStorage.getItem('console:queryLimit') || 10, 10),
limit: 10

...defaultViewState,
query: {
columns: currentColumns,
limit: 10,
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't delete this line.

where: { delivered: false, error: false },
},
],
limit: 10,
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't delete this line.

@polRk
Copy link
Author

polRk commented Feb 12, 2020

@beerose How can i change the base ?

@hasura-bot
Copy link
Contributor

Review app for commit 05e2ede deployed to Heroku: https://hge-ci-pull-3850.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3850-05e2eded

@beerose
Copy link
Contributor

beerose commented Feb 12, 2020

@polRk You would need to create a new PR and choose my fork and browse-table-improvements branch.

Screenshot 2020-02-12 at 12 51 07

But what happened here?

Screenshot 2020-02-12 at 12 54 01

@polRk
Copy link
Author

polRk commented Feb 12, 2020

But what happened here?

I made a rebase to get new code from the master branch. Standard practice

@beerose
Copy link
Contributor

beerose commented Feb 12, 2020

But what happened here?

I made a rebase to get new code from the master branch. Standard practice

I think something went wrong here because you have 706 commits to merge.
What you could do now is:

  1. Fetch the newest Hasura master.
git remote add hasura git@github.com:hasura/graphql-engine.git

git fetch hasura master
  1. Do a soft reset:
git reset --soft hasura/master
  1. Commit your changes.
git commit -m 'Save limit value in localStorage'

@polRk
Copy link
Author

polRk commented Feb 12, 2020

I think something went wrong here because you have 706 commits to merge.

I rebased wrong master. Solved, thank you

@hasura-bot
Copy link
Contributor

Review app for commit 1df76bb deployed to Heroku: https://hge-ci-pull-3850.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3850-1df76bb8

@polRk polRk changed the title Save limit value in localStorage WIP: Save limit value in localStorage Feb 14, 2020
@CLAassistant
Copy link

CLA assistant check
All committers have signed the CLA.

@beerose
Copy link
Contributor

beerose commented Apr 7, 2020

Hi @polRk! It's been a while since your last commit, so I want to ask if you still plan to work on this PR?

@polRk
Copy link
Author

polRk commented Apr 7, 2020

Hi @beerose! I don’t have enough time for this PR. I want to make hasura console better, if someone can to do this faster than me, it will be good. Sorry for waiting

@beerose
Copy link
Contributor

beerose commented Apr 7, 2020

Closing in favor of #4323.

@beerose beerose closed this Apr 7, 2020
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-3850.herokuapp.com is deleted

@hasura-bot
Copy link
Contributor

Beep boop! 🤖

Hey @polRk!

Sorry that your PR wasn’t merged.

Do take a look at any of the other open issues to see if you’d like to take something up! We’re around on Discord if you have any questions 😄

@polRk polRk deleted the patch-1 branch April 8, 2020 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants