Skip to content

Commit

Permalink
fix: disable search for workspace dropdown if not logged in (#3414)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Taylor <nick@nickyt.co>
  • Loading branch information
zeucapua and nickytonline committed May 17, 2024
1 parent ec2a53f commit b242e92
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/shared/AppSidebar/AppSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface AppSideBarProps {
}

export const AppSideBar = ({ workspaceId, hideSidebar, sidebarCollapsed }: AppSideBarProps) => {
const { user } = useSupabaseAuth();
const { user, signIn } = useSupabaseAuth();
const { data: rawRepoInsights, isLoading: repoInsightsLoading } = useWorkspacesRepositoryInsights({ workspaceId });
const { data: rawContributorInsights, isLoading: contributorInsightsLoading } = useWorkspacesContributorInsights({
workspaceId,
Expand Down Expand Up @@ -107,7 +107,7 @@ export const AppSideBar = ({ workspaceId, hideSidebar, sidebarCollapsed }: AppSi
<label className="workspace-drop-down flex flex-col w-full gap-2 ml-2">
<span className="sr-only">Workspace</span>
<SingleSelect
isSearchable
isSearchable={!!user}
options={[
{ label: "Create new workspace...", value: "new" },
...workspaces.map(({ id, name }) => ({
Expand All @@ -120,6 +120,15 @@ export const AppSideBar = ({ workspaceId, hideSidebar, sidebarCollapsed }: AppSi
placeholder="Select a workspace"
onValueChange={(value) => {
if (value === "new") {
if (!user) {
signIn({
provider: "github",
options: {
redirectTo: `${new URL("/workspaces/new", window.location.href)}`,
},
});
return;
}
router.push("/workspaces/new");
return;
}
Expand Down

0 comments on commit b242e92

Please sign in to comment.