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

Feature: Allow copying the table definition from the dropdown menu #27621

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

nickterhaar
Copy link

@nickterhaar nickterhaar commented Jun 28, 2024

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Feature

What is the current behavior?

#27538

We can now get the table definition from here
Would be great if we could copy it from here ("Copy table definition")

What is the new behavior?

Now in the 'Table Editor', when opening the menu of one of the tables, you'll get the option to 'Copy Definition' (see screenshot).

Additional context

I've used the same 'copy' icon as which is being used for 'Duplicate Table'. Because of this, I've put the 'Copy Definition' at the bottom of the list. Let me know if I need to use a different icon for this.

I've also created a 'useTableDefinition' hook, the logic of this hook was found in the 'TableDefinition.tsx' component. Because I had to reuse this logic, I thought it would be a better idea to write one new hook and let the existing component and my new feature make use of it, instead of reusing/copying the same code. Please let me know is this is okay or if I need to do it differently.

Add any other context or screenshots.
copy-defintion

Copy link

vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
studio-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 5, 2024 1:17pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
design-system ⬜️ Ignored (Inspect) Visit Preview Jul 5, 2024 1:17pm
docs ⬜️ Ignored (Inspect) Visit Preview Jul 5, 2024 1:17pm
studio ⬜️ Ignored (Inspect) Visit Preview Jul 5, 2024 1:17pm
studio-self-hosted ⬜️ Ignored (Inspect) Visit Preview Jul 5, 2024 1:17pm
zone-www-dot-com ⬜️ Ignored (Inspect) Visit Preview Jul 5, 2024 1:17pm

Copy link

vercel bot commented Jun 28, 2024

@nickterhaar is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@@ -0,0 1,66 @@
import { useMemo } from 'react'
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

The useMemo is what was used in the logic I got from the 'TableDefinition.tsx'. But I'll take a look into using the 'table-definition-query.ts'

Copy link
Author

Choose a reason for hiding this comment

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

Removed the use of useMemo. We still need the rest to have a tableResult or a viewResult. Also the useTableDefinitionQuery returns a not so nice formatted (unnecessary spaces, etc.) , uppercase version of the query, so formatDefinition is still used to make it look as nice as it already was in the definition tab.

copyDefinition()
}}
>
<IconCopy size="tiny" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think let's use https://lucide.dev/icons/files instead?

Copy link
Author

Choose a reason for hiding this comment

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

I think that icon is usable. I'll change it.

Copy link
Author

Choose a reason for hiding this comment

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

Changed the icon to IconClipboard.
I've tried the files one from lucide, but it wasn't displaying in the correct color as the other icons. Also, because the function copy's the definition to the clipboard, I thought maybe this one was more suiting. Let me know.

@@ -29,6 29,8 @@ import {
import { useProjectContext } from '../ProjectLayout/ProjectContext'
import { useProjectLintsQuery } from 'data/lint/lint-query'
import { getEntityLintDetails } from 'components/interfaces/TableGridEditor/TableEntity.utils'
import useTableDefinition from '../../../hooks/misc/useTableDefinition'
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

I'll change the import as it is in the given example.
Got mine from somewhere else where it's also done the way I did it, but how it's done in the example is much cleaner.

Copy link
Author

Choose a reason for hiding this comment

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

Cleaned up the hook imports.

@saltcod
Copy link
Contributor

saltcod commented Jul 2, 2024

Thanks @nickterhaar ! Left a couple of comments

@nickterhaar
Copy link
Author

Thanks @nickterhaar ! Left a couple of comments

@saltcod Thanks for the comments. Gonna work on them asap.
Would it also be a welcoming addition to the Database where there is also a dropdown with almost the same option as in the Table Editor? Let me know if you want me to also add this option to that menu.

@nickterhaar nickterhaar force-pushed the feature/Allow-copying-the-table-definition-from-the-dropdown-menu branch from 2603529 to ae217bb Compare July 3, 2024 09:00
@saltcod
Copy link
Contributor

saltcod commented Jul 3, 2024

yeah sure @nickterhaar making the dropdowns consistent would be great.
Feel free to do in a separate PR though — we can get this one in now and avoid any additional conflicts

@nickterhaar
Copy link
Author

yeah sure @nickterhaar making the dropdowns consistent would be great. Feel free to do in a separate PR though — we can get this one in now and avoid any additional conflicts

Alright! I will start working on that soon and will create a new PR for that.

Is there anything else that I can do for this PR? If so, let me know and I will do that first.

@saltcod
Copy link
Contributor

saltcod commented Jul 3, 2024

@nickterhaar any idea what happened with all the file changes? There's 120 file changes in this PR now 😬

@nickterhaar
Copy link
Author

@nickterhaar any idea what happened with all the file changes? There's 120 file changes in this PR now 😬

@saltcod I merged master with my branch and suddenly had 'some' extra files. My mistake.

@saltcod
Copy link
Contributor

saltcod commented Jul 5, 2024

@nickterhaar
With all the conflicts and changes, I think you might be better recreating this branch, cherry picking the good commits?

@nickterhaar
Copy link
Author

@saltcod I've reverted the merge with master commit, changed the icon in EntityListItem.tsx back to lucide 'files'. So the amount of changed files is back to 3 again and all 3 should be and work as intended.

@nickterhaar
Copy link
Author

See #27900 for the same functionality on the Database page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow copying the table definition from the dropdown menu
2 participants