From 7b723d220cf16aa0807d91204e66f09e2d97eaf1 Mon Sep 17 00:00:00 2001 From: AishDani Date: Thu, 8 May 2025 12:42:48 +0530 Subject: [PATCH 01/13] fix:resolved the bug [CMG-634] --- ui/src/components/ContentMapper/index.scss | 4 ++++ ui/src/components/ContentMapper/index.tsx | 28 ++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ui/src/components/ContentMapper/index.scss b/ui/src/components/ContentMapper/index.scss index fa2f9f237..96a42ced4 100644 --- a/ui/src/components/ContentMapper/index.scss +++ b/ui/src/components/ContentMapper/index.scss @@ -311,3 +311,7 @@ div .table-row { font-size: $size-font-large; font-weight: $font-weight-semi-bold; } +.filtetButton-color{ + color: $color-brand-primary-base; + font-weight: $font-weight-bold; +} \ No newline at end of file diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 0ffa4c062..3ce478a78 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -35,7 +35,7 @@ import { updateMigrationData, updateNewMigrationData } from '../../store/slice/m // Utilities import { CS_ENTRIES, CONTENT_MAPPING_STATUS, STATUS_ICON_Mapping } from '../../utilities/constants'; -import { validateArray } from '../../utilities/functions'; +import { isEmptyString, validateArray } from '../../utilities/functions'; import useBlockNavigation from '../../hooks/userNavigation'; // Interface @@ -291,6 +291,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R const [isContentDeleted, setIsContentDeleted] = useState(false); const [isCsCTypeUpdated, setsCsCTypeUpdated] = useState(false); const [isLoadingSaveButton, setisLoadingSaveButton] = useState(false); + const [activeFilter, setActiveFilter] = useState(''); /** ALL HOOKS Here */ @@ -1240,7 +1241,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R //utility function to map the source cms field type to content type field type function checkConditions(fieldTypeToMatch: string | string[], value: ContentTypesSchema, data: FieldMapType) { - const fieldTypes = new Set(['number', 'isodate', 'file', 'reference', 'boolean', 'group', 'link','global_field','json','blocks']); + const fieldTypes = new Set(['number', 'isodate', 'file', 'reference', 'boolean', 'group', 'link','global_field','json','blocks','taxonomy']); switch (fieldTypeToMatch) { case 'text': return ( @@ -1373,7 +1374,6 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R return OptionsForRow; }; - const SelectAccessorOfColumn = (data: FieldMapType) => { // Fetch options for the current row from Fields based on backupFieldType( empty stack options) const OptionsForEachRow = Fields?.[data?.backupFieldType]?.options; @@ -1424,7 +1424,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R const fieldTypeToMatch = Fields[data?.backupFieldType as keyof Mapping]?.type; //check if UID of souce field is matching to exsting content type field UID for (const value of contentTypeSchema) { - if (data?.uid === value?.uid || (data?.uid === value?.uid && data?.otherCmsType === value?.data_type)) { + if (data?.uid === value?.uid && data?.contentstackFieldType === value?.data_type) { OptionsForRow.push({ label: value?.display_name, value, isDisabled: false }); break; } @@ -1821,10 +1821,23 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R }; dispatch(updateNewMigrationData(newMigrationDataObj)); const resetCT = filteredContentTypes?.map?.(ct => + ct?.id === selectedContentType?.id ? { ...ct, status: data?.data?.status } : ct + ) + + let filteredCT = resetCT; + if (!isEmptyString(activeFilter)) { + filteredCT = resetCT?.filter((ct) => + CONTENT_MAPPING_STATUS?.[ct?.status] === activeFilter + ); + } + + const resetContentTypes = contentTypes?.map?.(ct => ct?.id === selectedContentType?.id ? { ...ct, status: data?.data?.status } : ct ); - setFilteredContentTypes(resetCT); - setContentTypes(resetCT); + setFilteredContentTypes(filteredCT); + setContentTypes(resetContentTypes); + setCount(filteredCT?.length); + Notification({ notificationContent: { text: data?.message }, notificationProps: { @@ -2138,6 +2151,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R // Function to filter content types as per the status const handleContentTypeFilter = (value: string, e: MouseOrKeyboardEvent) => { + setActiveFilter(value); const li_list = document.querySelectorAll('.filter-wrapper li'); if(li_list) { li_list?.forEach((ele) => { @@ -2240,7 +2254,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R } }} > - {CONTENT_MAPPING_STATUS[key] && {CONTENT_MAPPING_STATUS[key]} } + {CONTENT_MAPPING_STATUS[key] && {CONTENT_MAPPING_STATUS[key]} } {STATUS_ICON_Mapping[key] && } From 016c9406a1e4a47cafdd0e4bda07de57e2173e3e Mon Sep 17 00:00:00 2001 From: AishDani Date: Thu, 8 May 2025 18:00:39 +0530 Subject: [PATCH 02/13] fix:[CMG-633]:prefiled values of affic and validation message on new project creation --- ui/src/components/Modal/index.tsx | 16 +++++---------- ui/src/components/Modal/modal.interface.ts | 2 +- ui/src/pages/Projects/index.tsx | 24 ++++++++++++++++++++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ui/src/components/Modal/index.tsx b/ui/src/components/Modal/index.tsx index e54106516..f5e135bf2 100644 --- a/ui/src/components/Modal/index.tsx +++ b/ui/src/components/Modal/index.tsx @@ -34,23 +34,17 @@ const Modal = (props: ProjectModalProps) => { title }, selectedOrg, - isOpen + isOpen, + createProject } = props; const [inputValue, setInputValue] = useState(false); - const handleSubmit = async (values: FormData): Promise => { + const handleSubmit = async (values: FormData)=> { // const payload = {name: values?.name, description: values?.description || ''} - const res = await createProject(selectedOrg?.uid || '', values); - if (res?.error) { - return res?.error; - } - if (res?.status === 201) { - const projectId = res?.data?.project?.id; - window.location.href = `/projects/${projectId}/migration/steps/1`; - } - return res; + const result = await createProject(values); + return result; }; const nameValidation = (value: string) => { diff --git a/ui/src/components/Modal/modal.interface.ts b/ui/src/components/Modal/modal.interface.ts index 7248e2cb2..29ef23ce3 100644 --- a/ui/src/components/Modal/modal.interface.ts +++ b/ui/src/components/Modal/modal.interface.ts @@ -4,12 +4,12 @@ import { ModalType } from '../../pages/Projects/projects.interface'; export interface ModalObj { closeModal: () => void; } - export interface ProjectModalProps { modalData: ModalType; selectedOrg: IDropDown; closeModal: () => void; isOpen: (flag: boolean) => void; + createProject: (values : FormData)=> void } export interface SettingsModalProps { selectedOrg: IDropDown; diff --git a/ui/src/pages/Projects/index.tsx b/ui/src/pages/Projects/index.tsx index 80e5b6712..f05ede6e2 100644 --- a/ui/src/pages/Projects/index.tsx +++ b/ui/src/pages/Projects/index.tsx @@ -10,7 +10,7 @@ import { } from '@contentstack/venus-components'; import { jsonToHtml } from '@contentstack/json-rte-serializer'; import HTMLReactParser from 'html-react-parser'; -import { useLocation } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; import { useSelector } from 'react-redux'; // Redux @@ -19,7 +19,7 @@ import useBlockNavigation from '../../hooks/userNavigation'; // Services import { getCMSDataFromFile } from '../../cmsData/cmsSelector'; -import { getAllProjects } from '../../services/api/project.service'; +import { createProject, getAllProjects } from '../../services/api/project.service'; // Utilities import { CS_ENTRIES } from '../../utilities/constants'; @@ -41,6 +41,9 @@ import { NO_PROJECTS, NO_PROJECTS_SEARCH } from '../../common/assets'; // styles import './index.scss'; +import { useDispatch } from 'react-redux'; +import { DEFAULT_NEW_MIGRATION } from '../../context/app/app.interface'; +import { updateNewMigrationData } from '../../store/slice/migrationDataSlice'; const Projects = () => { const [data, setData] = useState({}); @@ -69,6 +72,8 @@ const Projects = () => { const [isModalOpen, setIsModalOpen] = useState(false); usePreventBackNavigation(); + const navigate = useNavigate(); + const dispatch = useDispatch(); const fetchProjects = async () => { setLoadStatus(true); @@ -132,6 +137,20 @@ const Projects = () => { }; useBlockNavigation(isModalOpen || true); + const createProjectCall = async(values : any) => { + const res:any = await createProject(selectedOrganisation?.uid || '', values); + if (res?.error) { + return res?.error; + } + if (res?.status === 201) { + const projectId = res?.data?.project?.id; + dispatch(updateNewMigrationData(DEFAULT_NEW_MIGRATION)) + navigate(`/projects/${projectId}/migration/steps/1`); + + } + return res; + + } // Function for open modal const openModal = () => { setIsModalOpen(true); @@ -144,6 +163,7 @@ const Projects = () => { } selectedOrg={selectedOrganisation} isOpen={setIsModalOpen} + createProject={createProjectCall} {...props} /> ), From be6771570e21380aac9287dd2b287713629daa00 Mon Sep 17 00:00:00 2001 From: AishDani Date: Tue, 13 May 2025 11:40:37 +0530 Subject: [PATCH 03/13] fix:resolved the bug [CMG-622] mapping of nested group in content mapper --- api/src/utils/content-type-creator.utils.ts | 117 ++++++++++++++------ api/src/utils/field-attacher.utils.ts | 2 +- 2 files changed, 85 insertions(+), 34 deletions(-) diff --git a/api/src/utils/content-type-creator.utils.ts b/api/src/utils/content-type-creator.utils.ts index e00b14c14..e5835b728 100644 --- a/api/src/utils/content-type-creator.utils.ts +++ b/api/src/utils/content-type-creator.utils.ts @@ -74,9 +74,19 @@ const arrangGroups = ({ schema, newStack }: any) => { schema?.forEach((item: any) => { if (item?.contentstackFieldType === 'group') { const groupSchema: any = { ...item, schema: [] } + if (item?.contentstackFieldUid?.includes('.')) { + const parts = item.contentstackFieldUid.split('.'); + groupSchema.contentstackFieldUid = parts[parts.length - 1]; + } schema?.forEach((et: any) => { if (et?.contentstackFieldUid?.includes(`${item?.contentstackFieldUid}.`) || (newStack === false && et?.uid?.includes(`${item?.uid}.`))) { + const target = groupSchema?.contentstackFieldUid; + const index = et?.contentstackFieldUid?.indexOf(target); + + if (index > 0) { + et.contentstackFieldUid = et?.contentstackFieldUid?.substring(index); + } groupSchema?.schema?.push(et); } }) @@ -112,7 +122,7 @@ const saveAppMapper = async ({ marketPlacePath, data, fileName }: any) => { } } -const convertToSchemaFormate = ({ field, advanced = true, marketPlacePath }: any) => { +const convertToSchemaFormate = ({ field, advanced = true, marketPlacePath, keyMapper }: any) => { switch (field?.contentstackFieldType) { case 'single_line_text': { return { @@ -435,7 +445,7 @@ const convertToSchemaFormate = ({ field, advanced = true, marketPlacePath }: any return { data_type: "reference", display_name: field?.title, - reference_to: field?.refrenceTo ?? [], + reference_to: field?.refrenceTo?.map((item:string) => keyMapper[item] || item) ?? [], field_metadata: { ref_multiple: true, ref_multiple_content_types: true @@ -654,45 +664,85 @@ const existingCtMapper = async ({ keyMapper, contentTypeUid, projectId, region, } } -const mergeArrays = async (a: any[], b: any[]) => { - for await (const fieldGp of b) { - const exists = a.some(fld => - fld?.uid === fieldGp?.uid && - fld?.data_type === fieldGp?.data_type +const mergeArrays = (a: any[], b: any[]): any[] => { + const result = [...a]; + + for (const field of b) { + const exists = result.some(f => + f?.uid === field?.uid && + f?.data_type === field?.data_type ); if (!exists) { - a.push(fieldGp); + result.push(field); + } + } + + return result; +}; + +const mergeFields = async (schema1: any[], schema2: any[]): Promise => { + const result: any[] = []; + + for (const field2 of schema2) { + if (field2.data_type === 'group') { + const machingGroup = findGroupByUid(schema1, field2?.uid); + if(machingGroup){ + const schema = await mergeArrays(machingGroup?.schema ?? [],field2?.schema ?? [] ); + result.push({ + ...field2, + schema: schema + }); + } + else{ + result.push({ + ...field2, + schema: await mergeFields(schema1, field2?.schema) + }) + } + } + else{ + const exists = schema1.find( + (fld) => + fld.uid === field2.uid && + fld.data_type === field2.data_type + ); + if (!exists) { + result.push(field2); + } + } + } - return a; + return result; } + +const findGroupByUid = ( + schema: any[], + uid: string, + excludeRef: any = null +): any | undefined => { + for (const field of schema) { + if (field.data_type === 'group') { + if (field.uid === uid && field !== excludeRef) return field; + const nested = findGroupByUid(field.schema ?? [], uid, excludeRef); + if (nested) return nested; + } + } + return undefined; +}; + const mergeTwoCts = async (ct: any, mergeCts: any) => { - const ctData: any = { - ...ct, + const merged :any = { title: mergeCts?.title, uid: mergeCts?.uid, options: { "singleton": false, - } - } - for await (const field of ctData?.schema ?? []) { - if (field?.data_type === 'group') { - const currentGroup = mergeCts?.schema?.find((grp: any) => grp?.uid === field?.uid && - grp?.data_type === 'group'); - const group = []; - for await (const fieldGp of currentGroup?.schema ?? []) { - const fieldNst = field?.schema?.find((fld: any) => fld?.uid === fieldGp?.uid && - fld?.data_type === fieldGp?.data_type); - if (fieldNst === undefined) { - group?.push(fieldGp); - } - } - field.schema = [...field?.schema ?? [], ...group]; - } - } - ctData.schema = await mergeArrays(ctData?.schema, mergeCts?.schema) ?? []; - return ctData; + }, + schema: await mergeFields(ct?.schema ?? [], mergeCts?.schema ?? []) + }; + + return merged; } export const contenTypeMaker = async ({ contentType, destinationStackId, projectId, newStack, keyMapper, region, user_id }: any) => { @@ -717,7 +767,7 @@ export const contenTypeMaker = async ({ contentType, destinationStackId, project "display_name": item?.contentstackField, "field_metadata": {}, "schema": [], - "uid": item?.contentstackFieldUid, + "uid": item?.contentstackFieldUid?.replace(/\./g, '_'), "multiple": false, "mandatory": false, "unique": false @@ -728,7 +778,7 @@ export const contenTypeMaker = async ({ contentType, destinationStackId, project uid: extractValue(element?.contentstackFieldUid, item?.contentstackFieldUid, '.'), title: extractValue(element?.contentstackField, item?.contentstackField, ' >')?.trim(), } - const schema: any = convertToSchemaFormate({ field, marketPlacePath }); + const schema: any = convertToSchemaFormate({ field, marketPlacePath, keyMapper}); if (typeof schema === 'object' && Array.isArray(group?.schema) && element?.isDeleted === false) { group.schema.push(schema); } @@ -741,7 +791,8 @@ export const contenTypeMaker = async ({ contentType, destinationStackId, project title: item?.contentstackField, uid: item?.contentstackFieldUid }, - marketPlacePath + marketPlacePath, + keyMapper }); if (dt && item?.isDeleted === false) { ct?.schema?.push(dt); diff --git a/api/src/utils/field-attacher.utils.ts b/api/src/utils/field-attacher.utils.ts index 7ac4efb68..1eafa6821 100644 --- a/api/src/utils/field-attacher.utils.ts +++ b/api/src/utils/field-attacher.utils.ts @@ -22,7 +22,7 @@ export const fieldAttacher = async ({ projectId, orgId, destinationStackId, regi contentType.fieldMapping = contentType?.fieldMapping?.map((fieldUid: any) => { const field = FieldMapperModel.chain .get("field_mapper") - .find({ id: fieldUid, projectId: projectId }) + .find({ id: fieldUid, projectId: projectId , contentTypeId: contentId}) .value() return field; }) From 67f11c894931895d5655079b5e4e7324670919a8 Mon Sep 17 00:00:00 2001 From: AishDani Date: Tue, 13 May 2025 14:13:56 +0530 Subject: [PATCH 04/13] fix:refactored the bug [CMG-639] When uid of the field is title and then for existing case it is getting mapped to title of existing content type --- .../advanceProperties.interface.ts | 2 +- ui/src/components/AdvancePropertise/index.tsx | 19 ++++++++++++------ ui/src/components/ContentMapper/index.tsx | 20 +++++++++---------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ui/src/components/AdvancePropertise/advanceProperties.interface.ts b/ui/src/components/AdvancePropertise/advanceProperties.interface.ts index 87d1b6830..f018cea6e 100644 --- a/ui/src/components/AdvancePropertise/advanceProperties.interface.ts +++ b/ui/src/components/AdvancePropertise/advanceProperties.interface.ts @@ -25,7 +25,7 @@ export interface SchemaProps { * @param value - The advanced settings. * @param checkBoxChanged - Indicates whether the checkbox has changed. */ - updateFieldSettings: (rowId: string, value: Advanced, checkBoxChanged: boolean) => void; + updateFieldSettings: (rowId: string, value: Advanced, checkBoxChanged: boolean, rowContentstackFieldUid: string) => void; /** * Indicates whether the field is localized. diff --git a/ui/src/components/AdvancePropertise/index.tsx b/ui/src/components/AdvancePropertise/index.tsx index fe3073873..7834b3dd2 100644 --- a/ui/src/components/AdvancePropertise/index.tsx +++ b/ui/src/components/AdvancePropertise/index.tsx @@ -147,7 +147,9 @@ const AdvancePropertise = (props: SchemaProps) => { title: currentToggleStates?.title, url: currentToggleStates?.url }, - checkBoxChanged + checkBoxChanged, + props?.data?.contentstackFieldUid + ); }; @@ -189,7 +191,8 @@ const AdvancePropertise = (props: SchemaProps) => { title: currentToggleStates?.title, url: currentToggleStates?.url }, - checkBoxChanged + checkBoxChanged, + props?.data?.contentstackFieldUid ); }; @@ -215,7 +218,8 @@ const AdvancePropertise = (props: SchemaProps) => { embedObject: currentToggleStates?.embedObject, embedObjects: embedObjectsLabels }, - true + true, + props?.data?.contentstackFieldUid ); }; @@ -251,7 +255,8 @@ const AdvancePropertise = (props: SchemaProps) => { embedObjects: embedObjectsLabels, options: options }, - true + true, + props?.data?.contentstackFieldUid ); }; const handleRemoveDefalutValue = (index: number) => { @@ -280,7 +285,8 @@ const AdvancePropertise = (props: SchemaProps) => { embedObjects: embedObjectsLabels, options: options }, - true + true, + props?.data?.contentstackFieldUid ); }; @@ -583,7 +589,8 @@ const AdvancePropertise = (props: SchemaProps) => { validationRegex: toggleStates?.validationRegex ?? '', embedObjects: embedObject }, - true + true, + props?.data?.contentstackFieldUid ); }} options={option} diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 3ce478a78..2ac9b5b9f 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -766,11 +766,11 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R }); } - const updateFieldSettings = (rowId: string, updatedSettings: Advanced, checkBoxChanged: boolean) => { + const updateFieldSettings = (rowId: string, updatedSettings: Advanced, checkBoxChanged: boolean, rowContentstackFieldUid: string) => { setIsDropDownChanged(checkBoxChanged); const newTableData = tableData?.map?.((row) => { - if (row?.uid === rowId) { + if (row?.uid === rowId && row?.contentstackFieldUid === rowContentstackFieldUid) { return { ...row, advanced: { ...row?.advanced, ...updatedSettings } }; } @@ -985,11 +985,11 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R }; // Method for change select value - const handleValueChange = (value: FieldTypes, rowIndex: string) => { + const handleValueChange = (value: FieldTypes, rowIndex: string, rowContentstackFieldUid: string) => { setIsDropDownChanged(true); setFieldValue(value); const updatedRows: FieldMapType[] = selectedEntries?.map?.((row) => { - if (row?.uid === rowIndex) { + if (row?.uid === rowIndex && row?.contentstackFieldUid === rowContentstackFieldUid) { return { ...row, contentstackFieldType: value?.value }; } return row; @@ -1069,7 +1069,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R { if (OptionsForRow?.length === 0) { - handleValueChange(selectedOption, data?.uid, data?.contentstackFieldUid) + handleValueChange(selectedOption, data?.uid, data?.backupFieldUid) } else { - handleFieldChange(selectedOption, data?.uid, data?.contentstackFieldUid) + handleFieldChange(selectedOption, data?.uid, data?.contentstackFieldUid, data?.backupFieldUid) } }} placeholder="Select Field" version={'v2'} maxWidth="290px" - isClearable={selectedOptions?.includes?.(existingField?.[data?.uid]?.label ?? '')} + isClearable={selectedOptions?.includes?.(existingField?.[data?.backupFieldUid]?.label ?? '')} options={adjustedOptions} isDisabled={OptionValue?.isDisabled || newMigrationData?.project_current_step > 4} menuPlacement="auto" @@ -1600,7 +1599,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R > diff --git a/ui/src/components/DestinationStack/index.tsx b/ui/src/components/DestinationStack/index.tsx index 1975da6aa..6e6ace5ea 100644 --- a/ui/src/components/DestinationStack/index.tsx +++ b/ui/src/components/DestinationStack/index.tsx @@ -100,15 +100,15 @@ const DestinationStackComponent = ({ setisProjectMapped(newMigrationData?.isprojectMapped); },[newMigrationData?.isprojectMapped]); - useEffect(()=>{ - if(! isEmptyString(newMigrationData?.destination_stack?.selectedStack?.value ) - ){ - handleAllStepsComplete(true); - } - else{ - handleAllStepsComplete(false); - } - },[newMigrationData]) + useEffect(()=>{ + if(! isEmptyString(newMigrationData?.destination_stack?.selectedStack?.value ) + ){ + handleAllStepsComplete(true); + } + else{ + handleAllStepsComplete(false); + } + },[newMigrationData?.destination_stack?.selectedStack]) return ( <> diff --git a/ui/src/components/Modal/index.tsx b/ui/src/components/Modal/index.tsx index f5e135bf2..8ddba2832 100644 --- a/ui/src/components/Modal/index.tsx +++ b/ui/src/components/Modal/index.tsx @@ -19,7 +19,6 @@ import { ProjectModalProps, FormData } from './modal.interface'; // Services import { useState } from 'react'; -import { createProject } from '../../services/api/project.service'; const Modal = (props: ProjectModalProps) => { const { diff --git a/ui/src/components/Modal/modal.interface.ts b/ui/src/components/Modal/modal.interface.ts index 29ef23ce3..76c5a2203 100644 --- a/ui/src/components/Modal/modal.interface.ts +++ b/ui/src/components/Modal/modal.interface.ts @@ -9,7 +9,7 @@ export interface ProjectModalProps { selectedOrg: IDropDown; closeModal: () => void; isOpen: (flag: boolean) => void; - createProject: (values : FormData)=> void + createProject: (values : FormData)=> Promise } export interface SettingsModalProps { selectedOrg: IDropDown; @@ -23,3 +23,17 @@ export interface SettingsModalProps { export interface FormData { name?: string; } + +export interface Project { + name: string; + id: string; + status: string; + created_at: string; + modified_at: string; +} + +export interface CreateProjectResponse { + status: "success"; + message: string; + project: Project; +} diff --git a/ui/src/pages/Projects/index.tsx b/ui/src/pages/Projects/index.tsx index f05ede6e2..140ca6614 100644 --- a/ui/src/pages/Projects/index.tsx +++ b/ui/src/pages/Projects/index.tsx @@ -27,7 +27,7 @@ import { validateObject } from '../../utilities/functions'; // Interfaces import { ProjectsType, ProjectsObj } from './projects.interface'; -import { ModalObj } from '../../components/Modal/modal.interface'; +import { CreateProjectResponse, ModalObj, FormData } from '../../components/Modal/modal.interface'; import { CTA } from '../Home/home.interface'; import usePreventBackNavigation from '../../hooks/usePreventBackNavigation'; @@ -137,8 +137,8 @@ const Projects = () => { }; useBlockNavigation(isModalOpen || true); - const createProjectCall = async(values : any) => { - const res:any = await createProject(selectedOrganisation?.uid || '', values); + const createProjectCall = async(values : FormData): Promise => { + const res = await createProject(selectedOrganisation?.uid || '', values); if (res?.error) { return res?.error; } From 06947c7155f43616a7483bb890ef12b08aa5ca5d Mon Sep 17 00:00:00 2001 From: AishDani Date: Mon, 2 Jun 2025 14:28:34 +0530 Subject: [PATCH 12/13] refactor:resolved PR comments --- .talismanrc | 5 ++--- api/src/services/wordpress.service.ts | 6 +++--- api/src/utils/content-type-creator.utils.ts | 2 +- ui/src/components/ContentMapper/index.tsx | 2 +- .../DestinationStack/Actions/LoadLanguageMapper.tsx | 6 +++--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.talismanrc b/.talismanrc index 1fd431471..93f1f002d 100644 --- a/.talismanrc +++ b/.talismanrc @@ -11,6 +11,5 @@ ignoreconfig: - Base64Detector - filename: ui/src/components/ContentMapper/index.tsx - checksum: 938aaf193e830bade84f9d8d385e55942269c3f2e7be82939994d64d76df3fa6 - -version: "1.0" + checksum: 6743142fce18f945d55fc61d7d774118db400b72ccc7a0b5e089ccc8aed20340 +version: "“1.0.1-beta”" diff --git a/api/src/services/wordpress.service.ts b/api/src/services/wordpress.service.ts index a72c917b3..9c9a4ea2a 100644 --- a/api/src/services/wordpress.service.ts +++ b/api/src/services/wordpress.service.ts @@ -2332,13 +2332,13 @@ async function extractPosts( packagePath: string, destinationStackId: string, pr postdataCombined = { ...postdataCombined, ...chunkPostData }; const seenTitles = new Map(); - Object?.entries(postdataCombined)?.forEach(([uid, item]:any) => { + Object?.entries?.(postdataCombined)?.forEach?.(([uid, item]:any) => { const originalTitle = item?.title; - if (seenTitles.has(originalTitle)) { + if (seenTitles?.has(originalTitle)) { item.title = `${originalTitle} - ${item?.uid}`; } - seenTitles.set(item?.title, true); + seenTitles?.set?.(item?.title, true); }); const message = getLogMessage( diff --git a/api/src/utils/content-type-creator.utils.ts b/api/src/utils/content-type-creator.utils.ts index 6eb2bb9df..2233faf68 100644 --- a/api/src/utils/content-type-creator.utils.ts +++ b/api/src/utils/content-type-creator.utils.ts @@ -82,7 +82,7 @@ const arrangGroups = ({ schema, newStack }: any) => { if (et?.contentstackFieldUid?.includes(`${item?.contentstackFieldUid}.`) || (newStack === false && et?.uid?.includes(`${item?.uid}.`))) { const target = groupSchema?.contentstackFieldUid; - const index = et?.contentstackFieldUid?.indexOf(target); + const index = et?.contentstackFieldUid?.indexOf?.(target); if (index > 0) { et.contentstackFieldUid = et?.contentstackFieldUid?.substring(index); diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index dfa3e887a..575247e04 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -2255,7 +2255,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R } }} > - {CONTENT_MAPPING_STATUS[key] && {CONTENT_MAPPING_STATUS[key]} } + {CONTENT_MAPPING_STATUS[key] && {CONTENT_MAPPING_STATUS[key]} } {STATUS_ICON_Mapping[key] && } diff --git a/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx b/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx index fa6249610..4537c2aa4 100644 --- a/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx +++ b/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx @@ -111,7 +111,7 @@ const Mapper = ({ // const validLabels = cmsLocaleOptions?.map((item)=> item?.label); - const existingMasterID = Object?.keys(selectedMappings || {})?.find((key) => + const existingMasterID = Object?.keys?.(selectedMappings || {})?.find((key) => key?.includes('-master_locale') ); @@ -140,7 +140,7 @@ const Mapper = ({ const existingLabel = existingMasterID; const expectedLabel = `${locale?.label}-master_locale`; - const isLabelMismatch = existingLabel && existingLabel.localeCompare(expectedLabel) !== 0; + const isLabelMismatch = existingLabel && existingLabel?.localeCompare(expectedLabel) !== 0; if(locale?.value === 'master_locale'){ if (!updatedExistingField?.[index]) { updatedExistingField[index] = { @@ -179,7 +179,7 @@ const Mapper = ({ ) => { const selectedLocaleKey = selectedValue?.value; - let existingLabel = existingField[index]; + let existingLabel = existingField?.[index]; if (!selectedValue?.label) { setselectedCsOption((prevSelected) => prevSelected?.filter((item) => item !== existingField?.[index]?.label) From 5ed10b259e3ae900ee4688fad8445c8b28bb049c Mon Sep 17 00:00:00 2001 From: Sayali Joshi Date: Mon, 2 Jun 2025 15:16:30 +0530 Subject: [PATCH 13/13] Update .talismanrc --- .talismanrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.talismanrc b/.talismanrc index 93f1f002d..3b24d02c6 100644 --- a/.talismanrc +++ b/.talismanrc @@ -12,4 +12,4 @@ ignoreconfig: - filename: ui/src/components/ContentMapper/index.tsx checksum: 6743142fce18f945d55fc61d7d774118db400b72ccc7a0b5e089ccc8aed20340 -version: "“1.0.1-beta”" +version: "1.0.1-beta"