From ea525701c5d36ce7e0fc85e793b081d7b2670bf4 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Mon, 5 Feb 2024 15:59:14 -0330 Subject: [PATCH] CleanupA --- .prettierrc | 3 +- .../Home/Connect/Connect.constants.ts | 10 ---- .../interfaces/Home/Connect/Connect.tsx | 60 ------------------- .../Home/Connect/ConnectDropdown.tsx | 2 - .../Home/Connect/ConnectFilesContent.tsx | 10 ---- .../Home/Connect/ConnectTabContent.tsx | 9 +-- .../interfaces/Home/Connect/ConnectTabs.tsx | 14 +++-- .../Home/Connect/content/graphql/content.tsx | 29 --------- 8 files changed, 13 insertions(+), 124 deletions(-) delete mode 100644 apps/studio/components/interfaces/Home/Connect/ConnectFilesContent.tsx delete mode 100644 apps/studio/components/interfaces/Home/Connect/content/graphql/content.tsx diff --git a/.prettierrc b/.prettierrc index 945dc3169e8..c60d3ab91ef 100644 --- a/.prettierrc +++ b/.prettierrc @@ -6,5 +6,6 @@ "printWidth": 100, "endOfLine": "lf", "sqlKeywordCase": "lower", - "pluginSearchDirs": false + "pluginSearchDirs": false, + "plugins": ["prettier-plugin-sql-cst"] } diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts b/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts index d6e5ac48c3d..369e8eaf4f8 100644 --- a/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts +++ b/apps/studio/components/interfaces/Home/Connect/Connect.constants.ts @@ -152,16 +152,6 @@ export const ORMS: ConnectionType[] = [ }, ] -// export const GRAPHQL: ConnectionType[] = [ -// { -// key: 'graphql', -// label: 'GraphQL', -// icon: 'graphql', -// guideLink: 'https://supabase.com/docs/guides/graphql', -// children: [], -// }, -// ] - export const CONNECTION_TYPES = [ { key: 'frameworks', label: 'App Frameworks', obj: FRAMEWORKS }, { key: 'orms', label: 'ORMs', obj: ORMS }, diff --git a/apps/studio/components/interfaces/Home/Connect/Connect.tsx b/apps/studio/components/interfaces/Home/Connect/Connect.tsx index e2a1ea852f4..d3ce767ea1b 100644 --- a/apps/studio/components/interfaces/Home/Connect/Connect.tsx +++ b/apps/studio/components/interfaces/Home/Connect/Connect.tsx @@ -39,33 +39,6 @@ type GetContentFilesArgs = { selectedGrandchild: string connectionObject: ConnectionType[] } -// const getContentFiles = ({ -// connectionObject, -// selectedParent, -// selectedChild, -// selectedGrandchild, -// }: GetContentFilesArgs) => { -// const parent = connectionObject.find((item) => item.key === selectedParent) - -// if (parent) { -// const child = parent.children.find((child) => child.key === selectedChild) - -// // check grandchild first, then child, then parent as the fallback -// if (child) { -// const grandchild = child.children.find((grandchild) => grandchild.key === selectedGrandchild) - -// if (grandchild) { -// return grandchild.files || [] -// } else { -// return child.files || [] -// } -// } else { -// return parent.files || [] -// } -// } - -// return [] -// } const getContentFilePath = ({ connectionObject, @@ -111,24 +84,6 @@ const Connect = () => { )?.children[0]?.key || '' ) - // const [contentFiles, setContentFiles] = useState( - // connectionObject - // .find((item) => item.key === selectedParent) - // ?.children.find((child) => child.key === selectedChild) - // ?.children.find((grandchild) => grandchild.key === selectedGrandchild)?.files || [] - // ) - console.log(selectedParent, selectedChild, selectedGrandchild) - // set the content files when the parent/child/grandchild changes - // useEffect(() => { - // const files = getContentFiles({ - // connectionObject, - // selectedParent, - // selectedChild, - // selectedGrandchild, - // }) - // //setContentFiles(files) - // }, [selectedParent, selectedChild, selectedGrandchild, connectionObject]) - const handleParentChange = (value: string) => { setSelectedParent(value) @@ -186,11 +141,6 @@ const Connect = () => { setConnectionObject(ORMS) handleConnectionTypeChange(ORMS) } - - // if (type === 'graphql') { - // setConnectionObject(GRAPHQL) - // handleConnectionTypeChange(GRAPHQL) - // } } const getChildOptions = () => { @@ -285,7 +235,6 @@ const Connect = () => {
{/* all parents */} { (connectionObject.find((parent) => parent.key === selectedParent) ?.children.length || 0) > 0 && ( { ?.children.find((child) => child.key === selectedChild)?.children .length || 0) > 0 && ( { - // Crappy hack to get the tabs to re-render when the defaultValue changes - // I can't figure out why it doesn't re-render with the correct tab selected - jordi - // const [syncedDefaultValue, setSyncedDefaultValue] = useState(defaultValue) - // const filePath = useEffect(() => { - // setSyncedDefaultValue(defaultValue) - // }, [defaultValue]) - return (
diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectDropdown.tsx b/apps/studio/components/interfaces/Home/Connect/ConnectDropdown.tsx index e34e5372c17..5f42c934f47 100644 --- a/apps/studio/components/interfaces/Home/Connect/ConnectDropdown.tsx +++ b/apps/studio/components/interfaces/Home/Connect/ConnectDropdown.tsx @@ -13,7 +13,6 @@ import { } from 'ui' interface ConnectDropdownProps { - level?: 'parent' | 'child' | 'grandchild' open: boolean setOpen: (open: boolean) => void state: string @@ -23,7 +22,6 @@ interface ConnectDropdownProps { } const ConnectDropdown = ({ - level, state, updateState, label, diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectFilesContent.tsx b/apps/studio/components/interfaces/Home/Connect/ConnectFilesContent.tsx deleted file mode 100644 index 1c42b2619e0..00000000000 --- a/apps/studio/components/interfaces/Home/Connect/ConnectFilesContent.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { FileJson2 } from 'lucide-react' -import { TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui' - -interface ConnectTabContentProps { - children: any - value: string -} -export const ConnectTabContent = ({ value, children }: ConnectTabContentProps) => { - return {children} -} diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx b/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx index 91ce110e5ba..81b9f6be687 100644 --- a/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx +++ b/apps/studio/components/interfaces/Home/Connect/ConnectTabContent.tsx @@ -9,14 +9,7 @@ interface ConnectContentTabProps { const ConnectTabContentNew = ({ projectKeys, filePath }: ConnectContentTabProps) => { const ContentFile = dynamic(() => import(`./content/${filePath}/content`)) - return ( - - - //
- // - // - //
- ) + return } export default ConnectTabContentNew diff --git a/apps/studio/components/interfaces/Home/Connect/ConnectTabs.tsx b/apps/studio/components/interfaces/Home/Connect/ConnectTabs.tsx index cf54bd8c647..e8184b51220 100644 --- a/apps/studio/components/interfaces/Home/Connect/ConnectTabs.tsx +++ b/apps/studio/components/interfaces/Home/Connect/ConnectTabs.tsx @@ -2,24 +2,30 @@ import { Tabs_Shadcn_ } from 'ui' import { FileJson2 } from 'lucide-react' import { TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui' import { TabsContent_Shadcn_ } from 'ui' +import React, { ReactNode } from 'react' interface ConnectTabTriggerProps { value: string } interface ConnectTabTriggersProps { - children: any + children: ReactNode[] } interface ConnectFileTabProps { - children: any + children: ReactNode[] } interface ConnectTabContentProps { - children: any + children: ReactNode value: string } const ConnectTabs = ({ children }: ConnectFileTabProps) => { - const defaultValue = children[0].props.children[0].props.value + const firstChild = children[0] + + const defaultValue = React.isValidElement(firstChild) + ? (firstChild.props as any)?.children[0]?.props?.value || '' + : null + return {children} } diff --git a/apps/studio/components/interfaces/Home/Connect/content/graphql/content.tsx b/apps/studio/components/interfaces/Home/Connect/content/graphql/content.tsx deleted file mode 100644 index 177bad20744..00000000000 --- a/apps/studio/components/interfaces/Home/Connect/content/graphql/content.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types' -import { ConnectTabContent } from 'components/interfaces/Home/Connect/ConnectFilesContent' -import { - ConnectTabs, - ConnectTabTrigger, - ConnectTabTriggers, -} from 'components/interfaces/Home/Connect/ConnectTabs' -import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock' - -const ContentFile = ({ projectKeys }: ContentFileProps) => { - return ( - - - - - - - - {` -SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'} -SUPABASE_KEY=${projectKeys.anonKey ?? 'your-anon-key'} - `} - - - - ) -} - -export default ContentFile