Skip to content

Commit 7215c01

Browse files
authored
Merge pull request #548 from contentstack/feature/dropdown-field-choices
Feature/dropdown field choices
2 parents 5237aca + bf5f277 commit 7215c01

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

ui/src/components/ContentMapper/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const Fields: MappingFields = {
189189
options: {
190190
'Select':'checkbox'
191191
},
192-
type:'display_type'
192+
type:'checkbox'
193193
},
194194
'global_field':{
195195
label : 'Global',

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const Mapper = ({
112112
type: 'csLocale' | 'sourceLocale'
113113
) => {
114114
const selectedLocaleKey = selectedValue?.value;
115-
if (!selectedLocaleKey) return;
115+
116116

117117
setExistingField((prevOptions: ExistingFieldType) => {
118118
const updatedOptions = {
@@ -139,7 +139,11 @@ const Mapper = ({
139139
setSelectedMappings((prev) => {
140140
const updatedMappings = { ...prev };
141141

142-
if (type === 'csLocale') {
142+
143+
if (!selectedValue) {
144+
delete updatedMappings[existingField[index]?.value];
145+
}
146+
else if (type === 'csLocale' && selectedLocaleKey) {
143147
updatedMappings[selectedLocaleKey] = existingLocale[index]?.label
144148
? existingLocale[index]?.label
145149
: '';

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Stack } from '../../../components/Common/AddStack/addStack.interface';
1616
import { isEmptyString, validateArray } from '../../../utilities/functions';
1717

1818
// Services
19-
import { createStacksInOrg, getAllStacksInOrg } from '../../../services/api/stacks.service';
19+
import { createStacksInOrg, getAllStacksInOrg, getStackLocales } from '../../../services/api/stacks.service';
2020

2121
// Components
2222
import AddStack from '../../../components/Common/AddStack/addStack';
@@ -186,7 +186,7 @@ const LoadStacks = (props: LoadFileFormatProps) => {
186186
if (allStack?.length <= 0) {
187187
setAllStack(loadingOption);
188188
const stackData = await getAllStacksInOrg(selectedOrganisation?.value, ''); // org id will always be there
189-
189+
const csLocales = await getStackLocales(selectedOrganisation?.value);
190190
const stackArray = validateArray(stackData?.data?.stacks)
191191
? stackData?.data?.stacks?.map((stack: StackResponse) => ({
192192
label: stack?.name,
@@ -235,6 +235,16 @@ const LoadStacks = (props: LoadFileFormatProps) => {
235235
// Dispatch the updated migration data to Redux
236236
dispatch(updateNewMigrationData(newMigrationDataObj));
237237
}
238+
const newMigrationDataObj: INewMigration = {
239+
// ...newMigrationDataRef?.current,
240+
...newMigrationData,
241+
destination_stack: {
242+
...newMigrationData?.destination_stack,
243+
csLocale: csLocales?.data?.locales
244+
}
245+
};
246+
// Dispatch the updated migration data to Redux
247+
dispatch(updateNewMigrationData(newMigrationDataObj));
238248
}
239249
} catch (error) {
240250
return error;

ui/src/pages/Migration/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const Migration = () => {
185185

186186
const data = await getMigrationData(selectedOrganisation?.value, params?.projectId ?? '');
187187
const migratedstacks = await getMigratedStacks(selectedOrganisation?.value, projectId );
188-
const csLocales = await getStackLocales(selectedOrganisation?.value);
188+
189189
if (data) {
190190
setIsLoading(false);
191191
setProjectData(data?.data);
@@ -267,7 +267,6 @@ const Migration = () => {
267267
stackArray: [],
268268
migratedStacks: migratedstacks?.data?.destinationStacks,
269269
sourceLocale: projectData?.source_locales,
270-
csLocale: csLocales?.data?.locales,
271270
localeMapping: locales
272271
},
273272
content_mapping: {

0 commit comments

Comments
 (0)