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
1 change: 1 addition & 0 deletions apps/docs/public/humans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Riccardo Busetti
Rodrigo Mansueli
Ronan Lehane
Rory Wilding
Sam Meech-Ward
Sam Rose
Sean Oliver
Sergio Cioban Filho
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { useQueryClient } from '@tanstack/react-query'
import { DollarSign, GitMerge, Github, Loader2 } from 'lucide-react'
import { DatabaseZap, DollarSign, GitMerge, Github, Loader2 } from 'lucide-react'
import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'next/router'
Expand All @@ -21,6 +21,7 @@ import { useBranchCreateMutation } from 'data/branches/branch-create-mutation'
import { useBranchesQuery } from 'data/branches/branches-query'
import { useCheckGithubBranchValidity } from 'data/integrations/github-branch-check-query'
import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query'
import { useCloneBackupsQuery } from 'data/projects/clone-query'
import { projectKeys } from 'data/projects/keys'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
Expand All @@ -45,6 +46,9 @@ import {
Input_Shadcn_,
Label_Shadcn_ as Label,
Switch,
Tooltip,
TooltipContent,
TooltipTrigger,
cn,
} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
Expand Down Expand Up @@ -85,6 +89,11 @@ export const CreateBranchModal = () => {
useCheckGithubBranchValidity({
onError: () => {},
})
const { data: cloneBackups, error: cloneBackupsError } = useCloneBackupsQuery({ projectRef })
const targetVolumeSizeGb = cloneBackups?.target_volume_size_gb ?? 0
const noPhysicalBackups = cloneBackupsError?.message.startsWith(
'Physical backups need to be enabled'
)

const { mutate: sendEvent } = useSendEventMutation()

Expand Down Expand Up @@ -172,6 +181,7 @@ export const CreateBranchModal = () => {
resolver: zodResolver(FormSchema),
defaultValues: { branchName: '', gitBranchName: '', withData: false },
})
const withData = form.watch('withData')

const canSubmit = !isCreating && !isChecking
const isDisabled =
Expand Down Expand Up @@ -344,9 +354,22 @@ export const CreateBranchModal = () => {
layout="flex-row-reverse"
description="Clone production data into this branch"
>
<FormControl_Shadcn_>
<Switch checked={field.value} onCheckedChange={field.onChange} />
</FormControl_Shadcn_>
<Tooltip>
<TooltipTrigger>
<FormControl_Shadcn_>
<Switch
disabled={noPhysicalBackups}
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl_Shadcn_>
</TooltipTrigger>
{noPhysicalBackups && (
<TooltipContent side="bottom">
PITR is required for the project to clone data into the branch
</TooltipContent>
)}
</Tooltip>
</FormItemLayout>
)}
/>
Expand All @@ -362,6 +385,30 @@ export const CreateBranchModal = () => {
promptProPlanUpgrade && 'opacity-25 pointer-events-none'
)}
>
{withData && (
<div className="flex flex-row gap-4">
<div>
<figure className="w-10 h-10 rounded-md bg-info-200 border border-info-400 flex items-center justify-center">
<DatabaseZap className="text-info" size={20} strokeWidth={2} />
</figure>
</div>
<div className="flex flex-col gap-y-1">
<p className="text-sm text-foreground">
Data branch takes longer time to create
</p>
<p className="text-sm text-foreground-light">
Since your target database volume size is{' '}
<code className="text-xs font-mono">{targetVolumeSizeGb} GB</code>, creating a
data branch is estimated to take around{' '}
<code className="text-xs font-mono">
{Math.round((720 / 21000) * targetVolumeSizeGb) + 3} minutes
</code>
.
</p>
</div>
</div>
)}

