From 75aaa173416ef578508aef3211e61976ebf912eb Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 03:07:21 +0000 Subject: [PATCH 01/16] updates Card component --- components/Card.tsx | 26 ++++++++++++++++++++++++++ fresh.gen.ts | 12 ++++++------ islands/Card.tsx | 15 --------------- islands/IssuesList.tsx | 33 +++++++++++++++++++++++++++++++++ routes/index.tsx | 27 ++++++++++++++------------- routes/projects.tsx | 37 +++++++++++++++---------------------- 6 files changed, 94 insertions(+), 56 deletions(-) create mode 100644 components/Card.tsx delete mode 100644 islands/Card.tsx create mode 100644 islands/IssuesList.tsx diff --git a/components/Card.tsx b/components/Card.tsx new file mode 100644 index 0000000..4b9c42d --- /dev/null +++ b/components/Card.tsx @@ -0,0 +1,26 @@ +import { ComponentChildren, JSX } from 'preact'; + +type CardProps = { + title: string; + content: string | JSX.Element; + link?: string; + link_text?: string; + children: ComponentChildren; +}; + +const Card = ({ title, content, link, link_text="", children }: CardProps) => { + return ( +
+
+

{title}

+ {content &&

{content}

} + {children} +
+ {link && ( + {link_text ? (link_text) : "Learn more"} + )} +
+ ); +} + +export default Card; diff --git a/fresh.gen.ts b/fresh.gen.ts index e65e186..3e5acd3 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -6,9 +6,9 @@ import * as $0 from "./routes/_404.tsx"; import * as $1 from "./routes/_app.tsx"; import * as $2 from "./routes/index.tsx"; import * as $3 from "./routes/projects.tsx"; -import * as $$0 from "./islands/Card.tsx"; -import * as $$1 from "./islands/Footer.tsx"; -import * as $$2 from "./islands/Header.tsx"; +import * as $$0 from "./islands/Footer.tsx"; +import * as $$1 from "./islands/Header.tsx"; +import * as $$2 from "./islands/IssuesList.tsx"; const manifest = { routes: { @@ -18,9 +18,9 @@ const manifest = { "./routes/projects.tsx": $3, }, islands: { - "./islands/Card.tsx": $$0, - "./islands/Footer.tsx": $$1, - "./islands/Header.tsx": $$2, + "./islands/Footer.tsx": $$0, + "./islands/Header.tsx": $$1, + "./islands/IssuesList.tsx": $$2, }, baseUrl: import.meta.url, }; diff --git a/islands/Card.tsx b/islands/Card.tsx deleted file mode 100644 index 0724721..0000000 --- a/islands/Card.tsx +++ /dev/null @@ -1,15 +0,0 @@ -type CardProps = { - title: string; - content: string | JSX.Element; -}; - -const Card = ({ title, content }: CardProps) => { - return ( -
-

{title}

-

{content}

-
- ); -} - -export default Card; diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx new file mode 100644 index 0000000..96f37d8 --- /dev/null +++ b/islands/IssuesList.tsx @@ -0,0 +1,33 @@ +import { GitHubIssue } from '../lib/github.ts'; +import Card from '../components/Card.tsx'; + +type Props = { + repos: Array; + issues: Array; +}; + +const IssuesList = ({repos, issues}: Props) => { + return ( + +
    + {issues.map((issue) => { + const [orgName, repoName] = issue.repository_url.split("/").slice(-2); + const repoPath = `${orgName}/${repoName}`; + const repoUrl = `https://github.com/${repoPath}`; + return ( +
  • + + + {repoPath}:{" "} + {issue.title} + + +
  • + ); + })} +
+
+ ) +}; + +export default IssuesList; diff --git a/routes/index.tsx b/routes/index.tsx index 4713ed3..241cf22 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -1,5 +1,6 @@ import { assert } from '$std/_util/asserts.ts' import { JSX } from 'preact' +import Card from '../components/Card.tsx'; import { fetchGitHubContributors, fetchGitHubMembers } from '../lib/github.ts' const DEVICT_REPOS: string[] = [ @@ -146,19 +147,19 @@ type ContributorsProps = { avatar_url: string html_url: string } -function Card({ title, content, link, link_text }: CardProps) { - return ( -
-
-

{title}

-

{content}

-
- {link && ( - {link_text ? (link_text) : "Learn more"} - )} -
- ) -} +// function Card({ title, content, link, link_text }: CardProps) { +// return ( +//
+//
+//

{title}

+//

{content}

+//
+// {link && ( +// {link_text ? (link_text) : "Learn more"} +// )} +//
+// ) +// } function Contributor({ login, avatar_url, html_url }: ContributorsProps) { return ( diff --git a/routes/projects.tsx b/routes/projects.tsx index 55307c6..e008916 100644 --- a/routes/projects.tsx +++ b/routes/projects.tsx @@ -1,5 +1,7 @@ import { assert } from "$std/_util/asserts.ts"; import { getHelpWantedIssues } from "../lib/github.ts"; +import Card from '../components/Card.tsx'; +import IssuesList from '../islands/IssuesList.tsx'; const DEVICT_REPOS: string[] = [ "devict/job-board", @@ -9,9 +11,6 @@ const DEVICT_REPOS: string[] = [ "devict/help", ]; -// const COMMUNITY_REPOS: string[] = []; -// const REPOS = [...DEVICT_REPOS, ...COMMUNITY_REPOS]; - export default async function Home() { const ghToken = Deno.env.get("GITHUB_TOKEN"); assert(ghToken); @@ -21,26 +20,20 @@ export default async function Home() { repos: DEVICT_REPOS, }); + const issuesListProps = { + repos: DEVICT_REPOS, + issues + }; + return ( - <> +

Contribute to devICT

-
    - {issues.map((issue) => { - const [orgName, repoName] = issue.repository_url.split("/").slice(-2); - const repoPath = `${orgName}/${repoName}`; - const repoUrl = `https://github.com/${repoPath}`; - return ( -
  • - - {repoPath}:{" "} - - - {issue.title} - -
  • - ); - })} -
- +
+
+ +
+ +
+
); } -- 2.51.2 From 114884710c7b4a3824c191db61371228779a31e1 Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 03:26:37 +0000 Subject: [PATCH 02/16] adds repo filtering --- islands/IssuesList.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index 96f37d8..88b83d3 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -1,5 +1,6 @@ import { GitHubIssue } from '../lib/github.ts'; import Card from '../components/Card.tsx'; +import { useCallback, useState } from 'preact/hooks'; type Props = { repos: Array; @@ -7,12 +8,23 @@ type Props = { }; const IssuesList = ({repos, issues}: Props) => { + const [repoFilter, setRepoFilter] = useState(null); return ( +
+ + {repoFilter && } +
    {issues.map((issue) => { const [orgName, repoName] = issue.repository_url.split("/").slice(-2); const repoPath = `${orgName}/${repoName}`; + + if (repoFilter && repoPath !== repoFilter) return; + const repoUrl = `https://github.com/${repoPath}`; return (
  • -- 2.51.2 From 2916c0a4bebabede8954b81099992faa202948fe Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 03:32:28 +0000 Subject: [PATCH 03/16] shows issue labels --- islands/IssuesList.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index 88b83d3..958786a 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -7,8 +7,21 @@ type Props = { issues: Array; }; +type LabelProps = { + name: string; + color: string; +} + const IssuesList = ({repos, issues}: Props) => { const [repoFilter, setRepoFilter] = useState(null); + const showLabel = (label: LabelProps) => { + return ( + + {label.name} + + ) + }; + return (
    @@ -24,7 +37,7 @@ const IssuesList = ({repos, issues}: Props) => { const repoPath = `${orgName}/${repoName}`; if (repoFilter && repoPath !== repoFilter) return; - + const repoUrl = `https://github.com/${repoPath}`; return (
  • @@ -34,6 +47,7 @@ const IssuesList = ({repos, issues}: Props) => { {issue.title} + {issue.labels.map(label => showLabel(label))}
  • ); })} -- 2.51.2 From 4821edbd3d1f81c083213269831d880ed8b5b2c7 Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 04:11:10 +0000 Subject: [PATCH 04/16] adds label filter --- islands/IssuesList.tsx | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index 958786a..e63b703 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -14,33 +14,52 @@ type LabelProps = { const IssuesList = ({repos, issues}: Props) => { const [repoFilter, setRepoFilter] = useState(null); + const [labelFilter, setLabelFilter] = useState({}); + + const clearFilters = () => { + setRepoFilter(null); + setLabelFilter({}); + } + const showLabel = (label: LabelProps) => { return ( - + setLabelFilter(label)} style={"background-color: #".concat(label.color)} class="cursor-pointer font-bold ml-2 px-2 py-1 rounded-xl text-white text-xs whitespace-nowrap hover:text-black"> {label.name} - - ) + + ); }; return (
    - - {repoFilter && } +
    + + + {labelFilter.name ? ( + <>Labeled with: {showLabel({...labelFilter})} + ) : ( + "Click a label to filter issues" + )} + +
    + {(repoFilter || labelFilter.name) && }
      {issues.map((issue) => { const [orgName, repoName] = issue.repository_url.split("/").slice(-2); const repoPath = `${orgName}/${repoName}`; - if (repoFilter && repoPath !== repoFilter) return; + if ( + (repoFilter && repoPath !== repoFilter) || + (labelFilter.name && !issue.labels.some(label => label.name == labelFilter.name)) + ) return; const repoUrl = `https://github.com/${repoPath}`; return ( -
    • +
    • {repoPath}:{" "} -- 2.51.2 From 46779de08546faa1b3330e48ee77b6018c9ed0f0 Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 04:20:53 +0000 Subject: [PATCH 05/16] adds repo list --- routes/projects.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/routes/projects.tsx b/routes/projects.tsx index e008916..ea2d3e9 100644 --- a/routes/projects.tsx +++ b/routes/projects.tsx @@ -32,7 +32,15 @@ export default async function Home() {
      - + +
      + ); -- 2.51.2 From e35b9a44a2728708f5cd2a14754d27cdb1a2872b Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 18:28:31 +0000 Subject: [PATCH 06/16] adds community repo links --- routes/projects.tsx | 53 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/routes/projects.tsx b/routes/projects.tsx index ea2d3e9..0f418b4 100644 --- a/routes/projects.tsx +++ b/routes/projects.tsx @@ -11,6 +11,17 @@ const DEVICT_REPOS: string[] = [ "devict/help", ]; +const COMMUNITY_REPOS: string[] = [ + "benblankley/fort-rpg", + "blunket/camelot", + "imacrayon/alpine-ajax", + "imacrayon/snowbodyknows", + "imacrayon/whatthetofu", + "kentonh/ProjectNameGenerator", + "sethetter/linktrap", + "sethetter/reqq" +]; + export default async function Home() { const ghToken = Deno.env.get("GITHUB_TOKEN"); assert(ghToken); @@ -25,22 +36,44 @@ export default async function Home() { issues }; + const shuffle = (array: string[]) => { + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + return array; + }; + return (

      Contribute to devICT

      -
      +
      - -
        - {DEVICT_REPOS.map(repo => { - const repoName = repo.split("/").slice(-1); - const repoUrl = `https://github.com/${repo}`; - return
      • {repoName}
      • ; - })} -
      -
      +
      +
      + +
        + {DEVICT_REPOS.map(repo => { + const repoName = repo.split("/").slice(-1); + const repoUrl = `https://github.com/${repo}`; + return
      • {repoName}
      • ; + })} +
      +
      +
      + +
        + {shuffle(COMMUNITY_REPOS).map(repo => { + const repoName = repo.split("/").slice(-1); + const repoUrl = `https://github.com/${repo}`; + return
      • {repoName}
      • ; + })} +
      +

      File a pull request to add your reo!

      +
      +
      ); -- 2.51.2 From eb142c289aac7d74f045ecc7ec6ae614613603e4 Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 18:42:56 +0000 Subject: [PATCH 07/16] adds community repo issues to /projects --- islands/IssuesList.tsx | 16 +++++++++------- lib/github.ts | 2 +- routes/projects.tsx | 5 +++-- twind.config.ts | 3 +++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index e63b703..b1837c5 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -1,6 +1,6 @@ import { GitHubIssue } from '../lib/github.ts'; import Card from '../components/Card.tsx'; -import { useCallback, useState } from 'preact/hooks'; +import { useState } from 'preact/hooks'; type Props = { repos: Array; @@ -23,7 +23,7 @@ const IssuesList = ({repos, issues}: Props) => { const showLabel = (label: LabelProps) => { return ( - setLabelFilter(label)} style={"background-color: #".concat(label.color)} class="cursor-pointer font-bold ml-2 px-2 py-1 rounded-xl text-white text-xs whitespace-nowrap hover:text-black"> + setLabelFilter(label)} style={"background-color: #".concat(label.color)} class="cursor-pointer font-bold mr-1 px-2 py-[0.125rem] rounded-xl text-white text-xxs whitespace-nowrap hover:text-black"> {label.name} ); @@ -35,7 +35,7 @@ const IssuesList = ({repos, issues}: Props) => {
      {labelFilter.name ? ( @@ -59,14 +59,16 @@ const IssuesList = ({repos, issues}: Props) => { const repoUrl = `https://github.com/${repoPath}`; return ( -
    • - +
    • +
      {repoPath}:{" "} {issue.title} - - {issue.labels.map(label => showLabel(label))} +
      +
      + {issue.labels.map(label => showLabel(label))} +
    • ); })} diff --git a/lib/github.ts b/lib/github.ts index 7b7a079..318d69f 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -49,7 +49,7 @@ async function fetchIssues(args: { perPage?: number; page?: number; }) { - const defaults = { perPage: 100, page: 1, labels: ["devict-help-wanted"] }; + const defaults = { perPage: 100, page: 1, labels: [] }; const { token, repo, labels, perPage, page } = { ...defaults, ...args }; const url = `https://api.github.com/repos/${repo}/issues?state=open&labels=${ diff --git a/routes/projects.tsx b/routes/projects.tsx index 0f418b4..ffaab85 100644 --- a/routes/projects.tsx +++ b/routes/projects.tsx @@ -23,16 +23,17 @@ const COMMUNITY_REPOS: string[] = [ ]; export default async function Home() { + const ALL_REPOS = DEVICT_REPOS.concat(COMMUNITY_REPOS); const ghToken = Deno.env.get("GITHUB_TOKEN"); assert(ghToken); const issues = await getHelpWantedIssues({ token: ghToken, - repos: DEVICT_REPOS, + repos: ALL_REPOS, }); const issuesListProps = { - repos: DEVICT_REPOS, + repos: ALL_REPOS, issues }; diff --git a/twind.config.ts b/twind.config.ts index a897a75..d31f275 100644 --- a/twind.config.ts +++ b/twind.config.ts @@ -10,6 +10,9 @@ export default { colors: { 'ict-orange': '#eb7f32' }, + fontSize: { + 'xxs': '0.65rem' + } }, }, }), -- 2.51.2 From 76785f803182429c44e64ab1e7d35f2377b49b7b Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Fri, 27 Oct 2023 18:47:19 +0000 Subject: [PATCH 08/16] fixes typo --- routes/projects.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/projects.tsx b/routes/projects.tsx index ffaab85..b710910 100644 --- a/routes/projects.tsx +++ b/routes/projects.tsx @@ -72,7 +72,7 @@ export default async function Home() { return
    • {repoName}
    • ; })}
    -

    File a pull request to add your reo!

    +

    Open a pull request to add your repo!

    -- 2.51.2 From 6ecfb6c36b95d5932e54b1b361a2a79297ce0ba3 Mon Sep 17 00:00:00 2001 From: Jake Suellentrop Date: Mon, 30 Oct 2023 09:39:28 -0500 Subject: [PATCH 09/16] removes unused 'Card' definition Co-authored-by: Seth Etter <655500+sethetter@users.noreply.github.com> --- routes/index.tsx | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/routes/index.tsx b/routes/index.tsx index 241cf22..eba8a91 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -147,19 +147,6 @@ type ContributorsProps = { avatar_url: string html_url: string } -// function Card({ title, content, link, link_text }: CardProps) { -// return ( -//
    -//
    -//

    {title}

    -//

    {content}

    -//
    -// {link && ( -// {link_text ? (link_text) : "Learn more"} -// )} -//
    -// ) -// } function Contributor({ login, avatar_url, html_url }: ContributorsProps) { return ( -- 2.51.2 From f324bf399bd99d14e39e2ee3242fe6a396a724fd Mon Sep 17 00:00:00 2001 From: Jake Suellentrop Date: Mon, 30 Oct 2023 09:40:19 -0500 Subject: [PATCH 10/16] makes some CardProps optional Co-authored-by: Seth Etter <655500+sethetter@users.noreply.github.com> --- components/Card.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Card.tsx b/components/Card.tsx index 4b9c42d..2df3c58 100644 --- a/components/Card.tsx +++ b/components/Card.tsx @@ -2,10 +2,10 @@ import { ComponentChildren, JSX } from 'preact'; type CardProps = { title: string; - content: string | JSX.Element; + content?: string | JSX.Element; link?: string; link_text?: string; - children: ComponentChildren; + children?: ComponentChildren; }; const Card = ({ title, content, link, link_text="", children }: CardProps) => { -- 2.51.2 From 6bea88c4bff464682b4c4b8015ea4a294b331047 Mon Sep 17 00:00:00 2001 From: Jake Suellentrop Date: Mon, 30 Oct 2023 09:42:16 -0500 Subject: [PATCH 11/16] adds types to filter states Co-authored-by: Seth Etter <655500+sethetter@users.noreply.github.com> --- islands/IssuesList.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index b1837c5..1133a1b 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -13,8 +13,9 @@ type LabelProps = { } const IssuesList = ({repos, issues}: Props) => { - const [repoFilter, setRepoFilter] = useState(null); - const [labelFilter, setLabelFilter] = useState({}); + const NO_FILTER = "none"; + const [repoFilter, setRepoFilter] = useState(NO_FILTER); + const [labelFilter, setLabelFilter] = useState(); const clearFilters = () => { setRepoFilter(null); -- 2.51.2 From 5943dccc74bf9ed2700c16f4f3e86b718db6c484 Mon Sep 17 00:00:00 2001 From: Jake Suellentrop Date: Mon, 30 Oct 2023 09:42:35 -0500 Subject: [PATCH 12/16] Update islands/IssuesList.tsx Co-authored-by: Seth Etter <655500+sethetter@users.noreply.github.com> --- islands/IssuesList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index 1133a1b..ad8176d 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -18,8 +18,8 @@ const IssuesList = ({repos, issues}: Props) => { const [labelFilter, setLabelFilter] = useState(); const clearFilters = () => { - setRepoFilter(null); - setLabelFilter({}); + setRepoFilter(NO_FILTER); + setLabelFilter(undefined); } const showLabel = (label: LabelProps) => { -- 2.51.2 From 0bf843567bb438f57c7333c19a9a35214f7419c0 Mon Sep 17 00:00:00 2001 From: Jake Suellentrop Date: Mon, 30 Oct 2023 09:55:46 -0500 Subject: [PATCH 13/16] Update islands/IssuesList.tsx Co-authored-by: Seth Etter <655500+sethetter@users.noreply.github.com> --- islands/IssuesList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index ad8176d..cec15e5 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -34,7 +34,7 @@ const IssuesList = ({repos, issues}: Props) => {
    - setRepoFilter(e.currentTarget.value)}> {repos.map(repo => )} -- 2.51.2 From 6420773a669ba64b955ccab5e01bc0addd2be130 Mon Sep 17 00:00:00 2001 From: Jake Suellentrop Date: Mon, 30 Oct 2023 09:56:00 -0500 Subject: [PATCH 14/16] Update islands/IssuesList.tsx Co-authored-by: Seth Etter <655500+sethetter@users.noreply.github.com> --- islands/IssuesList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index cec15e5..2a2cb6b 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -35,7 +35,7 @@ const IssuesList = ({repos, issues}: Props) => {
    -- 2.51.2 From d78ca5108810529951f74b7fa73991056276c95f Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Mon, 30 Oct 2023 15:52:13 +0000 Subject: [PATCH 15/16] adds RepoList component --- components/RepoList.tsx | 36 ++++++++++++++++++++++++++++++++++++ islands/IssuesList.tsx | 8 ++++---- routes/projects.tsx | 31 +++---------------------------- 3 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 components/RepoList.tsx diff --git a/components/RepoList.tsx b/components/RepoList.tsx new file mode 100644 index 0000000..3474733 --- /dev/null +++ b/components/RepoList.tsx @@ -0,0 +1,36 @@ +import Card from '../components/Card.tsx'; + +type RepoListProps = { + title: string; + list: string[]; + shuffleList: boolean; +}; + +const shuffle = (array: string[]) => { + let shuffled: string[] = []; + shuffled.concat(array); + + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [shuffled[i], shuffled[j]] = [array[j], array[i]]; + } + return shuffled; +}; + +const RepoList = ({title, list, shuffleList = false}: RepoListProps) => { + let repos = shuffleList ? shuffle(list) : list; + + return ( + +
      + {repos.map(repo => { + const repoName = repo.split("/").slice(-1); + const repoUrl = `https://github.com/${repo}`; + return
    • {repoName}
    • ; + })} +
    +
    + ); +} + +export default RepoList; diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index 2a2cb6b..cfcfa9c 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -39,14 +39,14 @@ const IssuesList = ({repos, issues}: Props) => { {repos.map(repo => )} - {labelFilter.name ? ( + {labelFilter ? ( <>Labeled with: {showLabel({...labelFilter})} ) : ( "Click a label to filter issues" )}
    - {(repoFilter || labelFilter.name) && } + {(repoFilter !== NO_FILTER || labelFilter) && }
      {issues.map((issue) => { @@ -54,8 +54,8 @@ const IssuesList = ({repos, issues}: Props) => { const repoPath = `${orgName}/${repoName}`; if ( - (repoFilter && repoPath !== repoFilter) || - (labelFilter.name && !issue.labels.some(label => label.name == labelFilter.name)) + (repoFilter !== NO_FILTER && repoPath !== repoFilter) || + (labelFilter && !issue.labels.some(label => label.name == labelFilter.name)) ) return; const repoUrl = `https://github.com/${repoPath}`; diff --git a/routes/projects.tsx b/routes/projects.tsx index b710910..2f29554 100644 --- a/routes/projects.tsx +++ b/routes/projects.tsx @@ -1,6 +1,6 @@ import { assert } from "$std/_util/asserts.ts"; import { getHelpWantedIssues } from "../lib/github.ts"; -import Card from '../components/Card.tsx'; +import RepoList from '../components/RepoList.tsx'; import IssuesList from '../islands/IssuesList.tsx'; const DEVICT_REPOS: string[] = [ @@ -37,14 +37,6 @@ export default async function Home() { issues }; - const shuffle = (array: string[]) => { - for (let i = array.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - [array[i], array[j]] = [array[j], array[i]]; - } - return array; - }; - return (

      Contribute to devICT

      @@ -54,26 +46,9 @@ export default async function Home() {
      - -
        - {DEVICT_REPOS.map(repo => { - const repoName = repo.split("/").slice(-1); - const repoUrl = `https://github.com/${repo}`; - return
      • {repoName}
      • ; - })} -
      -
      +
      - -
        - {shuffle(COMMUNITY_REPOS).map(repo => { - const repoName = repo.split("/").slice(-1); - const repoUrl = `https://github.com/${repo}`; - return
      • {repoName}
      • ; - })} -
      -

      Open a pull request to add your repo!

      -
      +
    -- 2.51.2 From 4c50311a75cd1044ff46af57b2735425ee9f4147 Mon Sep 17 00:00:00 2001 From: jakesuellentrop Date: Mon, 30 Oct 2023 16:11:35 +0000 Subject: [PATCH 16/16] updates filter logic --- islands/IssuesList.tsx | 57 +++++++++++++++++++++++------------------- lib/github.ts | 8 +++++- routes/index.tsx | 8 ------ 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/islands/IssuesList.tsx b/islands/IssuesList.tsx index cfcfa9c..18de946 100644 --- a/islands/IssuesList.tsx +++ b/islands/IssuesList.tsx @@ -1,6 +1,6 @@ -import { GitHubIssue } from '../lib/github.ts'; +import { GitHubIssue, issueRepoPath } from '../lib/github.ts'; import Card from '../components/Card.tsx'; -import { useState } from 'preact/hooks'; +import { useMemo, useState } from 'preact/hooks'; type Props = { repos: Array; @@ -30,6 +30,19 @@ const IssuesList = ({repos, issues}: Props) => { ); }; + const filteredIssues = useMemo(() => + issues.filter((issue) => { + const repoPath = issueRepoPath(issue); + + const isFilteredByRepo = repoFilter !== NO_FILTER && + repoPath !== repoFilter; + const isFilteredByLabel = labelFilter && + !issue.labels.some((label) => label.name == labelFilter.name); + + return !(isFilteredByRepo || isFilteredByLabel); + }), [issues, repoFilter, labelFilter] + ); + return (
    @@ -49,30 +62,22 @@ const IssuesList = ({repos, issues}: Props) => { {(repoFilter !== NO_FILTER || labelFilter) && }
      - {issues.map((issue) => { - const [orgName, repoName] = issue.repository_url.split("/").slice(-2); - const repoPath = `${orgName}/${repoName}`; - - if ( - (repoFilter !== NO_FILTER && repoPath !== repoFilter) || - (labelFilter && !issue.labels.some(label => label.name == labelFilter.name)) - ) return; - - const repoUrl = `https://github.com/${repoPath}`; - return ( -
    • - -
      - {issue.labels.map(label => showLabel(label))} -
      -
    • - ); - })} + {filteredIssues.map((issue) => ( +
    • + +
      + {issue.labels.map((label) => showLabel(label))} +
      +
    • + ))}
    ) diff --git a/lib/github.ts b/lib/github.ts index 318d69f..120ef0b 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -49,7 +49,7 @@ async function fetchIssues(args: { perPage?: number; page?: number; }) { - const defaults = { perPage: 100, page: 1, labels: [] }; + const defaults = { perPage: 100, page: 1, labels: ["devict-help-wanted"] }; const { token, repo, labels, perPage, page } = { ...defaults, ...args }; const url = `https://api.github.com/repos/${repo}/issues?state=open&labels=${ @@ -121,3 +121,9 @@ export async function fetchGitHubContributors(token: string, repos: string[]) { return allContributors; } + +export function issueRepoPath (issue: GitHubIssue) { + const [orgName, repoName] = issue.repository_url.split("/").slice(-2); + + return `${orgName}/${repoName}`; +} diff --git a/routes/index.tsx b/routes/index.tsx index eba8a91..2b61f64 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -134,14 +134,6 @@ export default async function Home() { ) } -type CardProps = { - title: string; - content: string | JSX.Element; - link: string; - link_text: string; -}; - - type ContributorsProps = { login: string avatar_url: string -- 2.51.2