SimpleConfigurationDetails.tsx69 lines · main
| 1 | import { Card } from 'ui' |
| 2 | |
| 3 | import { DESCRIPTIONS, LABELS, OPTION_ORDER } from './AnalyticsBucketDetails.constants' |
| 4 | import { CopyEnvButton } from './CopyEnvButton' |
| 5 | import { DecryptedReadOnlyInput } from './DecryptedReadOnlyInput' |
| 6 | import { useAnalyticsBucketWrapperInstance } from './useAnalyticsBucketWrapperInstance' |
| 7 | import { INTEGRATIONS } from '@/components/interfaces/Integrations/Landing/Integrations.constants' |
| 8 | import { WrapperMeta } from '@/components/interfaces/Integrations/Wrappers/Wrappers.types' |
| 9 | import { convertKVStringArrayToJson } from '@/components/interfaces/Integrations/Wrappers/Wrappers.utils' |
| 10 | import { |
| 11 | ScaffoldHeader, |
| 12 | ScaffoldSection, |
| 13 | ScaffoldSectionDescription, |
| 14 | ScaffoldSectionTitle, |
| 15 | } from '@/components/layouts/Scaffold' |
| 16 | import { InlineLink } from '@/components/ui/InlineLink' |
| 17 | import { DOCS_URL } from '@/lib/constants' |
| 18 | |
| 19 | export const SimpleConfigurationDetails = ({ bucketName }: { bucketName?: string }) => { |
| 20 | const integration = INTEGRATIONS.find((i) => i.id === 'iceberg_wrapper' && i.type === 'wrapper') |
| 21 | const wrapperMeta = (integration?.type === 'wrapper' && integration.meta) as WrapperMeta |
| 22 | |
| 23 | /** The wrapper instance is the wrapper that is installed for this Analytics bucket. */ |
| 24 | const { data: wrapperInstance } = useAnalyticsBucketWrapperInstance({ bucketId: bucketName }) |
| 25 | const wrapperValues = convertKVStringArrayToJson(wrapperInstance?.server_options ?? []) |
| 26 | |
| 27 | if (!wrapperInstance) return null |
| 28 | |
| 29 | return ( |
| 30 | <ScaffoldSection isFullWidth> |
| 31 | <ScaffoldHeader className="flex flex-row justify-between items-end gap-x-8 pt-0"> |
| 32 | <div> |
| 33 | <ScaffoldSectionTitle>Connection details</ScaffoldSectionTitle> |
| 34 | <ScaffoldSectionDescription> |
| 35 | Connect to this bucket from an Iceberg client.{' '} |
| 36 | <InlineLink |
| 37 | href={`${DOCS_URL}/guides/storage/analytics/connecting-to-analytics-bucket`} |
| 38 | > |
| 39 | Learn more |
| 40 | </InlineLink> |
| 41 | </ScaffoldSectionDescription> |
| 42 | </div> |
| 43 | <CopyEnvButton |
| 44 | serverOptions={wrapperMeta.server.options.filter( |
| 45 | (option) => !option.hidden && wrapperValues[option.name] |
| 46 | )} |
| 47 | values={wrapperValues} |
| 48 | /> |
| 49 | </ScaffoldHeader> |
| 50 | |
| 51 | <Card> |
| 52 | {wrapperMeta.server.options |
| 53 | .filter((option) => !option.hidden && wrapperValues[option.name]) |
| 54 | .sort((a, b) => OPTION_ORDER.indexOf(a.name) - OPTION_ORDER.indexOf(b.name)) |
| 55 | .map((option) => { |
| 56 | return ( |
| 57 | <DecryptedReadOnlyInput |
| 58 | key={option.name} |
| 59 | label={LABELS[option.name]} |
| 60 | value={wrapperValues[option.name]} |
| 61 | secureEntry={option.secureEntry} |
| 62 | descriptionText={DESCRIPTIONS[option.name]} |
| 63 | /> |
| 64 | ) |
| 65 | })} |
| 66 | </Card> |
| 67 | </ScaffoldSection> |
| 68 | ) |
| 69 | } |