Skip to content

Commit

Permalink
Filter out undefined names in context arrays
Browse files Browse the repository at this point in the history
Updated the smart field processing to filter out undefined names in the service, config, and network context arrays. This ensures that only valid names are set, preventing potential issues with unintended undefined values.
  • Loading branch information
SquirrelDevelopper committed Oct 10, 2024
1 parent 6a8dce1 commit 6718cc7
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,32 @@ export const SmartSelect: React.FC<SmartFieldsProps> = ({
switch (id) {
case 'depends_on':
if (values && values.services) {
const names = Object.values(values.services).map((service: any) => {
return { origin: 'This stack', value: service.name };
});
const names = Object.values(values.services)
?.filter((e: any) => e.name)
.map((service: any) => {
return { origin: 'This stack', value: service.name };
});
setContextNames(names);
}
return;
case 'service-configs':
if (values && values.configs) {
const names = Object.values(values.configs).map((config: any) => {
return { origin: 'This stack', value: config.name };
});
const names = Object.values(values.configs)
?.filter((e: any) => e.name)
.map((config: any) => {
return { origin: 'This stack', value: config.name };
});
setContextNames(names);
}
return;
case 'service-networks':
const names =
values.networks && values.networks
? Object.values(values.networks).map((network: any) => {
return { origin: 'This stack', value: network.name };
})
? Object.values(values.networks)
?.filter((e: any) => e.name)
.map((network: any) => {
return { origin: 'This stack', value: network.name };
})
: [];
const networksData = await getNetworks();
const uniqueNamesMap: Map<
Expand Down

0 comments on commit 6718cc7

Please sign in to comment.