Skip to content
Merged

Dev #103

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
84dd11c
add trim false in case of tfa token in login api
shristi-sinha May 7, 2024
c15d573
Merge pull request #93 from contentstack/feature/tfa-token-validation
umeshmore45 May 7, 2024
bb54887
add advanced field in mapper model
shristi-sinha May 7, 2024
091b2b1
Merge pull request #94 from contentstack/feature/add-mapper-json
shreyasBhoyar May 7, 2024
bae09bf
code refactor
sayalijoshi27 May 7, 2024
647ca18
solved locale issue
snehalsankhe May 8, 2024
3dbe63c
add validation for error handling
snehalsankhe May 9, 2024
a361b9f
Merge pull request #95 from contentstack/cmg-99-locales-search
AishDani May 9, 2024
53d848b
create a function to get all locals of particular stack and add that…
shristi-sinha May 9, 2024
06dcd46
Merge pull request #96 from contentstack/feature/get-all-locale
shreyasBhoyar May 9, 2024
d65aa5f
Solved bugs
snehalsankhe May 9, 2024
8513574
Merge pull request #97 from contentstack/cmg-99-locales-search
sayalijoshi27 May 9, 2024
d115a48
[CMG-103] - UI for Mapping with group field
sayalijoshi27 May 9, 2024
1a6e4fb
Code refactored: resolved PR comments
sayalijoshi27 May 10, 2024
90700da
Merge pull request #98 from contentstack/feature/CMG-103
AishDani May 10, 2024
ffc12dc
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 May 10, 2024
2953148
feat:integrated advanced propertise with backend
AishDani May 10, 2024
3df80e2
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani May 10, 2024
02f5f32
refactor:resized modal size
AishDani May 10, 2024
0bad06d
refactor:changed library sequences
AishDani May 10, 2024
b1565f8
Merge pull request #99 from contentstack/feature/project-dashboard
sayalijoshi27 May 10, 2024
3bd3583
[CMG-102] - UI for for On row uncheck make isdeleted value to true
sayalijoshi27 May 10, 2024
f4f8ded
Content mapper merged
sayalijoshi27 May 10, 2024
ad7d166
Removed console
sayalijoshi27 May 10, 2024
b978606
Merge pull request #100 from contentstack/feature/CMG-102
AishDani May 10, 2024
71142e7
refactor:resolved project name error showing on tab change
AishDani May 10, 2024
3040039
[CMG-105] - UI - Disable Title and Url fields from being mapped
sayalijoshi27 May 10, 2024
0c869ce
Merge pull request #101 from contentstack/feature/project-dashboard
sayalijoshi27 May 10, 2024
f0af2e3
Merge pull request #102 from contentstack/feature/CMG-102
snehalsankhe May 13, 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
9 changes: 9 additions & 0 deletions api/src/models/FieldMapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { JSONFile } from "lowdb/node";
import LowWithLodash from "../utils/lowdb-lodash.utils.js";

interface Advanced {
validationRegex: string,
Mandatory:boolean,
Multiple:boolean,
Unique:boolean,
NonLocalizable:boolean
}

interface FieldMapper {
field_mapper: {
id: string;
Expand All @@ -13,6 +21,7 @@ interface FieldMapper {
isDeleted: boolean;
backupFieldType: string;
refrenceTo: { uid: string; title: string };
advanced:Advanced
}[];
}

Expand Down
65 changes: 58 additions & 7 deletions api/src/services/org.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,10 @@ const getAllStacks = async (req: Request): Promise<LoginServiceType> => {
status: err.response.status,
};
}

let locale = await getStackLocal(token_payload, res.data.stacks);
return {
data: {
stacks:
res.data.stacks?.map((stack: any) => ({
name: stack.name,
api_key: stack.api_key,
master_locale: stack.master_locale,
})) || [],
stacks: locale,
},
status: res.status,
};
Expand Down Expand Up @@ -280,6 +275,62 @@ const getStackStatus = async (req: Request) => {
);
}
};
//get all locals of particular stack
const getStackLocal = async (token_payload: any, data: any) => {
const srcFun = "getStackLocal";
return new Promise(async (resolve, reject) => {
const authtoken = await getAuthtoken(
token_payload?.region,
token_payload?.user_id
);
let stacks = [];
for (let stack of data) {
const [err, res] = await safePromise(
https({
method: "GET",
url: `${config.CS_API[
token_payload?.region as keyof typeof config.CS_API
]!}/locales`,
headers: {
api_key: stack.api_key,
authtoken,
},
})
);
if (err) {
logger.error(
getLogMessage(
srcFun,
HTTP_TEXTS.CS_ERROR,
token_payload,
err.response.data
)
);

return {
data: err.response.data,
status: err.response.status,
};
}
let localesArr:any =[]
res?.data?.locales.map((lang:any)=>{
return localesArr.push({
code:lang.code,
name:lang.name
})
})

let obj = {
name: stack.name,
api_key: stack.api_key,
master_locale: stack.master_locale,
locales: localesArr
};
stacks.push(obj);
}
resolve(stacks);
});
};

