Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,13 @@ const Mapper = ({
updatedMappings[selectedLocaleKey] = existingLocale?.[index]?.label;
delete updatedMappings?.[CS_ENTRIES?.UNMAPPED_LOCALE_KEY];
}else{
updatedMappings[selectedLocaleKey] = existingLocale?.[index]?.label
? existingLocale?.[index]?.label
: '';
const oldlabel = Object?.keys?.(updatedMappings)?.[index - 1];

// Delete old key and assign to new key
delete updatedMappings?.[oldlabel];
updatedMappings[selectedLocaleKey] = existingLocale?.[index]?.label
? existingLocale?.[index]?.label
: '';
}
}

Expand Down Expand Up @@ -295,7 +299,7 @@ const Mapper = ({
}
else if (selectedLocaleKey) {

updatedMappings[existingLabel?.value] = selectedValue?.label
updatedMappings[existingLabel?.value ?? index] = selectedValue?.label
? selectedValue?.label
: '';
}
Expand Down
7 changes: 4 additions & 3 deletions ui/src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC, useEffect, useState } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';

import { clearOrganisationData, getUserDetails, setAuthToken, setUser } from '../../store/slice/authSlice';
import { clearOrganisationData, getUserDetails, setAuthToken, setUser, clearAuthToken } from '../../store/slice/authSlice';
import {
Button,
Field,
Expand All @@ -22,7 +22,7 @@ import {
TFA_VIA_SMS_MESSAGE,
CS_ENTRIES
} from '../../utilities/constants';
import { failtureNotification, setDataInLocalStorage } from '../../utilities/functions';
import { clearLocalStorage, failtureNotification, setDataInLocalStorage } from '../../utilities/functions';

// API Service
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';
Expand Down Expand Up @@ -153,7 +153,8 @@ const Login: FC<IProps> = () => {
setIsLoading(false);
failtureNotification(response?.data?.error_message || response?.data?.error?.message);
}

dispatch(clearAuthToken());
localStorage?.removeItem('app_token');
if (response?.status === 200 && response?.data?.message === LOGIN_SUCCESSFUL_MESSAGE) {
setIsLoading(false);
setDataInLocalStorage('app_token', response?.data?.app_token);
Expand Down
3 changes: 2 additions & 1 deletion ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ const Migration = () => {
value !== '' &&
value !== null &&
value !== undefined &&
label !== 'undefined'
label !== 'undefined' &&
isNaN(Number(label))
);

const master_locale: LocalesType = {};
Expand Down
52 changes: 26 additions & 26 deletions ui/src/services/api/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { API_VERSION, EXECUTION_LOGS_ERROR_TEXT } from '../../utilities/constant
import { getDataFromLocalStorage } from '../../utilities/functions';
import { getCall, postCall, putCall, patchCall } from './service';

const options = {
const options = () => ({
headers: {
app_token: getDataFromLocalStorage('app_token')
}
};
});

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

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

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

export const updateFileFormatData = (orgId: string, projectId: string, data: ObjectType) => {
try {
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/file-format`, data, options);
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/file-format`, data, options());
} catch (error) {
if (error instanceof Error) {
throw new Error(`${error.message}`);
Expand All @@ -62,7 +62,7 @@ export const updateDestinationStack = (orgId: string, projectId: string, data: O
return putCall(
`${API_VERSION}/org/${orgId}/project/${projectId}/destination-stack`,
data,
options
options()
);
} catch (error) {
if (error instanceof Error) {
Expand All @@ -75,7 +75,7 @@ export const updateDestinationStack = (orgId: string, projectId: string, data: O

export const updateCurrentStepData = (orgId: string, projectId: string, data: ObjectType = {}) => {
try {
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/current-step`, data, options);
return putCall(`${API_VERSION}/org/${orgId}/project/${projectId}/current-step`, data, options());
} catch (error) {
if (error instanceof Error) {
throw new Error(`${error.message}`);
Expand All @@ -90,7 +90,7 @@ export const affixConfirmation = (orgId: string, projectId: string, data: Object
return putCall(
`${API_VERSION}/org/${orgId}/project/${projectId}/affix_confirmation`,
data,
options
options()
);
} catch (error) {
return error;
Expand All @@ -102,7 +102,7 @@ export const fileformatConfirmation = (orgId: string, projectId: string, data: O
return putCall(
`${API_VERSION}/org/${orgId}/project/${projectId}/fileformat_confirmation`,
data,
options
options()
);
} catch (error) {
return error;
Expand All @@ -119,7 +119,7 @@ export const getContentTypes = (
const encodedSearchText = encodeURIComponent(searchText);
return getCall(
`${API_VERSION}/mapper/contentTypes/${projectId}/${skip}/${limit}/${encodedSearchText}?`,
options
options()
);
} catch (error) {
if (error instanceof Error) {
Expand All @@ -141,7 +141,7 @@ export const getFieldMapping = async (
const encodedSearchText = encodeURIComponent(searchText);
return await getCall(
`${API_VERSION}/mapper/fieldMapping/${projectId}/${contentTypeId}/${skip}/${limit}/${encodedSearchText}?`,
options
options()
);
} catch (error) {
if (error instanceof Error) {
Expand Down Expand Up @@ -187,7 +187,7 @@ export const updateContentType = async (
return await putCall(
`${API_VERSION}/mapper/contentTypes/${orgId}/${projectId}/${contentTypeId}`,
data,
options
options()
);
} catch (error) {
if (error instanceof Error) {
Expand All @@ -208,7 +208,7 @@ export const resetToInitialMapping = async (
return await putCall(
`${API_VERSION}/mapper/resetFields/${orgId}/${projectId}/${contentTypeId}`,
data,
options
options()
);
} catch (error) {
if (error instanceof Error) {
Expand All @@ -221,7 +221,7 @@ export const resetToInitialMapping = async (

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

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

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

Expand All @@ -264,7 +264,7 @@ export const updateContentMapper = async (
return await patchCall(
`${API_VERSION}/mapper/${orgId}/${projectId}/mapper_keys`,
mapperKeys,
options
options()
);
} catch (error) {
if (error instanceof Error) {
Expand All @@ -278,7 +278,7 @@ export const updateContentMapper = async (
export const updateStackDetails = async (orgId: string, projectId: string, data: ObjectType) => {
try {
const Data = { stack_details: data };
return await patchCall(`${API_VERSION}/org/${orgId}/project/${projectId}/stack-details`, Data, options);
return await patchCall(`${API_VERSION}/org/${orgId}/project/${projectId}/stack-details`, Data, options());
} catch (error) {
return error;

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

export const getOrgDetails = async (orgId: string) => {
try {
return await getCall(`${API_VERSION}/org/${orgId}/get_org_details`, options);
return await getCall(`${API_VERSION}/org/${orgId}/get_org_details`, options());
} catch (error) {
return error;
}
Expand All @@ -298,7 +298,7 @@ export const createTestStack = async (orgId: string, projectId: string, data: Ob
return await postCall(
`${API_VERSION}/migration/create-test-stack/${orgId}/${projectId}`,
data,
options
options()
);
} catch (error) {
return error;
Expand All @@ -308,7 +308,7 @@ export const createTestStack = async (orgId: string, projectId: string, data: Ob
export const createTestMigration = async (orgId: string, projectId: string) => {
try {
return await postCall(
`${API_VERSION}/migration/test-stack/${orgId}/${projectId}`, {}, options);
`${API_VERSION}/migration/test-stack/${orgId}/${projectId}`, {}, options());
} catch (error) {
return error;
}
Expand All @@ -317,7 +317,7 @@ export const createTestMigration = async (orgId: string, projectId: string) => {
export const startMigration = async (orgId: string, projectId: string) => {
try {
return await postCall(
`${API_VERSION}/migration/start/${orgId}/${projectId}`, {}, options);
`${API_VERSION}/migration/start/${orgId}/${projectId}`, {}, options());
} catch (error) {
return error;
}
Expand All @@ -326,7 +326,7 @@ export const startMigration = async (orgId: string, projectId: string) => {
export const updateMigrationKey = async (orgId: string, projectId: string) => {
try {
return await putCall(
`${API_VERSION}/org/${orgId}/project/${projectId}/migration-excution`, {}, options);
`${API_VERSION}/org/${orgId}/project/${projectId}/migration-excution`, {}, options());
} catch (error) {
return error;
}
Expand All @@ -335,7 +335,7 @@ export const updateMigrationKey = async (orgId: string, projectId: string) => {
export const updateLocaleMapper = async(projectId: string, data: any) => {
try {
return await postCall(
`${API_VERSION}/migration/updateLocales/${projectId}`, data, options);
`${API_VERSION}/migration/updateLocales/${projectId}`, data, options());
} catch (error) {
return error;
}
Expand All @@ -345,7 +345,7 @@ export const getMigrationLogs = async (orgId: string, projectId: string, stackId
try {
return await getCall(
`${API_VERSION}/migration/get_migration_logs/${orgId}/${projectId}/${stackId}/${skip}/${limit}/${startIndex}/${stopIndex}/${searchText}/${filter}`,
options
options()
);
} catch (error) {
if (error instanceof Error) {
Expand Down
10 changes: 5 additions & 5 deletions ui/src/services/api/stacks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import { getDataFromLocalStorage } from '../../utilities/functions';
import { getCall, postCall } from './service';
import { Stack } from '../../components/Common/AddStack/addStack.interface';

const options = {
const options = () => ({
headers: {
app_token: getDataFromLocalStorage('app_token')
}
};
});

export const getAllStacksInOrg = async (orgId: string, searchText: string) => {
try {
return await getCall(`${API_VERSION}/org/${orgId}/stacks/${searchText}?`, options);
return await getCall(`${API_VERSION}/org/${orgId}/stacks/${searchText}?`, options());
} catch (error) {
return error;
}
};

export const createStacksInOrg = async (orgId: string, data: Stack) => {
try {
return await postCall(`${API_VERSION}/org/${orgId}/stacks`, data, options);
return await postCall(`${API_VERSION}/org/${orgId}/stacks`, data, options());
} catch (error) {
if (error instanceof Error) {
throw new Error(`Error in userSession: ${error.message}`);
Expand All @@ -34,7 +34,7 @@ export const getStackStatus = async (orgId: string, data: string) => {
const stack_api = {
stack_api_key: data
};
return await postCall(`${API_VERSION}/org/${orgId}/stack_status`, stack_api, options);
return await postCall(`${API_VERSION}/org/${orgId}/stack_status`, stack_api, options());
} catch (error) {
if (error instanceof Error) {
throw new Error(`Error in userSession: ${error.message}`);
Expand Down
6 changes: 5 additions & 1 deletion ui/src/store/slice/authSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ const authSlice = createSlice({
clearOrganisationData: (state) => {
state.organisationsList = [];
state.selectedOrganisation = DEFAULT_DROPDOWN;
},
clearAuthToken: (state) => {
state.authToken = '';
state.isAuthenticated = false;
}


Expand All @@ -120,7 +124,7 @@ const authSlice = createSlice({

},
})
export const { setAuthToken, reInitiliseState, setOrganisationsList, setSelectedOrganisation, setUser, clearOrganisationData } = authSlice.actions;
export const { setAuthToken, reInitiliseState, setOrganisationsList, setSelectedOrganisation, setUser, clearOrganisationData, clearAuthToken } = authSlice.actions;

export {getUserDetails};
export default authSlice.reducer;