From: stanislavh Date: Fri, 24 Feb 2023 14:20:44 +0000 (+0100) Subject: SONAR-18535 SONAR-18547 Microfocus compilation constants for COBOL language is broken... X-Git-Tag: 10.0.0.68432~187 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0d118342612cd3c9ccf2385b81449fb76c98dca2;p=sonarqube.git SONAR-18535 SONAR-18547 Microfocus compilation constants for COBOL language is broken on ui --- diff --git a/server/sonar-web/src/main/js/api/settings.ts b/server/sonar-web/src/main/js/api/settings.ts index e42dfd6bfa7..1d81865ddbe 100644 --- a/server/sonar-web/src/main/js/api/settings.ts +++ b/server/sonar-web/src/main/js/api/settings.ts @@ -25,6 +25,7 @@ import { BranchParameters } from '../types/branch-like'; import { ExtendedSettingDefinition, SettingDefinition, + SettingType, SettingValue, SettingValueResponse, } from '../types/settings'; @@ -71,12 +72,12 @@ export function setSettingValue( const { key } = definition; const data: RequestData = { key, component }; - if (isCategoryDefinition(definition) && definition.multiValues) { - data.values = value; - } else if (definition.type === 'PROPERTY_SET') { + if (definition.type === SettingType.PROPERTY_SET) { data.fieldValues = value .map((fields: any) => omitBy(fields, (value) => value == null)) .map(JSON.stringify); + } else if (isCategoryDefinition(definition) && definition.multiValues) { + data.values = value; } else { data.value = value; } diff --git a/server/sonar-web/src/main/js/apps/settings/utils.ts b/server/sonar-web/src/main/js/apps/settings/utils.ts index b1879ee1c4c..d1654f6e323 100644 --- a/server/sonar-web/src/main/js/apps/settings/utils.ts +++ b/server/sonar-web/src/main/js/apps/settings/utils.ts @@ -86,10 +86,10 @@ export function getUniqueName(definition: SettingDefinition, index?: string) { export function getSettingValue(definition: SettingDefinition, settingValue?: SettingValue) { const { fieldValues, value, values } = settingValue || {}; - if (isCategoryDefinition(definition) && definition.multiValues) { - return values; - } else if (definition.type === SettingType.PROPERTY_SET) { + if (definition.type === SettingType.PROPERTY_SET) { return fieldValues; + } else if (isCategoryDefinition(definition) && definition.multiValues) { + return values; } else if (definition.type === SettingType.FORMATTED_TEXT) { return values ? values[0] : undefined; } @@ -151,15 +151,15 @@ export function isCategoryDefinition(item: SettingDefinition): item is ExtendedS export function getEmptyValue(item: SettingDefinition | ExtendedSettingDefinition): any { if (isCategoryDefinition(item)) { - if (item.multiValues) { - return [getEmptyValue({ ...item, multiValues: false })]; - } - - if (item.type === 'PROPERTY_SET') { + if (item.type === SettingType.PROPERTY_SET) { const value: Dict = {}; item.fields.forEach((field) => (value[field.key] = getEmptyValue(field))); return [value]; } + + if (item.multiValues) { + return [getEmptyValue({ ...item, multiValues: false })]; + } } if (item.type === 'BOOLEAN' || item.type === 'SINGLE_SELECT_LIST') { @@ -193,7 +193,11 @@ export function getDefaultValue(setting: Setting) { return parentValues.join(', '); } - if (definition.type === 'PROPERTY_SET' && parentFieldValues && parentFieldValues.length > 0) { + if ( + definition.type === SettingType.PROPERTY_SET && + parentFieldValues && + parentFieldValues.length > 0 + ) { return translate('settings.default.complex_value'); }