export const orgService = {
getAllStacks,
Expand Down
2 changes: 1 addition & 1 deletion api/src/validators/auth.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ export default checkSchema({
errorMessage: VALIDATION_ERRORS.STRING_REQUIRED.replace("$", "2FA Token"),
bail: true,
},
trim: true,
trim: false,
},
});
2 changes: 1 addition & 1 deletion ui/src/cmsData/login.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"locale": "en-us",
"uid": "blt058427c4131df78a",
"_in_progress": false,
"copyrightText": "© 2023-2024 Contentstack Inc. All rights reserved.",
"copyrightText": "Contentstack Inc. All rights reserved.",
"created_at": "2024-02-22T11:20:53.435Z",
"created_by": "bltb317ebe35429ebe6",
"heading": "Stacks Not Suites",
Expand Down
7 changes: 5 additions & 2 deletions ui/src/components/AccountPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import './index.scss';
const AccountPage = (props: AccountObj): JSX.Element => {
const { heading, subtitle, copyrightText } = props.data;

const currentYear = new Date().getFullYear();
const previousYear = currentYear - 1;

return (
// eslint-disable-next-line react/no-unknown-property
<div className="AccountPage" heap-ignore="true">
Expand All @@ -32,8 +35,8 @@ const AccountPage = (props: AccountObj): JSX.Element => {
<span className="AccountPage__circle AccountPage__circle_seven"></span>
</div>
<div className="AccountPage__action">
<div className="AccountPage__content">{props.children}</div>
<p className='copyright_text'>{copyrightText}</p>
<div className="AccountPage__content">{props?.children}</div>
<p className='copyright_text'>{`© ${previousYear}-${currentYear} ${copyrightText}`}</p>
</div>
</div>
);
Expand Down
63 changes: 56 additions & 7 deletions ui/src/components/AdvancePropertise/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,72 @@
import { useState } from 'react';

import {
ModalBody,
ModalHeader,
FieldLabel,
TextInput,
ToggleSwitch
ToggleSwitch,
Tooltip
} from '@contentstack/venus-components';

import './index.scss';


export interface SchemaProps {
fieldtype: string;
value: any;
rowId: string;
updateFieldSettings:(rowId:string, value:any, checkBoxChanged:boolean)=> void;
isLocalised:boolean;
closeModal: () => void;
data:any
}
const AdvancePropertise = (props: SchemaProps) => {
const AdvancePropertise = (props: SchemaProps) => {


const [toggleStates, setToggleStates] = useState({
validationRegex: props?.value?.ValidationRegex,
mandatory: props?.value?.Mandatory,
multiple: props?.value?.Multiple,
unique: props?.value?.Unique,
nonLocalizable: props?.value?.NonLocalizable
});

const handleToggleChange = (field: string, value: boolean, checkBoxChanged: boolean) => {

setToggleStates(prevStates => ({
...prevStates,
[field]: value
}));

props?.updateFieldSettings(props?.rowId, {[field?.charAt(0)?.toUpperCase() + field?.slice(1)]: value}, checkBoxChanged);
};

const handleOnChange = ( field: string, event: any, checkBoxChanged: boolean) => {
setToggleStates(prevStates => ({
...prevStates,
[field]: event?.target?.value
}));

props?.updateFieldSettings(props?.rowId, {[field?.charAt(0)?.toUpperCase() + field?.slice(1)]: event?.target?.value}, checkBoxChanged);

}


return (
<>
<ModalHeader title={`${props.fieldtype} propertise`} closeModal={props.closeModal} />
<ModalHeader title={`${props?.fieldtype} propertise`} closeModal={props?.closeModal} />
<ModalBody>
<FieldLabel htmlFor="someInput" version="v2">
Validation (Regex)
</FieldLabel>
<TextInput
className="validation-input"
type="text"
value={toggleStates?.validationRegex}
placeholder="Enter value"
version="v2"
onChange={(e:any)=> handleOnChange("validationRegex",e, true)}
/>
<FieldLabel className="option-label" htmlFor="someInput" version="v2">
Options
Expand All @@ -36,26 +76,35 @@ const AdvancePropertise = (props: SchemaProps) => {
label="Mandatory"
labelColor="primary"
labelPosition="right"
checked={props?.value?.mandatory}
checked={toggleStates?.mandatory}
onChange={(e:any) => handleToggleChange("mandatory" , e?.target?.checked, true)}
/>
<ToggleSwitch
label="Multiple"
labelColor="primary"
labelPosition="right"
checked={props?.value?.multiple}
checked={toggleStates?.multiple}
onChange={(e:any) => handleToggleChange("multiple" ,e?.target?.checked, true)}
/>
<ToggleSwitch
label="Unique"
labelColor="primary"
labelPosition="right"
checked={props?.value?.unique}
checked={toggleStates?.unique}
onChange={(e:any) => handleToggleChange("unique" , e?.target?.checked,true)}
/>
<Tooltip content='Available only if there are multiple languages in your stack' position='top' disabled={props?.isLocalised}>
<ToggleSwitch
id="disabled"
disabled={ ! props?.isLocalised}
label="Non-localizable"
labelColor="primary"
labelPosition="right"
checked={props?.value?.non_localizable}
checked={toggleStates?.nonLocalizable}
onChange={(e:any) => handleToggleChange("nonLocalizable" , e?.target?.checked,true)}
/>

</Tooltip>
<p className="non-localizable-message">
If enabled, editing this field is restricted in localized entries. The field will use
the value of the master-language entry in all localized entries.
Expand Down
30 changes: 26 additions & 4 deletions ui/src/components/Common/AddStack/addStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import { AddStackCMSData, defaultAddStackCMSData } from './addStack.interface';

// Styles
import './addStack.scss';
import { getAllLocales } from '../../../services/api/user.service';
import { validateObject } from '../../../utilities/functions';
import { IDropDown } from '../../../context/app/app.interface';
export interface Stack {
name: string;
description: string;
Expand All @@ -37,11 +40,11 @@ export interface Stack {
const AddStack = (props: any): JSX.Element => {
const [isProcessing, setIsProcessing] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [allLocales, setAllLocales] = useState<IDropDown[]>([]);
const [addStackCMSData, setAddStackCMSData] = useState<AddStackCMSData>(defaultAddStackCMSData);

const onSubmit = async (formData: any) => {
setIsProcessing(true);
const resp = await props.onSubmit({
const resp = await props?.onSubmit({
name: formData?.name || props?.defaultValues?.name,
description: formData?.description || props?.defaultValues?.description,
locale: formData?.locale?.value || props?.defaultValues?.locale
Expand All @@ -52,7 +55,7 @@ const AddStack = (props: any): JSX.Element => {
notificationContent: { text: 'Stack created successfully' },
type: 'success'
});
props.closeModal();
props?.closeModal();
} else {
Notification({ notificationContent: { text: 'Failed to create the stack' }, type: 'error' });
}
Expand All @@ -77,6 +80,25 @@ const AddStack = (props: any): JSX.Element => {
console.error(err);
setIsLoading(false);
});

//fetch all locales
getAllLocales(props?.selectedOrganisation).then((response:any) => {
const rawMappedLocalesMapped = validateObject(response?.data) && response?.data?.locales
? Object?.keys(response?.data?.locales)?.map((key) => ({
uid: key,
label: response?.data?.locales[key],
value: key,
master_locale: key,
locales:[],
created_at: key
}))
: [];
setAllLocales(rawMappedLocalesMapped);
})
.catch((err: any) => {
console.error(err);
});
//org id will always be there
}, []);
return (
<>
Expand Down Expand Up @@ -202,7 +224,7 @@ const AddStack = (props: any): JSX.Element => {
}}
name="locale"
width="300px"
options={props?.locales}
options={allLocales}
maxMenuHeight={200}
isClearable={true}
version={'v2'}
Expand Down
21 changes: 19 additions & 2 deletions ui/src/components/ContentMapper/contentMapper.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ interface mapDataType {
contentTypes: ContentType[];
projectId: string;
}
interface Advanced {
ValidationRegex: string,
mandatory:boolean,
multiple:boolean,
unique:boolean,
nonLocalizable:boolean
}
export interface ContentMapperType {
content_types_heading?: string;
cta: CTA;
Expand All @@ -24,7 +31,7 @@ export interface ContentstackFields {

export interface FieldTypes {
label: string;
value: string;
value: any;
}
export interface TableTypes {
sortBy: any;
Expand All @@ -47,6 +54,7 @@ export interface ContentType {

export interface FieldMapType {
ContentstackFieldType: string;
child?: FieldMapType[] | undefined;
backupFieldType: string;
contentstackField: string;
contentstackFieldUid: string;
Expand All @@ -55,7 +63,8 @@ export interface FieldMapType {
otherCmsType: string;
uid: string;
id: string;
_invalid?: boolean;
_canSelect?: boolean;
advanced:Advanced
}

export interface ItemStatus {
Expand Down Expand Up @@ -99,3 +108,11 @@ export interface optionsType {
export interface ExstingContentTypeMatch {
[key: string]: string;
}

export interface UidMap {
[key: string]: boolean;
}

export interface ContentTypeMap {
[key: string]: string;
}
Loading