Skip to content

Commit 18281e4

Browse files
check for repository property on context (#16929)
1 parent 7b7c729 commit 18281e4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

components/dashboard/src/workspaces/CreateWorkspacePage.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,20 @@ export function CreateWorkspacePage() {
6666
);
6767
const workspaceContext = useWorkspaceContext(contextURL);
6868
const isLoading = workspaceContext.isLoading || projects.isLoading;
69+
70+
// see if we have a matching project based on context url and project's repo url
6971
const project = useMemo(() => {
7072
if (!workspaceContext.data || !projects.data) {
7173
return undefined;
7274
}
73-
const cloneUrl = (workspaceContext.data as CommitContext).repository.cloneUrl;
74-
return projects.data.projects.find((p) => p.cloneUrl === cloneUrl);
75+
if ("repository" in workspaceContext.data) {
76+
const cloneUrl = (workspaceContext.data as CommitContext)?.repository?.cloneUrl;
77+
if (!cloneUrl) {
78+
return;
79+
}
80+
81+
return projects.data.projects.find((p) => p.cloneUrl === cloneUrl);
82+
}
7583
}, [projects.data, workspaceContext.data]);
7684

7785
useEffect(() => {

0 commit comments

Comments
 (0)