Skip to content
Draft
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
Expand Up @@ -24,7 +24,7 @@ export const useDropdownItems = ({

const filteredOrgs = useMemo(() => {
return projects.flatMap((project) =>
orgs.filter((org) => org.id === project.organization_id && !project.is_demo),
orgs.filter((org) => org.id === project.organization_id),
)
}, [projects, orgs])

Expand Down
5 changes: 2 additions & 3 deletions web/oss/src/components/pages/WorkspaceRedirect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {useEffect, useMemo} from "react"

import {Spin} from "antd"
import {useRouter} from "next/router"
import {useAtomValue} from "jotai"
import {useRouter} from "next/router"

import useURL from "@/oss/hooks/useURL"
import {projectsAtom} from "@/oss/state/project"
Expand All @@ -20,8 +20,7 @@ const WorkspaceRedirect = () => {
return workspaceMatch || orgMatch
})
if (!belonging.length) return null
const nonDemo = belonging.find((project) => !project.is_demo)
return (nonDemo ?? belonging[0])?.project_id ?? null
return belonging[0]?.project_id ?? null
}, [projects, workspaceId])

const targetPath = useMemo(() => {
Expand Down
11 changes: 2 additions & 9 deletions web/oss/src/state/project/selectors/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,13 @@ const projectMatchesWorkspace = (project: ProjectsResponse, workspaceId: string)
const pickPreferredProject = (projects: ProjectsResponse[], workspaceId: string | null) => {
if (!projects.length) return null

const nonDemo = projects.filter((project) => !project.is_demo)
if (workspaceId) {
const workspaceMatch = projects.find(
(project) => projectMatchesWorkspace(project, workspaceId) && !project.is_demo,
)
if (workspaceMatch) return workspaceMatch

const workspaceAny = projects.find((project) =>
const workspaceMatch = projects.find((project) =>
projectMatchesWorkspace(project, workspaceId),
)
if (workspaceAny) return workspaceAny
if (workspaceMatch) return workspaceMatch
}

if (nonDemo.length) return nonDemo[0]
return projects[0]
}

Expand Down
6 changes: 1 addition & 5 deletions web/oss/src/state/url/postLoginRedirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ const pickPreferredProject = (
? projects.filter((project) => projectMatchesWorkspace(project, workspaceId))
: projects

const nonDemoScoped = scoped.find((project) => !project.is_demo)
if (nonDemoScoped) return nonDemoScoped

if (scoped.length > 0) return scoped[0]

const nonDemoAny = projects.find((project) => !project.is_demo)
return nonDemoAny ?? projects[0]
return projects[0]
}

export interface WorkspaceContext {
Expand Down