diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/settings')
9 files changed, 138 insertions, 143 deletions
diff --git a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.js b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.js index 2f215d01723..8aceab77b13 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.js +++ b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.js @@ -46,7 +46,8 @@ export default class SubCategoryDefinitionsList extends React.PureComponent { description: getSubCategoryDescription(bySubCategory[key][0].definition.category, key) })); const sortedSubCategories = sortBy(subCategories, subCategory => - subCategory.name.toLowerCase()); + subCategory.name.toLowerCase() + ); return ( <ul className="settings-sub-categories-list"> diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/MultiValueInput.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/MultiValueInput.js index 3e17e9db704..a5346068192 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/MultiValueInput.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/MultiValueInput.js @@ -85,7 +85,8 @@ export default class MultiValueInput extends React.PureComponent { <div> <ul> {displayedValue.map((value, index) => - this.renderInput(value, index, index === displayedValue.length - 1))} + this.renderInput(value, index, index === displayedValue.length - 1) + )} </ul> </div> ); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js index 0c3884b288b..5f807976d4d 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js @@ -104,7 +104,8 @@ export default class PropertySetInput extends React.PureComponent { </thead> <tbody> {displayedValue.map((fieldValues, index) => - this.renderFields(fieldValues, index, index === displayedValue.length - 1))} + this.renderFields(fieldValues, index, index === displayedValue.length - 1) + )} </tbody> </table> </div> diff --git a/server/sonar-web/src/main/js/apps/settings/store/actions.js b/server/sonar-web/src/main/js/apps/settings/store/actions.js index 212ddc47f7d..fab49983ff7 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/actions.js +++ b/server/sonar-web/src/main/js/apps/settings/store/actions.js @@ -34,69 +34,66 @@ import { isEmptyValue } from '../utils'; import { translate } from '../../../helpers/l10n'; import { getSettingsAppDefinition, getSettingsAppChangedValue } from '../../../store/rootReducer'; -export const fetchSettings = componentKey => - dispatch => { - return getDefinitions(componentKey) - .then(definitions => { - const withoutLicenses = definitions.filter(definition => definition.type !== 'LICENSE'); - dispatch(receiveDefinitions(withoutLicenses)); - const keys = withoutLicenses.map(definition => definition.key).join(); - return getValues(keys, componentKey); - }) - .then(settings => { - dispatch(receiveValues(settings)); - dispatch(closeAllGlobalMessages()); - }) - .catch(e => parseError(e).then(message => dispatch(addGlobalErrorMessage(message)))); - }; +export const fetchSettings = componentKey => dispatch => { + return getDefinitions(componentKey) + .then(definitions => { + const withoutLicenses = definitions.filter(definition => definition.type !== 'LICENSE'); + dispatch(receiveDefinitions(withoutLicenses)); + const keys = withoutLicenses.map(definition => definition.key).join(); + return getValues(keys, componentKey); + }) + .then(settings => { + dispatch(receiveValues(settings)); + dispatch(closeAllGlobalMessages()); + }) + .catch(e => parseError(e).then(message => dispatch(addGlobalErrorMessage(message)))); +}; -export const saveValue = (key, componentKey) => - (dispatch, getState) => { - dispatch(startLoading(key)); +export const saveValue = (key, componentKey) => (dispatch, getState) => { + dispatch(startLoading(key)); - const state = getState(); - const definition = getSettingsAppDefinition(state, key); - const value = getSettingsAppChangedValue(state, key); + const state = getState(); + const definition = getSettingsAppDefinition(state, key); + const value = getSettingsAppChangedValue(state, key); - if (isEmptyValue(definition, value)) { - dispatch(failValidation(key, translate('settings.state.value_cant_be_empty'))); + if (isEmptyValue(definition, value)) { + dispatch(failValidation(key, translate('settings.state.value_cant_be_empty'))); + dispatch(stopLoading(key)); + return Promise.reject(); + } + + return setSettingValue(definition, value, componentKey) + .then(() => getValues(key, componentKey)) + .then(values => { + dispatch(receiveValues(values)); + dispatch(cancelChange(key)); + dispatch(passValidation(key)); + dispatch(stopLoading(key)); + }) + .catch(e => { dispatch(stopLoading(key)); + parseError(e).then(message => dispatch(failValidation(key, message))); return Promise.reject(); - } - - return setSettingValue(definition, value, componentKey) - .then(() => getValues(key, componentKey)) - .then(values => { - dispatch(receiveValues(values)); - dispatch(cancelChange(key)); - dispatch(passValidation(key)); - dispatch(stopLoading(key)); - }) - .catch(e => { - dispatch(stopLoading(key)); - parseError(e).then(message => dispatch(failValidation(key, message))); - return Promise.reject(); - }); - }; + }); +}; -export const resetValue = (key, componentKey) => - dispatch => { - dispatch(startLoading(key)); +export const resetValue = (key, componentKey) => dispatch => { + dispatch(startLoading(key)); - return resetSettingValue(key, componentKey) - .then(() => getValues(key, componentKey)) - .then(values => { - if (values.length > 0) { - dispatch(receiveValues(values)); - } else { - dispatch(receiveValues([{ key }])); - } - dispatch(passValidation(key)); - dispatch(stopLoading(key)); - }) - .catch(e => { - dispatch(stopLoading(key)); - parseError(e).then(message => dispatch(failValidation(key, message))); - return Promise.reject(); - }); - }; + return resetSettingValue(key, componentKey) + .then(() => getValues(key, componentKey)) + .then(values => { + if (values.length > 0) { + dispatch(receiveValues(values)); + } else { + dispatch(receiveValues([{ key }])); + } + dispatch(passValidation(key)); + dispatch(stopLoading(key)); + }) + .catch(e => { + dispatch(stopLoading(key)); + parseError(e).then(message => dispatch(failValidation(key, message))); + return Promise.reject(); + }); +}; diff --git a/server/sonar-web/src/main/js/apps/settings/store/definitions/reducer.js b/server/sonar-web/src/main/js/apps/settings/store/definitions/reducer.js index 6d473517a27..08a736f5c3f 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/definitions/reducer.js +++ b/server/sonar-web/src/main/js/apps/settings/store/definitions/reducer.js @@ -49,7 +49,8 @@ export const getDefinitionsForCategory = (state: State, category: string) => export const getAllCategories = (state: State) => uniqBy(getAllDefinitions(state).map(definition => definition.category), category => - category.toLowerCase()); + category.toLowerCase() + ); export const getDefaultCategory = (state: State) => { const categories = getAllCategories(state); @@ -57,7 +58,8 @@ export const getDefaultCategory = (state: State) => { return DEFAULT_CATEGORY; } else { const sortedCategories = sortBy(categories, category => - getCategoryName(category).toLowerCase()); + getCategoryName(category).toLowerCase() + ); return sortedCategories[0]; } }; diff --git a/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js b/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js index eac17044bec..3c9ee71d934 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js +++ b/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js @@ -36,49 +36,45 @@ const startLoading = dispatch => { dispatch(closeAllGlobalMessages()); }; -const handleError = dispatch => - error => { - parseError(error).then(message => { - dispatch(addGlobalErrorMessage(message)); - dispatch(updateEncryption({ loading: false })); - }); - }; +const handleError = dispatch => error => { + parseError(error).then(message => { + dispatch(addGlobalErrorMessage(message)); + dispatch(updateEncryption({ loading: false })); + }); +}; -export const checkSecretKey = () => - dispatch => { - startLoading(dispatch); - api - .checkSecretKey() - .then(data => dispatch(updateEncryption({ ...data, loading: false }))) - .catch(handleError(dispatch)); - }; +export const checkSecretKey = () => dispatch => { + startLoading(dispatch); + api + .checkSecretKey() + .then(data => dispatch(updateEncryption({ ...data, loading: false }))) + .catch(handleError(dispatch)); +}; -export const generateSecretKey = () => - dispatch => { - startLoading(dispatch); - api - .generateSecretKey() - .then(data => - dispatch( - updateEncryption({ - ...data, - secretKeyAvailable: false, - loading: false - }) - )) - .catch(handleError(dispatch)); - }; +export const generateSecretKey = () => dispatch => { + startLoading(dispatch); + api + .generateSecretKey() + .then(data => + dispatch( + updateEncryption({ + ...data, + secretKeyAvailable: false, + loading: false + }) + ) + ) + .catch(handleError(dispatch)); +}; -export const encryptValue = value => - dispatch => { - startLoading(dispatch); - api - .encryptValue(value) - .then(data => dispatch(updateEncryption({ ...data, loading: false }))) - .catch(handleError(dispatch)); - }; +export const encryptValue = value => dispatch => { + startLoading(dispatch); + api + .encryptValue(value) + .then(data => dispatch(updateEncryption({ ...data, loading: false }))) + .catch(handleError(dispatch)); +}; -export const startGeneration = () => - dispatch => { - dispatch(updateEncryption({ secretKeyAvailable: false, secretKey: undefined })); - }; +export const startGeneration = () => dispatch => { + dispatch(updateEncryption({ secretKeyAvailable: false, secretKey: undefined })); +}; diff --git a/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js b/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js index baa19b1323d..c24cae2d6d2 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js +++ b/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js @@ -33,41 +33,38 @@ const receiveLicenses = licenses => ({ licenses }); -const handleError = dispatch => - error => { - parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); - return Promise.reject(); - }; +const handleError = dispatch => error => { + parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); + return Promise.reject(); +}; -export const fetchLicenses = () => - dispatch => { - return licenses - .getLicenses() - .then(licenses => { - dispatch(receiveLicenses(licenses)); - /* eslint import/namespace: 0 */ - const invalidLicenses = licenses.some(isLicenseInvalid); - if (invalidLicenses) { - dispatch(addGlobalErrorMessage(translate('licenses.there_are_invalid'))); - } - }) - .catch(handleError(dispatch)); - }; +export const fetchLicenses = () => dispatch => { + return licenses + .getLicenses() + .then(licenses => { + dispatch(receiveLicenses(licenses)); + /* eslint import/namespace: 0 */ + const invalidLicenses = licenses.some(isLicenseInvalid); + if (invalidLicenses) { + dispatch(addGlobalErrorMessage(translate('licenses.there_are_invalid'))); + } + }) + .catch(handleError(dispatch)); +}; -export const setLicense = (key, value) => - dispatch => { - const request = value ? licenses.setLicense(key, value) : licenses.resetLicense(key); +export const setLicense = (key, value) => dispatch => { + const request = value ? licenses.setLicense(key, value) : licenses.resetLicense(key); - return request - .then(() => { - licenses.getLicenses().then(licenses => { - dispatch(receiveLicenses(licenses)); - if (isLicenseFromListInvalid(licenses, key)) { - dispatch(addGlobalErrorMessage(translate('licenses.error_message'))); - } else { - dispatch(addGlobalSuccessMessage(translate('licenses.success_message'))); - } - }); - }) - .catch(handleError(dispatch)); - }; + return request + .then(() => { + licenses.getLicenses().then(licenses => { + dispatch(receiveLicenses(licenses)); + if (isLicenseFromListInvalid(licenses, key)) { + dispatch(addGlobalErrorMessage(translate('licenses.error_message'))); + } else { + dispatch(addGlobalSuccessMessage(translate('licenses.success_message'))); + } + }); + }) + .catch(handleError(dispatch)); +}; diff --git a/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js b/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js index c78b114484c..d11c40e34e2 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js +++ b/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js @@ -32,7 +32,7 @@ const reducer = (state: State = {}, action: Object) => { if (action.type === 'SET_APP_STATE') { const settingsByKey = {}; Object.keys(action.appState.settings).forEach( - key => settingsByKey[key] = { value: action.appState.settings[key] } + key => (settingsByKey[key] = { value: action.appState.settings[key] }) ); return { ...state, ...settingsByKey }; } diff --git a/server/sonar-web/src/main/js/apps/settings/utils.js b/server/sonar-web/src/main/js/apps/settings/utils.js index 56ae346e1f4..704ae2c45c1 100644 --- a/server/sonar-web/src/main/js/apps/settings/utils.js +++ b/server/sonar-web/src/main/js/apps/settings/utils.js @@ -84,7 +84,7 @@ export function getEmptyValue(definition) { if (definition.type === TYPE_PROPERTY_SET) { const value = {}; - definition.fields.forEach(field => value[field.key] = getEmptyValue(field)); + definition.fields.forEach(field => (value[field.key] = getEmptyValue(field))); return [value]; } |