From 542b663208310022831601d4bac313fbda5bf606 Mon Sep 17 00:00:00 2001 From: Josh Wong <23216828+josh-wong@users.noreply.github.com> Date: Fri, 21 Mar 2025 19:15:01 +0900 Subject: [PATCH 1/4] Fix random GitHub issue linking issue On some pages, the GitHub issue link wouldn't open. This commit implements the linking mechanism in a slightly different way. --- .../Support/SupportDropdownMenu.tsx | 163 +++++++++--------- 1 file changed, 82 insertions(+), 81 deletions(-) diff --git a/src/components/Support/SupportDropdownMenu.tsx b/src/components/Support/SupportDropdownMenu.tsx index f66c35d4..71c8b3f8 100644 --- a/src/components/Support/SupportDropdownMenu.tsx +++ b/src/components/Support/SupportDropdownMenu.tsx @@ -9,6 +9,7 @@ const SupportDropdownMenu: React.FC = () => { const [isOpen, setIsOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false); const [storedUrl, setStoredUrl] = useState(null); + const [githubIssueUrl, setGithubIssueUrl] = useState("#"); const dropdownRef = useRef(null); const location = useLocation(); @@ -23,14 +24,60 @@ const SupportDropdownMenu: React.FC = () => { if (typeof window !== "undefined") { const currentUrl = `https://scalardb.scalar-labs.com${location.pathname}`; localStorage.setItem("currentUrl", currentUrl); - - const savedUrl = localStorage.getItem("currentUrl"); - if (savedUrl) { - setStoredUrl(savedUrl); - } + setStoredUrl(currentUrl); } }, [location]); + useEffect(() => { + if (typeof window !== "undefined") { + const repoUrl = "https://github.com/scalar-labs/docs-scalardb/issues/new"; + const issueTitle = encodeURIComponent( + isJapanese ? `フィードバック: \`${docTitle}\` ページ` : `Feedback: \`${docTitle}\` page` + ); + + const issueBody = encodeURIComponent( + isJapanese + ? `**ドキュメントページの URL:** ${window.location.href.replace(/#.*$/, '')} + + ## 期待される動作 + + どのような動作を期待しましたか? + + ## 問題の説明 + + 問題の内容をわかりやすく説明してください。 + + ### 再現手順 (該当する場合) + + 問題を再現できる場合、手順を記載してください。 + + ### スクリーンショット (該当する場合) + + 該当する場合は、スクリーンショットを添付してください。` + : `**Documentation page URL:** ${window.location.href.replace(/#.*$/, '')} + + ## Expected behavior + + What did you expect to happen? + + ## Describe the problem + + Please provide a clear and concise description of what the issue is. + + ### Steps to reproduce (if applicable) + + If the issue is reproducible, please list the steps to reproduce it. + + ### Screenshots (if applicable) + + If applicable, add screenshots to help explain your problem.` + ); + + const issueUrl = `${repoUrl}?title=${issueTitle}&body=${issueBody}&labels=documentation`; + setGithubIssueUrl(issueUrl); + } + }, [isJapanese, docTitle]); + const toggleDropdown = () => { setIsOpen((prev) => !prev); }; @@ -45,67 +92,23 @@ const SupportDropdownMenu: React.FC = () => { setIsModalOpen(false); }; - const handleSupportClick = () => { + const handleSupportClick = (event: MouseEvent) => { + event.preventDefault(); if (typeof window !== "undefined") { const finalUrl = storedUrl || `https://scalardb.scalar-labs.com${location.pathname}`; const reportUrl = `https://support.scalar-labs.com/hc/ja/requests/new?ticket_form_id=8641483507983&tf_11847415366927=${encodeURIComponent(finalUrl)}`; - window.open(reportUrl, "_blank"); } }; - const githubIssueUrl: string = typeof window !== "undefined" ? (() => { - const repoUrl = "https://github.com/scalar-labs/docs-scalardb/issues/new"; - const issueTitle = encodeURIComponent( - isJapanese ? `フィードバック: \`${docTitle}\` ページ` : `Feedback: \`${docTitle}\` page` - ); - - const issueBody = encodeURIComponent( - isJapanese - ? `**ドキュメントページの URL:** ${window.location.href.replace(/#.*$/, '')} - -## 期待される動作 - -どのような動作を期待しましたか? - -## 問題の説明 - -問題の内容をわかりやすく説明してください。 - -### 再現手順 (該当する場合) - -問題を再現できる場合、手順を記載してください。 - -### スクリーンショット (該当する場合) - -該当する場合は、スクリーンショットを添付してください。 -` - : `**Documentation page URL:** ${window.location.href.replace(/#.*$/, '')} - -## Expected behavior - -What did you expect to happen? - -## Describe the problem - -Please provide a clear and concise description of what the issue is. - -### Steps to reproduce (if applicable) - -If the issue is reproducible, please list the steps to reproduce it. - -### Screenshots (if applicable) - -If applicable, add screenshots to help explain your problem. -` - ); - - const issueUrl = `${repoUrl}?title=${issueTitle}&body=${issueBody}&labels=documentation`; - - console.log("GitHub Issue URL: ", issueUrl); // Debugging line - - return issueUrl; - })() : "#"; + const handleGitHubClick = (event: MouseEvent) => { + event.preventDefault(); + if (githubIssueUrl !== "#") { + window.open(githubIssueUrl, "_blank", "noopener,noreferrer"); + } else { + console.error("GitHub issue URL is not set correctly."); + } + }; useEffect(() => { function handleClickOutside(event: MouseEvent | Event) { @@ -126,32 +129,30 @@ If applicable, add screenshots to help explain your problem. return (
-
- -
- {/* - {isJapanese ? "Stack Overflow をチェック" : "Check Stack Overflow"}
- {isJapanese ? "すべてのユーザーがご利用いただけます。" : "Available to all users."} -
-
*/} - - {isJapanese ? "AI に聞く (試験運用中)" : "Ask AI (experimental)"}
- {isJapanese ? "Scalar Membership Programにご参加の方のみご利用いただけます。" : "Available only to members of the Scalar Membership Program."} -
-
- - {isJapanese ? "ドキュメントの問題を報告" : "Report doc issue"}
- {isJapanese ? "このページについて何かお気づきの点がありましたら、こちらから報告いただけます。" : "If you have any feedback about this page, please submit an issue."} +
{isModalOpen && ( Loading...
}> From e34df5550b966e814380a0eb99b1106cdeb025d6 Mon Sep 17 00:00:00 2001 From: Josh Wong <23216828+josh-wong@users.noreply.github.com> Date: Fri, 21 Mar 2025 19:15:08 +0900 Subject: [PATCH 2/4] Make cosmetic changes to syntax --- src/components/Support/SupportDropdownMenu.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Support/SupportDropdownMenu.tsx b/src/components/Support/SupportDropdownMenu.tsx index 71c8b3f8..ff8dfdaa 100644 --- a/src/components/Support/SupportDropdownMenu.tsx +++ b/src/components/Support/SupportDropdownMenu.tsx @@ -1,9 +1,9 @@ -import React, { useState, useEffect, useRef, lazy, Suspense, MouseEvent } from 'react'; -import { useDoc } from '@docusaurus/plugin-content-docs/client'; +import React, { useState, useEffect, useRef, lazy, Suspense, MouseEvent } from "react"; +import { useDoc } from "@docusaurus/plugin-content-docs/client"; import { useLocation } from "@docusaurus/router"; // Lazy-load AssistantModal. -const AssistantModal = lazy(() => import('./AssistantModal')); +const AssistantModal = lazy(() => import("./AssistantModal")); const SupportDropdownMenu: React.FC = () => { const [isOpen, setIsOpen] = useState(false); From 66bb32068444d705e6a7646c55ead3d68fc76b87 Mon Sep 17 00:00:00 2001 From: Josh Wong <23216828+josh-wong@users.noreply.github.com> Date: Fri, 21 Mar 2025 19:15:26 +0900 Subject: [PATCH 3/4] Change announcement link to absolute The Docusaurus docs site uses an absolute link, so I think we should follow that as well. --- docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index de2ef0f6..a715ea7a 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -513,7 +513,7 @@ const config = { announcementBar: { id: 'new_version', content: - 'Announcing the release of ScalarDB 3.15!🚀 For details on what\'s included in this new version, see the release notes.', + 'Announcing the release of ScalarDB 3.15!🚀 For details on what\'s included in this new version, see the release notes.', // 'Announcing the release of ScalarDB X.X!🚀 For details on what\'s included in this new version, see the release notes.', backgroundColor: '#2673BB', textColor: '#FFFFFF', From 7d02e858d23b7fc60e7cf449ebb8120e15cdc284 Mon Sep 17 00:00:00 2001 From: Josh Wong <23216828+josh-wong@users.noreply.github.com> Date: Fri, 21 Mar 2025 20:14:22 +0900 Subject: [PATCH 4/4] Fix announcement link --- docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index a715ea7a..5ff24e98 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -513,7 +513,7 @@ const config = { announcementBar: { id: 'new_version', content: - 'Announcing the release of ScalarDB 3.15!🚀 For details on what\'s included in this new version, see the release notes.', + 'Announcing the release of ScalarDB 3.15!🚀 For details on what\'s included in this new version, see the release notes.', // 'Announcing the release of ScalarDB X.X!🚀 For details on what\'s included in this new version, see the release notes.', backgroundColor: '#2673BB', textColor: '#FFFFFF',