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
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Code, Github, Lock, Play, Server, Terminal } from 'lucide-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useMemo } from 'react'

import { useParams } from 'common'
import { ScaffoldSectionTitle } from 'components/layouts/Scaffold'
import { DocsButton } from 'components/ui/DocsButton'
import { ResourceItem } from 'components/ui/Resource/ResourceItem'
import { ResourceList } from 'components/ui/Resource/ResourceList'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state'
import {
Expand Down Expand Up @@ -39,6 +41,16 @@ export const FunctionsEmptyState = () => {
const { mutate: sendEvent } = useSendEventMutation()
const { data: org } = useSelectedOrganizationQuery()

const showStripeExample = useIsFeatureEnabled('edge_functions:show_stripe_example')
const templates = useMemo(() => {
if (showStripeExample) {
return EDGE_FUNCTION_TEMPLATES
}

// Filter out Stripe template
return EDGE_FUNCTION_TEMPLATES.filter((template) => template.value !== 'stripe-webhook')
}, [showStripeExample])

return (
<>
<Card>
Expand Down Expand Up @@ -157,7 +169,7 @@ export const FunctionsEmptyState = () => {
Start with a template
</ScaffoldSectionTitle>
<ResourceList>
{EDGE_FUNCTION_TEMPLATES.map((template) => (
{templates.map((template) => (
<ResourceItem
key={template.name}
media={<Code strokeWidth={1.5} size={16} className="-translate-y-[9px]" />}
Expand All @@ -181,6 +193,16 @@ export const FunctionsEmptyState = () => {
}

export const FunctionsEmptyStateLocal = () => {
const showStripeExample = useIsFeatureEnabled('edge_functions:show_stripe_example')
const templates = useMemo(() => {
if (showStripeExample) {
return EDGE_FUNCTION_TEMPLATES
}

// Filter out Stripe template
return EDGE_FUNCTION_TEMPLATES.filter((template) => template.value !== 'stripe-webhook')
}, [showStripeExample])

return (
<>
<div className="flex flex-col gap-y-4">
Expand Down Expand Up @@ -295,7 +317,7 @@ curl --request POST 'http://localhost:54321/functions/v1/hello-world' \\

<ScaffoldSectionTitle className="text-xl mt-12">Explore our templates</ScaffoldSectionTitle>
<ResourceList>
{EDGE_FUNCTION_TEMPLATES.map((template) => (
{templates.map((template) => (
<Dialog>
<DialogTrigger asChild>
<ResourceItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ export function getAvailableRegions(cloudProvider: CloudProvider): Region {
switch (cloudProvider) {
case 'AWS':
case 'AWS_K8S':
case 'AWS_NIMBUS':
return AWS_REGIONS
case 'AWS_NIMBUS':
// Only allow US East for Nimbus
return {
EAST_US: AWS_REGIONS.EAST_US,
}
case 'FLY':
return FLY_REGIONS
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ export const RegionSelector = ({
)

const { data: availableRegionsData, isLoading: isLoadingAvailableRegions } =
useOrganizationAvailableRegionsQuery(
{
slug,
cloudProvider,
},
{ enabled: smartRegionEnabled }
)
useOrganizationAvailableRegionsQuery({ slug, cloudProvider }, { enabled: smartRegionEnabled })

const smartRegions = availableRegionsData?.all.smartGroup ?? []
const allRegions = availableRegionsData?.all.specific ?? []
Expand Down
11 changes: 8 additions & 3 deletions apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export const ProjectDropdown = () => {
setOpen={setOpen}
selectedRef={ref}
onSelect={(project) => {
router.push(`/project/${project.ref}`)
const sanitizedRoute = sanitizeRoute(router.route, router.query)
const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
router.push(href)
}}
renderTrigger={() => (
<Button
Expand All @@ -87,11 +89,14 @@ export const ProjectDropdown = () => {
// [Joshen] Temp while we're interim between v1 and v2 billing
const sanitizedRoute = sanitizeRoute(router.route, router.query)
const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
const isSelected = project.ref === ref

return (
<Link href={href} className="w-full flex items-center justify-between">
{project.name}
{project.ref === ref && <Check size={16} />}
<span className={cn('truncate', isSelected ? 'max-w-60' : 'max-w-64')}>
{project.name}
</span>
{isSelected && <Check size={16} />}
</Link>
)
}}
Expand Down
7 changes: 5 additions & 2 deletions apps/studio/pages/new/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import {
} from 'lib/constants'
import passwordStrength from 'lib/password-strength'
import { generateStrongPassword } from 'lib/project'
import type { CloudProvider } from 'shared-data'
import { AWS_REGIONS, type CloudProvider } from 'shared-data'
import type { NextPageWithLayout } from 'types'
import {
Badge,
Expand Down Expand Up @@ -159,6 +159,7 @@ const Wizard: NextPageWithLayout = () => {
const projectCreationDisabled = useFlag('disableProjectCreationAndUpdate')
const showPostgresVersionSelector = useFlag('showPostgresVersionSelector')
const cloudProviderEnabled = useFlag('enableFlyCloudProvider')

const { data: membersExceededLimit } = useFreeProjectLimitCheckQuery(
{ slug },
{ enabled: isFreePlan }
Expand Down Expand Up @@ -258,7 +259,9 @@ const Wizard: NextPageWithLayout = () => {
const regionError = smartRegionEnabled ? availableRegionsError : defaultRegionError
const defaultRegion = smartRegionEnabled
? availableRegionsData?.recommendations.smartGroup.name
: _defaultRegion
: defaultProvider === 'AWS_NIMBUS'
? AWS_REGIONS.EAST_US.displayName
: _defaultRegion

const { can: isAdmin } = useAsyncCheckPermissions(PermissionAction.CREATE, 'projects')

Expand Down
15 changes: 12 additions & 3 deletions apps/studio/pages/project/[ref]/functions/new.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { AlertCircle, Book, Check } from 'lucide-react'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { useEffect, useMemo, useState } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import * as z from 'zod'
Expand All @@ -14,7 +14,7 @@ import { PageLayout } from 'components/layouts/PageLayout/PageLayout'
import FileExplorerAndEditor from 'components/ui/FileExplorerAndEditor/FileExplorerAndEditor'
import { useEdgeFunctionDeployMutation } from 'data/edge-functions/edge-functions-deploy-mutation'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useOrgAiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { BASE_PATH } from 'lib/constants'
Expand Down Expand Up @@ -103,6 +103,7 @@ const NewFunctionPage = () => {
const { data: org } = useSelectedOrganizationQuery()
const snap = useAiAssistantStateSnapshot()
const { mutate: sendEvent } = useSendEventMutation()
const showStripeExample = useIsFeatureEnabled('edge_functions:show_stripe_example')

const [files, setFiles] = useState<
{ id: number; name: string; content: string; selected?: boolean }[]
Expand All @@ -118,6 +119,14 @@ const NewFunctionPage = () => {
const [isPreviewingTemplate, setIsPreviewingTemplate] = useState(false)
const [savedCode, setSavedCode] = useState<string>('')

const templates = useMemo(() => {
if (showStripeExample) {
return EDGE_FUNCTION_TEMPLATES
}
// Filter out Stripe template
return EDGE_FUNCTION_TEMPLATES.filter((template) => template.value !== 'stripe-webhook')
}, [showStripeExample])

const form = useForm<FormValues>({
resolver: zodResolver(FormSchema),
defaultValues: {
Expand Down Expand Up @@ -288,7 +297,7 @@ const NewFunctionPage = () => {
<CommandList_Shadcn_>
<CommandEmpty_Shadcn_>No templates found.</CommandEmpty_Shadcn_>
<CommandGroup_Shadcn_>
{EDGE_FUNCTION_TEMPLATES.map((template) => (
{templates.map((template) => (
<CommandItem_Shadcn_
key={template.value}
value={template.value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const logTypes = [
{
value: LogsTableName.FN_EDGE,
label: 'Function Edge Logs',
description: 'Edge function execution logs with request/response data',
description: 'Edge function execution logs with request and response metadata',
},
{
value: LogsTableName.AUTH,
Expand Down Expand Up @@ -66,7 +66,7 @@ const logTypes = [
{
value: LogsTableName.EDGE,
label: 'Edge Logs',
description: 'HTTP requests and responses from Edge Functions',
description: 'HTTP requests and responses from the data API',
},

{
Expand All @@ -89,11 +89,6 @@ const logTypes = [
label: 'PgBouncer Logs',
description: 'Legacy connection pooling logs',
},
{
value: LogsTableName.WAREHOUSE,
label: 'Warehouse Logs',
description: 'Data warehouse operations and analytics',
},
{
value: LogsTableName.PG_UPGRADE,
label: 'PostgreSQL Upgrade Logs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export enum LogsTableName {
POSTGREST = 'postgrest_logs',
SUPAVISOR = 'supavisor_logs',
PGBOUNCER = 'pgbouncer_logs',
WAREHOUSE = 'warehouse_logs',
PG_UPGRADE = 'pg_upgrade_logs',
}

Expand Down
Loading
Loading