Skip to content

Commit

Permalink
chore: release 2.41.0 (#3672)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored Jul 3, 2024
2 parents dce7b4f + 20c30ff commit eb0d2b1
Show file tree
Hide file tree
Showing 22 changed files with 321 additions and 236 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@

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

## [2.41.0-beta.1](https://github.com/open-sauced/app/compare/v2.40.1-beta.4...v2.41.0-beta.1) (2024-07-02)


### 🍕 Features

* add range filter when importing GitHub repos for an org ([#3665](https://github.com/open-sauced/app/issues/3665)) ([89abf59](https://github.com/open-sauced/app/commit/89abf59f6770507ce7c659016ca88240e907f2da))

## [2.40.1-beta.4](https://github.com/open-sauced/app/compare/v2.40.1-beta.3...v2.40.1-beta.4) (2024-07-02)


### 🐛 Bug Fixes

* now workspace pages on smaller screens keep their layout in bounds ([#3664](https://github.com/open-sauced/app/issues/3664)) ([8b2a879](https://github.com/open-sauced/app/commit/8b2a8795f2d10a30cc187431cce2e199c4802d9b))

## [2.40.1-beta.3](https://github.com/open-sauced/app/compare/v2.40.1-beta.2...v2.40.1-beta.3) (2024-07-02)


### 🐛 Bug Fixes

* now OSCR that is 0 gets rendered as a dash ([#3662](https://github.com/open-sauced/app/issues/3662)) ([5e12564](https://github.com/open-sauced/app/commit/5e1256491964dc6e443b0f6db5bef59a9b9c57e9))
* remove dots from `IssueChart` & `PRChart` ([#3659](https://github.com/open-sauced/app/issues/3659)) ([deb24a0](https://github.com/open-sauced/app/commit/deb24a0be3b040883e4f03c31db50e48a90dbde1))

## [2.40.1-beta.2](https://github.com/open-sauced/app/compare/v2.40.1-beta.1...v2.40.1-beta.2) (2024-07-01)


### 🐛 Bug Fixes

* workspace insight header paddings ([#3623](https://github.com/open-sauced/app/issues/3623)) ([10438b4](https://github.com/open-sauced/app/commit/10438b4935a2020bd2e1171c2e63c048e0be81cd))

## [2.40.1-beta.1](https://github.com/open-sauced/app/compare/v2.40.0...v2.40.1-beta.1) (2024-06-29)


### 🐛 Bug Fixes

* reset input after deleting contributor insight list ([#3600](https://github.com/open-sauced/app/issues/3600)) ([2a2ac76](https://github.com/open-sauced/app/commit/2a2ac7653bfe61914a950edb0cbe7d419d1ee2df))
* reset input after deleting contributor insight list([#3553](https://github.com/open-sauced/app/issues/3553)) ([e436e8d](https://github.com/open-sauced/app/commit/e436e8d1f5fccb4ca6e640b85a889dfd53132907))

## [2.40.0](https://github.com/open-sauced/app/compare/v2.39.0...v2.40.0) (2024-06-27)


Expand Down
4 changes: 4 additions & 0 deletions components/Contributors/OscrPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Tooltip from "components/atoms/Tooltip/tooltip";
export const OscrPill = ({ rating }: { rating: number }) => {
const percentageRating = Math.floor(rating * 100);

if (percentageRating < 1) {
return null;
}

return (
<Tooltip direction="top" content="Open Source Contributor Rating (OSCR)">
<Pill color="purple" size="small" text={`${percentageRating}`} />
Expand Down
4 changes: 2 additions & 2 deletions components/Graphs/IssuesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export default function IssuesChart({ stats, velocity, syncId, range = 30, isLoa
/>
<Tooltip content={CustomTooltip} filterNull={false} />
<CartesianGrid vertical={false} strokeDasharray="4" stroke="#E2E8F0" />
<Line dataKey="opened_issues" stroke="#16a34a" strokeWidth={2} />
<Line dataKey="closed_issues" stroke="#9333ea" strokeWidth={2} />
<Line dataKey="opened_issues" stroke="#16a34a" strokeWidth={2} dot={false} />
<Line dataKey="closed_issues" stroke="#9333ea" strokeWidth={2} dot={false} />
</LineChart>
)}
</ResponsiveContainer>
Expand Down
4 changes: 2 additions & 2 deletions components/Graphs/PRChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export default function PRChart({ stats, velocity, syncId, range = 30, isLoading
/>
<Tooltip content={CustomTooltip} filterNull={false} />
<CartesianGrid vertical={false} strokeDasharray="4" stroke="#E2E8F0" />
<Line dataKey="active_prs" stroke="#16a34a" strokeWidth={2} />
<Line dataKey="accepted_prs" stroke="#9333ea" strokeWidth={2} />
<Line dataKey="active_prs" stroke="#16a34a" strokeWidth={2} dot={false} />
<Line dataKey="accepted_prs" stroke="#9333ea" strokeWidth={2} dot={false} />
</LineChart>
)}
</ResponsiveContainer>
Expand Down
19 changes: 15 additions & 4 deletions components/Workspaces/TrackedRepoWizard/SelectOrgReposStep.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import { Avatar } from "components/atoms/Avatar/avatar-hover-card";
import { DayRangePicker } from "components/shared/DayRangePicker";
import { SearchedReposTable } from "../SearchReposTable";

interface SearchByReposStepProps {
Expand Down Expand Up @@ -53,6 +55,9 @@ export const SelectOrgReposStep = ({
hasError,
}: SearchByReposStepProps) => {
const [filteredRepositories, setFilteredRepositories] = useState<Map<string, boolean>>(repositories);
const router = useRouter();
const initialRange = router.query.range as string;
const [range, setRange] = useState(initialRange ? Number(initialRange) : 30);

useEffect(() => {
const lowercasedOrg = organization.toLowerCase();
Expand All @@ -78,11 +83,17 @@ export const SelectOrgReposStep = ({

return (
<div className="flex flex-col gap-4 h-96 max-h-96">
<div className="flex items-center gap-2 font-semibold">
<Avatar contributor={organization} size="xsmall" />
<span>{organization}</span>
<div className="flex w-full justify-between gap-2 font-semibold">
<div className="flex gap-2 justify-start align-middle">
<Avatar contributor={organization} size="small" />
<span className="flex align-middle">{organization}</span>
</div>
<DayRangePicker onDayRangeChanged={(e) => setRange(Number(e))} />
</div>
<p>Select the organization repositories that you want to track.</p>
<p>
Select the organization repositories updated in the last <span className="font-bold">{range} days</span> that
you want to track.
</p>
<SearchedReposTable
type="by-org"
repositories={filteredRepositories}
Expand Down
15 changes: 12 additions & 3 deletions components/Workspaces/TrackedRepoWizard/TrackedRepoWizard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLocalStorage } from "react-use";
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import { useSearchRepos } from "lib/hooks/useSearchRepos";
import { useUserOrganizations } from "lib/hooks/useUserOrganizations";
import { useGetOrgRepos } from "lib/hooks/useGetOrgRepos";
Expand Down Expand Up @@ -33,10 +34,12 @@ async function organizationExists(orgSearchTerm: string) {
}

export const TrackedReposWizard = ({ onAddToTrackingList, onCancel, onCloseModal }: TrackedReposWizardProps) => {
const router = useRouter();
const range = router.query.range as string;
const initialOrg = router.query.organization as string;
const [step, setStep] = useState<TrackedReposStep>("pickReposOrOrg");
const [organization, setOrganization] = useState<string | undefined>();
const [organization, setOrganization] = useState<string | undefined>(initialOrg);
const [currentTrackedRepositories, setCurrentTrackedRepositories] = useState<Map<string, boolean>>(new Map());

const suggestedRepos: any[] = [];
const [searchTerm, setSearchTerm] = useState<string | undefined>();
const [orgSearchTerm, setOrgSearchTerm] = useState<string | undefined>();
Expand Down Expand Up @@ -74,7 +77,7 @@ export const TrackedReposWizard = ({ onAddToTrackingList, onCancel, onCloseModal
// passing it as a dependency will cause an infinite loop though as the reference to it
// keeps changing. This is a workaround to avoid that.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [organization, isOrgReposError, isLoadingOrgRepos]);
}, [organization, isOrgReposError, isLoadingOrgRepos, range]);

useEffect(() => {
if (rawUserOrgs) {
Expand Down Expand Up @@ -149,6 +152,11 @@ export const TrackedReposWizard = ({ onAddToTrackingList, onCancel, onCloseModal
break;
}
}
useEffect(() => {
if (organization) {
setStep("pickOrgRepos");
}
}, [range, organization]);

function onSearchRepos(searchTerm?: string) {
if (searchTerm && searchTerm.length > 2) {
Expand Down Expand Up @@ -204,6 +212,7 @@ export const TrackedReposWizard = ({ onAddToTrackingList, onCancel, onCloseModal
<SearchOrgStep
onSelectOrg={(org) => {
setOrganization(org);
router.push({ query: { ...router.query, organization: org, range: range } });
setStep("pickOrgRepos");
}}
onSearch={(searchTerm) => {
Expand Down
6 changes: 4 additions & 2 deletions components/Workspaces/WorkspaceHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { writeToClipboard } from "lib/utils/write-to-clipboard";

interface WorkspaceHeaderProps {
workspace: Workspace;
children?: React.ReactNode;
}

export const WorkspaceHeader = ({ workspace }: WorkspaceHeaderProps) => {
export const WorkspaceHeader = ({ workspace, children }: WorkspaceHeaderProps) => {
const { toast } = useToast();
const posthog = usePostHog();
const { userId } = useSupabaseAuth();
Expand Down Expand Up @@ -44,7 +45,8 @@ export const WorkspaceHeader = ({ workspace }: WorkspaceHeaderProps) => {
</span>
<Pill className="font-medium" text={workspace.is_public ? "Public" : "Private"} />
</h1>
<div className="flex gap-4">
<div className="flex gap-2 justify-end">
{children}
<Button
variant="outline"
onClick={copyUrlToClipboard}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const ContributorListTableRow = ({

{/* Column: OSCR */}
<div className={clsx("flex-1 lg:max-w-[5rem] text-light-slate-11 justify-center lg:flex ")}>
<div className="flex gap-x-3">{contributor.oscr ? <OscrPill rating={contributor.oscr} /> : "-"}</div>
<div className="flex gap-x-3">{contributor.oscr ? <OscrPill rating={contributor.oscr} /> ?? "-" : "-"}</div>
</div>

{/* Column Repositories */}
Expand Down
2 changes: 1 addition & 1 deletion components/molecules/InsightHeader/insight-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const InsightHeader = ({
</div>
</div>
</div>
<div className="absolute right-0 bottom-0 top-0 flex flex-col items-end gap-3 py-2 md:items-center md:flex-row md:static">
<div className="flex gap-2 items-center">
<Button
onClick={() => handleCopyToClipboard(insightPageLink)}
className="px-6 py-2 bg-white w-max"
Expand Down
1 change: 1 addition & 0 deletions components/organisms/ListPage/DeleteListPageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const DeleteListPageModal: FC<ModalProps> = ({
const handleOnConfirm = async () => {
if (input !== listName) return;
await onConfirm();
setInput("");
};

const disabled = input !== listName || submitted;
Expand Down
2 changes: 1 addition & 1 deletion components/organisms/ToolList/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Nav: React.FC<NavProps> = ({
aria-orientation="horizontal"
aria-label="Browse the tools"
tabIndex={0}
className="tool-list-nav flex w-full overflow-x-auto overflow-y-hidden gap-2 px-4 md:px-16 border-b pt-3"
className="tool-list-nav flex w-full overflow-x-auto overflow-y-hidden gap-2 border-b pt-3"
>
{toolList.map((tool, index) => {
// TODO: Too much is going on here in terms of handling URLs. This should be revisited.
Expand Down
2 changes: 1 addition & 1 deletion layouts/hub-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const HubPageLayout = ({
return (
<>
<div>
<Header>
<Header classNames="px-0 md:px-0 pt-0">
<ClientOnly>
{isLoading ? (
<div className="flex justify-between w-full h-46">
Expand Down
4 changes: 2 additions & 2 deletions layouts/lists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const ListPageLayout = ({

return (
<>
<div>
<div className="px-4 pt-6 lg:px-16">
<Header classNames="px-0 md:px-0">
{list && (
<ListHeader
Expand Down Expand Up @@ -86,7 +86,7 @@ const ListPageLayout = ({
</div>

<main className="flex flex-col items-center flex-1 w-full py-8 bg-light-slate-2">
<div className="container px-2 mx-auto md:px-16">{children}</div>
<div className="container">{children}</div>
</main>
</>
);
Expand Down
29 changes: 22 additions & 7 deletions lib/hooks/useGetOrgRepos.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import useSWR, { Fetcher } from "swr";
import { useRouter } from "next/router";
import { supabase } from "lib/utils/supabase";
import { calcDaysFromToday } from "lib/utils/date-utils";
import { useIsWorkspaceUpgraded } from "./api/useIsWorkspaceUpgraded";

const baseUrl = "https://api.github.com";

Expand Down Expand Up @@ -29,9 +32,13 @@ const githubApiRepoFetcher: Fetcher = async (apiUrl: string) => {
throw error;
}

const requestUrl = new URL(apiUrl, baseUrl);
const upgraded = requestUrl.searchParams.get("upgraded");
const linkHeader = res.headers.get("link");

if (linkHeader && linkHeader.includes('rel="last"')) {
const responses = [res];

if (linkHeader && linkHeader.includes('rel="last"') && upgraded === "true") {
// @ts-expect-error the regex group will exist as the link header is present as per https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2022-11-28#using-link-headers
const groups = /page=(?<lastPage>\d+)>;\s+rel="last"/.exec(linkHeader).groups as { lastPage: string };

Expand All @@ -44,16 +51,16 @@ const githubApiRepoFetcher: Fetcher = async (apiUrl: string) => {
return url.toString();
});

const responses = await Promise.all(
const resolvedResponses = await Promise.all(
pageUrls.map((url) =>
fetch(url, {
headers,
})
}).catch(() => new Response(JSON.stringify({})))
)
);

// add the initial request's reponse to the start of the array of paged data responses
responses.unshift(res);
responses.push(...resolvedResponses);

const data = await Promise.all(responses.map((response) => response.json()));

Expand All @@ -64,11 +71,16 @@ const githubApiRepoFetcher: Fetcher = async (apiUrl: string) => {
};

export const useGetOrgRepos = ({ organization, limit = 100 }: { organization: string | undefined; limit?: number }) => {
const router = useRouter();
const workspaceId = router.query.workspaceId as string;
const range = router.query.range as string;
const { data: exceededLimit } = useIsWorkspaceUpgraded({ workspaceId });
const query = new URLSearchParams();
query.set("per_page", `${limit}`);
query.set("type", "public");
query.set("sort", "full_name");
query.set("direction", "asc");
query.set("sort", "pushed");
query.set("direction", "desc");
query.set("upgraded", !exceededLimit ? "true" : "false");

const endpointString = organization ? `orgs/${organization}/repos?${query}` : null;

Expand All @@ -78,7 +90,10 @@ export const useGetOrgRepos = ({ organization, limit = 100 }: { organization: st
);

return {
data: data?.map((item) => item.full_name) ?? [],
data:
data
?.filter((item) => calcDaysFromToday(new Date(item.pushed_at)) <= Number(range ?? 30))
.map((item) => item.full_name) ?? [],
isLoading: !error && !data,
isError: !!error,
mutate,
Expand Down
1 change: 1 addition & 0 deletions next-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ interface GhOrg {
id: number;
name: string;
full_name: string;
pushed_at: string;
private: boolean;
}

Expand Down
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@open-sauced/app",
"description": "🍕The dashboard for open source discovery.",
"keywords": [],
"version": "2.40.0",
"version": "2.41.0-beta.1",
"author": "Brian Douglas <[email protected]>",
"private": true,
"license": "Apache 2.0",
Expand Down
Loading

0 comments on commit eb0d2b1

Please sign in to comment.