Skip to content

Commit 94618f3

Browse files
authored
Merge pull request #586 from contentstack/feature/content-mapper
Improved Language mapper section
2 parents ef89655 + 923d552 commit 94618f3

File tree

7 files changed

+33
-31
lines changed

7 files changed

+33
-31
lines changed

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@types/react": "^18.2.28",
1313
"@types/react-dom": "^18.2.13",
1414
"@types/react-redux": "^7.1.33",
15-
"axios": "^1.8.2",
15+
"axios": "^1.8.3",
1616
"bootstrap": "5.1.3",
1717
"chokidar": "^3.6.0",
1818
"final-form": "^4.20.10",

ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ const LanguageMapper = () => {
508508
type="Secondary"
509509
/>
510510
<Button
511-
className="ml-10 mt-10 mb-10"
511+
className="mt-10"
512512
buttonType="secondary"
513513
aria-label="add language"
514514
version={'v2'}

ui/src/components/DestinationStack/Actions/LoadStacks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { RootState } from '../../../store';
1515
import { updateNewMigrationData } from '../../../store/slice/migrationDataSlice';
1616

1717
// Interface
18-
import { DEFAULT_DROPDOWN, IDropDown, INewMigration } from '../../../context/app/app.interface';
18+
import { IDropDown, INewMigration } from '../../../context/app/app.interface';
1919
import { StackResponse } from '../../../services/api/service.interface';
2020
import { Stack } from '../../../components/Common/AddStack/addStack.interface';
2121

ui/src/components/DestinationStack/Actions/tableHeader.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@ const TableHeader = ({ cms }: { cms: string }) => {
99
htmlFor="Content Types"
1010
className="contentTypeRows__label field-color field-label"
1111
version="v2"
12-
requiredText="(destination language)"
12+
requiredText="(destination)"
1313
>
1414
Contentstack
1515
</FieldLabel>
1616

17-
<div style={{ marginLeft: '15px' }}>
1817
<FieldLabel
1918
htmlFor="Fields"
20-
className="contentTypeRows__label field-color field-label"
21-
requiredText="(source language)"
19+
className="contentTypeRows__label field-color field-label ml-20"
20+
requiredText="(source)"
2221
version="v2"
2322
>
2423
{cms}
2524
</FieldLabel>
26-
</div>
2725
</div>
2826
);
2927
};

