Skip to content

Commit 7b20417

Browse files
committed
Refactor migration and UI components for improved functionality
- Updated migration service to use the correct destination stack ID. - Enhanced AdvancePropertise component to include additional toggle states in field settings. - Modified ContentMapper styles for better layout, including a sticky footer for the save button and adjustments to prevent header wrapping. - Improved file processing error handling in upload API to ensure robust responses and logging.
2 parents 2e69836 + 387859d commit 7b20417

File tree

5 files changed

+115
-49
lines changed

5 files changed

+115
-49
lines changed

api/src/services/migration.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ const startMigration = async (req: Request): Promise<any> => {
10201020
await aemService.createAssets({
10211021
projectId,
10221022
packagePath,
1023-
destinationStackId: project?.current_test_stack_id,
1023+
destinationStackId: project?.destination_stack_id,
10241024
});
10251025
await aemService.createEntry({
10261026
packagePath,

ui/src/components/AdvancePropertise/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@ const AdvancePropertise = (props: SchemaProps) => {
826826
props?.updateFieldSettings(
827827
props?.rowId,
828828
{
829+
...props?.value,
830+
mandatory: toggleStates?.mandatory,
831+
nonLocalizable: toggleStates?.nonLocalizable,
832+
referenedItems: toggleStates?.referenedItems,
829833
validationRegex: toggleStates?.validationRegex ?? '',
830834
embedObjects: embedObject,
831835
embedObject: !shouldToggleOff

ui/src/components/ContentMapper/index.scss

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
overflow-x: hidden;
6060
}
6161
.ct-list {
62-
border-right: 1px solid $color-brand-secondary-lightest;
6362
list-style-type: none;
6463
padding: 15px 0 15px 0;
6564
li {
@@ -151,7 +150,7 @@
151150
}
152151
.Table {
153152
border-left: 0 none;
154-
min-height: 26.25rem;
153+
min-height: 24.25rem;
155154
.Table__body__row {
156155
.Table-select-body {
157156
>.checkbox-wrapper {
@@ -426,4 +425,47 @@ div .table-row {
426425
.advanced-setting-button,
427426
.table-row button {
428427
flex-shrink: 0;
428+
}
429+
430+
// Prevent header wrapping
431+
.nowrap-header {
432+
white-space: nowrap;
433+
display: inline-block;
434+
}
435+
436+
// Make sure table and save button stay fully visible
437+
.table-wrapper {
438+
position: relative;
439+
padding-bottom: 70px;
440+
}
441+
442+
// Sticky footer for Save button
443+
.mapper-footer {
444+
position: sticky;
445+
bottom: 0;
446+
background: #fff;
447+
padding: 12px 18px;
448+
border-top: 1px solid #e5e5e5;
449+
display: flex;
450+
justify-content: space-between;
451+
align-items: center;
452+
z-index: 100;
453+
}
454+
455+
// Ensure Save button is never clipped
456+
.saveButton {
457+
min-width: 90px;
458+
}
459+
460+
// Prevent bottom overflow issues with InfiniteScrollTable
461+
.infinite-scroll-table,
462+
.infinite-scroll-table-wrapper {
463+
overflow-y: auto !important;
464+
}
465+
466+
// Safety for small screens
467+
@media (max-height: 800px) {
468+
.mapper-footer {
469+
padding: 10px;
470+
}
429471
}

ui/src/components/ContentMapper/index.tsx

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,26 +1336,15 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
13361336
options={option}
13371337
menuPlacement="auto"
13381338
isDisabled={
1339-
data?.contentstackFieldType === 'group' ||
1340-
(data?.contentstackFieldType === 'text') ||
1341-
(data?.contentstackFieldType === 'url') ||
1342-
data?.backupFieldType === 'reference' ||
1343-
data?.backupFieldType === 'taxonomy' ||
1344-
data?.backupFieldType === 'file' ||
1345-
data?.backupFieldType === 'boolean' ||
1346-
data?.backupFieldType === 'number' ||
1347-
data?.backupFieldType === 'link' ||
1348-
data?.backupFieldType === 'date' ||
1349-
data?.contentstackFieldType === "global_field" ||
1339+
!(data?.contentstackFieldType === 'single_line_text' ||
1340+
data?.contentstackFieldType === 'multi_line_text' || data?.contentstackFieldType === 'html' || data?.contentstackFieldType === 'json') ||
13501341
data?.otherCmsType === undefined ||
1351-
newMigrationData?.project_current_step > 4 ||
1352-
data?.backupFieldType === 'extension' ||
1353-
data?.backupFieldType === 'app'
1342+
newMigrationData?.project_current_step > 4
13541343
}
13551344
/>
13561345
</div>
13571346
{!(
1358-
data?.contentstackFieldType === 'Group' ||
1347+
data?.contentstackFieldType === 'group' ||
13591348
data?.contentstackFieldType === 'text' ||
13601349
data?.contentstackFieldType === 'url' ||
13611350
data?.contentstackFieldType === 'global_field' ||
@@ -1810,20 +1799,10 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
18101799
? {
18111800
label: Fields[data?.contentstackFieldType]?.label ?? 'No Option',
18121801
value: Fields[data?.contentstackFieldType]?.label ?? 'No Option',
1813-
isDisabled: data?.contentstackFieldType === 'text' ||
1814-
data?.contentstackFieldType === 'group' ||
1815-
data?.contentstackFieldType === 'url' ||
1816-
data?.backupFieldType === "reference" ||
1817-
data?.backupFieldType === 'taxonomy' ||
1818-
data?.backupFieldType === 'file' ||
1819-
data?.backupFieldType === 'boolean' ||
1820-
data?.backupFieldType === 'number' ||
1821-
data?.backupFieldType === 'link' ||
1822-
data?.backupFieldType === 'date' ||
1823-
data?.contentstackFieldType === "global_field" ||
1824-
data?.otherCmsType === undefined ||
1825-
data?.backupFieldType === 'app' ||
1826-
data?.backupFieldType === 'extension'
1802+
isDisabled: !(data?.contentstackFieldType === 'single_line_text' ||
1803+
data?.contentstackFieldType === 'multi_line_text' || data?.contentstackFieldType === 'html' || data?.contentstackFieldType === 'json') ||
1804+
data?.otherCmsType === undefined
1805+
18271806
}
18281807
: {
18291808
label: `${selectedOption} matches`,
@@ -2420,10 +2399,12 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
24202399
const columns = [
24212400
{
24222401
disableSortBy: true,
2423-
Header: `${newMigrationData?.legacy_cms?.selectedCms?.title}: ${otherCmsTitle}`,
2402+
Header: (
2403+
<span className="nowrap-header">
2404+
{`${newMigrationData?.legacy_cms?.selectedCms?.title}: ${otherCmsTitle}`}
2405+
</span>
2406+
),
24242407
accessor: accessorCall,
2425-
// accessor: 'otherCmsField',
2426-
default: false,
24272408
id: 'uuid'
24282409
}
24292410
];
@@ -2433,19 +2414,25 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
24332414
if (!isNewStack) {
24342415
columns?.push({
24352416
disableSortBy: true,
2436-
Header: `Contentstack: ${isOtherContentType ? otherContentType?.label : otherCmsTitle}`,
2417+
Header: (
2418+
<span className="nowrap-header">
2419+
{`Contentstack: ${isOtherContentType ? otherContentType?.label : otherCmsTitle}`}
2420+
</span>
2421+
),
24372422
// accessor: 'ct_field',
24382423
accessor: SelectAccessorOfColumn,
24392424
id: 'contentstack_field',
2440-
default: false
24412425
});
24422426
} else {
24432427
columns?.push({
24442428
disableSortBy: true,
2445-
Header: `Contentstack: ${isNewStack ? otherCmsTitle : otherContentType?.label ?? ''}`,
2429+
Header: (
2430+
<span className="nowrap-header">
2431+
{`Contentstack: ${isNewStack ? otherCmsTitle : otherContentType?.label ?? ''}`}
2432+
</span>
2433+
),
24462434
accessor: SelectAccessor,
24472435
id: 'contentstack_cms_field',
2448-
default: false
24492436
});
24502437
}
24512438

@@ -2719,7 +2706,7 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
27192706
plural: totalCounts === 0 ? 'Count' : ''
27202707
}}
27212708
/>
2722-
<div className='d-flex align-items-center justify-content-between my-2 mx-3 px-1 py-1'>
2709+
<div className="mapper-footer">
27232710
<div>Total Fields: <strong>{totalCounts}</strong></div>
27242711
<Button
27252712
className="saveButton"

upload-api/src/routes/index.ts

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,51 @@ router.get(
370370

371371
//buffer fully stremd
372372
bodyStream.on('end', async () => {
373-
if (!zipBuffer) {
374-
throw new Error('No data collected from the stream.');
373+
try {
374+
if (!zipBuffer) {
375+
throw new Error('No data collected from the stream.');
376+
}
377+
378+
console.log('📦 Processing S3 file with handleFileProcessing...');
379+
const data = await handleFileProcessing(fileExt, zipBuffer, cmsType, fileName);
380+
console.log('✓ S3 file processing complete.');
381+
382+
console.log('📦 SENDING FILE VALIDATION RESPONSE TO UI (S3):');
383+
console.log(' ✓ Status:', data?.status || 200);
384+
console.log(' ✓ Message:', data?.message);
385+
386+
res.status(data?.status || 200).json(data);
387+
388+
if (data?.status === 200) {
389+
let filePath = path.join(__dirname, '..', '..', 'extracted_files', fileName);
390+
391+
// If the processor returned a specific file/folder, update the path
392+
if (data?.file) {
393+
filePath = path.join(
394+
__dirname,
395+
'..',
396+
'..',
397+
'extracted_files',
398+
fileName,
399+
data.file
400+
);
401+
}
402+
403+
createMapper(filePath, projectId, app_token, affix, config);
404+
}
405+
} catch (error: any) {
406+
console.error('Processing error:', error);
407+
if (!res.headersSent) {
408+
res.status(500).json({ error: 'Failed to process file' });
409+
}
375410
}
411+
});
376412

377-
const data = await handleFileProcessing(fileExt, zipBuffer, cmsType, fileName);
378-
res.json(data);
379-
res.send('file validated successfully.');
380-
let filePath = path.join(__dirname, '..', '..', 'extracted_files', fileName);
381-
if (data?.file !== undefined) {
382-
filePath = path.join(__dirname, '..', '..', 'extracted_files', fileName, data?.file);
413+
bodyStream.on('error', (error) => {
414+
console.error('Stream error:', error);
415+
if (!res.headersSent) {
416+
res.status(500).json({ error: 'Stream processing failed' });
383417
}
384-
createMapper(filePath, projectId, app_token, affix, config);
385418
});
386419
}
387420
}

0 commit comments

Comments
 (0)