Files
supabase/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts
Jordi Enric 03665dfdcd Log Drains UI (#28044)
* add main log drain form and navigation

* fix submit and select

* add mutation and update form

* fix submit issue

* fix issues with validation

* fix typeerrs

* add log drain table

* update create log drain mutation

* add delete log drain mutation

* update get log drains query

* fix new log drain click in cards

* add delete mutation

* add delete log drain

* refactor gzip switch

* refactor radiogroup to use formfield

* add headers form

* fix validation, custom headers errors

* refactor to support update in form

* format

* add log drains to nav

* update api spec and list logdrains query

* wire backend

* fix datadog region values

* make api input password

* fix url elastic

* fix typerr

* rm unnecessary value setter

* fix state issue log drains update form

* Add default values setting in useEffect to fix form issues

* format

* Update LogDrains table header width to 250px

* add upgrade plan card when free plan

* fix dumb if statement

* fix the freaking headers

* fix upgrade to team state

* fix plan check and loading state

* disable type update

* Add link to documentation in Log Drains settings

* show add destination only after empty state

* fix bug with inputs not resetting

* add gzip tooltip

* rm command

* defaultValue to value

* add defaultValue

* rm consolelog

* rm anys
2024-08-01 22:03:10 +02:00

159 lines
4.1 KiB
TypeScript

import type { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'
import type { Project } from 'data/projects/project-detail-query'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import type { Organization } from 'types'
export const generateSettingsMenu = (
ref?: string,
project?: Project,
organization?: Organization,
features?: {
auth?: boolean
edgeFunctions?: boolean
storage?: boolean
invoices?: boolean
warehouse?: boolean
logDrains?: boolean
}
): ProductMenuGroup[] => {
const isProjectBuilding = project?.status === PROJECT_STATUS.COMING_UP
const buildingUrl = `/project/${ref}`
const authEnabled = features?.auth ?? true
const edgeFunctionsEnabled = features?.edgeFunctions ?? true
const storageEnabled = features?.storage ?? true
const warehouseEnabled = features?.warehouse ?? false
const logDrainsEnabled = features?.logDrains ?? false
return [
{
title: 'Project Settings',
items: [
{
name: 'General',
key: 'general',
url: `/project/${ref}/settings/general`,
items: [],
},
{
name: 'Infrastructure',
key: 'infrastructure',
url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/infrastructure`,
items: [],
},
...(IS_PLATFORM
? [
{
name: 'Integrations',
key: 'integrations',
url: `/project/${ref}/settings/integrations`,
items: [],
},
]
: []),
...[
{
name: 'Add Ons',
key: 'addons',
url: `/project/${ref}/settings/addons`,
items: [],
},
],
{
name: 'Vault',
key: 'vault',
url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/vault/secrets`,
items: [],
label: 'BETA',
},
],
},
{
title: 'Configuration',
items: [
{
name: 'Database',
key: 'database',
url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/database`,
items: [],
},
{
name: 'API',
key: 'api',
url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/api`,
items: [],
},
...(IS_PLATFORM && authEnabled
? [
{
name: 'Authentication',
key: 'auth',
url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/auth`,
items: [],
},
]
: []),
...(IS_PLATFORM && storageEnabled
? [
{
name: 'Storage',
key: 'storage',
url: `/project/${ref}/settings/storage`,
items: [],
},
]
: []),
...(IS_PLATFORM && edgeFunctionsEnabled
? [
{
name: 'Edge Functions',
key: 'functions',
url: `/project/${ref}/settings/functions`,
items: [],
},
]
: []),
...(IS_PLATFORM && warehouseEnabled
? [
{
name: 'Warehouse',
key: 'warehouse',
url: `/project/${ref}/settings/warehouse`,
items: [],
},
]
: []),
...(IS_PLATFORM && logDrainsEnabled
? [
{
name: `Log Drains`,
key: `log-drains`,
url: `/project/${ref}/settings/log-drains`,
items: [],
},
]
: []),
],
},
{
title: 'Billing',
items: [
{
name: 'Subscription',
key: 'subscription',
url: `/org/${organization?.slug}/billing`,
items: [],
},
{
name: 'Usage',
key: 'usage',
url: `/org/${organization?.slug}/usage?projectRef=${ref}`,
items: [],
},
],
},
]
}