-
Notifications
You must be signed in to change notification settings - Fork 2.8k
console: fix visiting view modify page overwriting raw sql content #4810
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
console: fix visiting view modify page overwriting raw sql content #4810
Conversation
|
Review app for commit 38cfb44 deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
Co-authored-by: Tirumarai Selvan <tirumarai.selvan@gmail.com>
tirumaraiselvan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog
|
Review app for commit 9651787 deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soorajshankar as we discussed, lets make modify of view happen in place and decouple it completely from the RawSQL page. We can allow the user to edit the view definition in the modify page itself and if we detect a change a Save button can be enabled.
Actually lets make the behaviour similar to the way we handle custom sql functions. The modify page willl have a code-block with the view definition and modify button which redirects to RawSQL page with the view definition prefilled
|
Deploy preview for hasura-docs ready! Built with commit 3c4956e |
|
@rikinsk |
|
Review app for commit 43a1d38 deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
rikinsk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UX approved
|
Review app for commit 467732e deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
beerose
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments.
> Alert > NotesSection
|
Review app for commit 99c4a27 deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
beerose
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding new state variable, we should implement the same solution as is now for modifying custom functions and work on how data is handled in Modify Actions. Right now when a view table is loaded, fetchViewDefinition function fetches view definition and stores it in RawSql/raw_sql, and this part should be decoupled. Raw SQL state shouldn't be updated on actions in the Modify view as they are two separate parts of the console.
sql: state.rawSQL.viewSql,This sql value should be taken from the Modify state, thus fetchViewDefinition should dispatch an action that updates Modify state. Then we could use this as previously:
<ViewDefinitions modifyViewOnClick={modifyViewOnClick} sql={sql} />And set raw_sql only if the user clicks modfiy and is redirected to the Raw SQL page.
For that we could actually use RawSqlButton component that is used for custom functions: https://github.com/hasura/graphql-engine/blob/master/console/src/components/Services/Data/TableModify/ComputedFieldsEditor.js#L305.
Btw, from the user perspective, let's say I have a query that I run very often. As long as it's persisted in local storage, everything is cool. But if I edit a view definition, it's quite a pity that my original query is overwritten in local storage. The same happens if I edit or create a custom function.
I see three possible solutions to this problem:
- Don't store SQL string in local storage when it's derived from view definition or custom function.
- Decouple modifying custom functions and views from the Raw SQL page and inline it on Modify pages.
- (My favorite) Create a history of executed queries in the Raw SQL page in a similar way as it is in the GraphiQL section (with a
clear allbutton). Then we wouldn't need to worry about possible overrides and it would also be an extremely useful feature.
Thoughts @rikinsk?
|
Review app for commit ae6de04 deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
|
@soorajshankar Can you take a look at the failing test? |
|
Review app for commit b6298cf deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
|
Review app for commit 12a1968 deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
This might be just as confusing as I would lose any edits I make to the edit view SQL on the Raw SQL page if I navigate. Typically I just expect the last content on the RawSQl page to persist so this doesnt seem ideal.
This would be the best solution but is a little tricky because we let the user execute any SQL and that can allow them to do unexpected things. e.g. if they drop the current view, the current page we are on will become a 404. If we can list all the possible end states and handle them or ensure that the user can only modify the current view (make the "create or replace view as " part of the statement fixed) this can be a good option.
This seems generally useful even beyond this issue and surprising no one has asked for this yet. Maybe we can create an issue and see the interest it gets and then decide when to pick it up. |
|
Review app for commit a6aad5c deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
console/src/components/Services/Data/RawSQL/molecules/NotesSection.tsx
Outdated
Show resolved
Hide resolved
…o fix/raw-sql-persist-data-#4798
|
Review app for commit 3c4956e deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
|
Review app for commit 3879e81 deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
|
Review app for commit c0cc2fe deployed to Heroku: https://hge-ci-pull-4810.herokuapp.com |
|
Review app https://hge-ci-pull-4810.herokuapp.com is deleted |
Description
Preserve data in local storage to ensure the user-provided data in raw SQL editor. data will preserve even after going to view modify tab.

Changelog
CHANGELOG.mdis updated with user-facing content relevant to this PR.Affected components
Related Issues
close #4798
Solution and Design
Since
data/sqlis used commonly a URL query string has been implemented. this helps to identify the container is mounted withmodify modeorrun sql mode.using this identity, local storage value/redux value is used in the editor.
Steps to test and verify
Run SQLpage and type some text.viewunder tables section.modifytab.Current Behaviour
viewunder table.Expected Behaviour
Limitations, known bugs & workarounds
Server checklist
Catalog upgrade
Does this PR change Hasura Catalog version?
Metadata
Does this PR add a new Metadata feature?
run_sqlauto manages the new metadata through schema diffing?run_sqlauto manages the definitions of metadata on renaming?export_metadata/replace_metadatasupports the new metadata added?GraphQL
Breaking changes
No Breaking changes
There are breaking changes:
Metadata API
Existing
querytypes:argspayload which is not backward compatibleJSONschemaGraphQL API
Schema Generation:
NamedTypeSchema Resolve:-
nullvalue for any input fieldsLogging
JSONschema has changedtypenames have changed