Skip to content

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

Bring changes from master and resolve conflicts

Joshen Lim502926ca0652
diff --cc studio/components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown.tsx
index 3d873b91d80,80152718fc4..02ffc054632
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown.tsx
@@@ -6,7 -6,8 +6,9 @@@ import { Button, Dropdown, IconCode, Ic
import { useProjectsQuery } from 'data/projects/projects-query'
import { useSelectedOrganization, useSelectedProject } from 'hooks'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
+import ShimmeringLoader from 'components/ui/ShimmeringLoader'
+ import { Organization, Project } from 'types'
+ import { useOrganizationsQuery } from 'data/organizations/organizations-query'
// [Fran] the idea is to let users change projects without losing the current page,
// but at the same time we need to redirect correctly between urls that might be
@@@ -31,22 -32,52 +33,56 @@@ export const sanitizeRoute = (route: st
}
}
- interface ProjectDropdownProps {
- alt?: boolean
+ const ProjectLink = ({
+ project,
+ organization,
+ }: {
+ project: Project
+ organization?: Organization
+ }) => {
+ const router = useRouter()
+ const selectedProject = useSelectedProject()
+ const sanitizedRoute = sanitizeRoute(router.route, router.query)
+ const isOrgBilling = !!organization?.subscription_id
+
+ // [Joshen] Temp while we're interim between v1 and v2 billing
+ let href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
+ if (href.endsWith('settings/addons') && !isOrgBilling) {
+ href = href.replace('settings/addons', 'settings/billing/subscription')
+ } else if (href.endsWith('settings/billing/subscription') && isOrgBilling) {
+ href = href.replace('settings/billing/subscription', 'settings/addons')
+ } else if (href.endsWith('settings/infrastructure') && !isOrgBilling) {
+ href = href.replace('settings/infrastructure', 'settings/billing/usage')
+ } else if (href.endsWith('settings/billing/usage') && !isOrgBilling) {
+ href = href.replace('settings/billing/usage', 'settings/infrastructure')
+ }
+
+ return (
+ <Link passHref href={href}>
+ <a className="block">
+ <Dropdown.Item
+ className={
+ selectedProject?.name === project.name ? 'font-bold bg-slate-400 dark:bg-slate-500' : ''
+ }
+ >
+ {project.name}
+ </Dropdown.Item>
+ </a>
+ </Link>
+ )
}
- const ProjectDropdown = ({ alt }: ProjectDropdownProps) => {
- const selectedOrganization = useSelectedOrganization()
-const ProjectDropdown = () => {
++const ProjectDropdown = ({ alt }: { alt?: boolean }) => {
const selectedProject = useSelectedProject()
+ const selectedOrganization = useSelectedOrganization()
- const { data: allProjects } = useProjectsQuery()
+ const { data: allProjects, isLoading: isLoadingProjects } = useProjectsQuery()
+ const { data: allOrganizations } = useOrganizationsQuery()
const selectedOrganizationSlug = selectedOrganization?.slug
- const router = useRouter()
- const sanitizedRoute = sanitizeRoute(router.route, router.query)
+ if (isLoadingProjects && alt) {
+ return <ShimmeringLoader className="w-[90px]" />
+ }
+
return IS_PLATFORM ? (
<Dropdown
side="bottom"