aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/settings/store
diff options
context:
space:
mode:
authorStas Vilchik <stas-vilchik@users.noreply.github.com>2017-03-17 09:10:48 +0100
committerGitHub <noreply@github.com>2017-03-17 09:10:48 +0100
commitde4365079bad2df3bdee2133576dc913ffbf1ab2 (patch)
treea522ccb952f0d37f454e8188e13b3dec3f731912 /server/sonar-web/src/main/js/apps/settings/store
parent6a03df65cc0c91a26150ea172a2c480e07326ea1 (diff)
downloadsonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.tar.gz
sonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.zip
format code using prettier (#1774)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/settings/store')
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/actions.js48
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/definitions/reducer.js18
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js68
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js31
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/rootReducer.js33
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/settingsPage/reducer.js7
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/values/reducer.js6
7 files changed, 119 insertions, 92 deletions
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 95e49dba581..212ddc47f7d 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
@@ -17,7 +17,12 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { getDefinitions, getValues, setSettingValue, resetSettingValue } from '../../../api/settings';
+import {
+ getDefinitions,
+ getValues,
+ setSettingValue,
+ resetSettingValue
+} from '../../../api/settings';
import { receiveValues } from './values/actions';
import { receiveDefinitions } from './definitions/actions';
import { startLoading, stopLoading } from './settingsPage/loading/actions';
@@ -29,8 +34,9 @@ import { isEmptyValue } from '../utils';
import { translate } from '../../../helpers/l10n';
import { getSettingsAppDefinition, getSettingsAppChangedValue } from '../../../store/rootReducer';
-export const fetchSettings = componentKey => dispatch => {
- return getDefinitions(componentKey)
+export const fetchSettings = componentKey =>
+ dispatch => {
+ return getDefinitions(componentKey)
.then(definitions => {
const withoutLicenses = definitions.filter(definition => definition.type !== 'LICENSE');
dispatch(receiveDefinitions(withoutLicenses));
@@ -42,22 +48,23 @@ export const fetchSettings = componentKey => dispatch => {
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')));
- dispatch(stopLoading(key));
- return Promise.reject();
- }
+ 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)
+ return setSettingValue(definition, value, componentKey)
.then(() => getValues(key, componentKey))
.then(values => {
dispatch(receiveValues(values));
@@ -70,12 +77,13 @@ export const saveValue = (key, componentKey) => (dispatch, getState) => {
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)
+ return resetSettingValue(key, componentKey)
.then(() => getValues(key, componentKey))
.then(values => {
if (values.length > 0) {
@@ -91,4 +99,4 @@ export const resetValue = (key, componentKey) => dispatch => {
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 62feda90947..4e96d1018de 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
@@ -39,25 +39,27 @@ const reducer = (state: State = {}, action: Action) => {
export default reducer;
-export const getDefinition = (state: State, key: string): Definition =>
- state[key];
+export const getDefinition = (state: State, key: string): Definition => state[key];
export const getAllDefinitions = (state: State): Definition[] =>
- Object.keys(state).map(key => state[key]);
+ Object.keys(state).map(key => state[key]);
export const getDefinitionsForCategory = (state: State, category: string) =>
- getAllDefinitions(state).filter(definition => definition.category.toLowerCase() === category.toLowerCase());
+ getAllDefinitions(state).filter(
+ definition => definition.category.toLowerCase() === category.toLowerCase()
+ );
-export const getAllCategories = (state: State) => uniqBy(
- getAllDefinitions(state).map(definition => definition.category),
- category => category.toLowerCase());
+export const getAllCategories = (state: State) =>
+ uniqBy(getAllDefinitions(state).map(definition => definition.category), category =>
+ category.toLowerCase());
export const getDefaultCategory = (state: State) => {
const categories = getAllCategories(state);
if (categories.includes(DEFAULT_CATEGORY)) {
return DEFAULT_CATEGORY;
} else {
- const sortedCategories = sortBy(categories, category => getCategoryName(category).toLowerCase());
+ const sortedCategories = sortBy(categories, category =>
+ 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 42d39768ce2..eac17044bec 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
@@ -19,7 +19,10 @@
*/
import * as api from '../../../../api/settings';
import { parseError } from '../../../code/utils';
-import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../../store/globalMessages/duck';
+import {
+ addGlobalErrorMessage,
+ closeAllGlobalMessages
+} from '../../../../store/globalMessages/duck';
export const UPDATE_ENCRYPTION = 'UPDATE_ENCRYPTION';
@@ -33,38 +36,49 @@ 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()
+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
- })))
+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)
+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 a63ef8d4103..baa19b1323d 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
@@ -19,7 +19,10 @@
*/
import * as licenses from '../../../../api/licenses';
import { parseError } from '../../../code/utils';
-import { addGlobalSuccessMessage, addGlobalErrorMessage } from '../../../../store/globalMessages/duck';
+import {
+ addGlobalSuccessMessage,
+ addGlobalErrorMessage
+} from '../../../../store/globalMessages/duck';
import { translate } from '../../../../helpers/l10n';
import { isLicenseFromListInvalid, isLicenseInvalid } from '../../licenses/licenseUtils';
@@ -30,13 +33,16 @@ 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()
+export const fetchLicenses = () =>
+ dispatch => {
+ return licenses
+ .getLicenses()
.then(licenses => {
dispatch(receiveLicenses(licenses));
/* eslint import/namespace: 0 */
@@ -46,12 +52,13 @@ export const fetchLicenses = () => dispatch => {
}
})
.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
+ return request
.then(() => {
licenses.getLicenses().then(licenses => {
dispatch(receiveLicenses(licenses));
@@ -63,4 +70,4 @@ export const setLicense = (key, value) => dispatch => {
});
})
.catch(handleError(dispatch));
-};
+ };
diff --git a/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js b/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js
index c6d5c1acde8..c11af77b997 100644
--- a/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js
+++ b/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js
@@ -48,40 +48,37 @@ const rootReducer = combineReducers({
export default rootReducer;
export const getDefinition = (state: State, key: string) =>
- fromDefinitions.getDefinition(state.definitions, key);
+ fromDefinitions.getDefinition(state.definitions, key);
export const getAllCategories = (state: State) =>
- fromDefinitions.getAllCategories(state.definitions);
+ fromDefinitions.getAllCategories(state.definitions);
export const getDefaultCategory = (state: State) =>
- fromDefinitions.getDefaultCategory(state.definitions);
+ fromDefinitions.getDefaultCategory(state.definitions);
-export const getValue = (state: State, key: string) =>
- fromValues.getValue(state.values, key);
+export const getValue = (state: State, key: string) => fromValues.getValue(state.values, key);
export const getSettingsForCategory = (state: State, category: string) =>
- fromDefinitions.getDefinitionsForCategory(state.definitions, category).map(definition => ({
- ...getValue(state, definition.key),
- definition
- }));
+ fromDefinitions.getDefinitionsForCategory(state.definitions, category).map(definition => ({
+ ...getValue(state, definition.key),
+ definition
+ }));
export const getChangedValue = (state: State, key: string) =>
- fromSettingsPage.getChangedValue(state.settingsPage, key);
+ fromSettingsPage.getChangedValue(state.settingsPage, key);
export const isLoading = (state: State, key: string) =>
- fromSettingsPage.isLoading(state.settingsPage, key);
+ fromSettingsPage.isLoading(state.settingsPage, key);
export const getLicenseByKey = (state: State, key: string) =>
- fromLicenses.getLicenseByKey(state.licenses, key);
+ fromLicenses.getLicenseByKey(state.licenses, key);
-export const getAllLicenseKeys = (state: State) =>
- fromLicenses.getAllLicenseKeys(state.licenses);
+export const getAllLicenseKeys = (state: State) => fromLicenses.getAllLicenseKeys(state.licenses);
export const getValidationMessage = (state: State, key: string) =>
- fromSettingsPage.getValidationMessage(state.settingsPage, key);
+ fromSettingsPage.getValidationMessage(state.settingsPage, key);
-export const getEncryptionState = (state: State) =>
- state.encryptionPage;
+export const getEncryptionState = (state: State) => state.encryptionPage;
export const getGlobalMessages = (state: State) =>
- fromGlobalMessages.getGlobalMessages(state.globalMessages);
+ fromGlobalMessages.getGlobalMessages(state.globalMessages);
diff --git a/server/sonar-web/src/main/js/apps/settings/store/settingsPage/reducer.js b/server/sonar-web/src/main/js/apps/settings/store/settingsPage/reducer.js
index a53bec442bd..f2bdf8c39b1 100644
--- a/server/sonar-web/src/main/js/apps/settings/store/settingsPage/reducer.js
+++ b/server/sonar-web/src/main/js/apps/settings/store/settingsPage/reducer.js
@@ -29,10 +29,9 @@ export default combineReducers({
});
export const getChangedValue = (state, key) =>
- fromChangedValues.getChangedValue(state.changedValues, key);
+ fromChangedValues.getChangedValue(state.changedValues, key);
export const getValidationMessage = (state, key) =>
- fromValidationMessages.getValidationMessage(state.validationMessages, key);
+ fromValidationMessages.getValidationMessage(state.validationMessages, key);
-export const isLoading = (state, key) =>
- fromLoading.isLoading(state.loading, key);
+export const isLoading = (state, key) => fromLoading.isLoading(state.loading, key);
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 bcad10fedac..1e75fe48727 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
@@ -31,9 +31,9 @@ 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] }
- ));
+ Object.keys(action.appState.settings).forEach(
+ key => settingsByKey[key] = { value: action.appState.settings[key] }
+ );
return { ...state, ...settingsByKey };
}