Skip to content

Commit 9237b6b

Browse files
committed
Merge branch 'dev' of https://github.com/contentstack/migration-v2-node-server into feature/new-logo-update
2 parents 9cad4ce + 3baf005 commit 9237b6b

File tree

10 files changed

+83
-50
lines changed

10 files changed

+83
-50
lines changed

.talismanrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,11 @@ fileignoreconfig:
9191
checksum: 38d2188de3b4df88ed5e195c13b77ad7c469fe5c4d1265f1ffb868dbe3844ae1
9292
- filename: api/package-lock.json
9393
checksum: 09b36877f7e86bb806a9657f852a448dc32fa1dfb350d0fde5fd843c54a27bf0
94+
- filename: ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx
95+
checksum: 4e9bd6dcdb08fab85a3d8200e0dffa0d003743ebbb42d5043228cfd46f7e91da
96+
- filename: ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx
97+
checksum: 4e9bd6dcdb08fab85a3d8200e0dffa0d003743ebbb42d5043228cfd46f7e91da
98+
- filename: ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx
99+
checksum: dde885393dfdd813f1dace88ce8ce79e3fb438801ee5e7bf19855fe1394cb78c
94100

95101
version: "1.0"

ui/src/components/AdvancePropertise/index.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@
105105
position: relative;
106106
z-index: 10000;
107107
}
108-
.Select__control--menu-is-open {
109-
position: relative;
110-
border: 2px solid red;
111-
z-index: 10000;
112-
}
113108
}
114109
.Radio-class {
115110
display: flex;

ui/src/components/ContentMapper/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,8 @@ div .table-row {
317317
.filterButton-color{
318318
color: $color-brand-primary-base;
319319
font-weight: $font-weight-bold;
320+
}
321+
.icon-padding{
322+
padding: 10px 10px;
323+
margin-left: 6px;
320324
}

ui/src/components/ContentMapper/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,17 +2470,17 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
24702470
/>
24712471
</div>
24722472

2473-
<Tooltip content={'Fetch content types from destination stack'} position="left">
2474-
<Button buttonType="light" icon={onlyIcon ? "v2-FetchTemplate" : ''}
2473+
<Tooltip content={'Fetch content types from destination stack'} position="top">
2474+
<Button className='icon-padding' buttonType="light" icon={onlyIcon ? "v2-FetchTemplate" : ''}
24752475
version="v2" onlyIcon={true} onlyIconHoverColor={'primary'}
24762476
size='small' onClick={handleFetchContentType}>
24772477
</Button>
24782478
</Tooltip>
24792479
</>
24802480
)}
24812481

2482-
<Tooltip content={'Reset to system mapping'} position="left">
2483-
<Button buttonType="light" icon={onlyIcon ? "v2-ResetReverse" : ''}
2482+
<Tooltip content={'Reset to system mapping'} position="top">
2483+
<Button className='icon-padding' buttonType="light" icon={onlyIcon ? "v2-ResetReverse" : ''}
24842484
version="v2" onlyIcon={true} onlyIconHoverColor={'primary'}
24852485
size='small' onClick={handleResetContentType}></Button>
24862486
</Tooltip>

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ const Mapper = ({
163163
setSelectedMappings(updatedSelectedMappings);
164164

165165
}
166+
else if ( !isLabelMismatch && !isStackChanged ) {
167+
const key = `${locale?.label}-master_locale`
168+
updatedSelectedMappings = {
169+
[key]: updatedSelectedMappings?.[`${locale?.label}-master_locale`] ? updatedSelectedMappings?.[`${locale?.label}-master_locale`] : '',
170+
};
171+
setSelectedMappings(updatedSelectedMappings);
172+
}
166173
}
167174
})
168175

