Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Merge branch 'master' into chore/orgs-and-projects-to-react-query

Alaister Young3abe40c890bb
diff --cc studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
index 43d80b3229c,0b41fdfacef..291c5a6179f
--- a/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
+++ b/studio/components/interfaces/Auth/AuthProvidersForm/ProviderForm.tsx
@@@ -160,9 -158,9 +160,9 @@@ const ProviderForm: FC<Props> = ({ prov
disabled
label="Redirect URL"
value={
- customDomainData?.customDomain
+ customDomainData?.customDomain?.status === 'active'
? `https://${customDomainData.customDomain?.hostname}/auth/v1/callback`
- : `https://${ui.selectedProjectRef}.supabase.co/auth/v1/callback`
+ : `https://${selectedProject?.ref}.supabase.co/auth/v1/callback`
}
/>
</>
diff --cc studio/components/interfaces/BillingV2/Subscription/AddOns/ComputeInstanceSidePanel.tsx
index 253b3c0e21e,81f20e7deb6..66502773dcd
--- a/studio/components/interfaces/BillingV2/Subscription/AddOns/ComputeInstanceSidePanel.tsx
+++ b/studio/components/interfaces/BillingV2/Subscription/AddOns/ComputeInstanceSidePanel.tsx
@@@ -13,9 -6,13 +13,10 @@@ import { useProjectAddonUpdateMutation
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import { useProjectSubscriptionV2Query } from 'data/subscriptions/project-subscription-v2-query'
import { checkPermissions, useStore } from 'hooks'
-import { BASE_PATH, PROJECT_STATUS } from 'lib/constants'
-import Link from 'next/link'
-import { useRouter } from 'next/router'
-import { useEffect, useState } from 'react'
+import { BASE_PATH } from 'lib/constants'
import { useSubscriptionPageStateSnapshot } from 'state/subscription-page'
import { Alert, Button, IconExternalLink, Modal, Radio, SidePanel } from 'ui'
+ import Telemetry from 'lib/telemetry'
const COMPUTE_CATEGORY_OPTIONS: {
id: 'micro' | 'optimized'
@@@ -104,9 -110,11 +116,11 @@@ const ComputeInstanceSidePanel = () =>
ui.setNotification({
duration: 8000,
category: 'success',
- message: `Successfully updated compute instance to ${selectedCompute?.name}. Your project is currently being restarted to update its instance`,
+ message: `Successfully updated compute instance to ${
+ selectedCompute?.name || 'Micro'
+ }. Your project is currently being restarted to update its instance`,
})
- app.onProjectStatusUpdated(projectId, PROJECT_STATUS.RESTORING)
+ await invalidateProjectsQuery(queryClient)
onClose()
router.push(`/project/${projectRef}`)
} catch (error: any) {
diff --cc studio/components/interfaces/BillingV2/Subscription/Tier/TierUpdateSidePanel.tsx
index 62f9a2aa6bc,aaec6fc3fec..4e70127394f
--- a/studio/components/interfaces/BillingV2/Subscription/Tier/TierUpdateSidePanel.tsx
+++ b/studio/components/interfaces/BillingV2/Subscription/Tier/TierUpdateSidePanel.tsx
@@@ -10,10 -5,9 +10,12 @@@ import { useFreeProjectLimitCheckQuery
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import { useProjectPlansQuery } from 'data/subscriptions/project-plans-query'
import { useProjectSubscriptionUpdateMutation } from 'data/subscriptions/project-subscription-update-mutation'
-import { checkPermissions, useStore } from 'hooks'
-import Link from 'next/link'
-import { useEffect, useState } from 'react'
+import { useProjectSubscriptionV2Query } from 'data/subscriptions/project-subscription-v2-query'
+import { checkPermissions, useSelectedOrganization, useStore } from 'hooks'
+import { PRICING_TIER_PRODUCT_IDS } from 'lib/constants'
++import Telemetry from 'lib/telemetry'
++import { useRouter } from 'next/router'
+import { plans as subscriptionsPlans } from 'shared-data/plans'
import { useSubscriptionPageStateSnapshot } from 'state/subscription-page'
import { Alert, Button, IconCheck, IconExternalLink, Modal, SidePanel } from 'ui'
import EnterpriseCard from './EnterpriseCard'
@@@ -23,8 -17,15 +25,9 @@@ import PaymentMethodSelection from './P
const TierUpdateSidePanel = () => {
const { ui } = useStore()
+ const router = useRouter()
- const slug = ui.selectedOrganization?.slug
+ const selectedOrganization = useSelectedOrganization()
+ const slug = selectedOrganization?.slug
const { ref: projectRef } = useParams()
const [isSubmitting, setIsSubmitting] = useState(false)
diff --cc studio/components/layouts/StorageLayout/StorageLayout.tsx
index b4a85a4ce73,4993b2c015f..9592b2f9c6b
--- a/studio/components/layouts/StorageLayout/StorageLayout.tsx
+++ b/studio/components/layouts/StorageLayout/StorageLayout.tsx
@@@ -1,12 -1,10 +1,9 @@@
- import { get as _get, filter, find } from 'lodash'
--import { observer } from 'mobx-react-lite'
- import { FC, ReactNode, useEffect } from 'react'
+ import { ReactNode, useEffect } from 'react'
import { useParams } from 'common/hooks'
import DeleteBucketModal from 'components/to-be-cleaned/Storage/DeleteBucketModal'
- import { formatPoliciesForStorage } from 'components/to-be-cleaned/Storage/Storage.utils'
import { AutoApiService, useProjectApiQuery } from 'data/config/project-api-query'
-import { useStore, withAuth } from 'hooks'
+import { useSelectedProject, useStore, withAuth } from 'hooks'
import { PROJECT_STATUS } from 'lib/constants'
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
import ProjectLayout from '../'
@@@ -17,18 -15,13 +14,14 @@@ export interface StorageLayoutProps
children: ReactNode
}
- const StorageLayout: FC<Props> = ({ title, children }) => {
- const { ui, meta } = useStore()
- const project = useSelectedProject()
+ const StorageLayout = ({ title, children }: StorageLayoutProps) => {
+ const { ui } = useStore()
const { ref: projectRef } = useParams()
++ const project = useSelectedProject()
+
const storageExplorerStore = useStorageStore()
- const {
- selectedBucketToEdit,
- closeDeleteBucketModal,
- showDeleteBucketModal,
- deleteBucket,
- buckets,
- } = storageExplorerStore || {}
+ const { selectedBucketToEdit, closeDeleteBucketModal, showDeleteBucketModal } =
+ storageExplorerStore || {}
const { data: settings, isLoading } = useProjectApiQuery({ projectRef })
const apiService = settings?.autoApiService
@@@ -97,4 -64,4 +64,4 @@@
)
}
--export default withAuth(observer(StorageLayout))
++export default withAuth(StorageLayout)
diff --cc studio/lib/auth.tsx
index d6bef4ea744,e8fcc561adf..fba39ed3aac
--- a/studio/lib/auth.tsx
+++ b/studio/lib/auth.tsx
@@@ -14,7 -12,8 +14,7 @@@ import { useProfileQuery } from 'data/p
import { useStore } from 'hooks'
import Telemetry from 'lib/telemetry'
import { GOTRUE_ERRORS, IS_PLATFORM } from './constants'
- import { clearLocalStorage } from './local-storage'
+ import { clearLocalStorage, resetSignInClicks } from './local-storage'
-import { useProfileCreateMutation } from 'data/profile/profile-create-mutation'
export const AuthContext = AuthContextInternal
diff --cc studio/pages/new/[slug].tsx
index 38c5c7dbb8f,4b61f61c060..b391a452a6c
--- a/studio/pages/new/[slug].tsx
+++ b/studio/pages/new/[slug].tsx
@@@ -1,25 -1,13 +1,26 @@@
-import Router, { useRouter } from 'next/router'
-import { useRef, useState, useEffect, PropsWithChildren } from 'react'
-import { debounce, isUndefined, values } from 'lodash'
-import { toJS } from 'mobx'
-import { observer } from 'mobx-react-lite'
-import generator from 'generate-password'
-import { Button, Listbox, IconUsers, Input, Alert, IconHelpCircle, Toggle, IconInfo } from 'ui'
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { NextPageWithLayout } from 'types'
-import { passwordStrength, pluckObjectFields } from 'lib/helpers'
+import generator from 'generate-password'
+import { debounce, isUndefined } from 'lodash'
+import { observer } from 'mobx-react-lite'
+import Router, { useRouter } from 'next/router'
+import { useEffect, useRef, useState } from 'react'
+
+import { useParams } from 'common/hooks'
+import SpendCapModal from 'components/interfaces/Billing/SpendCapModal'
+import {
+ EmptyPaymentMethodWarning,
+ FreeProjectLimitWarning,
+ NotOrganizationOwnerWarning,
+} from 'components/interfaces/Organization/NewProject'
+import { WizardLayoutWithoutAuth } from 'components/layouts'
+import DisabledWarningDueToIncident from 'components/ui/DisabledWarningDueToIncident'
+import InformationBox from 'components/ui/InformationBox'
+import Panel from 'components/ui/Panel'
+import PasswordStrengthBar from 'components/ui/PasswordStrengthBar'
+import { useFreeProjectLimitCheckQuery } from 'data/organizations/free-project-limit-check-query'
+import { useOrganizationsQuery } from 'data/organizations/organizations-query'
++import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
+import { useCheckPermissions, useFlag, useStore, withAuth } from 'hooks'
import { get, post } from 'lib/common/fetch'
import {
API_URL,
@@@ -67,10 -67,15 +68,15 @@@ const Wizard: NextPageWithLayout = () =
const [isSpendCapEnabled, setIsSpendCapEnabled] = useState(true)
- const organizations = values(toJS(app.organizations.list()))
- const currentOrg = organizations.find((o: any) => o.slug === slug)
+ const { data: organizations, isSuccess: isOrganizationsSuccess } = useOrganizationsQuery()
+ const currentOrg = organizations?.find((o: any) => o.slug === slug)
const billedViaOrg = Boolean(currentOrg?.subscription_id)
+ const { data: orgSubscription } = useOrgSubscriptionQuery(
+ { orgSlug: slug },
+ { enabled: billedViaOrg }
+ )
+
const [availableRegions, setAvailableRegions] = useState(
getAvailableRegions(PROVIDERS[cloudProvider].id)
)
diff --cc studio/pages/project/[ref]/storage/buckets/[bucketId].tsx
index 87078dbacab,8eee76102c8..fbdf24b49a5
--- a/studio/pages/project/[ref]/storage/buckets/[bucketId].tsx
+++ b/studio/pages/project/[ref]/storage/buckets/[bucketId].tsx
@@@ -4,23 -4,22 +4,21 @@@ import { useEffect } from 'react
import { useParams } from 'common'
import { StorageLayout } from 'components/layouts'
+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
+ import StorageBucketsError from 'components/layouts/StorageLayout/StorageBucketsError'
import { StorageExplorer } from 'components/to-be-cleaned/Storage'
+ import { useBucketsQuery } from 'data/storage/buckets-query'
-import { useFlag, useStore } from 'hooks'
+import { useFlag } from 'hooks'
import { post } from 'lib/common/fetch'
import { API_URL, PROJECT_STATUS } from 'lib/constants'
- import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
import { NextPageWithLayout } from 'types'
- /**
- * PageLayout is used to setup layout - as usual it will requires inject global store
- */
const PageLayout: NextPageWithLayout = () => {
const { ref, bucketId } = useParams()
-
- const { ui } = useStore()
- const project = ui.selectedProject
+ const { project } = useProjectContext()
- const storageStore = useStorageStore()
- const { buckets, loaded } = storageStore
+ const { data, isSuccess, isError, error } = useBucketsQuery({ projectRef: ref })
+ const buckets = data ?? []
const kpsEnabled = useFlag('initWithKps')
@@@ -28,7 -27,7 +26,7 @@@
if (project && project.status === PROJECT_STATUS.INACTIVE) {
post(`${API_URL}/projects/${ref}/restore`, { kps_enabled: kpsEnabled })
}
-- }, [project])
++ }, [ref, project])
if (!project) return <div></div>
diff --cc studio/pages/project/[ref]/storage/buckets/index.tsx
index 875857294ac,5084b25a7fd..663126a9447
--- a/studio/pages/project/[ref]/storage/buckets/index.tsx
+++ b/studio/pages/project/[ref]/storage/buckets/index.tsx
@@@ -2,26 -3,27 +2,30 @@@ import { useEffect } from 'react
import { useParams } from 'common/hooks'
import { StorageLayout } from 'components/layouts'
+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
+ import StorageBucketsError from 'components/layouts/StorageLayout/StorageBucketsError'
import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
+ import { useBucketsQuery } from 'data/storage/buckets-query'
-import { useFlag, useStore } from 'hooks'
+import { useFlag } from 'hooks'
import { post } from 'lib/common/fetch'
import { API_URL, PROJECT_STATUS } from 'lib/constants'
import { NextPageWithLayout } from 'types'
-const PageLayout: NextPageWithLayout = ({}) => {
+/**
+ * PageLayout is used to setup layout - as usual it will requires inject global store
+ */
+const PageLayout: NextPageWithLayout = () => {
const { ref } = useParams()
- const { ui } = useStore()
- const project = ui.selectedProject
+ const { project } = useProjectContext()
const kpsEnabled = useFlag('initWithKps')
+ const { error, isError } = useBucketsQuery({ projectRef: ref })
+
useEffect(() => {
if (project && project.status === PROJECT_STATUS.INACTIVE) {
post(`${API_URL}/projects/${ref}/restore`, { kps_enabled: kpsEnabled })
}
-- }, [project])
++ }, [ref, project])
if (!project) return <div></div>