Skip to content

Commit

Permalink
chore: release 2.49.0 (#3825)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored Aug 1, 2024
2 parents c8569eb + 1acd18b commit 329e509
Show file tree
Hide file tree
Showing 29 changed files with 1,288 additions and 161 deletions.
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,55 @@

> All notable changes to this project will be documented in this file

## [2.49.0-beta.6](https://github.com/open-sauced/app/compare/v2.49.0-beta.5...v2.49.0-beta.6) (2024-08-01)


### 🐛 Bug Fixes

* updated OSCR login CTA for OSCR pill component ([#3823](https://github.com/open-sauced/app/issues/3823)) ([90d3ccd](https://github.com/open-sauced/app/commit/90d3ccd5e938e59ca81f08aa26934f93692c25ca))

## [2.49.0-beta.5](https://github.com/open-sauced/app/compare/v2.49.0-beta.4...v2.49.0-beta.5) (2024-08-01)


### 🐛 Bug Fixes

* contributors grid view in repo pages ([#3820](https://github.com/open-sauced/app/issues/3820)) ([75c5965](https://github.com/open-sauced/app/commit/75c59657d9e3d006d8697d526d0f7b9e3d5ceb48))

## [2.49.0-beta.4](https://github.com/open-sauced/app/compare/v2.49.0-beta.3...v2.49.0-beta.4) (2024-08-01)


### 🍕 Features

* added OSCR to user profile page ([#3821](https://github.com/open-sauced/app/issues/3821)) ([928c8db](https://github.com/open-sauced/app/commit/928c8dbf98ffc71eebe89d253565acc490b456ce))

## [2.49.0-beta.3](https://github.com/open-sauced/app/compare/v2.49.0-beta.2...v2.49.0-beta.3) (2024-07-31)


### 🍕 Features

* refactor `ContributorsTable` with TanStack Table ([#3626](https://github.com/open-sauced/app/issues/3626)) ([6ae8738](https://github.com/open-sauced/app/commit/6ae873885ece571b947ecb514f00310409c689b6))

## [2.49.0-beta.2](https://github.com/open-sauced/app/compare/v2.49.0-beta.1...v2.49.0-beta.2) (2024-07-31)


### 🍕 Features

* show OSSF Score in Repo Pages ([#3793](https://github.com/open-sauced/app/issues/3793)) ([a18ced7](https://github.com/open-sauced/app/commit/a18ced759007b12363747e23def12e5674923575))

## [2.49.0-beta.1](https://github.com/open-sauced/app/compare/v2.48.1-beta.1...v2.49.0-beta.1) (2024-07-31)


### 🍕 Features

* now OSCR component has a CTA to log in if logged out ([#3814](https://github.com/open-sauced/app/issues/3814)) ([c4d7a50](https://github.com/open-sauced/app/commit/c4d7a506a23fab083a69f7a261a4a9f5ad0ede88))

## [2.48.1-beta.1](https://github.com/open-sauced/app/compare/v2.48.0...v2.48.1-beta.1) (2024-07-31)


### 🐛 Bug Fixes

* Now you can't type more than 255 characters in the bio field of user settings ([#2615](https://github.com/open-sauced/app/issues/2615)) ([2d58445](https://github.com/open-sauced/app/commit/2d58445e5667b6eeb764761eb9d7cdda5bfffa74))

## [2.48.0](https://github.com/open-sauced/app/compare/v2.47.0...v2.48.0) (2024-07-30)


Expand Down
165 changes: 165 additions & 0 deletions components/Contributors/AddToContributorInsightDrawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import { useState } from "react";
import { useRouter } from "next/router";
import { BsGithub } from "react-icons/bs";
import { usePostHog } from "posthog-js/react";
import { safeParse } from "valibot";
import SingleSelect from "components/atoms/Select/single-select";
import Button from "components/shared/Button/button";
import { fetchApiData } from "helpers/fetchApiData";
import useSupabaseAuth from "lib/hooks/useSupabaseAuth";
import { useToast } from "lib/hooks/useToast";
import Text from "components/atoms/Typography/text";
import { useFetchAllLists } from "lib/hooks/useList";
import useWorkspaces from "lib/hooks/api/useWorkspaces";
import { Drawer } from "components/shared/Drawer";
import { UuidSchema } from "lib/validation-schemas";

type AddToContributorInsightDrawerProps = {
repository: string;
contributors: string[];
};

export default function AddToContributorInsightDrawer({
repository,
contributors,
}: AddToContributorInsightDrawerProps) {
const { toast } = useToast();
const router = useRouter();
const posthog = usePostHog();
const { signIn, user, sessionToken } = useSupabaseAuth();
const { data: contributorInsights, isLoading } = useFetchAllLists();
const [workspaceId, setWorkspaceId] = useState("new");
const { data: workspaces, isLoading: workspacesLoading, mutate } = useWorkspaces({ load: !!user, limit: 100 });

const [selectedInsight, setSelectedInsight] = useState("new");

const addToContributorInsight = async () => {
posthog.capture(`Repo Pages: add to contributor insight`, {
repository,
count: contributors.length,
});

const { error } = await fetchApiData({
method: "POST",
path: `lists/${selectedInsight}/contributors`,
body: {
contributors: contributors.map((contributor) => {
return { login: contributor };
}),
},
bearerToken: sessionToken!,
pathValidator: () => safeParse(UuidSchema, selectedInsight).success,
});

if (error) {
toast({ description: `Error adding contributors to the insight. Please try again`, variant: "danger" });
} else {
toast({ description: `Added contributors successfully`, variant: "success" });
}
};

const createContributorInsight = async () => {
posthog.capture(`Repo Pages: create new contributor insight`, {
repository,
count: contributors.length,
});

router.push(
`/workspaces/${workspaceId}/contributor-insights/new?contributors=${encodeURIComponent(
JSON.stringify(contributors)
)}`
);
return;
};

return (
<Drawer
title="Add contributors to insight"
description="Create a new contributor insight or add to an existing one."
showCloseButton
trigger={
<Button variant="primary" className="shrink-0 items-center gap-3 w-fit">
Add to Insight
</Button>
}
>
{!user ? (
<div className="flex flex-col gap-4 text-center">
<img
src="/assets/workspace_overview.png"
alt="Workspace screenshot from documentation"
className="border-2 border-light-orange-9 shadow-md rounded-lg"
/>
<Text>
Keep track of repositories and contributors easily with our new feature
<span className="font-semibold"> Workspaces!</span> If you&apos;ve used OpenSauced before, your insights and
lists are now part of your personal workspace.
</Text>
<p className="font-medium text-light-orange-10">
Create a new contributor insight on a workspace and explore open source like never before!
</p>
<Button
variant="primary"
className="w-fit gap-2 self-center"
onClick={() => {
signIn({
provider: "github",
});
}}
>
<BsGithub className="w-5 h-5" />
Connect with GitHub
</Button>
</div>
) : (
<>
{isLoading ? (
<p>Loading...</p>
) : (
<SingleSelect
options={[
{ label: "Create new insight...", value: "new" },
...contributorInsights.map(({ id, name }) => ({
label: name,
value: id,
})),
]}
value={selectedInsight ?? "new"}
placeholder="Select a workspace"
onValueChange={(value) => {
setSelectedInsight(value);
}}
/>
)}

{selectedInsight === "new" &&
(workspacesLoading ? (
<p>Loading...</p>
) : (
<SingleSelect
options={[
...workspaces.map(({ id, name }) => ({
label: name,
value: id,
})),
]}
value={workspaceId}
placeholder="Select a workspace"
onValueChange={(value) => {
setWorkspaceId(value);
}}
/>
))}

<Button
onClick={selectedInsight === "new" ? createContributorInsight : addToContributorInsight}
variant="primary"
className="w-fit self-end"
>
Confirm
</Button>
</>
)}
</Drawer>
);
}
169 changes: 169 additions & 0 deletions components/Contributors/AddToContributorInsightModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import { useState } from "react";
import { useRouter } from "next/router";
import { BsGithub } from "react-icons/bs";
import { usePostHog } from "posthog-js/react";
import { safeParse } from "valibot";
import Card from "components/atoms/Card/card";
import SingleSelect from "components/atoms/Select/single-select";
import { Dialog, DialogContent } from "components/molecules/Dialog/dialog";
import Button from "components/shared/Button/button";
import { fetchApiData } from "helpers/fetchApiData";
import useSupabaseAuth from "lib/hooks/useSupabaseAuth";
import { useToast } from "lib/hooks/useToast";
import Text from "components/atoms/Typography/text";
import { useFetchAllLists } from "lib/hooks/useList";
import useWorkspaces from "lib/hooks/api/useWorkspaces";
import { UuidSchema } from "lib/validation-schemas";

type AddToContributorInsightModalProps = {
repository: string;
contributors: string[];
isOpen: boolean;
onCloseModal: () => void;
};

export default function AddToContributorInsightModal({
repository,
contributors,
isOpen,
onCloseModal,
}: AddToContributorInsightModalProps) {
const { toast } = useToast();
const router = useRouter();
const posthog = usePostHog();
const { signIn, user, sessionToken } = useSupabaseAuth();
const { data: contributorInsights, isLoading } = useFetchAllLists();
const [workspaceId, setWorkspaceId] = useState("new");
const { data: workspaces, isLoading: workspacesLoading, mutate } = useWorkspaces({ load: !!user, limit: 100 });

const [selectedInsight, setSelectedInsight] = useState("new");

const addToContributorInsight = async () => {
posthog.capture(`Repo Pages: add to contributor insight`, {
repository,
count: contributors.length,
});

const { error } = await fetchApiData({
method: "POST",
path: `lists/${selectedInsight}/contributors`,
body: {
contributors: contributors.map((contributor) => {
return { login: contributor };
}),
},
bearerToken: sessionToken!,
pathValidator: () => safeParse(UuidSchema, selectedInsight).success,
});

if (error) {
toast({ description: `Error adding contributors to the insight. Please try again`, variant: "danger" });
} else {
toast({ description: `Added contributors successfully`, variant: "success" });
onCloseModal();
}
};

const createContributorInsight = async () => {
posthog.capture(`Repo Pages: create new contributor insight`, {
repository,
count: contributors.length,
});

router.push(
`/workspaces/${workspaceId}/contributor-insights/new?contributors=${encodeURIComponent(
JSON.stringify(contributors)
)}`
);
return;
};

return (
<Dialog open={isOpen}>
<DialogContent autoStyle={false} onEscapeKeyDown={onCloseModal} onInteractOutside={onCloseModal}>
<Card heading={<h1 className="text-xl font-semibold">Add to workspace</h1>}>
<div className="flex flex-col gap-4 w-[32rem] h-full px-8 py-4">
{!user ? (
<div className="flex flex-col gap-4 text-center">
<img
src="/assets/workspace_overview.png"
alt="Workspace screenshot from documentation"
className="border-2 border-light-orange-9 shadow-md rounded-lg"
/>
<Text>
Keep track of repositories and contributors easily with our new feature
<span className="font-semibold"> Workspaces!</span> If you&apos;ve used OpenSauced before, your
insights and lists are now part of your personal workspace.
</Text>
<p className="font-medium text-light-orange-10">
Create a new contributor insight on a workspace and explore open source like never before!
</p>
<Button
variant="primary"
className="w-fit gap-2 self-center"
onClick={() => {
signIn({
provider: "github",
});
}}
>
<BsGithub className="w-5 h-5" />
Connect with GitHub
</Button>
</div>
) : (
<>
<p>Create a new contributor insight or add to an existing one.</p>
{isLoading ? (
<p>Loading...</p>
) : (
<SingleSelect
options={[
{ label: "Create new insight...", value: "new" },
...contributorInsights.map(({ id, name }) => ({
label: name,
value: id,
})),
]}
value={selectedInsight ?? "new"}
placeholder="Select a workspace"
onValueChange={(value) => {
setSelectedInsight(value);
}}
/>
)}

{selectedInsight === "new" &&
(workspacesLoading ? (
<p>Loading...</p>
) : (
<SingleSelect
options={[
...workspaces.map(({ id, name }) => ({
label: name,
value: id,
})),
]}
value={workspaceId}
placeholder="Select a workspace"
onValueChange={(value) => {
setWorkspaceId(value);
}}
/>
))}

<Button
onClick={selectedInsight === "new" ? createContributorInsight : addToContributorInsight}
variant="primary"
className="w-fit self-end"
>
Confirm
</Button>
</>
)}
</div>
</Card>
</DialogContent>
</Dialog>
);
}
Loading

0 comments on commit 329e509

Please sign in to comment.