Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b9f8d52
solved bugs
snehalsankhe Aug 28, 2024
e48781b
solved bugs
snehalsankhe Aug 28, 2024
c81f4a5
merged from dev
snehalsankhe Aug 28, 2024
1c887a1
Merge pull request #252 from contentstack/bugsDest
RohitKini Aug 28, 2024
1db0093
refactor:resolved checkbox and advance propertise bugs of content mapper
AishDani Aug 29, 2024
b64b061
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Aug 29, 2024
47ea753
Merge pull request #253 from contentstack/bugfix/legacy-cms
RohitKini Aug 29, 2024
a4a9359
refactor:resolved advanced propertise bugs
AishDani Aug 29, 2024
2d3b6e6
refactor:removed log
AishDani Aug 29, 2024
1388b66
Merge pull request #254 from contentstack/bugfix/legacy-cms
RohitKini Aug 29, 2024
ae74707
solved bugs
snehalsankhe Aug 29, 2024
60a7438
merged from dev
snehalsankhe Aug 29, 2024
123073f
optimised code
snehalsankhe Aug 29, 2024
eb7a099
Merge pull request #255 from contentstack/bugsDest
RohitKini Aug 30, 2024
b5426c7
[CMG-254]
sayalijoshi27 Sep 2, 2024
b75c511
region fixes
sayalijoshi27 Sep 2, 2024
02011ae
Merge pull request #257 from contentstack/bugfix/content-mapper
RohitKini Sep 2, 2024
2098bd6
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Sep 2, 2024
4b7102c
refactor:refactored the legacy cms redux with the new redux setup me…
AishDani Sep 2, 2024
a1e193f
refactor:legacy cms redux logic
AishDani Sep 2, 2024
dfe412e
refactor:removed projectdata prop from legacy cms
AishDani Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/src/models/FieldMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ interface Advanced {
Multiple: boolean;
Unique: boolean;
NonLocalizable: boolean;
EmbedObject: boolean;
EmbedObjects:any;
MinChars: string;
MaxChars: number;
}

/**
Expand Down
1 change: 1 addition & 0 deletions api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface Project {
isNewStack: boolean;
newStackId: string;
stackDetails: [];
mapper_keys: [];
}

interface ProjectDocument {
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const putTestData = async (req: Request) => {
const id = field?.id?.replace(/[{}]/g, "")?.toLowerCase() || uuidv4();
field.id = id;
fieldIds.push(id);
return { id, projectId, isDeleted: true, ...field };
return { id, projectId, isDeleted: false, ...field };
});
FieldMapperModel.update((data: any) => {
data.field_mapper = [...(data?.field_mapper ?? []), ...fields];
Expand Down Expand Up @@ -419,7 +419,7 @@ const updateContentType = async (req: Request) => {
if (fieldIndex > -1 && field?.ContentstackFieldType !== "") {
FieldMapperModel.update((data: any) => {
data.field_mapper[fieldIndex] = field;
data.field_mapper[fieldIndex].isDeleted = false;
//data.field_mapper[fieldIndex].isDeleted = false;
});
}
});
Expand Down
8 changes: 5 additions & 3 deletions api/src/services/org.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const getAllStacks = async (req: Request): Promise<LoginServiceType> => {
},
})
);

// console.info(err, res);
if (err) {
logger.error(
getLogMessage(
Expand All @@ -63,10 +63,12 @@ const getAllStacks = async (req: Request): Promise<LoginServiceType> => {
);
});
}
const locale = await getStackLocal(token_payload, stacks);
// const locale:any[]
// const locale = await getStackLocal(token_payload, stacks);
return {
data: {
stacks: locale,
// stacks: locale,
stacks,
},
status: res.status,
};
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ const updateContentMapper = async (req: Request) => {

try {
ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].content_mapper = content_mapper;
data.projects[projectIndex].mapper_keys = content_mapper;
data.projects[projectIndex].updated_at = new Date().toISOString();
});

Expand Down
17 changes: 15 additions & 2 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense } from 'react';
import { Suspense, useEffect } from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { FullPageLoader } from '@contentstack/venus-components';
Expand All @@ -18,6 +18,20 @@ import { useNetworkCheck } from './components/NetworkProvider';
function App() {
const isOnline = useNetworkCheck();

useEffect(() => {
const selectModal = document.querySelector('.ReactModalPortal');

if (selectModal instanceof HTMLElement) {
if (!isOnline) {
// Hide the modal by setting display to none
selectModal.style.display = 'none';
} else {
// Show the modal by setting display to block
selectModal.style.display = 'block';
}
}
}, [isOnline]);

return (
<>
{isOnline ? (
Expand All @@ -38,5 +52,4 @@ function App() {
</>
);
}

export default App;
6 changes: 3 additions & 3 deletions ui/src/cmsData/region_login.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"_metadata": { "uid": "cs77a3bf15c456afbb" }
},
{
"region": "EU",
"region": "GCP_NA",
"service_icon": {
"uid": "blt57dafa9c1472b46f",
"created_at": "2024-07-29T10:57:59.058Z",
Expand Down Expand Up @@ -82,7 +82,7 @@
}
},
{
"region": "AZURE_EU",
"region": "EU",
"service_icon": {
"uid": "bltbe45879eac0025d8",
"created_at": "2023-10-31T06:59:22.783Z",
Expand All @@ -106,7 +106,7 @@
"_metadata": { "uid": "csf578f8fbea1ae0c0" }
},
{
"region": "GCP_NA",
"region": "AZURE_EU",
"service_icon": {
"uid": "blt85d2a7024c613199",
"created_at": "2023-10-31T07:00:56.567Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export interface UpdatedSettings {
* Indicates whether the component is non-localizable.
*/
NonLocalizable?: boolean;