{githubConnection && (
<div className="flex flex-row gap-4">
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,22 @@ export const UpdateRolesConfirmationModal = ({
.map((id) => {
return [...org_scoped_roles, ...project_scoped_roles].find((r) => r.id === id)
})
.map((x) => {
// [Joshen] This is merely a patch to handle a issue on the BE whereby for a project-scoped member,
// if one of the projects that the member is deleted, the roles isn't cleaned up on the BE
// Hence adding an FE patch here for dashboard to self-remediate by omitting any project IDs from the role
// which no longer exists in the organization projects list
if (!!x?.project_ids) {
return {
...x,
project_ids: x.project_ids.filter((id) => orgProjects.some((p) => id === p.id)),
}
} else {
return x
}
})
.filter(Boolean) as OrganizationRole[]

const isChangeWithinOrgScope =
projectsRoleConfiguration.length === 1 && projectsRoleConfiguration[0].ref === undefined

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export const formatMemberRoleToProjectRoleConfiguration = (
}
})
.filter(Boolean)
.flat() as ProjectRoleConfiguration[]
.flat()
.filter(
(p) => p !== undefined && 'baseRoleId' in p && p.ref !== undefined
) as ProjectRoleConfiguration[]

return roleConfiguration
}
Expand Down
63 changes: 63 additions & 0 deletions apps/studio/components/interfaces/Reports/Reports.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,66 @@ export const DEPRECATED_REPORTS = [
'total_storage_patch_requests',
'total_options_requests',
]

export const EDGE_FUNCTION_REGIONS = [
{
key: 'ap-northeast-1',
label: 'Tokyo',
},
{
key: 'ap-northeast-2',
label: 'Seoul',
},
{
key: 'ap-south-1',
label: 'Mumbai',
},
{
key: 'ap-southeast-1',
label: 'Singapore',
},
{
key: 'ap-southeast-2',
label: 'Sydney',
},
{
key: 'ca-central-1',
label: 'Canada Central',
},
{
key: 'us-east-1',
label: 'N. Virginia',
},
{
key: 'us-west-1',
label: 'N. California',
},
{
key: 'ap-northeast-2',
label: 'Seoul',
},
{
key: 'us-west-2',
label: 'Oregon',
},
{
key: 'eu-central-1',
label: 'Frankfurt',
},
{
key: 'eu-west-1',
label: 'Ireland',
},
{
key: 'eu-west-2',
label: 'London',
},
{
key: 'eu-west-3',
label: 'Paris',
},
{
key: 'sa-east-1',
label: 'São Paulo',
},
]
36 changes: 19 additions & 17 deletions apps/studio/components/interfaces/Reports/v2/ReportChartV2.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import { Loader2 } from 'lucide-react'
import { useState } from 'react'
import { useEffect, useState } from 'react'

import { ComposedChart } from 'components/ui/Charts/ComposedChart'
import type { AnalyticsInterval } from 'data/analytics/constants'
Expand All @@ -10,18 +10,16 @@ import { useCurrentOrgPlan } from 'hooks/misc/useCurrentOrgPlan'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { Card, CardContent, cn } from 'ui'
import { ReportChartUpsell } from './ReportChartUpsell'

export interface ReportChartV2Props {
report: ReportConfig
projectRef: string
startDate: string
endDate: string
interval: AnalyticsInterval
updateDateRange: (from: string, to: string) => void
functionIds?: string[]
edgeFnIdToName?: (id: string) => string | undefined
className?: string
syncId?: string
filters?: any
}

export const ReportChartV2 = ({
Expand All @@ -31,10 +29,9 @@ export const ReportChartV2 = ({
endDate,
interval,
updateDateRange,
functionIds,
edgeFnIdToName,
className,
syncId,
filters,
}: ReportChartV2Props) => {
const { data: org } = useSelectedOrganizationQuery()
const { plan: orgPlan } = useCurrentOrgPlan()
Expand All @@ -49,21 +46,21 @@ export const ReportChartV2 = ({
data: queryResult,
isLoading: isLoadingChart,
error,
isFetching,
} = useQuery(
['projects', projectRef, 'report-v2', report.id, { startDate, endDate, interval, functionIds }],
[
'projects',
projectRef,
'report-v2',
{ reportId: report.id, startDate, endDate, interval, filters },
],
async () => {
return await report.dataProvider(
projectRef,
startDate,
endDate,
interval,
functionIds,
edgeFnIdToName
)
return await report.dataProvider(projectRef, startDate, endDate, interval, filters)
},
{
enabled: Boolean(projectRef && canFetch && isAvailable),
refetchOnWindowFocus: false,
staleTime: 0,
}
)

Expand Down Expand Up @@ -95,12 +92,17 @@ export const ReportChartV2 = ({

return (
<Card id={report.id} className={cn('relative w-full overflow-hidden scroll-mt-16', className)}>
<CardContent className="flex flex-col gap-4 min-h-[280px] items-center justify-center">
<CardContent
className={cn(
'flex flex-col gap-4 min-h-[280px] items-center justify-center',
isFetching && 'opacity-50'
)}
>
{isLoadingChart ? (
<Loader2 className="size-5 animate-spin text-foreground-light" />
) : showEmptyState ? (
<p className="text-sm text-foreground-light text-center h-full flex items-center justify-center">
No data available for the selected time range
No data available for the selected time range and filters
</p>
) : isErrorState ? (
<p className="text-sm text-foreground-light text-center h-full flex items-center justify-center">
Expand Down
Loading
Loading