Copilot commented on code in PR #987:
URL: 
https://github.com/apache/dolphinscheduler-website/pull/987#discussion_r2598581190


##########
src/components/Footer/index.jsx:
##########
@@ -11,6 +12,26 @@ import "./index.scss";
 
 const Footer = () => {
   const { locale, t } = useTranslation();
+
+  useEffect(() => {
+    const script = document.createElement("script");
+    script.src = "https://widget.kapa.ai/kapa-widget.bundle.js";;
+    script.async = true;
+    script.dataset.websiteId = "e3268e5d-c0f1-4e71-819c-c60ebb2215a7";
+    script.dataset.projectName = "Apache DolphinScheduler";
+    script.dataset.projectColor = "#0097E0";
+    script.dataset.projectLogo =
+      "https://dolphinscheduler.apache.org/images/logo_400x400.jpg";;
+    script.dataset.modalDisclaimer =
+      "This is a custom LLM for Apache DolphinScheduler with access to all 
developer Documentation, Blog, GitHub issues and discussions.";
+    script.dataset.modalExampleQuestions =
+      "Why we need DolphinScheduler?,How to deploy DolphinScheduler?,How to 
submit task?,How to contribute?";
+    document.body.appendChild(script);
+
+    return () => {
+      document.body.removeChild(script);

Review Comment:
   The cleanup function attempts to remove a script element that may no longer 
exist in the DOM. If the script element is removed by other code or if the 
cleanup runs after the script has already been removed, this will throw a 
`NotFoundError`. 
   
   Consider checking if the script exists before attempting to remove it:
   
   ```javascript
   return () => {
     if (script.parentNode) {
       document.body.removeChild(script);
     }
   };
   ```
   
   Alternatively, store a reference to check if it's still in the body:
   
   ```javascript
   return () => {
     if (document.body.contains(script)) {
       document.body.removeChild(script);
     }
   };
   ```
   ```suggestion
         if (document.body.contains(script)) {
           document.body.removeChild(script);
         }
   ```



##########
src/components/Footer/index.jsx:
##########
@@ -11,6 +12,26 @@ import "./index.scss";
 
 const Footer = () => {
   const { locale, t } = useTranslation();
+
+  useEffect(() => {
+    const script = document.createElement("script");
+    script.src = "https://widget.kapa.ai/kapa-widget.bundle.js";;
+    script.async = true;
+    script.dataset.websiteId = "e3268e5d-c0f1-4e71-819c-c60ebb2215a7";
+    script.dataset.projectName = "Apache DolphinScheduler";
+    script.dataset.projectColor = "#0097E0";
+    script.dataset.projectLogo =
+      "https://dolphinscheduler.apache.org/images/logo_400x400.jpg";;
+    script.dataset.modalDisclaimer =
+      "This is a custom LLM for Apache DolphinScheduler with access to all 
developer Documentation, Blog, GitHub issues and discussions.";
+    script.dataset.modalExampleQuestions =
+      "Why we need DolphinScheduler?,How to deploy DolphinScheduler?,How to 
submit task?,How to contribute?";

Review Comment:
   [nitpick] The example questions lack spacing after commas, which affects 
readability. Consider adding a space after each comma for better formatting:
   
   ```javascript
   script.dataset.modalExampleQuestions =
     "Why we need DolphinScheduler?, How to deploy DolphinScheduler?, How to 
submit task?, How to contribute?";
   ```
   ```suggestion
         "Why we need DolphinScheduler?, How to deploy DolphinScheduler?, How 
to submit task?, How to contribute?";
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to