ui/src/components/DestinationStack/DestinationStack.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,10 @@
4545
border-radius: 4px;
4646
}
4747
.destination-stack-container {
48-
padding-left: 25px !important;
49-
padding-top: 26px;
50-
padding-right: 30px;
51-
48+
height: 100%;
5249
overflow-y: auto;
5350
overflow-x: hidden;
54-
max-height: 65vh;
51+
padding: 25px;
5552
.migration-vertical-stepper {
5653
padding: 24px 30px;
5754
border: 1px solid $color-brand-secondary-lightest;
@@ -207,6 +204,7 @@
207204
//padding-bottom: 50px;
208205
}
209206
.language-mapper {
207+
border-top: 1px solid $color-brand-secondary-lightest;
210208
margin-top: 16px;
211209

212210
.table-content-section {
@@ -220,6 +218,7 @@
220218
}
221219
.field-content__content {
222220
height: auto !important;
221+
margin-left: 0;
223222
max-height: unset !important;
224223
overflow: visible !important;
225224
z-index: 9999;
@@ -229,7 +228,8 @@
229228
padding: 10px 20px;
230229
}
231230
.field-label {
232-
padding: 10px 0;
231+
padding: 15px 0 0;
232+
width: 290px;
233233
}
234234
}
235235

@@ -253,9 +253,9 @@
253253
//width: 120px;
254254
}
255255
.lang-container {
256-
margin-bottom: 30px;
257-
margin-left: 10px;
258-
margin-top: 10px;
256+
// margin-bottom: 30px;
257+
// margin-left: 10px;
258+
// margin-top: 10px;
259259
display: flex;
260260
}
261261
.info-tag {

ui/src/context/app/app.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface FileDetails {
5656
bucketName?: string;
5757
buketKey?: string;
5858
};
59+
filePath?: string | undefined;
5960
}
6061
export interface IFile {
6162
id?: string;

ui/src/pages/Migration/index.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ import {
4444
ICMSType,
4545
ILegacyCMSComponent,
4646
DEFAULT_CMS_TYPE,
47-
TestStacks
47+
TestStacks,
48+
FileDetails
4849
} from '../../context/app/app.interface';
4950
import { ContentTypeSaveHandles } from '../../components/ContentMapper/contentMapper.interface';
5051
import { ICardType } from '../../components/Common/Card/card.interface';
@@ -60,7 +61,6 @@ import TestMigration from '../../components/TestMigration';
6061
import MigrationExecution from '../../components/MigrationExecution';
6162
import SaveChangesModal from '../../components/Common/SaveChangesModal';
6263
import { getMigratedStacks } from '../../services/api/project.service';
63-
import { getStackLocales } from '../../services/api/stacks.service';
6464
import { getConfig } from '../../services/api/upload.service';
6565

6666
type StepperComponentRef = {
@@ -69,6 +69,9 @@ type StepperComponentRef = {
6969
type LegacyCmsRef = {
7070
getInternalActiveStepIndex: () => number;
7171
};
72+
type LocalesType = {
73+
[key: string]: any
74+
}
7275

7376
const Migration = () => {
7477
const params: Params<string> = useParams();
@@ -190,18 +193,18 @@ const Migration = () => {
190193

191194
// Use regex to extract the file extension
192195
const match = normalizedPath?.match(/\.([a-zA-Z0-9]+)$/);
193-
const ext = match ? match[1]?.toLowerCase() : "";
196+
const ext = match ? match?.[1]?.toLowerCase() : "";
194197

195-
const fileName = filePath?.split('/')?.pop();
198+
// const fileName = filePath?.split('/')?.pop();
196199
//const ext = fileName?.split('.')?.pop();
197200
const validExtensionRegex = /\.(pdf|zip|xml|json)$/i;
198201
return ext && validExtensionRegex?.test(`.${ext}`) ? `${ext}` : '';
199202
};
200-
203+
201204
// funcrion to form file format object from config response
202-
const fetchFileFormat = (data:any) => {
205+
const fetchFileFormat = (data: FileDetails) => {
203206
const filePath = data?.localPath?.toLowerCase();
204-
const fileFormat = getFileExtension(filePath);
207+
const fileFormat = getFileExtension(filePath ?? '');
205208
const selectedFileFormatObj = {
206209
description: "",
207210
fileformat_id: fileFormat,
@@ -213,11 +216,11 @@ const Migration = () => {
213216
}
214217

215218
// funcrion to form upload object from config response
216-
const getFileInfo = (data:any) => {
219+
const getFileInfo = (data: FileDetails) => {
217220
const newMigrationDataObj = {
218221
name: data?.localPath,
219222
url: data?.localPath,
220-
isValidated: data?.localePath !== newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath ? false : newMigrationData?.legacy_cms?.uploadedFile?.isValidated,
223+
isValidated: data?.localPath !== newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath ? false : newMigrationData?.legacy_cms?.uploadedFile?.isValidated,
221224
file_details: {
222225
isLocalPath: data?.isLocalPath,
223226
cmsType: data?.cmsType,
@@ -534,11 +537,11 @@ const Migration = () => {
534537
(value) => value !== '' && value !== null && value !== undefined
535538
);
536539

537-
const master_locale: any = {};
538-
const locales: any = {};
539-
Object.entries(newMigrationData?.destination_stack?.localeMapping).forEach(([key, value]) => {
540-
if (key.includes('master_locale')) {
541-
master_locale[key.replace('-master_locale', '')] = value;
540+
const master_locale: LocalesType = {};
541+
const locales: LocalesType = {};
542+
Object.entries(newMigrationData?.destination_stack?.localeMapping)?.forEach(([key, value]) => {
543+
if (key?.includes('master_locale')) {
544+
master_locale[key?.replace('-master_locale', '')] = value;
542545
} else {
543546
locales[key] = value;
544547
}

0 commit comments

Comments
 (0)