Skip to content

Commit 89c8035

Browse files
ivasilovalaister
andauthored
feat: Analytic storage bucket (supabase#37003)
* Migrate the CreateBucketModal to use RHF. * Minor fixes for the create bucket modal. * Use the bucket type from the API everywhere. * Improve the types on some functions. Add "skip" mode to FDWCreateMutation. * Expand the CreateBucketModal to explain what will happen when creating an iceberg bucket. * Add a page for iceberg buckets. * Add error states to the iceberg explorer. * Fix the names for the FDWs. * Add a dialog for setting up namespace. * Restructure the new files. * Add a download env button. * Add warning to install the wrappers extension when creating an iceberg bucket. * Add failover details when the FDW is not setup. * Fix a lint error. * Fix a type error. * Minor fixes. * Fix the server name. * Add an icon for iceberg buckets. * Fix the import foreign schema dialog. * Make the setup wrapper button functional. * Fix a bad useMemo dependency. * Small changes to the iceberg bucket page. * Minor fix for the edit wrapper sheet. * Rename the files from kebab-case to PascalCase. * Rename the files again to include Analytic instead of Iceberg. * Rename Iceberg type to Analytic. * Add a switch for creating namespace in the import foreign schema dialog. * Fix the CreateBucketModal. * Fix the delete modal feature. * Fix the S3 keys in the FDW. * Only create a namespace if the switch is true. * Regenerate and fix the types. * Fix the FDW create mutation to handle numbers in the FDW names. * Make the icon smaller. * Check whether the namespace exists, if it doesn't create it. * Hide action from the analytic bucket which don't work. * Invalidate namespaces when creating them. * Add small explanation for the creation of namespaces. * Minor fixes. * Tons of changes to make the namespace feature work. * Fix type errors. * Fix bad import. * Minor copy fixes. * Replace the multiple cards with a table of namespaces. * update copy icon * tiny copy update * Fix the empty state for foreign tables. * Hide the analytics bucket option for self-hosted. * Minor copy fixes. * Expand the CTA on no namespaces state. * More minor fixes. * More small fixes. --------- Co-authored-by: Alaister Young <[email protected]>
1 parent 16ee99f commit 89c8035

32 files changed

+1885
-224
lines changed

apps/studio/components/grid/components/grid/Grid.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { formatForeignKeys } from 'components/interfaces/TableGridEditor/SidePan
66
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
77
import AlertError from 'components/ui/AlertError'
88
import { useForeignKeyConstraintsQuery } from 'data/database/foreign-key-constraints-query'
9+
import { ENTITY_TYPE } from 'data/entity-types/entity-type-constants'
910
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
1011
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
1112
import { useTableEditorStateSnapshot } from 'state/table-editor'
1213
import { useTableEditorTableStateSnapshot } from 'state/table-editor-table'
1314
import { Button, cn } from 'ui'
14-
import { GenericSkeletonLoader } from 'ui-patterns'
15+
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
1516
import type { Filter, GridProps, SupaRow } from '../../types'
1617
import { useOnRowsChange } from './Grid.utils'
1718
import RowRenderer from './RowRenderer'
@@ -67,6 +68,7 @@ export const Grid = memo(
6768
}
6869

6970
const table = snap.table
71+
const tableEntityType = snap.originalTable?.entity_type
7072

7173
const { mutate: sendEvent } = useSendEventMutation()
7274
const org = useSelectedOrganization()
@@ -82,13 +84,13 @@ export const Grid = memo(
8284
table?.columns.find((x) => x.name == columnName)?.foreignKey ?? {}
8385

8486
const fk = data?.find(
85-
(key: any) =>
87+
(key) =>
8688
key.source_schema === table?.schema &&
8789
key.source_table === table?.name &&
8890
key.source_columns.includes(columnName) &&
8991
key.target_schema === targetTableSchema &&
9092
key.target_table === targetTableName &&
91-
key.target_columns.includes(targetColumnName)
93+
key.target_columns.includes(targetColumnName ?? '')
9294
)
9395

9496
return fk !== undefined ? formatForeignKeys([fk])[0] : undefined
@@ -141,11 +143,15 @@ export const Grid = memo(
141143
{(filters ?? []).length === 0 ? (
142144
<div className="flex flex-col items-center justify-center col-span-full h-full">
143145
<p className="text-sm text-light">This table is empty</p>
144-
<p className="text-sm text-light mt-1">
145-
Add rows to your table to get started.
146-
</p>
147-
<div className="flex items-center space-x-2 mt-4">
148-
{
146+
{tableEntityType === ENTITY_TYPE.FOREIGN_TABLE ? (
147+
<div className="flex items-center space-x-2 mt-4">
148+
<p className="text-sm text-light">
149+
This table is a foreign table. Add data to the connected source to get
150+
started.
151+
</p>
152+
</div>
153+
) : (
154+
<div className="flex items-center space-x-2 mt-4">
149155
<Button
150156
type="default"
151157
className="pointer-events-auto"
@@ -163,8 +169,8 @@ export const Grid = memo(
163169
>
164170
Import data from CSV
165171
</Button>
166-
}
167-
</div>
172+
</div>
173+
)}
168174
</div>
169175
) : (
170176
<div className="flex flex-col items-center justify-center col-span-full">

apps/studio/components/interfaces/Integrations/Wrappers/EditWrapperSheet.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export const EditWrapperSheet = ({
5858
},
5959
})
6060

61-
const [wrapperTables, setWrapperTables] = useState(formatWrapperTables(wrapper, wrapperMeta))
61+
const [wrapperTables, setWrapperTables] = useState(() =>
62+
formatWrapperTables(wrapper, wrapperMeta)
63+
)
6264
const [isEditingTable, setIsEditingTable] = useState(false)
6365
const [selectedTableToEdit, setSelectedTableToEdit] = useState<FormattedWrapperTable | undefined>(
6466
undefined
@@ -93,7 +95,8 @@ export const EditWrapperSheet = ({
9395

9496
const { wrapper_name } = values
9597
if (wrapper_name.length === 0) errors.name = 'Please provide a name for your wrapper'
96-
if (wrapperTables.length === 0) errors.tables = 'Please add at least one table'
98+
if (!wrapperMeta.canTargetSchema && wrapperTables.length === 0)
99+
errors.tables = 'Please add at least one table'
97100
if (!isEmpty(errors)) return setFormErrors(errors)
98101

99102
updateFDW({

apps/studio/components/interfaces/Integrations/Wrappers/Wrappers.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const formatWrapperTables = (
109109
})
110110
}
111111

112-
export const convertKVStringArrayToJson = (values: string[]) => {
112+
export const convertKVStringArrayToJson = (values: string[]): Record<string, string> => {
113113
return Object.fromEntries(values.map((value) => value.split('=')))
114114
}
115115

0 commit comments

Comments
 (0)