@@ -227,9 +234,13 @@ const Mapper = ({
227234
updatedMappings[selectedLocaleKey] = existingLocale?.[index]?.label;
228235
delete updatedMappings?.[CS_ENTRIES?.UNMAPPED_LOCALE_KEY];
229236
}else{
230-
updatedMappings[selectedLocaleKey] = existingLocale?.[index]?.label
231-
? existingLocale?.[index]?.label
232-
: '';
237+
const oldlabel = Object?.keys?.(updatedMappings)?.[index - 1];
238+
239+
// Delete old key and assign to new key
240+
delete updatedMappings?.[oldlabel];
241+
updatedMappings[selectedLocaleKey] = existingLocale?.[index]?.label
242+
? existingLocale?.[index]?.label
243+
: '';
233244
}
234245
}
235246

@@ -288,7 +299,7 @@ const Mapper = ({
288299
}
289300
else if (selectedLocaleKey) {
290301

291-
updatedMappings[existingLabel?.value] = selectedValue?.label
302+
updatedMappings[existingLabel?.value ?? index] = selectedValue?.label
292303
? selectedValue?.label
293304
: '';
294305
}
@@ -513,7 +524,7 @@ const LanguageMapper = ({stack, uid} :{ stack : IDropDown, uid : string}) => {
513524
const [options, setoptions] = useState<{ label: string; value: string }[]>([]);
514525
const [cmsLocaleOptions, setcmsLocaleOptions] = useState<{ label: string; value: string }[]>([]);
515526
const [sourceLocales, setsourceLocales] = useState<{ label: string; value: string }[]>([]);
516-
const [isLoading, setisLoading] = useState<boolean>(false);
527+
const [isLoading, setisLoading] = useState<boolean>(true);
517528
const [currentStack, setCurrentStack] = useState<IDropDown>(stack);
518529
const [previousStack, setPreviousStack] = useState<IDropDown>();
519530
const [isStackChanged, setisStackChanged] = useState<boolean>(false);
@@ -618,6 +629,7 @@ const LanguageMapper = ({stack, uid} :{ stack : IDropDown, uid : string}) => {
618629
// return await getStackLocales(newMigrationData?.destination_stack?.selectedOrg?.value);
619630
// };
620631
const addRowComp = () => {
632+
setisStackChanged(false);
621633
setcmsLocaleOptions((prevList: { label: string; value: string }[]) => [
622634
...prevList, // Keep existing elements
623635
{
@@ -628,6 +640,7 @@ const LanguageMapper = ({stack, uid} :{ stack : IDropDown, uid : string}) => {
628640
};
629641

630642
const handleDeleteLocale = (id: number, locale: { label: string; value: string }) => {
643+
setisStackChanged(false);
631644
setcmsLocaleOptions((prevList) => {
632645
return prevList?.filter(
633646
(item: { label: string; value: string }) => item?.label !== locale?.label

ui/src/pages/Login/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FC, useEffect, useState } from 'react';
33
import { useNavigate, useLocation } from 'react-router-dom';
44
import { useDispatch, useSelector } from 'react-redux';
55

6-
import { getUserDetails, setAuthToken, setUser } from '../../store/slice/authSlice';
6+
import { clearOrganisationData, getUserDetails, setAuthToken, setUser, clearAuthToken } from '../../store/slice/authSlice';
77
import {
88
Button,
99
Field,
@@ -22,7 +22,7 @@ import {
2222
TFA_VIA_SMS_MESSAGE,
2323
CS_ENTRIES
2424
} from '../../utilities/constants';
25-
import { failtureNotification, setDataInLocalStorage } from '../../utilities/functions';
25+
import { clearLocalStorage, failtureNotification, setDataInLocalStorage } from '../../utilities/functions';
2626

2727
// API Service
2828
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';
@@ -153,10 +153,16 @@ const Login: FC<IProps> = () => {
153153
setIsLoading(false);
154154
failtureNotification(response?.data?.error_message || response?.data?.error?.message);
155155
}
156-
156+
dispatch(clearAuthToken());
157+
localStorage?.removeItem('app_token');
157158
if (response?.status === 200 && response?.data?.message === LOGIN_SUCCESSFUL_MESSAGE) {
158159
setIsLoading(false);
159160
setDataInLocalStorage('app_token', response?.data?.app_token);
161+
162+
// Clear any previous organization data to ensure fresh organization selection for new user
163+
localStorage?.removeItem('organization');
164+
dispatch(clearOrganisationData());
165+
160166
const authenticationObj = {
161167
authToken: response?.data?.app_token,
162168
isAuthenticated: true

ui/src/pages/Migration/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,8 @@ const Migration = () => {
587587
value !== '' &&
588588
value !== null &&
589589
value !== undefined &&
590-
label !== 'undefined'
590+
label !== 'undefined' &&
591+
isNaN(Number(label))
591592
);
592593

593594
const master_locale: LocalesType = {};

ui/src/services/api/migration.service.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { API_VERSION, EXECUTION_LOGS_ERROR_TEXT } from '../../utilities/constant
33
import { getDataFromLocalStorage } from '../../utilities/functions';
44
import { getCall, postCall, putCall, patchCall } from './service';
55

6-
const options = {
6+
const options = () => ({
77
headers: {
88
app_token: getDataFromLocalStorage('app_token')
99
}
10-
};
10+
});
1111

1212
export const getMigrationData = (orgId: string, projectId: string) => {
1313
try {
14-
return getCall(`${API_VERSION}/org/${orgId}/project/${projectId}/`, options);
14+
return getCall(`${API_VERSION}/org/${orgId}/project/${projectId}`, options());
1515
} catch (error) {
1616
if (error instanceof Error) {
1717
throw new Error(`Error in getting migrationData: ${error.message}`);
@@ -23,7 +23,7 @@ export const getMigrationData = (orgId: string, projectId: string) => {
2323

2424
export const updateLegacyCMSData = (orgId: string, projectId: string, data: ObjectType) => {
2525
try {
26-
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/legacy-cms`, data, options);
26+
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/legacy-cms`, data, options());
2727
} catch (error) {
2828
if (error instanceof Error) {
2929
throw new Error(`${error.message}`);
@@ -35,7 +35,7 @@ export const updateLegacyCMSData = (orgId: string, projectId: string, data: Obje
3535

3636
export const updateAffixData = (orgId: string, projectId: string, data: ObjectType) => {
3737
try {
38-
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/affix`, data, options);
38+
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/affix`, data, options());
3939
} catch (error) {
4040
if (error instanceof Error) {
4141
throw new Error(`${error.message}`);
@@ -47,7 +47,7 @@ export const updateAffixData = (orgId: string, projectId: string, data: ObjectTy
4747

4848
export const updateFileFormatData = (orgId: string, projectId: string, data: ObjectType) => {
4949
try {
50-
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/file-format`, data, options);
50+
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/file-format`, data, options());
5151
} catch (error) {
5252
if (error instanceof Error) {
5353
throw new Error(`${error.message}`);
@@ -62,7 +62,7 @@ export const updateDestinationStack = (orgId: string, projectId: string, data: O
6262
return putCall(
6363
`${API_VERSION}/org/${orgId}/project/${projectId}/destination-stack`,
6464
data,
65-
options
65+
options()
6666
);
6767
} catch (error) {
6868
if (error instanceof Error) {
@@ -75,7 +75,7 @@ export const updateDestinationStack = (orgId: string, projectId: string, data: O
7575

7676
export const updateCurrentStepData = (orgId: string, projectId: string, data: ObjectType = {}) => {
7777
try {
78-
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/current-step`, data, options);
78+
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/current-step`, data, options());
7979
} catch (error) {
8080
if (error instanceof Error) {
8181
throw new Error(`${error.message}`);
@@ -90,7 +90,7 @@ export const affixConfirmation = (orgId: string, projectId: string, data: Object
9090
return putCall(
9191
`${API_VERSION}/org/${orgId}/project/${projectId}/affix_confirmation`,
9292
data,
93-
options
93+
options()
9494
);
9595
} catch (error) {
9696
return error;
@@ -102,7 +102,7 @@ export const fileformatConfirmation = (orgId: string, projectId: string, data: O
102102
return putCall(
103103
`${API_VERSION}/org/${orgId}/project/${projectId}/fileformat_confirmation`,
104104
data,
105-
options
105+
options()
106106
);
107107
} catch (error) {
108108
return error;
@@ -119,7 +119,7 @@ export const getContentTypes = (
119119
const encodedSearchText = encodeURIComponent(searchText);
120120
return getCall(
121121
`${API_VERSION}/mapper/contentTypes/${projectId}/${skip}/${limit}/${encodedSearchText}?`,
122-
options
122+
options()
123123
);
124124
} catch (error) {
125125
if (error instanceof Error) {
@@ -141,7 +141,7 @@ export const getFieldMapping = async (
141141
const encodedSearchText = encodeURIComponent(searchText);
142142
return await getCall(
143143
`${API_VERSION}/mapper/fieldMapping/${projectId}/${contentTypeId}/${skip}/${limit}/${encodedSearchText}?`,
144-
options
144+
options()
145145
);
146146
} catch (error) {
147147
if (error instanceof Error) {
@@ -187,7 +187,7 @@ export const updateContentType = async (
187187
return await putCall(
188188
`${API_VERSION}/mapper/contentTypes/${orgId}/${projectId}/${contentTypeId}`,
189189
data,
190-
options
190+
options()
191191
);
192192
} catch (error) {
193193
if (error instanceof Error) {
@@ -208,7 +208,7 @@ export const resetToInitialMapping = async (
208208
return await putCall(
209209
`${API_VERSION}/mapper/resetFields/${orgId}/${projectId}/${contentTypeId}`,
210210
data,
211-
options
211+
options()
212212
);
213213
} catch (error) {
214214
if (error instanceof Error) {
@@ -221,7 +221,7 @@ export const resetToInitialMapping = async (
221221

222222
export const getExistingContentTypes = async (projectId: string, contentTypeUid?: string) => {
223223
try {
224-
return await getCall(`${API_VERSION}/mapper/${projectId}/contentTypes/${contentTypeUid ?? ''}`, options);
224+
return await getCall(`${API_VERSION}/mapper/${projectId}/contentTypes/${contentTypeUid ?? ''}`, options());
225225
} catch (error) {
226226
if (error instanceof Error) {
227227
throw new Error(`${error.message}`);
@@ -233,7 +233,7 @@ export const getExistingContentTypes = async (projectId: string, contentTypeUid?
233233

234234
export const getExistingGlobalFields = async (projectId: string, globalFieldUid?: string) => {
235235
try {
236-
return await getCall(`${API_VERSION}/mapper/${projectId}/globalFields/${globalFieldUid ?? ''}`, options);
236+
return await getCall(`${API_VERSION}/mapper/${projectId}/globalFields/${globalFieldUid ?? ''}`, options());
237237
} catch (error) {
238238
if (error instanceof Error) {
239239
throw new Error(`${error.message}`);
@@ -246,7 +246,7 @@ export const getExistingGlobalFields = async (projectId: string, globalFieldUid?
246246

247247
export const removeContentMapper = async (orgId: string, projectId: string) => {
248248
try {
249-
return await getCall(`${API_VERSION}/mapper/${orgId}/${projectId}/content-mapper`, options);
249+
return await getCall(`${API_VERSION}/mapper/${orgId}/${projectId}/content-mapper`, options());
250250
} catch (error) {
251251
return error;
252252

@@ -264,7 +264,7 @@ export const updateContentMapper = async (
264264
return await patchCall(
265265
`${API_VERSION}/mapper/${orgId}/${projectId}/mapper_keys`,
266266
mapperKeys,
267-
options
267+
options()
268268
);
269269
} catch (error) {
270270
if (error instanceof Error) {
@@ -278,7 +278,7 @@ export const updateContentMapper = async (
278278
export const updateStackDetails = async (orgId: string, projectId: string, data: ObjectType) => {
279279
try {
280280
const Data = { stack_details: data };
281-
return await patchCall(`${API_VERSION}/org/${orgId}/project/${projectId}/stack-details`, Data, options);
281+
return await patchCall(`${API_VERSION}/org/${orgId}/project/${projectId}/stack-details`, Data, options());
282282
} catch (error) {
283283
return error;
284284

@@ -287,7 +287,7 @@ export const updateStackDetails = async (orgId: string, projectId: string, data:
287287

288288
export const getOrgDetails = async (orgId: string) => {
289289
try {
290-
return await getCall(`${API_VERSION}/org/${orgId}/get_org_details`, options);
290+
return await getCall(`${API_VERSION}/org/${orgId}/get_org_details`, options());
291291
} catch (error) {
292292
return error;
293293
}
@@ -298,7 +298,7 @@ export const createTestStack = async (orgId: string, projectId: string, data: Ob
298298
return await postCall(
299299
`${API_VERSION}/migration/create-test-stack/${orgId}/${projectId}`,
300300
data,
301-
options
301+
options()
302302
);
303303
} catch (error) {
304304
return error;
@@ -308,7 +308,7 @@ export const createTestStack = async (orgId: string, projectId: string, data: Ob
308308
export const createTestMigration = async (orgId: string, projectId: string) => {
309309
try {
310310
return await postCall(
311-
`${API_VERSION}/migration/test-stack/${orgId}/${projectId}`, {}, options);
311+
`${API_VERSION}/migration/test-stack/${orgId}/${projectId}`, {}, options());
312312
} catch (error) {
313313
return error;
314314
}
@@ -317,7 +317,7 @@ export const createTestMigration = async (orgId: string, projectId: string) => {
317317
export const startMigration = async (orgId: string, projectId: string) => {
318318
try {
319319
return await postCall(
320-
`${API_VERSION}/migration/start/${orgId}/${projectId}`, {}, options);
320+
`${API_VERSION}/migration/start/${orgId}/${projectId}`, {}, options());
321321
} catch (error) {
322322
return error;
323323
}
@@ -326,7 +326,7 @@ export const startMigration = async (orgId: string, projectId: string) => {
326326
export const updateMigrationKey = async (orgId: string, projectId: string) => {
327327
try {
328328
return await putCall(
329-
`${API_VERSION}/org/${orgId}/project/${projectId}/migration-excution`, {}, options);
329+
`${API_VERSION}/org/${orgId}/project/${projectId}/migration-excution`, {}, options());
330330
} catch (error) {
331331
return error;
332332
}
@@ -335,7 +335,7 @@ export const updateMigrationKey = async (orgId: string, projectId: string) => {
335335
export const updateLocaleMapper = async(projectId: string, data: any) => {
336336
try {
337337
return await postCall(
338-
`${API_VERSION}/migration/updateLocales/${projectId}`, data, options);
338+
`${API_VERSION}/migration/updateLocales/${projectId}`, data, options());
339339
} catch (error) {
340340
return error;
341341
}
@@ -345,7 +345,7 @@ export const getMigrationLogs = async (orgId: string, projectId: string, stackId
345345
try {
346346
return await getCall(
347347
`${API_VERSION}/migration/get_migration_logs/${orgId}/${projectId}/${stackId}/${skip}/${limit}/${startIndex}/${stopIndex}/${searchText}/${filter}`,
348-
options
348+
options()
349349
);
350350
} catch (error) {
351351
if (error instanceof Error) {

0 commit comments

Comments
 (0)