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

relation selector component (close #2296) #4089

Closed
wants to merge 6 commits into from

Conversation

beerose
Copy link
Contributor

@beerose beerose commented Mar 11, 2020

Solves #2296

Description

This PR adds a select component for columns with foreign key relation. For example, if we have table users with columns id and name, and table articles with columns id, author_id (referencing users.id), then when adding/editing foreign we can specify display_column:
captured (4)

Then in insert row and edit row view, we can choose a value from a dropdown where column specified as display column is used as a label. By default, only 20 rows are displayed in the dropdown. When typing data is filtered by the current input value.

Screenshot 2020-03-31 at 19 33 01

We're not limited to using the dropdown and filtering the data by display column. Providing own value (in this case user.id) also works.

Screenshot 2020-03-31 at 19 29 30

Affected components

  • Console

Design solution

Modify Table

Insert/edit item

  1. When the user goes to insert/edit row, the user will now see a new dropdown called "Display Name" if the column is having a foreign
  2. Whenever the user choose the display name, display name preference in every table is stored in the local storage as a single object.
  3. based on the display name, when the user types the input column value, UI shows a helper dropdown through which the user can select the foreign row by display name (example: shows name instead of confusing with user id)

Limitations

Since I'm using ilike for filtering data, the user can only choose column of type text, varchar or citext for display column.

Affected console components

  1. Migrated SearchableSelect.js to TypeScript. Extended custom filter to full-text filtering. Added two optional props:
  • onSearchValueChange
  1. Migrated jsUtils.js to TypeScript.
  2. Migrated v1QueryUtils.js to TypeScript.
  3. Migrated TypedInput to TypeScript. Extended implementation. (Described above)
  4. EditItem, InsertItem -- added handling selecting value from the dropdown.
  5. Migrated Data/utils.js to TypeScript. Changed implementation a bit in two places (same issue): https://github.com/hasura/graphql-engine/pull/4089/files#diff-089d4fb070627c2802e8853d6bb14f30R190
    It was done because we were taking advantage of JavaScript accepting the following code:
rcol = [foreignKeyConstraintOn.column]; // rcol = ["example"]
lcol = [column_mapping[rco]]; // column_mapping[["example"]] <- valid JS

I changed it because TypeScript doesn't accept it: link.

Ideas

  • Make common abstraction on insert row and edit row.

@beerose beerose added the c/console Related to console label Mar 11, 2020
@hasura-bot
Copy link
Contributor

Review app for commit 8371f43 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-8371f432

@netlify
Copy link

netlify bot commented Mar 17, 2020

Deploy preview for hasura-docs ready!

Built with commit 66c8244

https://deploy-preview-4089--hasura-docs.netlify.app

@hasura-bot
Copy link
Contributor

Review app for commit 88493f3 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-88493f30

@hasura-bot
Copy link
Contributor

Review app for commit 01fec00 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-01fec003

@hasura-bot
Copy link
Contributor

Review app for commit e224a48 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-e224a485

@hasura-bot
Copy link
Contributor

Review app for commit ccf0657 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-ccf0657b

@hasura-bot
Copy link
Contributor

Review app for commit 364a35c deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-364a35cf

@hasura-bot
Copy link
Contributor

Review app for commit 404e67a deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-404e67a5

@hasura-bot
Copy link
Contributor

Review app for commit bc1298b deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-bc1298b8

@hasura-bot
Copy link
Contributor

Review app for commit ef36206 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-ef362067

@hasura-bot
Copy link
Contributor

Review app for commit f46ef08 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-f46ef080

@beerose beerose marked this pull request as ready for review March 31, 2020 17:37
@beerose beerose requested a review from a team as a code owner March 31, 2020 17:37
@beerose beerose assigned wawhal and rikinsk and unassigned wawhal Apr 2, 2020
@hasura-bot
Copy link
Contributor

Review app for commit eb0720b deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-eb0720b4

@rikinsk rikinsk assigned beerose and unassigned rikinsk May 20, 2020
@hasura-bot
Copy link
Contributor

Review app for commit ff45f55 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-ff45f552

@beerose beerose assigned soorajshankar and unassigned beerose Jun 11, 2020
@beerose beerose marked this pull request as draft June 11, 2020 15:58
@@ -196,6 +238,127 @@ const initQueries = {
},
};

const loadConsoleOpts = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get rid of this

};
};

const getForeignKeyOptions = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get rid of this — move to LS

*
* @param {DisplayConfig} displayConfig
*/
const setConsoleFKOptions = displayConfig => (dispatch, getState) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get rid of in favor of LS

@soorajshankar soorajshankar added the s/do-not-merge Do not merge this pull request to master label Jun 16, 2020
@hasura-bot
Copy link
Contributor

Review app for commit 5deaded deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-5deadede

@hasura-bot
Copy link
Contributor

Review app for commit ab8fbab deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-ab8fbabf

@soorajshankar soorajshankar removed the s/do-not-merge Do not merge this pull request to master label Jun 25, 2020
@soorajshankar soorajshankar requested a review from rikinsk June 25, 2020 09:46
@hasura-bot
Copy link
Contributor

Review app for commit f1b64df deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-f1b64df9

@hasura-bot
Copy link
Contributor

Review app for commit 00a72d2 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-00a72d2d

@hasura-bot
Copy link
Contributor

Review app for commit 9c54750 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-9c547502

@hasura-bot
Copy link
Contributor

Review app for commit 7961226 deployed to Heroku: https://hge-ci-pull-4089.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4089-79612265

@beerose beerose assigned rikinsk and unassigned beerose Jul 13, 2020
@beerose
Copy link
Contributor Author

beerose commented Jul 13, 2020

@soorajshankar could you fix the conflicts?

@rikinsk rikinsk removed their assignment Aug 24, 2020
@soorajshankar soorajshankar marked this pull request as draft September 14, 2020 17:12
@soorajshankar soorajshankar marked this pull request as ready for review September 18, 2020 05:13
@soorajshankar
Copy link
Member

/heroku deploy

@beerose beerose assigned beerose and unassigned soorajshankar Nov 18, 2020
@beerose beerose closed this Jul 23, 2021
@beerose beerose deleted the feat/fk-select branch July 23, 2021 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/console Related to console
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants