From e5ee0ba9466ef65c247f2928caccca8982a8cc52 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 14 Aug 2024 15:08:59 -0300 Subject: [PATCH] refactor: Add ComponentTextModal and Prompt modal for displaying and editing text areas and components (#3346) * add separated component for prompt modal * refactor: rename promptAreaModal to promptModal and update type import * refactor: update promptComponent to use PromptModal instead of GenericModal * refactor: update textarea-primary class in applies.css * refactor: add ComponentTextModal for displaying and editing text areas Add a new component, ComponentTextModal, for displaying and editing text areas. This component includes a textarea input, a title, and an icon. It also supports password visibility toggling. The ComponentTextModal is used within a BaseModal component and includes a save button for finishing the editing process. This commit refactors the code to add the ComponentTextModal and its related functionality. * refactor: Add ComponentTextModal for displaying and editing text areas * delete genericModal component and their references * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../src/components/promptComponent/index.tsx | 11 +- .../components/textAreaComponent/index.tsx | 11 +- .../{genericModal => promptModal}/index.tsx | 174 +++++------------- .../utils/var-highlight-html.tsx | 0 .../src/modals/textAreaModal/index.tsx | 106 +++++++++++ src/frontend/src/style/applies.css | 2 +- src/frontend/src/types/components/index.ts | 22 +++ 7 files changed, 186 insertions(+), 140 deletions(-) rename src/frontend/src/modals/{genericModal => promptModal}/index.tsx (63%) rename src/frontend/src/modals/{genericModal => promptModal}/utils/var-highlight-html.tsx (100%) create mode 100644 src/frontend/src/modals/textAreaModal/index.tsx diff --git a/src/frontend/src/components/promptComponent/index.tsx b/src/frontend/src/components/promptComponent/index.tsx index c2e721baf..3d3ed8084 100644 --- a/src/frontend/src/components/promptComponent/index.tsx +++ b/src/frontend/src/components/promptComponent/index.tsx @@ -1,7 +1,5 @@ +import PromptModal from "@/modals/promptModal"; import { useEffect } from "react"; - -import { TypeModal } from "../../constants/enums"; -import GenericModal from "../../modals/genericModal"; import { PromptAreaComponentType } from "../../types/components"; import IconComponent from "../genericIconComponent"; import { Button } from "../ui/button"; @@ -25,14 +23,11 @@ export default function PromptAreaComponent({ return (
- - +
); } diff --git a/src/frontend/src/components/textAreaComponent/index.tsx b/src/frontend/src/components/textAreaComponent/index.tsx index 67e1251ed..2894c2a13 100644 --- a/src/frontend/src/components/textAreaComponent/index.tsx +++ b/src/frontend/src/components/textAreaComponent/index.tsx @@ -1,8 +1,6 @@ +import ComponentTextModal from "@/modals/textAreaModal"; import { classNames } from "@/utils/utils"; import { useEffect } from "react"; -import { EDIT_TEXT_MODAL_TITLE } from "../../constants/constants"; -import { TypeModal } from "../../constants/enums"; -import GenericModal from "../../modals/genericModal"; import { TextAreaComponentType } from "../../types/components"; import IconComponent from "../genericIconComponent"; import { Button } from "../ui/button"; @@ -47,11 +45,8 @@ export default function TextAreaComponent({ onChange(event.target.value); }} /> - { onChange(value); @@ -76,7 +71,7 @@ export default function TextAreaComponent({ /> - + {password !== undefined && ( - - )}
- {type === TypeModal.PROMPT && isEdit && !readonly ? ( + {isEdit && !readonly ? (