From 902f5c259e477e8c3a19a236d05040090452b93a Mon Sep 17 00:00:00 2001 From: ajasma6570 Date: Sat, 7 Sep 2024 18:48:54 +0530 Subject: [PATCH] createDoc: deploy git added --- web/package-lock.json | 122 ++++- web/package.json | 1 + web/public/locales/en/translation.json | 7 +- web/src/api/Requests.ts | 5 + .../CreateDocumentModal/CreateDocModal.tsx | 452 +++++++++++------- web/src/types/doc.ts | 5 + web/src/utils/Common.ts | 37 ++ 7 files changed, 451 insertions(+), 178 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index 34a4dbd..3beb9ee 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -13,6 +13,7 @@ "@blocknote/react": "^0.15.4", "@emoji-mart/data": "^1.2.1", "@emoji-mart/react": "^1.1.1", + "@headlessui/react": "^2.1.5", "@hello-pangea/dnd": "^16.6.0", "@iconify/icons-mdi": "^1.2.48", "@iconify/react": "^5.0.1", @@ -1072,6 +1073,24 @@ "integrity": "sha512-XGndio0l5/Gvd6CLIABvsav9HHezgDFFhDfHk1bvLfr9ni8dojqLSvBbotJEjmIwNHL7vK4QzBJTdBRoB+c1ww==", "license": "MIT" }, + "node_modules/@headlessui/react": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-2.1.5.tgz", + "integrity": "sha512-m3vzqwMTyDbgaNiSXQdrw8R4tRdnxVHHm4G/ZGS0TP6T8blEj3Ib1/zIJBzlvTXpBjTpd1DsUnRTonHyONMjSQ==", + "dependencies": { + "@floating-ui/react": "^0.26.16", + "@react-aria/focus": "^3.17.1", + "@react-aria/interactions": "^3.21.3", + "@tanstack/react-virtual": "^3.8.1" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^18", + "react-dom": "^18" + } + }, "node_modules/@hello-pangea/dnd": { "version": "16.6.0", "resolved": "https://registry.npmjs.org/@hello-pangea/dnd/-/dnd-16.6.0.tgz", @@ -1933,6 +1952,83 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@react-aria/focus": { + "version": "3.18.2", + "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.18.2.tgz", + "integrity": "sha512-Jc/IY+StjA3uqN73o6txKQ527RFU7gnG5crEl5Xy3V+gbYp2O5L3ezAo/E0Ipi2cyMbG6T5Iit1IDs7hcGu8aw==", + "dependencies": { + "@react-aria/interactions": "^3.22.2", + "@react-aria/utils": "^3.25.2", + "@react-types/shared": "^3.24.1", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@react-aria/interactions": { + "version": "3.22.2", + "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.22.2.tgz", + "integrity": "sha512-xE/77fRVSlqHp2sfkrMeNLrqf2amF/RyuAS6T5oDJemRSgYM3UoxTbWjucPhfnoW7r32pFPHHgz4lbdX8xqD/g==", + "dependencies": { + "@react-aria/ssr": "^3.9.5", + "@react-aria/utils": "^3.25.2", + "@react-types/shared": "^3.24.1", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@react-aria/ssr": { + "version": "3.9.5", + "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.5.tgz", + "integrity": "sha512-xEwGKoysu+oXulibNUSkXf8itW0npHHTa6c4AyYeZIJyRoegeteYuFpZUBPtIDE8RfHdNsSmE1ssOkxRnwbkuQ==", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@react-aria/utils": { + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.25.2.tgz", + "integrity": "sha512-GdIvG8GBJJZygB4L2QJP1Gabyn2mjFsha73I2wSe+o4DYeGWoJiMZRM06PyTIxLH4S7Sn7eVDtsSBfkc2VY/NA==", + "dependencies": { + "@react-aria/ssr": "^3.9.5", + "@react-stately/utils": "^3.10.3", + "@react-types/shared": "^3.24.1", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@react-stately/utils": { + "version": "3.10.3", + "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.3.tgz", + "integrity": "sha512-moClv7MlVSHpbYtQIkm0Cx+on8Pgt1XqtPx6fy9rQFb2DNc9u1G3AUVnqA17buOkH1vLxAtX4MedlxMWyRCYYA==", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@react-types/shared": { + "version": "3.24.1", + "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.24.1.tgz", + "integrity": "sha512-AUQeGYEm/zDTN6zLzdXolDxz3Jk5dDL7f506F07U8tBwxNNI3WRdhU84G0/AaFikOZzDXhOZDr3MhQMzyE7Ydw==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/@remirror/core-constants": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@remirror/core-constants/-/core-constants-2.0.2.tgz", @@ -2261,11 +2357,35 @@ "version": "0.5.11", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.11.tgz", "integrity": "sha512-YNlnKRWF2sVojTpIyzwou9XoTNbzbzONwRhOoniEioF1AtaitTvVZblaQRrAzChWQ1bLYyYSWzM18y4WwgzJ+A==", - "dev": true, "dependencies": { "tslib": "^2.4.0" } }, + "node_modules/@tanstack/react-virtual": { + "version": "3.10.7", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.10.7.tgz", + "integrity": "sha512-yeP+M0G8D+15ZFPivpuQ5hoM4Fa/PzERBx8P8EGcfEsXX3JOb9G9UUrqc47ZXAxvK+YqzM9T5qlJUYUFOwCZJw==", + "dependencies": { + "@tanstack/virtual-core": "3.10.7" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@tanstack/virtual-core": { + "version": "3.10.7", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.10.7.tgz", + "integrity": "sha512-ND5dfsU0n9F4gROzwNNDJmg6y8n9pI8YWxtgbfJ5UcNn7Hx+MxEXtXcQ189tS7sh8pmCObgz2qSiyRKTZxT4dg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@tiptap/core": { "version": "2.5.9", "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.5.9.tgz", diff --git a/web/package.json b/web/package.json index 4fb6092..df17521 100644 --- a/web/package.json +++ b/web/package.json @@ -8,6 +8,7 @@ "@blocknote/react": "^0.15.4", "@emoji-mart/data": "^1.2.1", "@emoji-mart/react": "^1.1.1", + "@headlessui/react": "^2.1.5", "@hello-pangea/dnd": "^16.6.0", "@iconify/icons-mdi": "^1.2.48", "@iconify/react": "^5.0.1", diff --git a/web/public/locales/en/translation.json b/web/public/locales/en/translation.json index 6296213..afad81c 100644 --- a/web/public/locales/en/translation.json +++ b/web/public/locales/en/translation.json @@ -83,7 +83,12 @@ "no_search_found":"No Search Found", "move":"Move", "enableAuthentication":"Enable Authentication", - + "deploy_to_git":"Deploy to Git", + "git_user":"Git User", + "git_repo":"Git Repo", + "git_email":"Git Email", + "git_password":"Git Password", + "git_branch":"Git Branch", "clone_documentation": "Clone Documentation", "delete_documentation": "Delete Documentation", diff --git a/web/src/api/Requests.ts b/web/src/api/Requests.ts index 5153463..2b67b3e 100644 --- a/web/src/api/Requests.ts +++ b/web/src/api/Requests.ts @@ -40,6 +40,11 @@ export interface DocumentationPayload { moreLabelLinks?: MoreLabelLinks[] | string; copyrightText: string; requireAuth?: boolean; + gitUser?: string; + gitRepo?: string; + gitEmail?: string; + gitPassword?: string; + gitBranch?: string; } interface CreateVersionPayload { diff --git a/web/src/components/CreateDocumentModal/CreateDocModal.tsx b/web/src/components/CreateDocumentModal/CreateDocModal.tsx index 80729d3..2c7106a 100644 --- a/web/src/components/CreateDocumentModal/CreateDocModal.tsx +++ b/web/src/components/CreateDocumentModal/CreateDocModal.tsx @@ -7,6 +7,7 @@ import data from "@emoji-mart/data"; import { EmojiMartData } from "@emoji-mart/data"; import Picker from "@emoji-mart/react"; import EmojiClickData from "@emoji-mart/react"; +import { Field, Label, Switch } from "@headlessui/react"; import { Icon } from "@iconify/react"; import { AnimatePresence, motion } from "framer-motion"; import React, { useContext, useEffect, useRef, useState } from "react"; @@ -145,7 +146,6 @@ const LabelAndCommunityComponent = ({
{t("link")} - * (false); const [isToggleOn, SetIsToggleOn] = useState(false); + const [gitDeployOn, SetGitDeployOn] = useState(false); const [activeFieldIndex, setActiveFieldIndex] = useState(null); const [showEmojiPicker, setShowEmojiPicker] = useState(false); const inputRefs = useRef<(HTMLInputElement | null)[]>([]); @@ -249,6 +255,11 @@ export default function CreateDocModal() { navImage: "", copyrightText: "", metaImage: "", + gitUser: "", + gitRepo: "", + gitEmail: "", + gitPassword: "", + gitBranch: "", }); const [moreField, setMoreField] = useState([ @@ -275,7 +286,7 @@ export default function CreateDocModal() { useOutsideAlerter(socialMediaRef, () => setIsIconSelectOpen(false)); useEffect(() => { - if (isToggleOn) { + if (isToggleOn || gitDeployOn) { window.scrollTo({ top: document.documentElement.scrollHeight, behavior: "smooth", @@ -286,7 +297,7 @@ export default function CreateDocModal() { behavior: "smooth", }); } - }, [isToggleOn]); + }, [isToggleOn, gitDeployOn]); useEffect(() => { if (mode === "edit") { @@ -298,6 +309,9 @@ export default function CreateDocModal() { const data: Documentation = result.data; setFormData(data); + if (data.gitUser) { + SetGitDeployOn(true); + } const footerLabelLinks: FooterLabelLinks[] = Array.isArray( data.footerLabelLinks, ) @@ -364,6 +378,11 @@ export default function CreateDocModal() { navImage: "", copyrightText: "", metaImage: "", + gitUser: "", + gitRepo: "", + gitEmail: "", + gitPassword: "", + gitBranch: "", }); SetIsAuthenticationToggleOn(false); setSocialPlatformField([{ icon: "", link: "" }]); @@ -434,7 +453,9 @@ export default function CreateDocModal() { }; const handleCreateDocument = async () => { - const validate = validateFormData(formData); + console.log(formData); + + const validate = validateFormData(formData, gitDeployOn); if (validate.status) { toastMessage(t(validate.message), "error"); return; @@ -460,6 +481,16 @@ export default function CreateDocModal() { const landingData = isToggleOn ? landingPage : {}; + const gitFields = gitDeployOn + ? { + gitUser: formData.gitUser || "", + gitRepo: formData.gitRepo || "", + gitEmail: formData.gitEmail || "", + gitPassword: formData.gitPassword || "", + gitBranch: formData.gitBranch || "", + } + : {}; + const payload: DocumentationPayload = { id: docId, name: formData.name || "", @@ -476,6 +507,7 @@ export default function CreateDocModal() { copyrightText: formData.copyrightText || "", metaImage: formData.metaImage || "", requireAuth: isAuthenticationToggleOn || false, + ...gitFields, landerDetails: JSON.stringify(landingData), footerLabelLinks: socialPlatformField ? JSON.stringify(socialPlatformField) @@ -590,7 +622,6 @@ export default function CreateDocModal() { updateFeature(index, "emoji", emojiObject.unified); setShowEmojiPicker(false); }; - console.log(isAuthenticationToggleOn); return ( @@ -916,187 +947,256 @@ export default function CreateDocModal() {
- - - {isToggleOn && ( -
-
- ) => { - updateCtaButtonText( - "ctaButtonLinkLabel", - e.target.value, - "ctaButtonText", - ); - }} - required={true} - /> +
+ - ) => { - updateCtaButtonText( - "ctaButtonLink", - e.target.value, - "ctaButtonText", - ); - }} - type="url" - required={true} - /> -
+ {isToggleOn && ( +
+
+ ) => { + updateCtaButtonText( + "ctaButtonLinkLabel", + e.target.value, + "ctaButtonText", + ); + }} + required={true} + /> -
- ) => - updateCtaButtonText( - "ctaButtonLinkLabel", - e.target.value, - "secondCtaButtonText", - ) - } - /> - ) => - updateCtaButtonText( - "ctaButtonLink", - e.target.value, - "secondCtaButtonText", - ) - } - type="url" - /> - ) => - setLandingPage((prevState) => ({ - ...prevState, - ctaImageLink: e.target.value, - })) - } - name="ctaImageLink" - type="url" - required={true} - /> -
+ ) => { + updateCtaButtonText( + "ctaButtonLink", + e.target.value, + "ctaButtonText", + ); + }} + type="url" + required={true} + /> +
-
- - {t("features")} - -
-
+
+ ) => + updateCtaButtonText( + "ctaButtonLinkLabel", + e.target.value, + "secondCtaButtonText", + ) + } + /> + ) => + updateCtaButtonText( + "ctaButtonLink", + e.target.value, + "secondCtaButtonText", + ) + } + type="url" + /> + ) => + setLandingPage((prevState) => ({ + ...prevState, + ctaImageLink: e.target.value, + })) + } + name="ctaImageLink" + type="url" + required={true} + /> +
- {landingPage.features.map((obj, index) => ( -
-
- - {t("emoji")} - - (inputRefs.current[index] = el)} - onFocus={() => toggleEmojiPicker(index)} - placeholder={`${convertToEmoji("26a1")} ${t("pick_your_emoji")}`} - className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - value={convertToEmoji(obj.emoji)} - readOnly - /> - {activeFieldIndex === index && showEmojiPicker && ( -
- - handleEmojiClick(index, emoji) +
+ + {t("features")} + +
+
+ + {landingPage.features.map((obj, index) => ( +
+
+ + {t("emoji")} + + (inputRefs.current[index] = el)} + onFocus={() => toggleEmojiPicker(index)} + placeholder={`${convertToEmoji("26a1")} ${t("pick_your_emoji")}`} + className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" + value={convertToEmoji(obj.emoji)} + readOnly + /> + {activeFieldIndex === index && showEmojiPicker && ( +
-
- )} -
+ style={{ transform: "translateY(-110%)" }} + > + + handleEmojiClick(index, emoji) + } + /> +
+ )} +
-
- - {t("title_label")} - - - updateFeature(index, "title", e.target.value) - } - value={obj.title} - type="text" - placeholder={t("landing_page_title_placeholder")} - className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - /> -
+
+ + {t("title_label")} + + + updateFeature(index, "title", e.target.value) + } + value={obj.title} + type="text" + placeholder={t("landing_page_title_placeholder")} + className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" + /> +
-
- - {t("text")} - - - updateFeature(index, "text", e.target.value) - } - value={obj.text} - type="text" - id="feature_desc" - placeholder={t("text_placeholder")} - className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" - /> +
+ + {t("text")} + + + updateFeature(index, "text", e.target.value) + } + value={obj.text} + type="text" + id="feature_desc" + placeholder={t("text_placeholder")} + className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" + /> +
+ ))} +
+ Promise.resolve(addRow("feature-filed"))} + /> + + Promise.resolve(deleteRow("feature-filed")) + } + />
- ))} -
- Promise.resolve(addRow("feature-filed"))} - /> - - Promise.resolve(deleteRow("feature-filed")) - } - />
-
- )} + )} +
+ +
+ + + + + + + + {gitDeployOn && ( +
+
+ + + +
+ +
+ + + +
+
+ )} +