Files
supabase/apps/studio/components/interfaces/Home/Connect/Connect.utils.ts
T
cc008ef983 Feat/homepage connect modal combined (#20328)
* First

* Update

* Move connection string panel to its own component

* Add connection strings

* Format button

* Add dummy files to get logic working

* Add mdx packages

* add file handling and change logic

* Support connections

* Fix icons, add direct and graphql

* Remove mdx stuff

* Add pooler toggle

* Fix child logic

* Fix grandchild logic

* Refactor data object

* Move back to dialog ui

* Refactor to shadcn tabs

* Find the files

* Wire up icons

* Loop over connection types

* Reformat file paths

* Remove from project home

* fix tab rendering issue

* Check for unique keys

* Add new libs

* comment

* Add direct connection ui

* Get project connection strings

* Cleanup

* Add project keys

* Add types file

* Undo update

* Add next app files

* Add files

* Add next pages files

* Add nuxt

* Fix env vars

* Add rest of frameworks, graphql and orms

* Add orms

* Fix types

* Add guide links

* Run prettier

* Separate graphql

* Move ui

* Move direct connection to first position

* Move to single files

* Update styling

* Fix locations

* Fix next content

* Fix dialog close button, add proper light mode theme

* Fix dialog style issues

* CleanupA

* Pin to top

* Feat/homepage connect modal combined  styling update (#21079)

* chore: update styling. also moved useStates as it was sort of duplicated

* Cleanup

---------

Co-authored-by: Terry Sutton <saltcod@gmail.com>

* Close pooler modal

* Make the db connection panel blend in

* Allow for DatabaseSelector

* Dont open by default

* Some fixes

* Set min height to loader

* Fix

* Small styling fixes for table editor sort filter popover

* Make connect button stand out

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-02-15 09:25:17 -03:30

46 lines
1.1 KiB
TypeScript

import { ConnectionType } from './Connect.constants'
export function getProjectRef(url: string): string | null {
const regex: RegExp = /https:\/\/([^\.]+)\./
const match: RegExpMatchArray | null = url.match(regex)
if (match) {
return match[1]
} else {
return null
}
}
export const getContentFilePath = ({
connectionObject,
selectedParent,
selectedChild,
selectedGrandchild,
}: {
selectedParent: string
selectedChild: string
selectedGrandchild: string
connectionObject: ConnectionType[]
}) => {
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 `${selectedParent}/${selectedChild}/${selectedGrandchild}`
} else {
return `${selectedParent}/${selectedChild}`
}
} else {
return selectedParent
}
}
return ''
}