-
Notifications
You must be signed in to change notification settings - Fork 10
feat(card): add third-party flagging system #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c834fa
feat(card): add third-party warning integration
MatteoGabriele 5f561f3
feat: move block in activity signal section
MatteoGabriele 1bb0cb3
fix: color for light theme
MatteoGabriele 182845b
fix: key and aria
MatteoGabriele 475ef4e
chore: change message
MatteoGabriele File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,70 @@ | ||
| <script setup lang="ts"> | ||
| const props = defineProps<{ | ||
| items: IntegrationItem[]; | ||
| }>(); | ||
|
|
||
| const isDisclosureOpen = ref<boolean>(false); | ||
| const counter = computed<number>(() => { | ||
| return props.items.length; | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <section> | ||
| <button | ||
| @click="isDisclosureOpen = !isDisclosureOpen" | ||
| :aria-expanded="isDisclosureOpen" | ||
| aria-controls="disclosure-external-analysis" | ||
| class="w-full bg-amber-500/10 text-amber-500 rounded-lg border-amber-500/40 border px-3 py-2 text-left transition-colors" | ||
| :class="{ | ||
| 'border-b-none rounded-b-none': isDisclosureOpen, | ||
| 'hover:border-amber-500': !isDisclosureOpen, | ||
| }" | ||
| > | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| <div class="flex items-center justify-between"> | ||
| <h3 class="flex items-center gap-2 text-sm"> | ||
| <span class="i-carbon:warning"></span> | ||
| <span>Suspicious Activity Reported</span> | ||
| </h3> | ||
| <div class="flex items-center gap-3"> | ||
| <span | ||
| class="bg-amber-500/20 text-amber-500 text-xs font-semibold px-2 py-1 rounded" | ||
| > | ||
| {{ counter }} | ||
| </span> | ||
| <span | ||
| :class="[ | ||
| 'i-carbon:chevron-down text-base transition-transform', | ||
| isDisclosureOpen && 'rotate-180', | ||
| ]" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </button> | ||
|
|
||
| <ul | ||
| v-if="isDisclosureOpen" | ||
| id="disclosure-external-analysis" | ||
| class="bg-amber-500/5 border border-t-amber-500/30 rounded-b-md border-amber-500/40 p-4 space-y-4" | ||
| > | ||
| <li | ||
| v-for="item in items" | ||
| :key="`${item.username}-${item.link}`" | ||
| class="p-3 space-y-2" | ||
| > | ||
| <h4 class="text-gh-text/90 text-sm">{{ item.label }}</h4> | ||
| <p class="text-gh-text/70 text-sm"> | ||
| {{ item.reason }} | ||
| </p> | ||
| <NuxtLink | ||
| external | ||
| :to="item.link" | ||
| class="inline-block text-gh-text/80 underline text-xs font-semibold hover:text-gh-text" | ||
| target="_blank" | ||
| > | ||
| View Report → | ||
| </NuxtLink> | ||
| </li> | ||
| </ul> | ||
| </section> | ||
| </template> | ||
This file contains hidden or 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,7 @@ | ||
| import type { IntegrationItem } from "~~/shared/types/integrations"; | ||
|
|
||
| export function useIntegrations() { | ||
| return useLazyAsyncData("integrations", async () => { | ||
| return $fetch<IntegrationItem[]>("/api/integration/unsafe-labs"); | ||
| }); | ||
| } |
This file contains hidden or 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 { Octokit } from "octokit"; | ||
| import dayjs from "dayjs"; | ||
| import type { IntegrationItem } from "~~/shared/types/integrations"; | ||
|
|
||
| export type IntegrationUsafeLab = { | ||
| username: string; | ||
| total_prs: number; | ||
| first_pr: string; | ||
| last_pr: string; | ||
| }; | ||
|
|
||
| export default defineEventHandler(async () => { | ||
| const config = useRuntimeConfig(); | ||
| const octokit = new Octokit({ auth: config.githubToken }); | ||
|
|
||
| try { | ||
| const { data } = await octokit.rest.repos.getContent({ | ||
| owner: "UnsafeLabs", | ||
| repo: "Bounty-Hunters", | ||
| path: "clankers.json", | ||
| }); | ||
|
|
||
| if ("content" in data) { | ||
| const content = Buffer.from(data.content, "base64").toString("utf-8"); | ||
| const integrationData = JSON.parse(content) as IntegrationUsafeLab[]; | ||
| return integrationData.map((d) => ({ | ||
| label: "UnsafeLabs Bounty Hunters", | ||
| username: d.username, | ||
| createdAt: d.first_pr, | ||
| reason: `This account appears in the UnsafeLabs bounty hunters database. Submitted a total of ${d.total_prs} PR${d.total_prs === 1 ? "" : "s"} to the project. Activity detected from ${dayjs(d.first_pr).format("MMM D, YYYY")} through ${dayjs(d.last_pr).format("MMM D, YYYY")}.`, | ||
| link: `https://github.com/UnsafeLabs/Bounty-Hunters/pulls?q=is%3Apr+author%3A${d.username}`, | ||
| })) satisfies IntegrationItem[]; | ||
| } | ||
|
|
||
| return []; | ||
| } catch (error) { | ||
| throw createError({ | ||
| statusCode: 500, | ||
| message: "Failed to fetch integration list", | ||
| cause: error, | ||
| }); | ||
| } | ||
| }); |
This file contains hidden or 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,7 @@ | ||
| export type IntegrationItem = { | ||
| label: string; | ||
| username: string; | ||
| createdAt?: string; | ||
| reason: string; | ||
| link: string; | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.