Multiple?: boolean;

EmbedObjects?: any
}

/**
Expand Down
94 changes: 59 additions & 35 deletions ui/src/components/AdvancePropertise/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import { ContentType } from '../ContentMapper/contentMapper.interface';
// Styles
import './index.scss';

interface ContentTypeOption {
label: string;
value: string;
}

/**
* Component for displaying advanced properties.
* @param props - The schema properties.
Expand All @@ -44,17 +49,23 @@ const AdvancePropertise = (props: SchemaProps) => {
allowImagesOnly: props?.value?.AllowImagesOnly,
nonLocalizable: props?.value?.NonLocalizable,
embedObject: true,
embedAssests: true
embedAssests: true,
multiple: props?.value?.Multiple,
embedObjects: props?.value?.EmbedObjects
});

const embedObjects = props?.value?.EmbedObjects?.map((item: string) => ({
label: item,
value: item,
}));
// State for content types
const [contentTypes, setContentTypes] = useState<ContentType[]>([]);
const [ctValue, setCTValue] = useState(null);
const [ctValue, setCTValue] = useState<ContentTypeOption[] | null>(embedObjects);
const [embedObjectslabels, setEmbedObjectsLabels] = useState<string[]>(props?.value?.EmbedObjects);

useEffect(() => {
fetchContentTypes('');
}, [])

/**
* Fetches the content types list.
* @param searchText - The search text.
Expand All @@ -77,16 +88,27 @@ const AdvancePropertise = (props: SchemaProps) => {
[field]: (event.target as HTMLInputElement)?.value
}));

const currentToggleStates = {
...toggleStates,
[field]: (event.target as HTMLInputElement)?.value,
};

props?.updateFieldSettings(
props?.rowId,
{
...props?.value,
[field?.charAt(0)?.toUpperCase() + field?.slice(1)]: (event.target as HTMLInputElement)?.value,
validationRegex: '',
Mandatory: false,
Multiple: false,
MinChars: currentToggleStates?.minChars,
MaxChars:currentToggleStates?.maxChars,
Mandatory: currentToggleStates?.mandatory,
Multiple: currentToggleStates?.multiple,
Unique: false,
NonLocalizable: false,
EmbedObject: false
NonLocalizable: currentToggleStates?.nonLocalizable,
EmbedObject: currentToggleStates?.embedObject,
EmbedObjects: embedObjectslabels,
MinRange: currentToggleStates?.minRange,
MaxRange: currentToggleStates?.maxRange,
},
checkBoxChanged
);
Expand All @@ -103,22 +125,35 @@ const AdvancePropertise = (props: SchemaProps) => {
...prevStates,
[field]: value
}));

const currentToggleStates = {
...toggleStates,
[field]: value,
};

props?.updateFieldSettings(
props?.rowId,
{
[field?.charAt(0)?.toUpperCase() + field?.slice(1)]: value,
validationRegex: '',
Mandatory: false,
Multiple: false,
Mandatory: currentToggleStates?.mandatory,
Multiple: currentToggleStates?.multiple,
Unique: false,
NonLocalizable: false,
EmbedObject: false
NonLocalizable: currentToggleStates?.nonLocalizable,
EmbedObject: currentToggleStates?.embedObject,
EmbedObjects : embedObjectslabels
},
checkBoxChanged
);
};

useEffect(() => {

if (ctValue && Array.isArray(ctValue)) {
const labels = ctValue.map((item) => item.label);
setEmbedObjectsLabels(labels);
}
}, [ctValue]);

// Option for content types
const option = Array.isArray(contentTypes)
? contentTypes.map((option) => ({ label: option?.otherCmsTitle, value: option?.otherCmsTitle }))
Expand Down Expand Up @@ -323,7 +358,18 @@ const AdvancePropertise = (props: SchemaProps) => {
<Select
value={ctValue}
isMulti={true}
onChange={setCTValue}
onChange={(selectedOptions:any) => {
setCTValue(selectedOptions);
const embedObject = selectedOptions.map((item: any) => item.label);// Update the state with the selected options
props?.updateFieldSettings(
props?.rowId,
{
validationRegex : toggleStates?.validationRegex || '',
EmbedObjects: embedObject
},
true,
);
}}
options={option}
placeholder="Select Content Types"
version='v2'
Expand All @@ -334,16 +380,6 @@ const AdvancePropertise = (props: SchemaProps) => {
/>
)}

<div className='ToggleWrap'>
<ToggleSwitch
label="Embed Asset(s)"
labelColor="primary"
labelPosition="right"
checked={toggleStates?.embedAssests}
disabled={toggleStates?.embedAssests}
onChange={handleToggleChange && ((e: React.MouseEvent<HTMLElement>) => handleToggleChange('embedAssests', (e.target as HTMLInputElement)?.checked, true))}
/>
</div>
</>
)}
{props?.fieldtype !== 'Global' && (
Expand All @@ -357,18 +393,6 @@ const AdvancePropertise = (props: SchemaProps) => {
/>
</div>
)}

{props?.fieldtype === 'File' && (
<div className='ToggleWrap'>
<ToggleSwitch
label="Allow Images Only"
labelColor="primary"
labelPosition="right"
checked={toggleStates?.allowImagesOnly}
onChange={handleToggleChange && ((e: React.MouseEvent<HTMLElement>) => handleToggleChange('allowImagesOnly', (e.target as HTMLInputElement)?.checked, true))}
/>
</div>
)}

<div className='ToggleWrap'>
<Tooltip
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const CardList = ({ project }: ProjectType) => {
// }, [selectedOrganisation?.value, project?.id]);

return (
<div style={{ margin: '0 20px 20px 0' }}>
<div style={{ margin: '0 19px 20px 0' }}>
<div onClick={() => onClickProject(project?.id || '')}>
<div className="ProjectCard">
<div className='ProjectCardWrapper'>
Expand Down
7 changes: 0 additions & 7 deletions ui/src/components/Common/Card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@
* CSS class for a centered card title.
* Adds a margin of 10px to the title.
*/
.centered-card-title {
margin: 10px;
}
.centered-card-title{
margin: 10px;
}

.centered-card-title {
margin: 10px;
p {
Expand Down
5 changes: 5 additions & 0 deletions ui/src/components/ContentMapper/contentMapper.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export interface Advanced {
Unique?: boolean;
NonLocalizable?: boolean;
EmbedObject?: boolean;
EmbedObjects?:any;
MinChars?: string;
MaxChars?: number;
MinRange?: number,
MaxRange?: number,
}

export interface ItemStatus {
Expand Down
Loading