From d0aa37930cd2dca46aa9b4adec140f86f54fea76 Mon Sep 17 00:00:00 2001 From: Rohit Kini Date: Thu, 11 Jul 2024 17:22:57 +0530 Subject: [PATCH 01/10] added comments on some UI files and looger windows functionality --- api/src/server.ts | 3 +- ui/src/common/assets/icons.tsx | 4 + ui/src/common/assets/index.ts | 3 + .../AccountPage/accountPage.interface.ts | 3 + ui/src/components/AccountPage/index.scss | 28 ++++ ui/src/components/AccountPage/index.tsx | 7 + .../advanceProperties.interface.ts | 62 ++++++++ .../components/AdvancePropertise/index.scss | 31 +++- ui/src/components/AdvancePropertise/index.tsx | 27 +++- ui/src/components/Card/card.interface.ts | 3 + ui/src/components/Card/card.scss | 80 ++++++++++- ui/src/components/Card/index.tsx | 6 + .../Common/AddStack/addStack.interface.ts | 30 ++++ .../components/Common/AddStack/addStack.scss | 14 ++ .../components/Common/AddStack/addStack.tsx | 7 + .../components/Common/Card/card.interface.ts | 22 +++ ui/src/components/Common/Card/card.scss | 43 ++++-- ui/src/components/Common/Card/card.tsx | 8 +- .../Common/DeleteProjectModal/index.tsx | 16 ++- ui/src/components/Common/DocLink/DocLink.tsx | 15 ++ .../Common/FileUpload/fileupload.scss | 21 +++ ui/src/components/Common/FileUpload/index.tsx | 40 ++++++ .../components/Common/FileUpload/upload.scss | 36 +++++ .../components/Common/FileUpload/upload.tsx | 4 + .../Common/Modal/FilterModal/FilterModal.scss | 96 ++++++++++--- .../Common/Modal/FilterModal/FilterModal.tsx | 8 ++ .../FilterModal/filterModal.interface.ts | 3 + .../Common/NotificationModal/index.tsx | 44 +++--- .../components/Common/ProgressBar/index.tsx | 7 + .../Common/ProgressBar/progressBar.scss | 21 ++- .../components/Common/Settings/Settings.scss | 83 +++++++---- ui/src/components/Common/Settings/index.tsx | 4 + .../Common/Settings/setting.interface.ts | 3 + .../Common/WordWrapper/WordWrapper.tsx | 6 + ui/src/components/Common/private-route.tsx | 8 ++ ui/src/components/Common/router.tsx | 4 + .../ContentMapper/contentMapper.interface.ts | 16 +++ ui/src/components/ContentMapper/index.scss | 32 +++++ ui/src/components/ContentMapper/index.tsx | 4 + .../Actions/LoadOrganisation.tsx | 80 ++++------- .../LegacyCms/Actions/LoadFileFormat.tsx | 2 +- ui/src/components/LogScreen/index.scss | 60 +++++--- ui/src/components/LogScreen/index.tsx | 133 +++++++++++++----- uplaode-api/src/config/index.ts | 4 +- 44 files changed, 923 insertions(+), 208 deletions(-) diff --git a/api/src/server.ts b/api/src/server.ts index 678121af..d8fbb2e8 100644 --- a/api/src/server.ts +++ b/api/src/server.ts @@ -55,7 +55,8 @@ try { logger.info(`Server listening at port ${config.PORT}`) ); // Chokidar - Watch for log file changes - const logFilePath = "/Users/sayali.joshi/Projects/migration-v2-node-server/api/combine.log"; // Replace with the actual path to your log file + ///Users/rohit/migration-v2-node-server/api/combine.log + const logFilePath = "/Users/rohit/migration-v2-node-server/api/combine.log"; // Replace with the actual path to your log file const watcher = chokidar.watch(logFilePath); // Socket.IO - Send logs to client const io = new Server( diff --git a/ui/src/common/assets/icons.tsx b/ui/src/common/assets/icons.tsx index 179668e2..e7a7b67e 100644 --- a/ui/src/common/assets/icons.tsx +++ b/ui/src/common/assets/icons.tsx @@ -1,3 +1,6 @@ +/** + * This file contains the definition of the SVG icon component. + */ export const NO_PROJECTS_SEARCH = ( ); + export const NO_PROJECTS = ( { const { heading, copyrightText } = props.data; diff --git a/ui/src/components/AdvancePropertise/advanceProperties.interface.ts b/ui/src/components/AdvancePropertise/advanceProperties.interface.ts index 6ce7ae7f..854de204 100644 --- a/ui/src/components/AdvancePropertise/advanceProperties.interface.ts +++ b/ui/src/components/AdvancePropertise/advanceProperties.interface.ts @@ -34,20 +34,82 @@ export interface Props { handleToggle?: (field: string, value: boolean, checkBoxChanged: boolean) => void; } +/** + * Represents the state type for advanced properties. + */ export interface StateType { + /** + * The minimum number of characters allowed. + */ minChars?: string; + + /** + * The maximum number of characters allowed. + */ maxChars?: number; + + /** + * The minimum range allowed. + */ minRange?: number; + + /** + * The maximum range allowed. + */ maxRange?: number; + + /** + * The minimum size allowed. + */ minSize?: string; + + /** + * The maximum size allowed. + */ maxSize?: number; + + /** + * The default value. + */ defaultValue?: string; + + /** + * The validation regular expression. + */ validationRegex?: string; + + /** + * The title. + */ title?: string; + + /** + * The URL. + */ url?: string; + + /** + * Indicates if the field is mandatory. + */ mandatory?: boolean; + + /** + * Indicates if only images are allowed. + */ allowImagesOnly?: boolean; + + /** + * Indicates if the field is non-localizable. + */ nonLocalizable?: boolean; + + /** + * Indicates if the object should be embedded. + */ embedObject?: boolean; + + /** + * Indicates if the assets should be embedded. + */ embedAssests?: boolean; } \ No newline at end of file diff --git a/ui/src/components/AdvancePropertise/index.scss b/ui/src/components/AdvancePropertise/index.scss index 212c06f8..5fa6c7ef 100644 --- a/ui/src/components/AdvancePropertise/index.scss +++ b/ui/src/components/AdvancePropertise/index.scss @@ -1,3 +1,7 @@ +/** + * Styles for the AdvancePropertise component. + */ + @import '../../scss/variables'; .options-class { @@ -9,36 +13,46 @@ grid-template-columns: 1fr; gap: 20px; } + .option-label { margin-bottom: $px-10; } + .non-localizable-message { margin-top: 0; margin-left: 30px; } + .modal-data { padding: 0.75rem; + .radio-field { margin-bottom: 0.75rem; } + .Radio { width: calc(33.33333% - .66667rem); padding: .5rem; margin: 0 !important; } + .FieldLabel { margin-bottom: $px-8; } + .info-style { margin-top: .75rem; margin-bottom: 1.5rem; + .Info__border { border-left-color: #0469e3; } } + .options-class { line-height: $line-height-reset; } + .nl-note { color: $color-font-base; font-size: $size-font-large; @@ -46,17 +60,21 @@ margin-left: 2.75rem; margin-top: -.25rem !important; } + .ToggleWrap { margin-top: 0.5rem; - padding: 0 0.5rem + padding: 0 0.5rem; } + .Field { margin-bottom: $px-24; } + .fields-group-separator { color: $color-base-black-base; margin: 0 16px; } + .Select { .Select__menu { .Select__menu-list { @@ -65,20 +83,23 @@ align-items: center; display: flex; } + .Checkbox__label { height: auto; } - } + } } - } - } + } + } + .Select__menu { position: relative; z-index: 10000; } + .Select__control--menu-is-open { position: relative; border: 2px solid red; z-index: 10000; - } + } } diff --git a/ui/src/components/AdvancePropertise/index.tsx b/ui/src/components/AdvancePropertise/index.tsx index 373737a5..060d9f93 100644 --- a/ui/src/components/AdvancePropertise/index.tsx +++ b/ui/src/components/AdvancePropertise/index.tsx @@ -22,7 +22,13 @@ import { ContentType } from '../ContentMapper/contentMapper.interface'; // Styles import './index.scss'; +/** + * Component for displaying advanced properties. + * @param props - The schema properties. + * @returns The rendered component. + */ const AdvancePropertise = (props: SchemaProps) => { + // State for toggle states const [toggleStates, setToggleStates] = useState({ minChars: props?.value?.MinChars, maxChars: props?.value?.MaxChars, @@ -41,6 +47,7 @@ const AdvancePropertise = (props: SchemaProps) => { embedAssests: true }); + // State for content types const [contentTypes, setContentTypes] = useState([]); const [ctValue, setCTValue] = useState(null); @@ -48,13 +55,22 @@ const AdvancePropertise = (props: SchemaProps) => { fetchContentTypes(''); }, []) - // Fetch content types list + /** + * Fetches the content types list. + * @param searchText - The search text. + */ const fetchContentTypes = async (searchText: string) => { const { data } = await getContentTypes(props?.projectId ?? '', 0, 10, searchText || ''); //org id will always present setContentTypes(data?.contentTypes); }; + /** + * Handles the change event for input fields. + * @param field - The field name. + * @param event - The change event. + * @param checkBoxChanged - Indicates if the checkbox was changed. + */ const handleOnChange = (field: string, event: React.ChangeEvent, checkBoxChanged: boolean) => { setToggleStates((prevStates) => ({ ...prevStates, @@ -76,6 +92,12 @@ const AdvancePropertise = (props: SchemaProps) => { ); }; + /** + * Handles the toggle change event. + * @param field - The field name. + * @param value - The new value. + * @param checkBoxChanged - Indicates if the checkbox was changed. + */ const handleToggleChange = (field: string, value: boolean, checkBoxChanged: boolean) => { setToggleStates((prevStates) => ({ ...prevStates, @@ -97,13 +119,14 @@ const AdvancePropertise = (props: SchemaProps) => { ); }; + // Option for content types const option = Array.isArray(contentTypes) ? contentTypes.map((option) => ({ label: option?.otherCmsTitle, value: option?.otherCmsTitle })) : [{ label: contentTypes, value: contentTypes }]; return ( <> - +
{(props?.fieldtype === 'Single Line Textbox' || props?.fieldtype === 'Multi Line Textbox') && ( diff --git a/ui/src/components/Card/card.interface.ts b/ui/src/components/Card/card.interface.ts index 74c43df1..fe72a87b 100644 --- a/ui/src/components/Card/card.interface.ts +++ b/ui/src/components/Card/card.interface.ts @@ -1,5 +1,8 @@ import { ProjectsObj } from '../../pages/Projects/projects.interface'; +/** + * Represents the project type. + */ export interface ProjectType { project?: ProjectsObj; } diff --git a/ui/src/components/Card/card.scss b/ui/src/components/Card/card.scss index 8a3917ea..a186d11a 100644 --- a/ui/src/components/Card/card.scss +++ b/ui/src/components/Card/card.scss @@ -1,5 +1,7 @@ @import '../../scss/variables'; - +/** + * Styles for the ProjectCard component. + */ .ProjectCard { background: $color-brand-white-base; border-radius: 0.6rem; @@ -7,14 +9,26 @@ transition: box-shadow 0.3s ease; width: 20rem; } + +/** + * Styles for the wrapper of the ProjectCard component. + */ .ProjectCardWrapper { padding: 18px; } + +/** + * Styles for the heading of the ProjectCard component. + */ .ProjectCard__heading { display: flex; margin-bottom: $px-20; padding: 0; } + +/** + * Styles for the title of the ProjectCard component. + */ .ProjectCard__title { color: $color-font-base; display: -webkit-box; @@ -28,6 +42,10 @@ -webkit-line-clamp: 2; -webkit-box-orient: vertical; } + +/** + * Styles for the footer of the ProjectCard component. + */ .ProjectCard__footer { display: flex; position: relative; @@ -39,14 +57,26 @@ padding: 0.9375rem 1.875rem; align-items: center; } + +/** + * Styles for the content of the ProjectCard component. + */ .ProjectCard__content { // margin: 0 1rem 2rem; padding: 0; text-align: center; } + +/** + * Styles for the status unit of the ProjectCard component. + */ .ProjectCard__Staus-unit { padding: 0 1em; } + +/** + * Styles for the unit of the ProjectCard component. + */ .ProjectCard__unit { border-left: 1px solid $color-brand-secondary-lightest; padding: 0 1em; @@ -60,6 +90,10 @@ justify-content: center; padding-bottom: $px-10; } + +/** + * Styles for the stats category of the ProjectCard component. + */ .ProjectCard__stats-category { border: 1px solid $color-brand-secondary-lightest; border-radius: 8px; @@ -84,15 +118,55 @@ background-color: $color-brand-attention-light; } } + +/** + * Styles for the draft stats category of the ProjectCard component. + */ +.ProjectCard__stats-category.draft { + background-color: $color-base-white-10; +} + +/** + * Styles for the completed stats category of the ProjectCard component. + */ +.ProjectCard__stats-category.completed { + background-color: $color-brand-success-light; +} + +/** + * Styles for the failed stats category of the ProjectCard component. + */ +.ProjectCard__stats-category.failed { + background-color: $color-brand-fail-light; +} + +/** + * Styles for the pending stats category of the ProjectCard component. + */ +.ProjectCard__stats-category.pending { + background-color: $color-brand-attention-light; +} + +/** + * Styles for the stats title of the ProjectCard component. + */ .ProjectCard__stats-Title { color: $color-stepper-title; display: block; font-size: $size-font-small; margin-bottom: $space-4; } + +/** + * Styles for the validation color of the ProjectCard component. + */ .validation-color { color: $color-brand-warning-medium; } + +/** + * Styles for the CMS of the ProjectCard component. + */ .ProjectCard__cms { border: 1px solid $color-brand-secondary-lightest; border-radius: 8px; @@ -101,6 +175,10 @@ padding: 4px 8px; text-transform: capitalize; } + +/** + * Styles for the modified date of the ProjectCard component. + */ .ProjectCard__modified-date { color: $color-stepper-title; display: block; diff --git a/ui/src/components/Card/index.tsx b/ui/src/components/Card/index.tsx index 44bc169f..09e1c623 100644 --- a/ui/src/components/Card/index.tsx +++ b/ui/src/components/Card/index.tsx @@ -12,6 +12,12 @@ import { getProject } from '../../services/api/project.service'; import './card.scss'; import { RootState } from '../../store'; +/** + * Renders a card component for a project in a list. + * @param {ProjectType} project - The project object. + * @returns {JSX.Element} The card component. + */ + const CardList = ({ project }: ProjectType) => { const navigate = useNavigate(); diff --git a/ui/src/components/Common/AddStack/addStack.interface.ts b/ui/src/components/Common/AddStack/addStack.interface.ts index da16ddc9..a1e64fa0 100644 --- a/ui/src/components/Common/AddStack/addStack.interface.ts +++ b/ui/src/components/Common/AddStack/addStack.interface.ts @@ -19,19 +19,49 @@ export interface SecondaryCta { title: string; } +/** + * Interface representing the default data for AddStackCMSData. + */ export const defaultAddStackCMSData: AddStackCMSData = { + /** + * The title of the primary call-to-action button. + */ primary_cta: { title: '' }, + /** + * The title of the secondary call-to-action button. + */ secondary_cta: { title: '' }, + /** + * The description of the stack. + */ stack_description: '', + /** + * The placeholder for the stack description. + */ stack_description_placeholder: '', + /** + * The locale-specific description of the stack. + */ stack_locale_description: '', + /** + * The locales supported by the stack. + */ stack_locales: '', + /** + * The name of the stack. + */ stack_name: '', + /** + * The placeholder for the stack name. + */ stack_name_placeholder: '', + /** + * The title of the stack. + */ title: '' }; diff --git a/ui/src/components/Common/AddStack/addStack.scss b/ui/src/components/Common/AddStack/addStack.scss index 5a6647c8..4d85d21a 100644 --- a/ui/src/components/Common/AddStack/addStack.scss +++ b/ui/src/components/Common/AddStack/addStack.scss @@ -1,3 +1,17 @@ +/** + * FILEPATH: /Users/rohit/migration-v2-node-server/ui/src/components/Common/AddStack/addStack.scss + * + * Styles for the ReactModal component used in the AddStack component. + * + * .ReactModal__add-stack - Styles for the parent container of the ReactModal component in the AddStack component. + * .Description-field > textarea - Styles for the textarea element inside the .Description-field class. + * resize: none; - Disables the ability to resize the textarea. + * .Select__single-value - Styles for the single-value element inside the .Select class. + * width: 200px !important; - Sets the width of the single-value element to 200 pixels, overriding any other styles. + * + * .ReactModal__Overlay .ReactModal__Content .ReactModal__Content__body.selectWrapperBody - Styles for the selectWrapperBody element inside the ReactModal component. + * overflow: visible; - Sets the overflow property of the selectWrapperBody element to visible. + */ .ReactModal__add-stack { .Description-field > textarea { resize: none; diff --git a/ui/src/components/Common/AddStack/addStack.tsx b/ui/src/components/Common/AddStack/addStack.tsx index f1cd4300..d7599e51 100644 --- a/ui/src/components/Common/AddStack/addStack.tsx +++ b/ui/src/components/Common/AddStack/addStack.tsx @@ -37,6 +37,13 @@ export interface Stack { locale: string; } +/** + * Renders the AddStack component. + * + * @param props - The component props. + * @returns The JSX element representing the AddStack component. + */ + const AddStack = (props: any): JSX.Element => { const [isProcessing, setIsProcessing] = useState(false); const [isLoading, setIsLoading] = useState(true); diff --git a/ui/src/components/Common/Card/card.interface.ts b/ui/src/components/Common/Card/card.interface.ts index c4847848..25ea31bf 100644 --- a/ui/src/components/Common/Card/card.interface.ts +++ b/ui/src/components/Common/Card/card.interface.ts @@ -1,8 +1,30 @@ +/** + * Represents the interface for a card type. + */ export interface ICardType { + /** + * The title of the card. + */ title: string; + + /** + * The group name of the card. + */ group_name?: string; + + /** + * The description of the card. + */ description?: string; + + /** + * The CMS ID of the card. + */ cms_id?: string; + + /** + * The file format ID of the card. + */ fileformat_id?: string; } diff --git a/ui/src/components/Common/Card/card.scss b/ui/src/components/Common/Card/card.scss index 6d90f282..c69f942d 100644 --- a/ui/src/components/Common/Card/card.scss +++ b/ui/src/components/Common/Card/card.scss @@ -1,5 +1,9 @@ @import '../../../scss/variables'; +/** + * Styles for the card component. + */ +// Styles for the service list container .service_list { text-align: center; display: flex; @@ -9,21 +13,33 @@ margin-bottom: 10px; } +// Styles for the trigger list container .trigger_list { min-width: 120px !important; } -.connector_list .tippy-box-light { - max-width: $px-360 !important; - padding: $px-15 !important; - line-height: 130%; - font-size: $px-12; - font-weight: $font-weight-regular; +// Styles for the connector list container +.connector_list { + // Styles for the tooltip box within the connector list + .tippy-box-light { + max-width: $px-360 !important; + padding: $px-15 !important; + line-height: 130%; + font-size: $px-12; + font-weight: $font-weight-regular; + } + + // Styles for the help text within the connector list tooltip box + .tippy-box-light #automationConnectorsHelpText { + cursor: default; + color: $color-base-gray-20; + } } -.connector_list, +// Styles for the action list and trigger list containers .action_list, .trigger_list { + // Styles for the container border //border: 1px solid $color-base-gray-40; border: 1px solid #6C5CE766; border-radius: $px-6; @@ -35,19 +51,17 @@ gap: 12px; } -.connector_list .tippy-box-light #automationConnectorsHelpText { - cursor: default; - color: $color-base-gray-20; -} - +// Styles for the connector list container on hover .connector_list:hover { box-shadow: 0 3px $px-5 $px-2 rgb(215 215 215); } +// Styles for the service icon .service_icon { padding: $space-20 0; } +// Styles for the service title .service_title { padding: $px-5 $px-5; min-height: $px-40; @@ -59,6 +73,7 @@ background: $color-base-white-10; } +// Styles for the full-screen page layout head .PageLayout--full-screen .PageLayout__head { position: relative; border-bottom: 1px solid rgb(226, 235, 248); @@ -67,6 +82,8 @@ margin-top: 3.5rem; z-index: 8; } -.centered-card-title{ + +// Styles for the centered card title +.centered-card-title { margin: 10px; } diff --git a/ui/src/components/Common/Card/card.tsx b/ui/src/components/Common/Card/card.tsx index fc0a9b7e..8cbd82b5 100644 --- a/ui/src/components/Common/Card/card.tsx +++ b/ui/src/components/Common/Card/card.tsx @@ -13,7 +13,13 @@ type CardProps = { cardType?: string; }; -const Card = ({ data, selectedCard, onCardClick, cardType, idField = 'id' }: CardProps) => { +/** + * Represents a card component. + * + * @param {CardProps} props - The props for the card component. + * @returns {JSX.Element} The rendered card component. + */ +const Card = ({ data, selectedCard, onCardClick, cardType, idField = 'id' }: CardProps): JSX.Element => { const imgStyle = { width: cardType === 'legacyCMS' ? '60px' : '46px', height: cardType === 'legacyCMS' ? '60px' : '46px' diff --git a/ui/src/components/Common/DeleteProjectModal/index.tsx b/ui/src/components/Common/DeleteProjectModal/index.tsx index d5abbf78..b4d63a43 100644 --- a/ui/src/components/Common/DeleteProjectModal/index.tsx +++ b/ui/src/components/Common/DeleteProjectModal/index.tsx @@ -15,6 +15,13 @@ import { deleteProject } from '../../../services/api/project.service'; // Interfaces import { SettingsModalProps } from '../../../components/Modal/modal.interface'; +/** + * Component for the Delete Project Modal. + * + * @component + * @param {SettingsModalProps} props - The props for the DeleteProjectModal component. + * @returns {JSX.Element} The JSX element representing the DeleteProjectModal component. + */ const DeleteProjectModal = (props: SettingsModalProps) => { const { closeModal, @@ -24,7 +31,13 @@ const DeleteProjectModal = (props: SettingsModalProps) => { selectedOrg } = props; - const handleDeleteProject = async (closeModal: () => void) => { + /** + * Handles the deletion of the project. + * + * @param {() => void} closeModal - The function to close the modal. + * @returns {Promise} A promise that resolves when the project is deleted. + */ + const handleDeleteProject = async (closeModal: () => void): Promise => { const response = await deleteProject(selectedOrg?.value || '', projectId ?? '',); if (response?.status === 200) { @@ -44,6 +57,7 @@ const DeleteProjectModal = (props: SettingsModalProps) => { }, 1200) } } + return ( <> ) => void; } +/** + * Renders a component that displays a link and a checkbox. + * + * @component + * @param {Object} props - The component props. + * @param {Object} props.cta - The link details. + * @param {string} props.cta.href - The URL of the link. + * @param {string} props.cta.title - The title of the link. + * @param {boolean} props.isCheckedBoxChecked - Indicates whether the checkbox is checked. + * @param {boolean} props.isDisable - Indicates whether the component is disabled. + * @param {string} props.label - The label for the checkbox. + * @param {boolean} props.isLabelFullWidth - Indicates whether the label should take up the full width. + * @param {function} props.onChange - The callback function to be called when the checkbox value changes. + * @returns {JSX.Element} The rendered component. + */ const DocLink = ({ cta, isCheckedBoxChecked, diff --git a/ui/src/components/Common/FileUpload/fileupload.scss b/ui/src/components/Common/FileUpload/fileupload.scss index 6a2e32bd..00eea59c 100644 --- a/ui/src/components/Common/FileUpload/fileupload.scss +++ b/ui/src/components/Common/FileUpload/fileupload.scss @@ -1,4 +1,7 @@ @import '../../../scss/variables'; +/** + * Styles for the file upload container. + */ .file-upload-container { display: flex; height: 21.25rem; @@ -10,6 +13,9 @@ border-radius: 0.25rem; border: 0.125rem dashed $color-base-gray-40; + /** + * Styles for the file upload element. + */ .file-upload { display: flex; height: 4.5rem; @@ -20,6 +26,9 @@ flex-shrink: 0; } + /** + * Styles for the text inside the file upload element. + */ .file-upload-text { text-align: center; font-family: Inter; @@ -30,6 +39,9 @@ letter-spacing: 0.16px; } + /** + * Styles for the image inside the file upload container. + */ .file-upload-image { width: 15rem; height: 15rem; @@ -37,14 +49,23 @@ } } +/** + * Styles for the hover effect on the file upload container. + */ .hover { border: 0.125rem dashed $color-base-purple; } +/** + * Styles for hiding an element. + */ .hidden { display: none; } +/** + * Styles for the validation container. + */ .validation-container { display: flex; background-color: $color-base-white-5; diff --git a/ui/src/components/Common/FileUpload/index.tsx b/ui/src/components/Common/FileUpload/index.tsx index 1945e995..184bb1bb 100644 --- a/ui/src/components/Common/FileUpload/index.tsx +++ b/ui/src/components/Common/FileUpload/index.tsx @@ -11,16 +11,30 @@ type FileUploadProps = { projectId: string; }; +/** + * FileUpload component for uploading files. + * + * @param {FileUploadProps} props - The props for the FileUpload component. + * @returns {JSX.Element} The rendered FileUpload component. + */ const FileUpload = (props: FileUploadProps) => { const [isDragOver, setIsDragOver] = useState(false); const fileInputRef = useRef(null); const targetRef = useRef(null); + /** + * Empty method to handle setting upload modal to false. + */ const handleSetUploadModalFalse = (): any => { // Empty Method }; + /** + * Reads the files selected for upload. + * + * @param {FileList | null} filesList - The list of files selected for upload. + */ const readFiles = (filesList: FileList | null) => { //handle Null check if (!filesList) return; @@ -49,6 +63,11 @@ const FileUpload = (props: FileUploadProps) => { setIsDragOver(false); }; + /** + * Handles the drop event when files are dropped onto the component. + * + * @param {DragEvent} e - The drop event. + */ const handleDrop = (e: DragEvent) => { e.preventDefault(); e.stopPropagation(); @@ -57,22 +76,43 @@ const FileUpload = (props: FileUploadProps) => { e.dataTransfer.clearData(); }; + /** + * Handles the drag toggle event when dragging files over the component. + * + * @param {boolean} flag - The flag indicating whether the files are being dragged over the component. + * @returns {Function} The event handler function. + */ const handleDragToggle = (flag: boolean) => (e: DragEvent) => { e.preventDefault(); setIsDragOver(flag); }; + /** + * Handles the file change event when files are selected using the file input. + * + * @param {ChangeEvent} e - The file change event. + */ const handleFileChange = (e: ChangeEvent) => { e.preventDefault(); readFiles(e?.target?.files); }; + /** + * Handles the file select event when the "Choose file" link is clicked. + * + * @param {any} e - The file select event. + */ const handleFileSelect = (e: any) => { e.preventDefault(); fileInputRef?.current?.click(); }; + /** + * Handles the onClose event after file upload. + * + * @param {IFile[]} files - The uploaded files. + */ const onCloseAfterUpload = (files: IFile[]) => { props.handleOnFileUpload(files); }; diff --git a/ui/src/components/Common/FileUpload/upload.scss b/ui/src/components/Common/FileUpload/upload.scss index b6b680fb..99feb555 100644 --- a/ui/src/components/Common/FileUpload/upload.scss +++ b/ui/src/components/Common/FileUpload/upload.scss @@ -1,3 +1,39 @@ +/** + * Styles for the asset upload component. + * + * This SCSS file contains styles for the asset upload window component. + * It includes styles for the heading, body, and various elements within the component. + * The component is used for uploading files and displaying their progress. + * + * @import '../../../scss/variables'; - Imports the SCSS variables file. + * + * CSS classes: + * - .asset-upload - The main container for the asset upload component. + * - .asset-upload__heading - The heading section of the asset upload component. + * - .asset-upload__heading.in-progress - Applied when the upload is in progress. + * - .asset-upload__heading.success - Applied when the upload is successful. + * - .asset-upload__heading.attention - Applied when attention is required. + * - .asset-upload__heading.warning - Applied when there is a warning. + * - .asset-upload__actions - Container for the upload actions. + * - .asset-upload__actions__cancel - Cancel upload action button. + * - .asset-upload__actions__minimize - Minimize upload action button. + * - .asset-upload__actions__maximize - Maximize upload action button. + * - .asset-upload__count - Displays the count of uploaded files. + * - .asset-upload__body - The body section of the asset upload component. + * - .asset-upload__file - Container for each uploaded file. + * - .asset-upload__file__name - Displays the name of the uploaded file. + * - .asset-upload__file__actions - Container for file actions. + * - .asset-upload__file__actions__progress - Container for file upload progress. + * - .asset-upload__file__actions__progress .file-loaded - Displays the loaded file size. + * - .asset-upload__file__actions__progress .total-size - Displays the total file size. + * - .asset-upload__file__actions .cancel-upload - Cancel upload action button for a file. + * + * @example + *
+ *
...
+ *
...
+ *
+ */ @import '../../../scss/variables'; /* Asset upload window css */ diff --git a/ui/src/components/Common/FileUpload/upload.tsx b/ui/src/components/Common/FileUpload/upload.tsx index fcae15a4..6c40f28a 100644 --- a/ui/src/components/Common/FileUpload/upload.tsx +++ b/ui/src/components/Common/FileUpload/upload.tsx @@ -100,6 +100,10 @@ const InterruptUpload = (props: any) => { ); }; +/** + * Component for handling file uploads. + */ + class Upload extends Component { state = { fileList: this.props.fileList, diff --git a/ui/src/components/Common/Modal/FilterModal/FilterModal.scss b/ui/src/components/Common/Modal/FilterModal/FilterModal.scss index a39ada6a..f304bf2d 100644 --- a/ui/src/components/Common/Modal/FilterModal/FilterModal.scss +++ b/ui/src/components/Common/Modal/FilterModal/FilterModal.scss @@ -1,6 +1,8 @@ @import '../../../../scss/variables'; - -.Filter__modal { +/** + * Styles for the FilterModal component. + */ + .Filter__modal { width: $px-400; z-index: 40; position: absolute; @@ -9,30 +11,48 @@ border-radius: $px-10; } -.Filter__modal .Checkbox input:checked ~ .Checkbox__tick, -.Filter__modal .Checkbox .Checkbox__box { - margin-top: $px-4; - font-size: $px-16; -} +/** + * Styles for the checkboxes inside the FilterModal component. + */ + .Filter__modal .Checkbox input:checked ~ .Checkbox__tick, + .Filter__modal .Checkbox .Checkbox__box { + margin-top: $px-4; + font-size: $px-16; + } -.Filter__modal .Filter__item { +/** + * Styles for each filter item inside the FilterModal component. + */ + .Filter__modal .Filter__item { cursor: pointer; padding: $px-10 $px-20; } -.Filter__modal .Filter__item:hover { +/** + * Styles for the filter item when hovered inside the FilterModal component. + */ + .Filter__modal .Filter__item:hover { background-color: $color-base-white-10; } -.Filter__modal .Filter__item:hover .WordWrapper { +/** + * Styles for the WordWrapper element when the filter item is hovered inside the FilterModal component. + */ + .Filter__modal .Filter__item:hover .WordWrapper { color: $color-brand-primary-base; } -.Filter__modal .Filter__item:hover .Checkbox__box { +/** + * Styles for the Checkbox__box element when the filter item is hovered inside the FilterModal component. + */ + .Filter__modal .Filter__item:hover .Checkbox__box { border: 1.5px solid $color-brand-primary-base; } -.Filter__modal-header { +/** + * Styles for the header of the FilterModal component. + */ + .Filter__modal-header { background: $color-base-white-10; border-bottom: 1px solid $color-brand-secondary-lightest; font-size: $px-20; @@ -41,7 +61,10 @@ padding: $px-14 $px-16; } -.Filter__modal-header .Filter__modal-header-container { +/** + * Styles for the container of the header in the FilterModal component. + */ + .Filter__modal-header .Filter__modal-header-container { align-items: center; display: flex; color: #222; @@ -53,11 +76,17 @@ font-weight: 600; } -.Filter__modal-header .Filter__modal-header-container .Filter__modal-header-title { +/** + * Styles for the title in the header of the FilterModal component. + */ + .Filter__modal-header .Filter__modal-header-container .Filter__modal-header-title { font-weight: 600; } -.Filter__modal-header .Filter__modal-header-container .Filter__modal-header-counter { +/** + * Styles for the counter in the header of the FilterModal component. + */ + .Filter__modal-header .Filter__modal-header-container .Filter__modal-header-counter { border: 1px solid $color-brand-secondary-lightest; border-radius: 1rem; color: $color-stepper-title; @@ -74,26 +103,44 @@ width: fit-content; } -.Filter__searchbox .Search--primary .Search__input { +/** + * Styles for the search box inside the FilterModal component. + */ + .Filter__searchbox .Search--primary .Search__input { height: $px-35; } -.Filter__modal-content { +/** + * Styles for the content area of the FilterModal component. + */ + .Filter__modal-content { overflow: scroll; max-height: $px-250; overflow-x: hidden; } -.Filter__icon { +/** + * Styles for the filter icon in the FilterModal component. + */ + .Filter__icon { cursor: pointer !important; padding: $px-5; border-radius: 10%; } -.Filter__icon:hover { +/** + * Styles for the background color of the filter icon in the FilterModal component. + */ + .Filter__icon:hover { background-color: rgba(108, 92, 231, 0.1); } +/** + * Styles for the cancel button in the header of the FilterModal component. + */ + .Filter__icon_bg_color { + background-color: rgba(108, 92, 231, 0.1); +} .Filter__icon_bg_color { background-color: rgba(108, 92, 231, 0.1); } @@ -108,8 +155,10 @@ .Filter__modal-header-cancel:hover { background-color: $color-brand-secondary-lightest; } - -.Filter__modal-footer { +/** + * Styles for the footer of the FilterModal component. + */ + .Filter__modal-footer { display: flex; border-top: 1px solid $color-brand-secondary-lightest; height: $px-70; @@ -117,7 +166,10 @@ padding: $px-20; } -.Filter__no-found { +/** + * Styles for the "no results found" message in the FilterModal component. + */ + .Filter__no-found { text-align: center; vertical-align: middle; line-height: $px-50; diff --git a/ui/src/components/Common/Modal/FilterModal/FilterModal.tsx b/ui/src/components/Common/Modal/FilterModal/FilterModal.tsx index 56b3e5d2..33669028 100644 --- a/ui/src/components/Common/Modal/FilterModal/FilterModal.tsx +++ b/ui/src/components/Common/Modal/FilterModal/FilterModal.tsx @@ -20,6 +20,14 @@ type Props = { iconSize?: 'original' | 'tiny' | 'mini' | 'small' | 'large' | 'medium' | 'extraSmall'; }; +/** + * Represents a filter modal component. + * + * @component + * @param {Props} props - The props for the FilterModal component. + * @returns {JSX.Element} The rendered FilterModal component. + */ + export const FilterModal = (props: Props) => { const { title, diff --git a/ui/src/components/Common/Modal/FilterModal/filterModal.interface.ts b/ui/src/components/Common/Modal/FilterModal/filterModal.interface.ts index 311d0aab..f5c43b55 100644 --- a/ui/src/components/Common/Modal/FilterModal/filterModal.interface.ts +++ b/ui/src/components/Common/Modal/FilterModal/filterModal.interface.ts @@ -1,3 +1,6 @@ +/** + * Represents the interface for a filter type. + */ export interface IFilterType { value: string; label: string; diff --git a/ui/src/components/Common/NotificationModal/index.tsx b/ui/src/components/Common/NotificationModal/index.tsx index 3ea4bddc..19d78b55 100644 --- a/ui/src/components/Common/NotificationModal/index.tsx +++ b/ui/src/components/Common/NotificationModal/index.tsx @@ -13,26 +13,32 @@ interface Props { goBack : () => void; } -const NotificationModal = (props:Props) => { - return( - <> - - -
- -
-
- +/** + * NotificationModal component displays a modal with a notification message. + * @param props - The component props. + * @param props.closeModal - A function to close the modal. + * @param props.goBack - A function to go back. + * @returns The rendered NotificationModal component. + */ +const NotificationModal = (props: Props) => { + return ( + <> + + +
+ +
+
+ - - - - - - ) - + + + +
+ + ); } export default NotificationModal; \ No newline at end of file diff --git a/ui/src/components/Common/ProgressBar/index.tsx b/ui/src/components/Common/ProgressBar/index.tsx index f15ae7d4..81260efc 100644 --- a/ui/src/components/Common/ProgressBar/index.tsx +++ b/ui/src/components/Common/ProgressBar/index.tsx @@ -24,6 +24,13 @@ type IStyle = { [key: string]: string } +/** + * Renders a progress bar component. + * + * @component + * @param {ProgressBarProps} props - The props for the ProgressBar component. + * @returns {JSX.Element} - The rendered ProgressBar component. + */ const ProgressBar = (props: ProgressBarProps) => { const { percentage, color, height, borderRadius, type, radius, stroke, bgColor } = props diff --git a/ui/src/components/Common/ProgressBar/progressBar.scss b/ui/src/components/Common/ProgressBar/progressBar.scss index fc0310e2..3ffaabe0 100644 --- a/ui/src/components/Common/ProgressBar/progressBar.scss +++ b/ui/src/components/Common/ProgressBar/progressBar.scss @@ -1,16 +1,31 @@ @import '../../../scss//variables'; - +/** + * Styles for the ProgressBar component. + * + * @class ProgressBar + */ .ProgressBar { border-radius: $space-4; overflow: hidden; + + /** + * Styles for the progress bar element. + * + * @class ProgressBar__bar + */ &__bar { - border-radius: inherit; height: inherit; transition: width 100ms linear; } - &__circle{ + + /** + * Styles for the progress circle element. + * + * @class ProgressBar__circle + */ + &__circle { stroke-width: 5%; transform: rotate(-90deg); transform-origin: 50% 50%; diff --git a/ui/src/components/Common/Settings/Settings.scss b/ui/src/components/Common/Settings/Settings.scss index 4c6377a3..c5875a94 100644 --- a/ui/src/components/Common/Settings/Settings.scss +++ b/ui/src/components/Common/Settings/Settings.scss @@ -1,19 +1,40 @@ +/** + * This SCSS file contains styles for the Settings component. + */ + @import '../../../scss/variables'; #setting-page { display: flex; width: 100%; + + /** + * Styles for the section header. + */ .SectionHeader { color: $color-stepper-title; font-weight: $font-weight-semi-bold; margin-bottom: 2rem; } + + /** + * Styles for the page layout. + */ .PageLayout { width: 100%; } - .PageLayout__head, .PageLayout__leftSidebar { + + /** + * Styles for the page layout's head and left sidebar. + */ + .PageLayout__head, + .PageLayout__leftSidebar { border-top: 0 none; } + + /** + * Styles for the primary page layout. + */ .PageLayout--primary { .PageLayout__content { .PageLayout__body { @@ -21,12 +42,20 @@ margin-left: 15rem; padding-top: $px-8; } - } - } + } + } + + /** + * Styles for the action component title. + */ .action-component-title { justify-content: space-between; width: calc(100vw - 326px); } + + /** + * Styles for the content block. + */ .content-block { margin-right: 0; padding: 1.5rem; @@ -34,28 +63,30 @@ } } +/** + * Styles for the field. + */ .Field { margin-bottom: $px-40; } + +/** + * Styles for hiding the left sidebar. + */ .PageLayout__leftSidebar--hide { display: none; } +/** + * Styles for the left sidebar. + */ .leftsidebar { margin-top: 0 !important; } -// .content-body .white-box-container { -// background-color: $color-brand-white-base; -// padding: 20px; -// margin-top: 50px !important; -// margin-left: 240px; -// margin-right: auto; -// position: relative; -// z-index: 10; -// height: 600px; -// } - +/** + * Styles for the stack settings heading. + */ .stack-settings__heading { color: $color-base-black-base; font-size: 0.875rem; @@ -65,26 +96,16 @@ margin-bottom: $px-20; } -// .toggle-class { -// width: calc(100% - 18.4375rem) !important; -// } -// .layout-container.specific-context .PageLayout__head { -// z-index: 10 !important; -// margin-left: 240px; -// width: 100% !important; -// } -// .SaveButton { -// padding: 30px 10px; -// } - -// .layout-container.content-body .PageLayout__body { -// margin-top: 90px !important; -// margin-left: 227px !important; -// } - +/** + * Styles for the page layout's left sidebar. + */ .PageLayout__leftSidebar { background-color: #f7f9fc !important; } + +/** + * Styles for the active list row. + */ .ListRowV2--active { background-color: #fff; border-left: 0.125rem solid; diff --git a/ui/src/components/Common/Settings/index.tsx b/ui/src/components/Common/Settings/index.tsx index 7103fb79..4f9d0d98 100644 --- a/ui/src/components/Common/Settings/index.tsx +++ b/ui/src/components/Common/Settings/index.tsx @@ -34,6 +34,10 @@ import DeleteProjectModal from '../DeleteProjectModal'; import './Settings.scss'; import { RootState } from '../../../store'; +/** + * Renders the Settings component. + * This component is responsible for displaying and updating project settings. + */ const Settings = () => { const params: Params = useParams(); diff --git a/ui/src/components/Common/Settings/setting.interface.ts b/ui/src/components/Common/Settings/setting.interface.ts index f0abcc5e..0d6a420e 100644 --- a/ui/src/components/Common/Settings/setting.interface.ts +++ b/ui/src/components/Common/Settings/setting.interface.ts @@ -1,3 +1,6 @@ +/** + * Represents a project. + */ interface IProject { title: string; name: string; diff --git a/ui/src/components/Common/WordWrapper/WordWrapper.tsx b/ui/src/components/Common/WordWrapper/WordWrapper.tsx index f9ca6238..9b86a8e3 100644 --- a/ui/src/components/Common/WordWrapper/WordWrapper.tsx +++ b/ui/src/components/Common/WordWrapper/WordWrapper.tsx @@ -10,6 +10,12 @@ type Props = { position?: string; }; +/** + * Renders a component that wraps text and provides a tooltip if the text exceeds a maximum length. + * + * @param {Props} props - The component props. + * @returns {JSX.Element} The rendered WordWrapper component. + */ function WordWrapper(props: Props) { const { maxLength, tooltipcontent, position = 'right' } = props; const text = props.text || ''; diff --git a/ui/src/components/Common/private-route.tsx b/ui/src/components/Common/private-route.tsx index 3ba2ce34..11ff6d63 100644 --- a/ui/src/components/Common/private-route.tsx +++ b/ui/src/components/Common/private-route.tsx @@ -7,6 +7,14 @@ type IProps = { redirectTo: string; }; +/** + * Renders a private route component that checks if the user is authenticated. + * If the user is authenticated, it renders the child components. + * If the user is not authenticated, it redirects to the specified route. + * + * @param redirectTo - The route to redirect to if the user is not authenticated. + * @returns The private route component. + */ const PrivateRoute: FC = ({ redirectTo }: IProps) => { const isAuthenticated = !!getDataFromLocalStorage('app_token'); diff --git a/ui/src/components/Common/router.tsx b/ui/src/components/Common/router.tsx index 6df9932c..0fffa4a2 100644 --- a/ui/src/components/Common/router.tsx +++ b/ui/src/components/Common/router.tsx @@ -19,6 +19,10 @@ const MigrationLazyLoad = lazy(() => import('../../pages/Migration')); const ProjectsLazyLoad = lazy(() => import('../../pages/Projects')); const SettingsLazyLoad = lazy(() => import ('../Common/Settings')) +/** + * Renders the application router. + * @returns The application router component. + */ const AppRouter = () => { return ( diff --git a/ui/src/components/ContentMapper/contentMapper.interface.ts b/ui/src/components/ContentMapper/contentMapper.interface.ts index a247930a..00b75055 100644 --- a/ui/src/components/ContentMapper/contentMapper.interface.ts +++ b/ui/src/components/ContentMapper/contentMapper.interface.ts @@ -50,19 +50,35 @@ export interface ContentType { fieldMapping?: FieldMapType[] | []; } +/** + * Represents the field mapping type for ContentMapper. + */ export interface FieldMapType { + /** The Contentstack field type. */ ContentstackFieldType: string; + /** The child field mappings. */ child?: FieldMapType[] | undefined; + /** The backup field type. */ backupFieldType: string; + /** The Contentstack field name. */ contentstackField: string; + /** The Contentstack field UID. */ contentstackFieldUid: string; + /** Indicates if the field is deleted. */ isDeleted: boolean; + /** The field name in another CMS. */ otherCmsField: string; + /** The field type in another CMS. */ otherCmsType: string; + /** The UID of the field mapping. */ uid: string; + /** The ID of the field mapping. */ id: string; + /** Indicates if the field can be selected. */ _canSelect?: boolean; + /** Advanced field options. */ advanced?: Advanced; + /** The Contentstack UID. */ contentstackUid: string; } diff --git a/ui/src/components/ContentMapper/index.scss b/ui/src/components/ContentMapper/index.scss index cf03e88c..92d13e73 100644 --- a/ui/src/components/ContentMapper/index.scss +++ b/ui/src/components/ContentMapper/index.scss @@ -1,3 +1,35 @@ +/** + * FILEPATH: /Users/rohit/migration-v2-node-server/ui/src/components/ContentMapper/index.scss + * + * This SCSS file contains styles for the ContentMapper component. + * The ContentMapper component is responsible for mapping content types and fields. + * It includes styles for the content types list, search bar, list items, options, table, and other UI elements. + * + * Styles are organized into different sections: + * - .content-types-list-wrapper: Styles for the wrapper of the content types list. + * - .content-types-list-header: Styles for the header of the content types list. + * - .ct-search-wrapper: Styles for the search bar wrapper. + * - .ct-list-wrapper: Styles for the wrapper of the content types list. + * - .ct-list: Styles for the content types list. + * - .mapped-icon: Styles for the mapped icon. + * - .dropdown-align: Styles for aligning the dropdown menu. + * - .content-type-list: Styles for the content type list. + * - .content-types-fields-wrapper: Styles for the wrapper of the content types fields. + * - .cta-wrapper: Styles for the call-to-action wrapper. + * - .table-container: Styles for the table container. + * - .table-wrapper: Styles for the table wrapper. + * - .disabled-field: Styles for disabled fields. + * - .action-btn-wrapper: Styles for the action button wrapper. + * - .action-component-body: Styles for the action component body. + * - .step-container: Styles for the step container. + * - .saveButton: Styles for the save button. + * - .btnWrapper: Styles for the button wrapper. + * - div .select: Styles for the select dropdown. + * - div .table-row: Styles for the table row. + * - .status-wrapper: Styles for the status wrapper. + * - .filter-wrapper: Styles for the filter wrapper. + * - .no-content: Styles for the no content message. + */ @import '../../scss/App.scss'; @import '../../scss/variables'; diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 932ed583..7e365ae6 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -99,6 +99,10 @@ const Fields: Mapping = { global_field: 'Global' }; +/** + * Component for mapping content types. + */ + const ContentMapper = () => { /** ALL CONTEXT HERE */ diff --git a/ui/src/components/DestinationStack/Actions/LoadOrganisation.tsx b/ui/src/components/DestinationStack/Actions/LoadOrganisation.tsx index cc31ab3d..a78ab6c2 100644 --- a/ui/src/components/DestinationStack/Actions/LoadOrganisation.tsx +++ b/ui/src/components/DestinationStack/Actions/LoadOrganisation.tsx @@ -1,60 +1,51 @@ -import { ChangeEvent, useEffect, useState } from 'react'; +// Importing necessary React hooks and Redux functions for state management. +import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; + +// Importing type definitions for dropdown and migration data structures. import { IDropDown, INewMigration } from '../../../context/app/app.interface'; + +// Importing UI components from @contentstack/venus-components. import { TextInput } from '@contentstack/venus-components'; +// Importing stylesheet for the DestinationStack component. import '../DestinationStack.scss'; + +// Utility function to check for empty strings. import { isEmptyString } from '../../../utilities/functions'; + +// RootState type for accessing the Redux store's state. import { RootState } from '../../../store'; + +// Action creator for updating migration data in the Redux store. import { updateNewMigrationData } from '../../../store/slice/migrationDataSlice'; +// Interface defining the props expected by the LoadOrganisation component. interface LoadOrganisationProps { - stepComponentProps: any; - currentStep: number; - handleStepChange: (stepIndex: number, closeStep?: boolean) => void; + stepComponentProps: any; // Props for the step component, type not specified. + currentStep: number; // The current step in a multi-step process. + handleStepChange: (stepIndex: number, closeStep?: boolean) => void; // Function to handle step changes. } +// The LoadOrganisation component is responsible for loading and displaying the selected organisation. const LoadOrganisation = (props: LoadOrganisationProps) => { - /**** ALL HOOKS HERE ****/ - - const newMigrationData = useSelector((state:RootState)=>state?.migration?.newMigrationData); - const selectedOrganisation = useSelector((state:RootState)=>state?.authentication?.selectedOrganisation); - // const organisationsList = useSelector((state:RootState)=>state?.authentication?.organisationsList); - + // State and dispatch hooks for interacting with the Redux store. + const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData); + const selectedOrganisation = useSelector((state: RootState) => state?.authentication?.selectedOrganisation); const dispatch = useDispatch(); + // Local state for tracking the selected organisation. const [selectedOrg, setSelectedOrg] = useState(); - /**** ALL METHODS HERE ****/ - //update new Migration Data + // Function to update the new migration data in the Redux store. const setNewMigrationData = (data: INewMigration) => { - dispatch(updateNewMigrationData((data))); + dispatch(updateNewMigrationData(data)); }; - - - //Handle Organisation selection - // const handleDropdownChange = (data: ChangeEvent) => { - // if (selectedOrg?.value !== data?.value) { - // setSelectedOrg(() => ({ ...data })); - - // setNewMigrationData({ - // ...newMigrationData, - // destination_stack: { - // ...newMigrationData.destination_stack, - // selectedOrg: { ...data } - // } - // }); - // } - - // call for Step Change - // props.handleStepChange(props.currentStep); - // }; - - /**** ALL USEEffects HERE ****/ + // Effect hook to initialize the selected organisation based on the Redux store or local state. useEffect(() => { const org = !isEmptyString(newMigrationData.destination_stack.selectedOrg.label) - ? newMigrationData?.destination_stack?.selectedOrg + ? newMigrationData.destination_stack.selectedOrg : selectedOrganisation; setSelectedOrg(org as any); @@ -67,22 +58,10 @@ const LoadOrganisation = (props: LoadOrganisationProps) => { } }); }, []); - + + // Render function for the LoadOrganisation component. return (
- {/*
- handleValueChange(selectedOption, data?.uid)} placeholder="Select Field" version={'v2'} @@ -925,13 +1021,15 @@ const ContentMapper = () => { } (e?.target as HTMLElement)?.closest('li')?.classList?.add('active-filter'); - const filteredCT = contentTypes?.filter((ct) => CONTENT_MAPPING_STATUS[ct?.status] === value); - + const filteredCT = contentTypes?.filter((ct) => {return CONTENT_MAPPING_STATUS[ct?.status] === value}); + if (value !== 'All') { - setFilteredContentTypes(filteredCT) + setFilteredContentTypes(filteredCT); + setCount(filteredCT?.length); } else { - setFilteredContentTypes(contentTypes) - } + setFilteredContentTypes(contentTypes); + setCount(contentTypes?.length); + } setShowFilter(false); } @@ -952,7 +1050,7 @@ const ContentMapper = () => { return result; } const tableHeight = calcHeight(); - + return (
@@ -960,7 +1058,7 @@ const ContentMapper = () => {
{contentTypesHeading &&

{contentTypesHeading}

} - {contentTypes && validateArray(contentTypes) && contentTypes?.length } + {contentTypes && validateArray(contentTypes) && count }
diff --git a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx index ba112b78..d6a47ac3 100644 --- a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx @@ -130,11 +130,9 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { dispatch(updateNewMigrationData(newMigrationDataObj)); if(res?.status === 200){ - setTimeout(()=>{ - setIsValidated(true); - setValidationMessage('Validation is successful'); - - },1000); + setIsValidated(true); + setValidationMessage('Validation is successful'); + setIsDisabled(true); if(! isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){ @@ -339,7 +337,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { setFileFormat(savedState.fileFormat); setProcessing(savedState.processing); } - if (savedState && savedState.isLoading) { + if (savedState && savedState.isLoading && !newMigrationData?.legacy_cms?.uploadedFile?.isValidated) { handleOnFileUploadCompletion(); } @@ -376,7 +374,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { ]); useEffect(()=>{ - if(newMigrationData?.legacy_cms?.uploadedFile?.isValidated) + if(newMigrationData?.legacy_cms?.uploadedFile?.isValidated && ! showProgress) { setIsValidated(true); @@ -431,7 +429,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
} - {showMessage && + {showMessage && ! showProgress && ( <> diff --git a/ui/src/components/MainHeader/index.tsx b/ui/src/components/MainHeader/index.tsx index f1391406..71efbf71 100644 --- a/ui/src/components/MainHeader/index.tsx +++ b/ui/src/components/MainHeader/index.tsx @@ -98,6 +98,7 @@ const MainHeader = () => { useEffect(()=>{ const handlePopState = (event: PopStateEvent) => { event.preventDefault(); + window.history.pushState(null, '', window.location.href); handleonClick(); }; diff --git a/ui/src/pages/Migration/index.tsx b/ui/src/pages/Migration/index.tsx index 8fb6b009..7fadece0 100644 --- a/ui/src/pages/Migration/index.tsx +++ b/ui/src/pages/Migration/index.tsx @@ -215,7 +215,7 @@ const Migration = () => { result = 'Imported File'; break; } - if (currentIndex !== 3) { + if (currentIndex !== 3 || currentIndex !== 4) { Notification({ notificationContent: { text: `Please complete ${result} step` }, type: 'warning' diff --git a/ui/src/services/api/migration.service.ts b/ui/src/services/api/migration.service.ts index ecbf72ac..e680370a 100644 --- a/ui/src/services/api/migration.service.ts +++ b/ui/src/services/api/migration.service.ts @@ -89,10 +89,11 @@ export const getContentTypes = ( skip: number, limit: number, searchText: string -) => { +) => { try { + const encodedSearchText = encodeURIComponent(searchText) ; return getCall( - `${API_VERSION}/mapper/contentTypes/${projectId}/${skip}/${limit}/${searchText}?`, + `${API_VERSION}/mapper/contentTypes/${projectId}/${skip}/${limit}/${encodedSearchText}?`, options ); } catch (error: any) { @@ -107,8 +108,9 @@ export const getFieldMapping = async ( searchText: string ) => { try { + const encodedSearchText = encodeURIComponent(searchText) ; return await getCall( - `${API_VERSION}/mapper/fieldMapping/${contentTypeId}/${skip}/${limit}/${searchText}?`, + `${API_VERSION}/mapper/fieldMapping/${contentTypeId}/${skip}/${limit}/${encodedSearchText}?`, options ); } catch (error: any) { From 3c9bef1fb1cc2b09614045777530972c77f1c06a Mon Sep 17 00:00:00 2001 From: snehalsankhe Date: Mon, 15 Jul 2024 18:26:57 +0530 Subject: [PATCH 10/10] solved bugs --- .../DestinationStack/Actions/LoadStacks.tsx | 57 +++++++++++-------- .../DestinationStack/DestinationStack.scss | 2 +- ui/src/pages/Migration/index.tsx | 6 +- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx index a7d41d94..2b8d688f 100644 --- a/ui/src/components/DestinationStack/Actions/LoadStacks.tsx +++ b/ui/src/components/DestinationStack/Actions/LoadStacks.tsx @@ -35,10 +35,8 @@ const LoadStacks = (props: LoadFileFormatProps) => { const selectedOrganisation = useSelector((state:RootState)=>state?.authentication?.selectedOrganisation); const dispatch = useDispatch(); /**** ALL UseStates HERE ****/ - const [selectedStack, setSelectedStack] = useState( - !isEmptyString(newMigrationData?.destination_stack?.selectedOrg?.value) - ? newMigrationData?.destination_stack?.selectedStack - : DEFAULT_DROPDOWN + const [selectedStack, setSelectedStack] = useState( + null ); /**** ALL METHODS HERE ****/ @@ -51,15 +49,15 @@ const LoadStacks = (props: LoadFileFormatProps) => { const [errorMessage, setErrorMessage] = useState(''); const [placeholder, setPlaceholder] = useState('Select a stack'); const [asyncMount, setAsyncMount] = useState(true) - - + const [ isSelectOpen, setIsSelectOpen ] = useState(false) const { projectId = '' }: Params = useParams(); + useEffect(()=>{ if(!isEmptyString(newMigrationData?.destination_stack?.selectedStack?.value)){ setSelectedStack(newMigrationData?.destination_stack?.selectedStack); } },[newMigrationData?.destination_stack?.selectedStack]) - + //Handle new stack details const handleOnSave = async (data: Stack) => { if (isSaving) return false; @@ -75,7 +73,7 @@ const LoadStacks = (props: LoadFileFormatProps) => { ...data, master_locale: data?.locale }); - + setIsSaving(false); if (resp.status === 201) { @@ -118,10 +116,10 @@ const LoadStacks = (props: LoadFileFormatProps) => { //Handle Legacy cms selection const handleDropdownChange = (name: string) => (data: IDropDown) => { - const stackCleared = data?.value === '' || data?.value === null || data === null; - + const stackCleared = data?.value === '' || data?.value === null || data === null; if (stackCleared === true) { - setPlaceholder('Select a stack'); + setIsError(true); + setErrorMessage("Please select a stack"); } if (name === 'stacks' && data?.value != '+ Create a new Stack') { @@ -136,6 +134,7 @@ const LoadStacks = (props: LoadFileFormatProps) => { dispatch(updateNewMigrationData((newMigrationDataObj))); if (!stackCleared) { + setIsError(false) if (props?.handleStepChange) { props?.handleStepChange(props?.currentStep, true); } @@ -176,10 +175,8 @@ const LoadStacks = (props: LoadFileFormatProps) => { if (stackData?.data?.stacks?.length === 0 && (!stackData?.data?.stack)) { setIsError(true); setErrorMessage("Please create new stack there is no stack available"); - } else { - setIsError(true) - setErrorMessage("Please select a stack") - } + } + stackArray.sort((a: IDropDown, b: IDropDown) => { return new Date(b?.created_at).getTime() - new Date(a?.created_at).getTime(); }); @@ -218,13 +215,13 @@ const LoadStacks = (props: LoadFileFormatProps) => { }, onClose: () => { resetAsyncSelect(); + setIsError(false) return; } } }); }; - const [ isSelectOpen, setIsSelectOpen ] = useState(false) useEffect(() => { // Fetch the select element using its class name or testId @@ -237,26 +234,40 @@ const LoadStacks = (props: LoadFileFormatProps) => { div.onclick = handleCreateNewStack selectElement.appendChild(div) } - }, [asyncMount, isSelectOpen]); + }, [asyncMount, isSelectOpen]); + useEffect(() => { + const checkIfClickedOutside = (e: MouseEvent) => { + // If the menu is open and the clicked target is not within the menu, + // then close the menu + if (isSelectOpen && ref.current && !ref.current.contains(e.target as Node)) { + setIsSelectOpen(false); + } + }; + + document.body.addEventListener('mousedown', checkIfClickedOutside); + + return () => { + // Cleanup the event listener + document.body.removeEventListener('mousedown', checkIfClickedOutside); + }; + }, [isSelectOpen]); const handleDivClick = () => { setIsSelectOpen(!isSelectOpen) } - return (
-
+
{asyncMount ? -
+
{ placeholder={placeholder} limit={10} updateOption={()=> undefined} - error={isLoading ? false : emptyStackValue ? true : false } + error={isLoading ? false : isError ? true : false } defaultOptions={true} debounceTimeout={0} menuIsOpen={isSelectOpen} @@ -275,7 +286,7 @@ const LoadStacks = (props: LoadFileFormatProps) => { : null }
- {(emptyStackValue && !isLoading) &&
{errorMessage}
} + {(isError && !isLoading) &&
{errorMessage}
}