Skip to content

Commit defe111

Browse files
committed
add bug report redirecter
1 parent 85656b0 commit defe111

5 files changed

Lines changed: 89 additions & 0 deletions

File tree

docusaurus.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ const config = {
4747

4848
onBrokenLinks: "warn",
4949

50+
customFields: {
51+
bug_report:
52+
"https://raw.githubusercontent.com/CodeShellDev/secured-signal-api/refs/heads/main/.github/ISSUE_TEMPLATE/external.bug_report.md",
53+
},
54+
5055
i18n: {
5156
defaultLocale: "en",
5257
locales: ["en"],

src/components/HomepageFeatures/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function Feature({ title, description, Svg }) {
5858
</div>
5959
)
6060
}
61+
6162
export default function HomepageFeatures() {
6263
return (
6364
<section className={styles.features}>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, { useEffect } from "react"
2+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"
3+
4+
export default function IssueReport({ templateUrl, labels = [], title = "" }) {
5+
const { siteConfig } = useDocusaurusContext()
6+
const { organizationName, projectName } = siteConfig
7+
8+
const REPO_ISSUE_URL = `https://github.com/${organizationName}/${projectName}/issues/new`
9+
10+
useEffect(() => {
11+
async function buildIssue() {
12+
let template = await fetch(templateUrl).then((r) => r.text())
13+
14+
const params = new URLSearchParams(window.location.search)
15+
16+
const version = params.get("version")
17+
18+
if (version) {
19+
labels.push(version)
20+
}
21+
22+
params.forEach((value, key) => {
23+
template = template.replaceAll(`\${[{${key.toUpperCase()}}]}`, value)
24+
})
25+
26+
const regex = /\$\{\[\{[A-Z0-9_]+\}\]\}/g
27+
28+
template = template.replaceAll(regex, "")
29+
30+
const body = encodeURIComponent(template)
31+
32+
const labelString = Array.isArray(labels) ? labels.join(",") : labels
33+
34+
const url = `${REPO_ISSUE_URL}?labels=${encodeURIComponent(
35+
labelString,
36+
)}&title=${title}&body=${body}${version ? `&milestone=${version}` : ""}`
37+
38+
window.location.href = url
39+
}
40+
41+
buildIssue()
42+
}, [templateUrl, REPO_ISSUE_URL, labels])
43+
44+
return ""
45+
}

src/pages/report/bug.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from "react"
2+
import Heading from "@theme/Heading"
3+
import Layout from "@theme/Layout"
4+
5+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"
6+
7+
import IssueReport from "@site/src/components/IssueReport"
8+
9+
import styles from "./index.module.css"
10+
11+
export default function ReportBugPage() {
12+
const { siteConfig } = useDocusaurusContext()
13+
14+
return (
15+
<Layout
16+
title={`${siteConfig.title}`}
17+
description="Official Secured Signal API Documentation"
18+
>
19+
<IssueReport
20+
templateUrl={siteConfig.customFields.bug_report}
21+
labels={["bug"]}
22+
/>
23+
<div className={styles.centered}>
24+
<Heading as="h3">Creating Issue</Heading>
25+
<Heading as="h4">preparing bug report…</Heading>
26+
</div>
27+
</Layout>
28+
)
29+
}

src/pages/report/index.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.centered {
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
5+
6+
height: 70vh;
7+
8+
flex-direction: column;
9+
}

0 commit comments

Comments
 (0)