This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: global repos list * fix: failing tests * fix: failing test * fix: failing test
- Loading branch information
1 parent
8f24eae
commit 15d769c
Showing
10 changed files
with
170 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import logger from "@config/logger"; | ||
import Profile from "@models/Profile"; | ||
|
||
export default async function handler(req, res) { | ||
if (req.method != "GET") { | ||
return res | ||
.status(400) | ||
.json({ error: "Invalid request: GET request required" }); | ||
} | ||
|
||
const repos = await getRepos(); | ||
return res.status(200).json(repos); | ||
} | ||
|
||
export async function getRepos() { | ||
let repos = []; | ||
try { | ||
repos = await Profile.aggregate([ | ||
{ $project: { username: 1, repos: 1, isEnabled: 1 } }, | ||
{ $match: { isEnabled: true } }, | ||
{ $unwind: "$repos" }, | ||
{ | ||
$sort: { "repos.dates.pushedAt": -1 }, | ||
}, | ||
{ | ||
$replaceRoot: { | ||
newRoot: "$repos", | ||
}, | ||
}, | ||
]).exec(); | ||
} catch (e) { | ||
logger.error(e, "Failed to load repos"); | ||
repos = []; | ||
} | ||
|
||
return JSON.parse(JSON.stringify(repos)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import DocsLayout from "@components/layouts/DocsLayout.js"; | ||
import ClipboardCopy from "@components/ClipboardCopy"; | ||
import Link from "@components/Link"; | ||
|
||
## GitHub Repos - with Forms | ||
|
||
Showcase your Open Source projects by adding the GitHub Repo to your Profile. | ||
|
||
## Add a GitHub Repo | ||
|
||
1. Go to the [LinkFree homepage](https://linkfree.io/) | ||
|
||
2. Click on `Log in` | ||
|
||
![LinkFree Homepage](https://github.com/EddieHubCommunity/LinkFree/assets/82668196/ce980ed7-ad4d-42c0-886c-447a2e2ab936) | ||
|
||
3. You will be taken to your Profile's Statistics page | ||
|
||
Click on `Repos` | ||
|
||
![LinkFree Profile](https://github.com/EddieHubCommunity/LinkFree/assets/624760/59e998c6-f757-4678-b973-1213b86dbd62) | ||
|
||
4. This will take you to the Repos page | ||
|
||
Enter your GitHub Repo URL and then click `Add Repo` | ||
|
||
![LinkFree Add Repo](https://github.com/EddieHubCommunity/LinkFree/assets/624760/26d11652-4085-4b02-80d7-81bd1cb6517c) | ||
|
||
Note: If you already have GitHub Repos in your Profile these will shown here. | ||
|
||
5. Your GitHub Repo will then be shown in your Profile on your custom URL (linkfree.io/eddiejaoude) and also the global Repo page | ||
|
||
![Global Repo page](https://github.com/EddieHubCommunity/LinkFree/assets/624760/f7135feb-56ba-4d62-9ed4-a6cedb4e0d39) | ||
|
||
export default ({ children }) => ( | ||
<DocsLayout | ||
title="LinkFree Links Documentation" | ||
section="Customising your Profile" | ||
name="Links" | ||
> | ||
{children} | ||
</DocsLayout> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { getRepos } from "./api/repos"; | ||
|
||
import Page from "@components/Page"; | ||
import PageHead from "@components/PageHead"; | ||
import UserRepos from "@components/user/UserRepos"; | ||
|
||
export async function getServerSideProps() { | ||
let repos = await getRepos(); | ||
|
||
return { | ||
props: { repos }, | ||
}; | ||
} | ||
|
||
export default function Repos({ repos }) { | ||
return ( | ||
<> | ||
<PageHead | ||
title="Repos from the LinkFree community members" | ||
description="Repo by the LinkFree community" | ||
/> | ||
|
||
<Page> | ||
<h1 className="text-4xl mb-4 font-bold">Community Repos</h1> | ||
|
||
<UserRepos repos={repos} /> | ||
</Page> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// @ts-check | ||
import { test, expect } from "@playwright/test"; | ||
import AxeBuilder from "@axe-core/playwright"; | ||
|
||
test("Click on repos in navbar navigates to repo page", async ({ page }) => { | ||
await page.goto("/"); | ||
await page | ||
.getByRole("navigation") | ||
.getByRole("link", { name: "Repos" }) | ||
.click(); | ||
await expect(page).toHaveURL("/repos"); | ||
}); | ||
|
||
test("Repos has title", async ({ page }) => { | ||
await page.goto("/repos"); | ||
await expect(page.locator("h1")).toHaveText("Community Repos"); | ||
}); | ||
|
||
test.describe("accessibility tests (light)", () => { | ||
test.use({ colorScheme: "light" }); | ||
|
||
test("should pass axe wcag accessibility tests", async ({ page }) => { | ||
await page.goto("/repos"); | ||
const accessibilityScanResults = await new AxeBuilder({ page }) | ||
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"]) | ||
.analyze(); | ||
expect(accessibilityScanResults.violations).toEqual([]); | ||
}); | ||
}); | ||
|
||
test.describe("accessibility tests (dark)", () => { | ||
test.use({ colorScheme: "dark" }); | ||
|
||
test("should pass axe wcag accessibility tests (dark)", async ({ page }) => { | ||
await page.goto("/repos"); | ||
const accessibilityScanResults = await new AxeBuilder({ page }) | ||
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"]) | ||
.analyze(); | ||
expect(accessibilityScanResults.violations).toEqual([]); | ||
}); | ||
}); |