Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
ui fixes and search locale
  • Loading branch information
snehalsankhe committed May 2, 2024
commit 67e1f227b26f628bb2a726132f985fd2ef0b29fb
14 changes: 7 additions & 7 deletions ui/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"semi": true,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": true
}
"semi": true,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": true
}
8 changes: 2 additions & 6 deletions ui/packaga-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -6905,9 +6905,7 @@
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz",
"integrity": "sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==",
"engines": [
"node >= 0.8.0"
],
"engines": ["node >= 0.8.0"],
"bin": {
"ansi-html": "bin/ansi-html"
}
Expand Down Expand Up @@ -11330,9 +11328,7 @@
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"os": ["darwin"],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/cmsData/legacyCms.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,4 @@
"restricted_keyword_checkbox_text": "Please acknowledge that you have referred to the Contentstack restricted keywords",
"affix_cta": "Continue",
"file_format_cta": "Continue"
}
}
4 changes: 2 additions & 2 deletions ui/src/components/Card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
}
.ProjectCard__modified-date {
color: $color-font-base;
display:block;
font-size:$size-font-small;
display: block;
font-size: $size-font-small;
font-weight: $font-weight-regular;
line-height: $line-height-reset;
padding-left: 8px;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Common/Settings/Settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.PageLayout {
width: 100%;
}
.PageLayout__head {
.PageLayout__head {
border-left: 0 none;
}
}
Expand Down
18 changes: 8 additions & 10 deletions ui/src/components/ContentMapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,14 @@ const ContentMapper = () => {
const accessorCall = (data: FieldMapType) => {
return (
<div>
<div className='cms-field'>{data?.otherCmsField}</div>
<div className="cms-field">{data?.otherCmsField}</div>
<InstructionText>
Other CMS Type: {data?.otherCmsType}<br />
UID: {data?.uid}
Other CMS Type: {data?.otherCmsType}
<br />
UID: {data?.uid}
</InstructionText>
</div>
)
);
};
interface UidMap {
[key: string]: boolean;
Expand All @@ -344,7 +345,6 @@ const ContentMapper = () => {
const handleDropDownChange = (value: FieldTypes) => {
setOtherContentType(value);
// fetchFields(contentTypes?.[i]?.id, searchText);

};

const handleAdvancedSetting = (fieldtype: string) => {
Expand Down Expand Up @@ -647,9 +647,7 @@ const ContentMapper = () => {
} else {
columns?.push({
disableSortBy: true,
Header: `Contentstack: ${
IsEmptyStack ? otherCmsTitle : OtherContentType?.label ?? ''
}`,
Header: `Contentstack: ${IsEmptyStack ? otherCmsTitle : OtherContentType?.label ?? ''}`,
accessor: SelectAccessor,
id: 'contentstack_cms_field',
default: false
Expand All @@ -672,10 +670,10 @@ const ContentMapper = () => {
{
label: 'Log selected Items',
cb: (data: any) => {
updateResetRowSelection(true)
updateResetRowSelection(true);
}
}
]
];

return (
<div className="step-container">
Expand Down
2 changes: 0 additions & 2 deletions ui/src/components/LegacyCms/Actions/LoadPrefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
setIsCheckedBoxChecked(checked);
};



/**** ALL USEEffects HERE ****/

const { restricted_keyword_link = DEFAULT_URL_TYPE, restricted_keyword_checkbox_text = '' } =
Expand Down
42 changes: 24 additions & 18 deletions ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,42 +89,46 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
updateCMSFilters(cmsFilter);
};

const getCmsType = async() => {
const res:any = await fileValidation();
const getCmsType = async () => {
const res: any = await fileValidation();
const cmsType = res?.data?.file_details?.cmsType;
return cmsType;
}
};
// Filter CMS Data
const filterCMSData = async (searchText: string) => {
const { all_cms = [] } = migrationData?.legacyCMSData || {};
const cmsType = await getCmsType(); // Fetch the specific CMS type
const cmsType = await getCmsType(); // Fetch the specific CMS type

let filteredCmsData: ICMSType[] = [];
if (isEmptyString(searchText) && !validateArray(cmsFilter) && !cmsType) {
filteredCmsData = all_cms;
} else {
if (cmsType) {
filteredCmsData = all_cms?.filter((cms: ICMSType) => cms?.cms_id === cmsType);
}

if (validateArray(cmsFilter) || !isEmptyString(searchText)) {
const searchTextLower = searchText?.toLowerCase();
filteredCmsData = all_cms
.filter(({ parent }: ICMSType) => !cmsFilter?.length || cmsFilter?.includes(parent))
.filter(({ title, cms_id }: ICMSType) =>
title?.toLowerCase()?.includes(searchTextLower) ||
cms_id?.toLowerCase()?.includes(searchTextLower)
.filter(
({ title, cms_id }: ICMSType) =>
title?.toLowerCase()?.includes(searchTextLower) ||
cms_id?.toLowerCase()?.includes(searchTextLower)
);
}
}

setCmsData(filteredCmsData); // Set filtered CMS data

// Determine if a new card should be selected
const newSelectedCard = filteredCmsData?.find(cms => cms?.cms_id === selectedCard?.cms_id) || filteredCmsData[0] || null;

const newSelectedCard =
filteredCmsData?.find((cms) => cms?.cms_id === selectedCard?.cms_id) ||
filteredCmsData[0] ||
null;

if (newSelectedCard?.cms_id !== selectedCard?.cms_id) {
setSelectedCard(newSelectedCard);
setSelectedCard(newSelectedCard);

const newMigrationDataObj: INewMigration = {
...newMigrationData,
Expand All @@ -133,12 +137,14 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
selectedCms: newSelectedCard
}
};
updateNewMigrationData(newMigrationDataObj);

updateNewMigrationData(newMigrationDataObj);

// API call for saving selected CMS, if a new card is selected
if (newSelectedCard) {
updateLegacyCMSData(selectedOrganisation?.value, projectId, { legacy_cms: newSelectedCard?.cms_id });
updateLegacyCMSData(selectedOrganisation?.value, projectId, {
legacy_cms: newSelectedCard?.cms_id
});
}
}
};
Expand Down
27 changes: 12 additions & 15 deletions ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,42 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
const { projectId = '' } = useParams();

//Handle further action on file is uploaded to server
const handleOnFileUploadCompletion = async() => {

const res : any = await fileValidation();
const handleOnFileUploadCompletion = async () => {
const res: any = await fileValidation();

const newMigrationDataObj: INewMigration = {
...newMigrationData,
legacy_cms: {
...newMigrationData.legacy_cms,
uploadedFile: {
name: res?.data?.file_details?.localPath,
url : res?.data?.file_details?.localPath,
url: res?.data?.file_details?.localPath,
validation: res?.data?.message,
isValidated: res?.data?.status== 200 ? true : false,
isValidated: res?.data?.status == 200 ? true : false,
file_details: {
isLocalPath:res?.data?.file_details?.isLocalPath,
isLocalPath: res?.data?.file_details?.isLocalPath,
cmsType: res?.data?.file_details?.cmsType,
localPath: res?.data?.file_details?.localPath,
awsData: {
awsRegion: res?.data?.file_details?.awsData?.awsRegion,
bucketName:res?.data?.file_details?.awsData?.bucketName,
buketKey:res?.data?.file_details?.awsData?.buketKey,
bucketName: res?.data?.file_details?.awsData?.bucketName,
buketKey: res?.data?.file_details?.awsData?.buketKey
}
}},
}
}
}
}
};
updateNewMigrationData(newMigrationDataObj);


props.handleStepChange(props.currentStep, true);


props.handleStepChange(props.currentStep, true);
};

const allowedFileExtentions = `.${
newMigrationData?.legacy_cms?.selectedFileFormat?.title || 'zip'
}`;
useEffect(() => {
handleOnFileUploadCompletion();
},[newMigrationData]);
}, [newMigrationData]);

return (
<div className="row">
Expand Down
47 changes: 21 additions & 26 deletions ui/src/components/LegacyCms/Summary/UploadFileSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ interface Props {
fileDetails: FileDetails;
}

const FileComponent : React.FC<Props>= ({fileDetails}) => {
const FileComponent: React.FC<Props> = ({ fileDetails }) => {
return (
<div className='col-11'>
<div className="col-11">
<p className="summary-title">Is Local Path: {fileDetails?.isLocalPath ? 'Yes' : 'No'}</p>
<p className="summary-title">CMS Type: {fileDetails?.cmsType}</p>
<p className="summary-title">Local Path: {fileDetails?.localPath}</p>
Expand All @@ -26,43 +26,38 @@ const FileComponent : React.FC<Props>= ({fileDetails}) => {
<p className="summary-title">Bucket Key: {fileDetails?.awsData?.buketKey}</p>
</div>
);


}
};

const UploadFileSummary = ({
stepComponentProps,
stepData
}: UploadFileSummaryProps): JSX.Element => {
const { newMigrationData } = useContext(AppContext);


return (
<div className="row bg-white">
{!isEmptyString(newMigrationData?.legacy_cms?.uploadedFile?.name)
? (
<div className="col-11 ">
<FileComponent fileDetails={newMigrationData?.legacy_cms?.uploadedFile?.file_details}/>
<br></br>
<span className="summary-title">{newMigrationData?.legacy_cms?.uploadedFile?.validation}</span>
{!isEmptyString(newMigrationData?.legacy_cms?.uploadedFile?.name) ? (
<div className="col-11 ">
<FileComponent fileDetails={newMigrationData?.legacy_cms?.uploadedFile?.file_details} />
<br></br>
<span className="summary-title">
{newMigrationData?.legacy_cms?.uploadedFile?.validation}
</span>

{!newMigrationData?.legacy_cms?.uploadedFile?.isValidated
?
(<p className=' ValidationMessage__v2'>Please upload the correct file</p>) :
(<></>)
}

</div>


{!newMigrationData?.legacy_cms?.uploadedFile?.isValidated ? (
<p className=" ValidationMessage__v2">Please upload the correct file</p>
) : (
<></>
)}
</div>
) : (
<div className="col-12 bg-white">
<span className="summary-title">{stepData?.empty_step_placeholder}</span>
{!newMigrationData?.legacy_cms?.uploadedFile?.isValidated
?
(<p className=' ValidationMessage__v2'>Please upload the correct file</p>) :
(<></>)
}
{!newMigrationData?.legacy_cms?.uploadedFile?.isValidated ? (
<p className=" ValidationMessage__v2">Please upload the correct file</p>
) : (
<></>
)}
</div>
)}
</div>
Expand Down
Loading