Remove alt prop from ProjectDropdown as no longer necessary

This commit is contained in:
Joshen Lim committed 2023-07-31 10:57:52 +08:00
1 parent 4924b41781
commit a3c505b60b
1 file changed
+7 -24
@@ -1,15 +1,14 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
import { ParsedUrlQuery } from 'querystring'
import { Badge, Button, Dropdown, IconCode, IconPlus, Popover } from 'ui'
import { Button, Dropdown, IconPlus, Popover } from 'ui'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
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'
import { useProjectSubscriptionV2Query } from 'data/subscriptions/project-subscription-v2-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
@@ -73,20 +72,14 @@ const ProjectLink = ({
)
}
const ProjectDropdown = ({ alt }: { alt?: boolean }) => {
const ProjectDropdown = () => {
const selectedProject = useSelectedProject()
const selectedOrganization = useSelectedOrganization()
const { data: allProjects, isLoading: isLoadingProjects } = useProjectsQuery()
const { data: allOrganizations } = useOrganizationsQuery()
const selectedOrganizationSlug = selectedOrganization?.slug
const isOrgBilling = !!selectedOrganization?.subscription_id
const { data: subscription, isSuccess } = useProjectSubscriptionV2Query(
{ projectRef: selectedProject?.ref },
{ enabled: alt && !isOrgBilling }
)
if (isLoadingProjects && alt) {
if (isLoadingProjects) {
return <ShimmeringLoader className="w-[90px]" />
}
@@ -112,23 +105,13 @@ const ProjectDropdown = ({ alt }: { alt?: boolean }) => {
</>
}
>
<Button
type="text"
iconRight={
alt ? <IconCode className="text-scale-1100 rotate-90" strokeWidth={2} size={12} /> : null
}
>
<Button type="text">
<span className="text-sm">{selectedProject?.name}</span>
{alt && isSuccess && !isOrgBilling && (
<Badge color="slate" className="ml-2">
{subscription?.plan.name}
</Badge>
)}
</Button>
</Dropdown>
) : (
<Button type="text">
<span className="text-sm">{selectedProject?.name}</span>
<span className="text-xs">{selectedProject?.name}</span>
</Button>
)
}