Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/studio/components/interfaces/APIKeys/ApiKeyPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function ApiKeyPill({

async function onCopy() {
// If key is already revealed, use that value
if (data?.api_key) return data?.api_key
if (data?.api_key) return data?.api_key ?? ''

try {
// Fetch full key and immediately clear from cache after copying
Expand All @@ -89,13 +89,15 @@ export function ApiKeyPill({
exact: true,
})

if (result.isSuccess) return result.data.api_key
if (result.isSuccess) return result.data.api_key ?? ''

if (error) {
toast.error('Failed to copy secret API key')
return ''
}
} catch (error) {
console.error('Failed to fetch API key:', error)
return ''
}

// Fallback to the masked version if fetch fails
Expand Down
58 changes: 58 additions & 0 deletions apps/studio/components/interfaces/Reports/ReportChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* ReportChart
*
* A wrapper component that uses the useChartData hook to fetch data for a chart
* and then passes the data and loading state to the ComposedChartHandler.
*
* This component acts as a bridge between the data-fetching logic and the
* presentational chart component.
*/
import ComposedChartHandler from 'components/ui/Charts/ComposedChartHandler'
import { useChartData } from 'hooks/useChartData'
import type { UpdateDateRange } from 'pages/project/[ref]/reports/database'
import type { MultiAttribute } from 'components/ui/Charts/ComposedChart.utils'

const ReportChart = ({
chart,
startDate,
endDate,
interval,
updateDateRange,
}: {
chart: any
startDate: string
endDate: string
interval: string
updateDateRange: UpdateDateRange
}) => {
const {
data,
isLoading: isLoading,
chartAttributes,
highlightedValue,
} = useChartData({
attributes: chart.attributes,
startDate,
endDate,
interval,
data: undefined,
highlightedValue:
chart.id === 'client-connections' || chart.id === 'pgbouncer-connections'
? true
: chart.showMaxValue,
})

return (
<ComposedChartHandler
{...chart}
attributes={
(chartAttributes.length > 0 ? chartAttributes : chart.attributes) as MultiAttribute[]
}
data={data}
isLoading={isLoading}
highlightedValue={highlightedValue as any}
updateDateRange={updateDateRange}
/>
)
}
export default ReportChart
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const ProjectUpgradeAlert = () => {
[right-sized](https://supabase.com/docs/guides/platform/upgrading#disk-sizing) with the upgrade.`}
/>
)}
{/* @ts-ignore */}
{(data?.potential_breaking_changes ?? []).length > 0 && (
<Alert_Shadcn_ variant="destructive" title="Breaking changes">
<AlertCircle className="h-4 w-4" strokeWidth={2} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ import {
AlertTitle_Shadcn_,
Alert_Shadcn_,
Badge,
Button,
Input,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'ui'
import { ProjectUpgradeAlert } from '../General/Infrastructure/ProjectUpgradeAlert'
import InstanceConfiguration from './InfrastructureConfiguration/InstanceConfiguration'
import {
DatabaseExtensionsWarning,
ObjectsToBeDroppedWarning,
ReadReplicasWarning,
UnsupportedExtensionsWarning,
UserDefinedObjectsInInternalSchemasWarning,
} from './UpgradeWarnings'

const InfrastructureInfo = () => {
const { ref } = useParams()
Expand Down Expand Up @@ -73,6 +79,12 @@ const InfrastructureInfo = () => {
const isInactive = project?.status === 'INACTIVE'
const hasReadReplicas = (databases ?? []).length > 1

// @ts-ignore [Bobbie] to be removed after 2025-06-30 prod deploy
const hasExtensionDependentObjects = (data?.extension_dependent_objects ?? []).length > 0
const hasObjectsToBeDropped = (data?.objects_to_be_dropped ?? []).length > 0
const hasUnsupportedExtensions = (data?.unsupported_extensions || []).length > 0
const hasObjectsInternalSchema = (data?.user_defined_objects_in_internal_schemas || []).length > 0

return (
<>
<ScaffoldDivider />
Expand Down Expand Up @@ -181,149 +193,38 @@ const InfrastructureInfo = () => {
</>
)}

{data?.eligible && !hasReadReplicas && <ProjectUpgradeAlert />}
{data.eligible && hasReadReplicas && (
<Alert_Shadcn_>
<AlertTitle_Shadcn_>
A new version of Postgres is available for your project
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
You will need to remove all read replicas prior to upgrading your Postgres
version to the latest available ({latestPgVersion}).
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
{/* TODO(bobbie): once extension_dependent_objects is removed on the backend, remove this block and the ts-ignores below */}
{!data?.eligible && (data?.extension_dependent_objects || []).length > 0 && (
<Alert_Shadcn_
variant="warning"
title="A new version of Postgres is available for your project"
>
<AlertTitle_Shadcn_>
A new version of Postgres is available
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_ className="flex flex-col gap-3">
<div>
<p className="mb-1">
You'll need to remove the following extensions before upgrading:
</p>

<ul className="pl-4">
{(data?.extension_dependent_objects || []).map((obj) => (
<li className="list-disc" key={obj}>
{obj}
</li>
))}
</ul>
</div>
<p>
{projectUpgradeEligibilityData?.potential_breaking_changes?.includes(
'pg17_upgrade_unsupported_extensions'
)
? 'These extensions are not supported in newer versions of Supabase Postgres. If you are not using them, it is safe to remove them.'
: 'Check the docs for which ones might need to be removed.'}
</p>
<div>
<Button size="tiny" type="default" asChild>
<a
href="https://supabase.com/docs/guides/platform/upgrading#extensions"
target="_blank"
rel="noreferrer"
>
View docs
</a>
</Button>
</div>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
{!data?.eligible &&
// @ts-ignore
(data?.objects_to_be_dropped || []).length > 0 && (
<Alert_Shadcn_
variant="warning"
title="A new version of Postgres is available for your project"
>
<AlertTitle_Shadcn_>
A new version of Postgres is available
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_ className="flex flex-col gap-3">
<div>
<p className="mb-1">
You'll need to remove the following objects before upgrading:
</p>

<ul className="pl-4">
{
// @ts-ignore
(data?.objects_to_be_dropped || []).map((obj: string) => (
<li className="list-disc" key={obj}>
{obj}
</li>
))
}
</ul>
</div>
<p>Check the docs for which objects need to be removed.</p>
<div>
<Button size="tiny" type="default" asChild>
<a
href="https://supabase.com/docs/guides/platform/upgrading#extensions"
target="_blank"
rel="noreferrer"
>
View docs
</a>
</Button>
</div>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
{!data?.eligible &&
// @ts-ignore
(data?.unsupported_extensions || []).length > 0 && (
<Alert_Shadcn_
variant="warning"
title="A new version of Postgres is available for your project"
>
<AlertTitle_Shadcn_>
A new version of Postgres is available
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_ className="flex flex-col gap-3">
<div>
<p className="mb-1">
You'll need to remove the following extensions before upgrading:
</p>
{data.eligible ? (
hasReadReplicas ? (
<ReadReplicasWarning latestPgVersion={latestPgVersion} />
) : (
<ProjectUpgradeAlert />
)
) : null}

<ul className="pl-4">
{
// @ts-ignore
(data?.unsupported_extensions || []).map((obj: string) => (
<li className="list-disc" key={obj}>
{obj}
</li>
))
}
</ul>
</div>
<p>
These extensions are not supported in newer versions of Supabase
Postgres. If you are not using them, it is safe to remove them.
</p>
<div>
<Button size="tiny" type="default" asChild>
<a
href="https://supabase.com/docs/guides/platform/upgrading#extensions"
target="_blank"
rel="noreferrer"
>
View docs
</a>
</Button>
</div>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
{!data.eligible ? (
hasExtensionDependentObjects ? (
<DatabaseExtensionsWarning
// @ts-ignore
extensions={data.extension_dependent_objects ?? []}
potentialBreakingChanges={
// @ts-ignore
projectUpgradeEligibilityData?.potential_breaking_changes
}
/>
) : hasObjectsToBeDropped ? (
<ObjectsToBeDroppedWarning
objectsToBeDropped={data.objects_to_be_dropped}
/>
) : hasUnsupportedExtensions ? (
<UnsupportedExtensionsWarning
unsupportedExtensions={data.unsupported_extensions}
/>
) : hasObjectsInternalSchema ? (
<UserDefinedObjectsInInternalSchemasWarning
objects={data.user_defined_objects_in_internal_schemas}
/>
) : null
) : null}
</>
)}
</>
Expand Down
Loading
Loading