From 4baf2a2f09cf898c7e7746f2c11b326f3bfdfc51 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Sat, 20 Jan 2024 16:59:34 +0530 Subject: [PATCH] fix: workspace project ids computed (#3417) --- .../account/o-auth/o-auth-options.tsx | 4 ++- web/store/project/project.store.ts | 26 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/web/components/account/o-auth/o-auth-options.tsx b/web/components/account/o-auth/o-auth-options.tsx index 3ad1c2fa1..7c8468acb 100644 --- a/web/components/account/o-auth/o-auth-options.tsx +++ b/web/components/account/o-auth/o-auth-options.tsx @@ -23,6 +23,8 @@ export const OAuthOptions: React.FC = observer((props) => { const { config: { envConfig }, } = useApplication(); + // derived values + const areBothOAuthEnabled = envConfig?.google_client_id && envConfig?.github_client_id; const handleGoogleSignIn = async ({ clientId, credential }: any) => { try { @@ -73,7 +75,7 @@ export const OAuthOptions: React.FC = observer((props) => {

Or continue with


-
+
{envConfig?.google_client_id && (
diff --git a/web/store/project/project.store.ts b/web/store/project/project.store.ts index c59d7af1e..1d51b781c 100644 --- a/web/store/project/project.store.ts +++ b/web/store/project/project.store.ts @@ -92,24 +92,26 @@ export class ProjectStore implements IProjectStore { * Returns searched projects based on search query */ get searchedProjects() { - if (!this.rootStore.app.router.workspaceSlug) return []; - const projectIds = Object.keys(this.projectMap); - return this.searchQuery === "" - ? projectIds - : projectIds?.filter((projectId) => { - this.projectMap[projectId].name.toLowerCase().includes(this.searchQuery.toLowerCase()) || - this.projectMap[projectId].identifier.toLowerCase().includes(this.searchQuery.toLowerCase()); - }); + const workspaceDetails = this.rootStore.workspaceRoot.currentWorkspace; + if (!workspaceDetails) return []; + const workspaceProjects = Object.values(this.projectMap).filter( + (p) => + p.workspace === workspaceDetails.id && + (p.name.toLowerCase().includes(this.searchQuery.toLowerCase()) || + p.identifier.toLowerCase().includes(this.searchQuery.toLowerCase())) + ); + return workspaceProjects.map((p) => p.id); } /** * Returns project IDs belong to the current workspace */ get workspaceProjectIds() { - if (!this.rootStore.app.router.workspaceSlug) return null; - const projectIds = Object.keys(this.projectMap); - if (!projectIds) return null; - return projectIds; + const workspaceDetails = this.rootStore.workspaceRoot.currentWorkspace; + if (!workspaceDetails) return null; + const workspaceProjects = Object.values(this.projectMap).filter((p) => p.workspace === workspaceDetails.id); + const projectIds = workspaceProjects.map((p) => p.id); + return projectIds ?? null; } /**