diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-04-20 11:10:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 11:10:13 +0200 |
commit | f6e90fdc19e222b3b238f0f5995a8039b7db158e (patch) | |
tree | 69c22415cb50a650b046ce4b9a9ac99e57695dfd /server/sonar-web/src/main/js/apps | |
parent | 36c9fa041018d7eed91f1d22e0c5eda075737ebc (diff) | |
download | sonarqube-f6e90fdc19e222b3b238f0f5995a8039b7db158e.tar.gz sonarqube-f6e90fdc19e222b3b238f0f5995a8039b7db158e.zip |
upgrade prettier (#1954)
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
120 files changed, 1082 insertions, 1075 deletions
diff --git a/server/sonar-web/src/main/js/apps/about/actions.js b/server/sonar-web/src/main/js/apps/about/actions.js index 279c6f46c49..18f1d88f09d 100644 --- a/server/sonar-web/src/main/js/apps/about/actions.js +++ b/server/sonar-web/src/main/js/apps/about/actions.js @@ -21,11 +21,10 @@ import { getValues } from '../../api/settings'; import { receiveValues } from '../settings/store/values/actions'; -export const fetchAboutPageSettings = (): Function => - (dispatch: Function): Promise<*> => { - const keys = ['sonar.lf.aboutText']; +export const fetchAboutPageSettings = (): Function => (dispatch: Function): Promise<*> => { + const keys = ['sonar.lf.aboutText']; - return getValues(keys.join()).then(values => { - dispatch(receiveValues(values)); - }); - }; + return getValues(keys.join()).then(values => { + dispatch(receiveValues(values)); + }); +}; diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutStandards.js b/server/sonar-web/src/main/js/apps/about/components/AboutStandards.js index 8a46026312e..d28330408b6 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutStandards.js +++ b/server/sonar-web/src/main/js/apps/about/components/AboutStandards.js @@ -25,8 +25,8 @@ import { getRulesUrl } from '../../../helpers/urls'; const link = 'https://redirect.sonarsource.com/doc/rules.html'; -const owaspTags = 'owasp-a1,owasp-a2,owasp-a3,owasp-a4,owasp-a5,' + - 'owasp-a6,owasp-a7,owasp-a8,owasp-a9,owasp-a10'; +const owaspTags = + 'owasp-a1,owasp-a2,owasp-a3,owasp-a4,owasp-a5,owasp-a6,owasp-a7,owasp-a8,owasp-a9,owasp-a10'; const sans25Tags = 'sans-top25-porous,sans-top25-risky,sans-top25-insecure'; type Props = { diff --git a/server/sonar-web/src/main/js/apps/about/routes.js b/server/sonar-web/src/main/js/apps/about/routes.js index 13940436e30..233b7e289ac 100644 --- a/server/sonar-web/src/main/js/apps/about/routes.js +++ b/server/sonar-web/src/main/js/apps/about/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/AboutApp').default })); + callback(null, { component: require('./components/AboutApp').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/account/notifications/Projects.js b/server/sonar-web/src/main/js/apps/account/notifications/Projects.js index 89a3a5e7661..318a53fa52a 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/Projects.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/Projects.js @@ -78,7 +78,8 @@ class Projects extends React.PureComponent { value: project.key, label: project.name, organization: project.organization - }))) + })) + ) .then(options => { cb(null, { options }); }); diff --git a/server/sonar-web/src/main/js/apps/account/notifications/actions.js b/server/sonar-web/src/main/js/apps/account/notifications/actions.js index 85e4821d73c..4ef2e0e3a25 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/actions.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/actions.js @@ -28,36 +28,33 @@ import { } from '../../../store/notifications/duck'; import type { Notification } from '../../../store/notifications/duck'; -export const fetchNotifications = () => - (dispatch: Function) => { - const onFulfil = (response: GetNotificationsResponse) => { - const organizations = response.notifications - .filter(n => n.organization) - .map(n => n.organization); +export const fetchNotifications = () => (dispatch: Function) => { + const onFulfil = (response: GetNotificationsResponse) => { + const organizations = response.notifications + .filter(n => n.organization) + .map(n => n.organization); - dispatch(fetchOrganizations(organizations)).then(() => { - dispatch( - receiveNotifications( - response.notifications, - response.channels, - response.globalTypes, - response.perProjectTypes - ) - ); - }); - }; - - return api.getNotifications().then(onFulfil, onFail(dispatch)); + dispatch(fetchOrganizations(organizations)).then(() => { + dispatch( + receiveNotifications( + response.notifications, + response.channels, + response.globalTypes, + response.perProjectTypes + ) + ); + }); }; -export const addNotification = (n: Notification) => - (dispatch: Function) => - api - .addNotification(n.channel, n.type, n.project) - .then(() => dispatch(addNotificationAction(n)), onFail(dispatch)); + return api.getNotifications().then(onFulfil, onFail(dispatch)); +}; + +export const addNotification = (n: Notification) => (dispatch: Function) => + api + .addNotification(n.channel, n.type, n.project) + .then(() => dispatch(addNotificationAction(n)), onFail(dispatch)); -export const removeNotification = (n: Notification) => - (dispatch: Function) => - api - .removeNotification(n.channel, n.type, n.project) - .then(() => dispatch(removeNotificationAction(n)), onFail(dispatch)); +export const removeNotification = (n: Notification) => (dispatch: Function) => + api + .removeNotification(n.channel, n.type, n.project) + .then(() => dispatch(removeNotificationAction(n)), onFail(dispatch)); diff --git a/server/sonar-web/src/main/js/apps/account/organizations/CreateOrganizationForm.js b/server/sonar-web/src/main/js/apps/account/organizations/CreateOrganizationForm.js index 7a9f2104777..aa1c16096b0 100644 --- a/server/sonar-web/src/main/js/apps/account/organizations/CreateOrganizationForm.js +++ b/server/sonar-web/src/main/js/apps/account/organizations/CreateOrganizationForm.js @@ -41,7 +41,7 @@ class CreateOrganizationForm extends React.PureComponent { state: State; props: { createOrganization: () => Promise<*>, - router: { push: (string) => void } + router: { push: string => void } }; constructor(props) { diff --git a/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.js b/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.js index e34189eb809..34fad4cf4c3 100644 --- a/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.js +++ b/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.js @@ -64,11 +64,11 @@ class UserOrganizations extends React.PureComponent { render() { const title = translate('my_account.organizations') + ' - ' + translate('my_account.page'); - const anyoneCanCreate = this.props.anyoneCanCreate != null && - this.props.anyoneCanCreate.value === 'true'; + const anyoneCanCreate = + this.props.anyoneCanCreate != null && this.props.anyoneCanCreate.value === 'true'; - const canCreateOrganizations = !this.state.loading && - (anyoneCanCreate || isUserAdmin(this.props.currentUser)); + const canCreateOrganizations = + !this.state.loading && (anyoneCanCreate || isUserAdmin(this.props.currentUser)); return ( <div className="account-body account-container"> diff --git a/server/sonar-web/src/main/js/apps/account/organizations/actions.js b/server/sonar-web/src/main/js/apps/account/organizations/actions.js index 9731c4dec15..345efe30660 100644 --- a/server/sonar-web/src/main/js/apps/account/organizations/actions.js +++ b/server/sonar-web/src/main/js/apps/account/organizations/actions.js @@ -23,22 +23,22 @@ import { receiveMyOrganizations } from '../../../store/organizations/duck'; import { getValues } from '../../../api/settings'; import { receiveValues } from '../../settings/store/values/actions'; -export const fetchMyOrganizations = (): Function => - (dispatch: Function): Promise<*> => { - return api.getMyOrganizations().then(keys => { - if (keys.length > 0) { - return api.getOrganizations(keys).then(({ organizations }) => { - return dispatch(receiveMyOrganizations(organizations)); - }); - } else { - return dispatch(receiveMyOrganizations([])); - } - }); - }; +export const fetchMyOrganizations = (): Function => (dispatch: Function): Promise<*> => { + return api.getMyOrganizations().then(keys => { + if (keys.length > 0) { + return api.getOrganizations(keys).then(({ organizations }) => { + return dispatch(receiveMyOrganizations(organizations)); + }); + } else { + return dispatch(receiveMyOrganizations([])); + } + }); +}; -export const fetchIfAnyoneCanCreateOrganizations = (): Function => - (dispatch: Function): Promise<*> => { - return getValues('sonar.organizations.anyoneCanCreate').then(values => { - dispatch(receiveValues(values)); - }); - }; +export const fetchIfAnyoneCanCreateOrganizations = (): Function => ( + dispatch: Function +): Promise<*> => { + return getValues('sonar.organizations.anyoneCanCreate').then(values => { + dispatch(receiveValues(values)); + }); +}; diff --git a/server/sonar-web/src/main/js/apps/account/routes.js b/server/sonar-web/src/main/js/apps/account/routes.js index 0fc03242eaa..43cd438d7b0 100644 --- a/server/sonar-web/src/main/js/apps/account/routes.js +++ b/server/sonar-web/src/main/js/apps/account/routes.js @@ -26,7 +26,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./profile/Profile').default })); + callback(null, { component: require('./profile/Profile').default }) + ); } }, { @@ -39,28 +40,32 @@ const routes = [ path: 'projects', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./projects/ProjectsContainer').default)); + callback(null, require('./projects/ProjectsContainer').default) + ); } }, { path: 'notifications', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./notifications/Notifications').default)); + callback(null, require('./notifications/Notifications').default) + ); } }, { path: 'organizations', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./organizations/UserOrganizations').default)); + callback(null, require('./organizations/UserOrganizations').default) + ); }, childRoutes: [ { path: 'create', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./organizations/CreateOrganizationForm').default)); + callback(null, require('./organizations/CreateOrganizationForm').default) + ); } } ] diff --git a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js index b34ba6668ab..9ab30012448 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js @@ -61,13 +61,10 @@ describe('Search', () => { const component = shallow(<Search {...defaultProps} onFilterUpdate={searchSpy} />); const searchInput = component.find('.js-search'); change(searchInput, 'some search query'); - setTimeout( - () => { - expect(searchSpy).toBeCalledWith({ query: 'some search query' }); - done(); - }, - DEBOUNCE_DELAY - ); + setTimeout(() => { + expect(searchSpy).toBeCalledWith({ query: 'some search query' }); + done(); + }, DEBOUNCE_DELAY); }); it('should reload', () => { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js index af0e2743612..6591fc3c4c5 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js @@ -43,7 +43,7 @@ import { fetchOrganizations } from '../../../store/rootActions'; type Props = { component: Object, location: Object, - fetchOrganizations: (Array<string>) => string + fetchOrganizations: Array<string> => string }; type State = { @@ -91,7 +91,8 @@ class BackgroundTasksApp extends React.PureComponent { componentDidUpdate(prevProps: Props) { if ( - prevProps.component !== this.props.component || prevProps.location !== this.props.location + prevProps.component !== this.props.component || + prevProps.location !== this.props.location ) { this.loadTasksDebounced(); } @@ -107,8 +108,8 @@ class BackgroundTasksApp extends React.PureComponent { const status = this.props.location.query.status || DEFAULT_FILTERS.status; const taskType = this.props.location.query.taskType || DEFAULT_FILTERS.taskType; const currents = this.props.location.query.currents || DEFAULT_FILTERS.currents; - const minSubmittedAt = this.props.location.query.minSubmittedAt || - DEFAULT_FILTERS.minSubmittedAt; + const minSubmittedAt = + this.props.location.query.minSubmittedAt || DEFAULT_FILTERS.minSubmittedAt; const maxExecutedAt = this.props.location.query.maxExecutedAt || DEFAULT_FILTERS.maxExecutedAt; const query = this.props.location.query.query || DEFAULT_FILTERS.query; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js b/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js index c20dafc23c6..677d7bcc48f 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/CurrentsFilter.js @@ -22,7 +22,7 @@ import React from 'react'; import Checkbox from '../../../components/controls/Checkbox'; import { CURRENTS } from '../constants'; -const CurrentsFilter = ({ value, onChange }: { value: ?string, onChange: (string) => void }) => { +const CurrentsFilter = ({ value, onChange }: { value: ?string, onChange: string => void }) => { function handleChange(value) { const newValue = value ? CURRENTS.ONLY_CURRENTS : CURRENTS.ALL; onChange(newValue); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.js index 856e93da7c6..119591b2e4e 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskDate.js @@ -21,9 +21,11 @@ import moment from 'moment'; import React from 'react'; -const TaskDate = ( - { date, baseDate, format }: { date: string, baseDate: string, format: string } -) => { +const TaskDate = ({ + date, + baseDate, + format +}: { date: string, baseDate: string, format: string }) => { const m = moment(date); const baseM = moment(baseDate); const diff = date && baseDate ? m.diff(baseM, 'days') : 0; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js index 2a0268be408..51d5fc4b759 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.js @@ -23,9 +23,11 @@ import Select from 'react-select'; import { ALL_TYPES } from '../constants'; import { translate } from '../../../helpers/l10n'; -const TypesFilter = ( - { value, onChange, types }: { value: string, onChange: Function, types: string[] } -) => { +const TypesFilter = ({ + value, + onChange, + types +}: { value: string, onChange: Function, types: string[] }) => { const options = types.map(t => { return { value: t, diff --git a/server/sonar-web/src/main/js/apps/background-tasks/routes.js b/server/sonar-web/src/main/js/apps/background-tasks/routes.js index b67c86a2771..bdc399c3b33 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/routes.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/BackgroundTasksApp').default })); + callback(null, { component: require('./components/BackgroundTasksApp').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/utils.js b/server/sonar-web/src/main/js/apps/background-tasks/utils.js index adb942dacd9..963fb60aea4 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/utils.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/utils.js @@ -22,7 +22,7 @@ import { STATUSES, ALL_TYPES, CURRENTS } from './constants'; import { Task } from './types'; export function updateTask(tasks: Task[], newTask: Task) { - return tasks.map(task => task.id === newTask.id ? newTask : task); + return tasks.map(task => (task.id === newTask.id ? newTask : task)); } export function mapFiltersToParameters(filters: Object = {}) { diff --git a/server/sonar-web/src/main/js/apps/code/components/App.js b/server/sonar-web/src/main/js/apps/code/components/App.js index 00f0dee1302..33c71efd189 100644 --- a/server/sonar-web/src/main/js/apps/code/components/App.js +++ b/server/sonar-web/src/main/js/apps/code/components/App.js @@ -89,8 +89,8 @@ class App extends React.PureComponent { loadComponent(componentKey) { this.setState({ loading: true }); - const isView = this.props.component.qualifier === 'VW' || - this.props.component.qualifier === 'SVW'; + const isView = + this.props.component.qualifier === 'VW' || this.props.component.qualifier === 'SVW'; retrieveComponent(componentKey, isView) .then(r => { if (this.mounted) { @@ -133,8 +133,8 @@ class App extends React.PureComponent { handleLoadMore() { const { baseComponent, page } = this.state; - const isView = this.props.component.qualifier === 'VW' || - this.props.component.qualifier === 'SVW'; + const isView = + this.props.component.qualifier === 'VW' || this.props.component.qualifier === 'SVW'; loadMoreChildren(baseComponent.key, page + 1, isView) .then(r => { if (this.mounted) { diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.js b/server/sonar-web/src/main/js/apps/code/components/Component.js index 5d55a82684c..1f5ea5fff04 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Component.js +++ b/server/sonar-web/src/main/js/apps/code/components/Component.js @@ -42,12 +42,9 @@ export default class Component extends React.PureComponent { // scroll viewport so the current selected component is visible if (selected) { - setTimeout( - () => { - this.handleScroll(); - }, - 0 - ); + setTimeout(() => { + this.handleScroll(); + }, 0); } } diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js index bfb5a4b8e40..e455acf4c4d 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.js @@ -27,7 +27,8 @@ const ComponentMeasure = ({ component, metricKey, metricType }) => { const finalMetricKey = isProject && isReleasability ? 'alert_status' : metricKey; const finalMetricType = isProject && isReleasability ? 'LEVEL' : metricType; - const measure = Array.isArray(component.measures) && + const measure = + Array.isArray(component.measures) && component.measures.find(measure => measure.metric === finalMetricKey); if (!measure) { diff --git a/server/sonar-web/src/main/js/apps/code/routes.js b/server/sonar-web/src/main/js/apps/code/routes.js index c2e9fd242f4..73a48b7b9c3 100644 --- a/server/sonar-web/src/main/js/apps/code/routes.js +++ b/server/sonar-web/src/main/js/apps/code/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/App').default })); + callback(null, { component: require('./components/App').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js index 865341fa43c..cc7a145f49c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js @@ -35,7 +35,7 @@ class CodingRulesAppContainer extends React.PureComponent { organizationKey?: string }, router: { - replace: (string) => void + replace: string => void } }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js index 1fd1c67ead6..0921e346de5 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js @@ -39,7 +39,7 @@ export default BaseFacet.extend({ const languages = languagesQuery != null ? languagesQuery.split(',') : []; const lang = languages.length === 1 ? languages[0] : null; const values = this.options.app.qualityProfiles - .filter(profile => lang != null ? profile.lang === lang : true) + .filter(profile => (lang != null ? profile.lang === lang : true)) .map(profile => ({ label: profile.name, extra: that.options.app.languages[profile.lang], diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js index 2e6a00b28d2..50f60aca78e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js @@ -44,7 +44,7 @@ export default CustomValuesFacet.extend({ getLabelsSource() { const source = {}; - this.options.app.repositories.forEach(repo => source[repo.key] = repo.name); + this.options.app.repositories.forEach(repo => (source[repo.key] = repo.name)); return source; }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/init.js b/server/sonar-web/src/main/js/apps/coding-rules/init.js index 437505c5eaf..e3e23817c05 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/init.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/init.js @@ -36,11 +36,13 @@ import FiltersView from './filters-view'; const App = new Marionette.Application(); -App.on('start', function(options: { - el: HTMLElement, - organization: ?string, - isDefaultOrganization: boolean -}) { +App.on('start', function( + options: { + el: HTMLElement, + organization: ?string, + isDefaultOrganization: boolean + } +) { const data = options.organization ? { organization: options.organization } : {}; $.get(window.baseUrl + '/api/rules/app', data) .done(r => { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js index 5ce696aa43c..194bb2cf823 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js @@ -85,10 +85,10 @@ export default ModalFormView.extend({ return `<i class="icon-severity-${state.id.toLowerCase()}"></i> ${state.text}`; } }; - const severity = (this.model && this.model.get('severity')) || - this.options.templateRule.get('severity'); - const status = (this.model && this.model.get('status')) || - this.options.templateRule.get('status'); + const severity = + (this.model && this.model.get('severity')) || this.options.templateRule.get('severity'); + const status = + (this.model && this.model.get('status')) || this.options.templateRule.get('status'); this.ui.customRuleCreationSeverity.val(severity); this.ui.customRuleCreationSeverity.select2({ diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js index 7ad2466241d..1f31421dba7 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js @@ -60,8 +60,8 @@ export default ModalForm.extend({ return `<i class="icon-severity-${state.id.toLowerCase()}"></i> ${state.text}`; } }; - const severity = (this.model && this.model.get('severity')) || - this.options.rule.get('severity'); + const severity = + (this.model && this.model.get('severity')) || this.options.rule.get('severity'); this.ui.qualityProfileSeverity.val(severity); this.ui.qualityProfileSeverity.select2({ width: '250px', @@ -69,12 +69,9 @@ export default ModalForm.extend({ formatResult: format, formatSelection: format }); - setTimeout( - () => { - that.$('a').first().focus(); - }, - 0 - ); + setTimeout(() => { + that.$('a').first().focus(); + }, 0); }, activate(e) { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js index 1f03259a1a8..bc9b79867b0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js @@ -129,8 +129,8 @@ export default Marionette.ItemView.extend({ } const parentKey = myProfile.parentKey; const parent = { ...this.options.app.qualityProfiles.find(p => p.key === parentKey) }; - const parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || - new Backbone.Model(); + const parentActiveInfo = + this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model(); Object.assign(parent, parentActiveInfo.toJSON()); return parent; }, diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/IconBubbles.js b/server/sonar-web/src/main/js/apps/component-measures/components/IconBubbles.js index 9ffdf57c2bd..130adcc0c15 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/IconBubbles.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/IconBubbles.js @@ -29,9 +29,7 @@ export default function IconBubbles() { clipRule="evenodd" strokeLinejoin="round" strokeMiterlimit="1.414"> - <path - d="M352 256c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96zM128 96c70.645 0 128 57.355 128 128 0 70.645-57.355 128-128 128C57.355 352 0 294.645 0 224 0 153.355 57.355 96 128 96zM352 0c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96z" - /> + <path d="M352 256c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96zM128 96c70.645 0 128 57.355 128 128 0 70.645-57.355 128-128 128C57.355 352 0 294.645 0 224 0 153.355 57.355 96 128 96zM352 0c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96z" /> </svg> ); } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/IconHistory.js b/server/sonar-web/src/main/js/apps/component-measures/components/IconHistory.js index 5173bf7c3c4..19db8dc375d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/IconHistory.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/IconHistory.js @@ -29,9 +29,7 @@ export default function IconHistory() { clipRule="evenodd" strokeLinejoin="round" strokeMiterlimit="1.414"> - <path - d="M512 384v32H0V32h32v352h480zM480 72v108.75q0 5.25-4.875 7.375t-8.875-1.875L436 156 277.75 314.25q-2.5 2.5-5.75 2.5t-5.75-2.5L208 256 104 360l-48-48 146.25-146.25q2.5-2.5 5.75-2.5t5.75 2.5L272 224l116-116-30.25-30.25q-4-4-1.875-8.875T363.25 64H472q3.5 0 5.75 2.25T480 72z" - /> + <path d="M512 384v32H0V32h32v352h480zM480 72v108.75q0 5.25-4.875 7.375t-8.875-1.875L436 156 277.75 314.25q-2.5 2.5-5.75 2.5t-5.75-2.5L208 256 104 360l-48-48 146.25-146.25q2.5-2.5 5.75-2.5t5.75 2.5L272 224l116-116-30.25-30.25q-4-4-1.875-8.875T363.25 64H472q3.5 0 5.75 2.25T480 72z" /> </svg> ); } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/IconList.js b/server/sonar-web/src/main/js/apps/component-measures/components/IconList.js index 56b40bca427..df6d69e7f3b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/IconList.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/IconList.js @@ -29,9 +29,7 @@ export default function ListIcon() { clipRule="evenodd" strokeLinejoin="round" strokeMiterlimit="1.414"> - <path - d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 240c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 336.03c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32z" - /> + <path d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 240c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 336.03c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32z" /> </svg> ); } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/IconTree.js b/server/sonar-web/src/main/js/apps/component-measures/components/IconTree.js index 95342ee9d91..9270286f6a8 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/IconTree.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/IconTree.js @@ -29,9 +29,7 @@ export default function IconTree() { clipRule="evenodd" strokeLinejoin="round" strokeMiterlimit="1.414"> - <path - d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-6.146-16-13.714-16H77.714C70.144 128 64 135.17 64 144v32c0 8.83 6.145 16 13.714 16h356.572c7.568 0 13.714-7.17 13.714-16v-32zM448 240c0-8.83-5.12-16-11.428-16H139.428C133.12 224 128 231.17 128 240v32c0 8.83 5.12 16 11.428 16h297.144c6.307 0 11.428-7.17 11.428-16v-32zM448 336.03c0-8.83-4.097-16-9.142-16H201.143c-5.046 0-9.143 7.17-9.143 16v32c0 8.83 4.097 16 9.143 16h237.715c5.045 0 9.142-7.17 9.142-16v-32z" - /> + <path d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-6.146-16-13.714-16H77.714C70.144 128 64 135.17 64 144v32c0 8.83 6.145 16 13.714 16h356.572c7.568 0 13.714-7.17 13.714-16v-32zM448 240c0-8.83-5.12-16-11.428-16H139.428C133.12 224 128 231.17 128 240v32c0 8.83 5.12 16 11.428 16h297.144c6.307 0 11.428-7.17 11.428-16v-32zM448 336.03c0-8.83-4.097-16-9.142-16H201.143c-5.046 0-9.143 7.17-9.143 16v32c0 8.83 4.097 16 9.143 16h237.715c5.045 0 9.142-7.17 9.142-16v-32z" /> </svg> ); } diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js index e37cdd2c688..a3b3946d56d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js @@ -88,9 +88,9 @@ export default class MeasureHistory extends React.PureComponent { return Promise.resolve([]); } - return getProjectActivity(this.props.component.key, { category: 'VERSION' }).then(({ - analyses - }) => { + return getProjectActivity(this.props.component.key, { + category: 'VERSION' + }).then(({ analyses }) => { const events = analyses.map(analysis => { const version = analysis.events.find(event => event.category === 'VERSION'); return { version: version.name, date: moment(analysis.date).toDate() }; diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js b/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js index d7dbd648955..7d700666a8f 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/HomeMeasuresList.js @@ -55,7 +55,8 @@ const HomeMeasuresList = ({ domain, component }) => { const configMain = config.main || []; const [mainMeasures, otherMeasures] = partition(filteredMeasures, measure => - configMain.includes(measure.metric.key)); + configMain.includes(measure.metric.key) + ); const configOrder = config.order || []; const sortedMainMeasures = sortMeasures(mainMeasures, configOrder); diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js b/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js index f529a7ac851..e75222924f6 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js @@ -49,7 +49,8 @@ function groupByDomains(measures) { 'name' ); const [knownDomains, unknownDomains] = partition(domains, domain => - KNOWN_DOMAINS.includes(domain.name)); + KNOWN_DOMAINS.includes(domain.name) + ); return [ ...sortBy(knownDomains, domain => KNOWN_DOMAINS.indexOf(domain.name)), ...sortBy(unknownDomains, domain => domain.name) diff --git a/server/sonar-web/src/main/js/apps/component-measures/routes.js b/server/sonar-web/src/main/js/apps/component-measures/routes.js index bbf67ad283b..a416e181a22 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/routes.js +++ b/server/sonar-web/src/main/js/apps/component-measures/routes.js @@ -31,14 +31,16 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./home/AllMeasuresContainer').default })); + callback(null, { component: require('./home/AllMeasuresContainer').default }) + ); } }, { path: 'domain/:domainName', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./home/DomainMeasuresContainer').default)); + callback(null, require('./home/DomainMeasuresContainer').default) + ); } } ] @@ -47,7 +49,8 @@ const routes = [ path: 'metric/:metricKey', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./details/MeasureDetailsContainer').default)); + callback(null, require('./details/MeasureDetailsContainer').default) + ); }, childRoutes: [ { @@ -65,28 +68,32 @@ const routes = [ path: 'list', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./details/drilldown/ListViewContainer').default)); + callback(null, require('./details/drilldown/ListViewContainer').default) + ); } }, { path: 'tree', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./details/drilldown/TreeViewContainer').default)); + callback(null, require('./details/drilldown/TreeViewContainer').default) + ); } }, { path: 'history', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./details/history/MeasureHistoryContainer').default)); + callback(null, require('./details/history/MeasureHistoryContainer').default) + ); } }, { path: 'treemap', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./details/treemap/MeasureTreemapContainer').default)); + callback(null, require('./details/treemap/MeasureTreemapContainer').default) + ); } } ] diff --git a/server/sonar-web/src/main/js/apps/custom-measures/routes.js b/server/sonar-web/src/main/js/apps/custom-measures/routes.js index bae2abe703a..f4e98ca2c3a 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/routes.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/CustomMeasuresAppContainer').default })); + callback(null, { component: require('./components/CustomMeasuresAppContainer').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/groups/list-view.js b/server/sonar-web/src/main/js/apps/groups/list-view.js index 52042b45663..6b424553c44 100644 --- a/server/sonar-web/src/main/js/apps/groups/list-view.js +++ b/server/sonar-web/src/main/js/apps/groups/list-view.js @@ -39,8 +39,8 @@ export default Marionette.CompositeView.extend({ this.$el.removeClass('new-loading'); const query = this.collection.q || ''; - const shouldHideAnyone = this.collection.organization || - !'anyone'.includes(query.toLowerCase()); + const shouldHideAnyone = + this.collection.organization || !'anyone'.includes(query.toLowerCase()); this.$('.js-anyone').toggleClass('hidden', shouldHideAnyone); }, diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js index 73574c611b5..efdfd182789 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.js +++ b/server/sonar-web/src/main/js/apps/issues/components/App.js @@ -65,7 +65,7 @@ type Props = { currentUser: CurrentUser, fetchIssues: () => Promise<*>, location: { pathname: string, query: { [string]: string } }, - onRequestFail: (Error) => void, + onRequestFail: Error => void, router: { push: () => void, replace: () => void } }; @@ -404,7 +404,8 @@ export default class App extends React.PureComponent { getCheckedIssues = () => { const issues = this.state.checked.map(checked => - this.state.issues.find(issue => issue.key === checked)); + this.state.issues.find(issue => issue.key === checked) + ); const paging = { pageIndex: 1, pageSize: issues.length, total: issues.length }; return Promise.resolve({ issues, paging }); }; @@ -465,7 +466,7 @@ export default class App extends React.PureComponent { handleIssueChange = (issue: Issue) => { this.setState(state => ({ - issues: state.issues.map(candidate => candidate.key === issue.key ? issue : candidate) + issues: state.issues.map(candidate => (candidate.key === issue.key ? issue : candidate)) })); }; diff --git a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js index c605961dcad..b654ce9687c 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js @@ -36,16 +36,13 @@ const mapStateToProps = (state, ownProps) => ({ currentUser: getCurrentUser(state) }); -const fetchIssues = (query: Query) => - (dispatch: Dispatch<*>) => - searchIssues({ ...query, additionalFields: '_all' }).then( - response => { - const parsedIssues = response.issues.map(issue => - parseIssueFromResponse(issue, response.components, response.users, response.rules)); - return { ...response, issues: parsedIssues }; - }, - onFail(dispatch) +const fetchIssues = (query: Query) => (dispatch: Dispatch<*>) => + searchIssues({ ...query, additionalFields: '_all' }).then(response => { + const parsedIssues = response.issues.map(issue => + parseIssueFromResponse(issue, response.components, response.users, response.rules) ); + return { ...response, issues: parsedIssues }; + }, onFail(dispatch)); const onRequestFail = (error: Error) => (dispatch: Dispatch<*>) => onFail(dispatch)(error); diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js index 3b7d454aa72..63b4680c2fe 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js @@ -42,7 +42,7 @@ type Props = {| fetchIssues: ({}) => Promise<*>, onClose: () => void, onDone: () => void, - onRequestFail: (Error) => void + onRequestFail: Error => void |}; type State = {| @@ -65,8 +65,8 @@ type State = {| type?: string |}; -const hasAction = (action: string) => - (issue: Issue): boolean => issue.actions && issue.actions.includes(action); +const hasAction = (action: string) => (issue: Issue): boolean => + issue.actions && issue.actions.includes(action); export default class BulkChangeModal extends React.PureComponent { mounted: boolean; @@ -115,9 +115,8 @@ export default class BulkChangeModal extends React.PureComponent { const options = []; if (currentUser.isLoggedIn) { - const canBeAssignedToMe = issues.filter( - issue => issue.assignee !== currentUser.login - ).length > 0; + const canBeAssignedToMe = + issues.filter(issue => issue.assignee !== currentUser.login).length > 0; if (canBeAssignedToMe) { options.push({ email: currentUser.email, @@ -140,29 +139,25 @@ export default class BulkChangeModal extends React.PureComponent { this.setState({ assignee }); }; - handleFieldCheck = (field: string) => - (checked: boolean) => { - if (!checked) { - this.setState({ [field]: undefined }); - } else if (field === 'notifications') { - this.setState({ [field]: true }); - } - }; + handleFieldCheck = (field: string) => (checked: boolean) => { + if (!checked) { + this.setState({ [field]: undefined }); + } else if (field === 'notifications') { + this.setState({ [field]: true }); + } + }; - handleFieldChange = (field: string) => - (event: { target: HTMLInputElement }) => { - this.setState({ [field]: event.target.value }); - }; + handleFieldChange = (field: string) => (event: { target: HTMLInputElement }) => { + this.setState({ [field]: event.target.value }); + }; - handleSelectFieldChange = (field: string) => - ({ value }: { value: string }) => { - this.setState({ [field]: value }); - }; + handleSelectFieldChange = (field: string) => ({ value }: { value: string }) => { + this.setState({ [field]: value }); + }; - handleMultiSelectFieldChange = (field: string) => - (options: Array<{ value: string }>) => { - this.setState({ [field]: options.map(option => option.value) }); - }; + handleMultiSelectFieldChange = (field: string) => (options: Array<{ value: string }>) => { + this.setState({ [field]: options.map(option => option.value) }); + }; handleSubmit = (e: Event) => { e.preventDefault(); @@ -473,8 +468,8 @@ export default class BulkChangeModal extends React.PureComponent { renderForm = () => { const { issues, paging, submitting } = this.state; - const limitReached: boolean = paging != null && - paging.total > paging.pageIndex * paging.pageSize; + const limitReached: boolean = + paging != null && paging.total > paging.pageIndex * paging.pageSize; return ( <form id="bulk-change-form" onSubmit={this.handleSubmit}> diff --git a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.js b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.js index bc12da43bf1..e11340fc943 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.js +++ b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.js @@ -37,8 +37,8 @@ export default class ComponentBreadcrumbs extends React.PureComponent { const { component, issue } = this.props; const displayOrganization = component == null || ['VW', 'SVW'].includes(component.qualifier); - const displayProject = component == null || - !['TRK', 'BRC', 'DIR'].includes(component.qualifier); + const displayProject = + component == null || !['TRK', 'BRC', 'DIR'].includes(component.qualifier); const displaySubProject = component == null || !['BRC', 'DIR'].includes(component.qualifier); return ( diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.js b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.js index 4bd9cf945d6..f5897fd518f 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.js +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.js @@ -28,9 +28,9 @@ type Props = {| component?: Component, issues: Array<Issue>, onFilterChange: (changes: {}) => void, - onIssueChange: (Issue) => void, - onIssueCheck?: (string) => void, - onIssueClick: (string) => void, + onIssueChange: Issue => void, + onIssueCheck?: string => void, + onIssueClick: string => void, selectedIssue: ?Issue |}; diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js index ff090ed8287..81fd47f1bd8 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js @@ -25,8 +25,8 @@ import type { Issue } from '../../../components/issue/types'; type Props = {| loadIssues: () => Promise<*>, - onIssueChange: (Issue) => void, - onIssueSelect: (string) => void, + onIssueChange: Issue => void, + onIssueSelect: string => void, openIssue: Issue |}; @@ -51,7 +51,7 @@ export default class IssuesSourceViewer extends React.PureComponent { const { openIssue } = this.props; return ( - <div ref={node => this.node = node}> + <div ref={node => (this.node = node)}> <SourceViewer aroundLine={openIssue.line} component={openIssue.component} diff --git a/server/sonar-web/src/main/js/apps/issues/components/ListItem.js b/server/sonar-web/src/main/js/apps/issues/components/ListItem.js index f8a0bdda14a..7d46d74eab7 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ListItem.js +++ b/server/sonar-web/src/main/js/apps/issues/components/ListItem.js @@ -28,9 +28,9 @@ type Props = {| checked: boolean, component?: Component, issue: IssueType, - onChange: (IssueType) => void, - onCheck?: (string) => void, - onClick: (string) => void, + onChange: IssueType => void, + onCheck?: string => void, + onClick: string => void, onFilterChange: (changes: {}) => void, previousIssue: ?Object, selected: boolean diff --git a/server/sonar-web/src/main/js/apps/issues/components/MyIssuesFilter.js b/server/sonar-web/src/main/js/apps/issues/components/MyIssuesFilter.js index 51fad9f386b..5c674e86355 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/MyIssuesFilter.js +++ b/server/sonar-web/src/main/js/apps/issues/components/MyIssuesFilter.js @@ -24,18 +24,17 @@ import { translate } from '../../../helpers/l10n'; type Props = {| myIssues: boolean, - onMyIssuesChange: (boolean) => void + onMyIssuesChange: boolean => void |}; export default class MyIssuesFilter extends React.PureComponent { props: Props; - handleClick = (myIssues: boolean) => - (e: Event & { currentTarget: HTMLElement }) => { - e.preventDefault(); - e.currentTarget.blur(); - this.props.onMyIssuesChange(myIssues); - }; + handleClick = (myIssues: boolean) => (e: Event & { currentTarget: HTMLElement }) => { + e.preventDefault(); + e.currentTarget.blur(); + this.props.onMyIssuesChange(myIssues); + }; render() { const { myIssues } = this.props; diff --git a/server/sonar-web/src/main/js/apps/issues/routes.js b/server/sonar-web/src/main/js/apps/issues/routes.js index 61893ce7fec..f4c372a1368 100644 --- a/server/sonar-web/src/main/js/apps/issues/routes.js +++ b/server/sonar-web/src/main/js/apps/issues/routes.js @@ -26,7 +26,8 @@ const routes = [ callback(null, { component: require('./components/AppContainer').default, onEnter - })); + }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js index cf7bb4be8f2..05479435763 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js @@ -127,7 +127,7 @@ export default class AssigneeFacet extends React.PureComponent { const assignees = sortBy( Object.keys(stats), // put unassigned first - key => key === '' ? 0 : 1, + key => (key === '' ? 0 : 1), // the sort by number key => -stats[key] ); diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.js index dd28ccfddea..d67b204f3cd 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.js +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.js @@ -70,38 +70,36 @@ export default class CreationDateFacet extends React.PureComponent { }); }; - handleBarClick = ( - { createdAfter, createdBefore }: { createdAfter: Object, createdBefore?: Object } - ) => { + handleBarClick = ({ + createdAfter, + createdBefore + }: { createdAfter: Object, createdBefore?: Object }) => { this.resetTo({ createdAfter: createdAfter.format(DATE_FORMAT), createdBefore: createdBefore && createdBefore.format(DATE_FORMAT) }); }; - handlePeriodChange = (property: string) => - (value: string) => { - this.props.onChange({ - createdAt: undefined, - createdInLast: undefined, - sinceLeakPeriod: undefined, - [property]: value - }); - }; - - handlePeriodClick = (period?: string) => - (e: Event & { target: HTMLElement }) => { - e.preventDefault(); - e.target.blur; - this.resetTo({ createdInLast: period }); - }; - - handleLeakPeriodClick = () => - (e: Event & { target: HTMLElement }) => { - e.preventDefault(); - e.target.blur; - this.resetTo({ sinceLeakPeriod: true }); - }; + handlePeriodChange = (property: string) => (value: string) => { + this.props.onChange({ + createdAt: undefined, + createdInLast: undefined, + sinceLeakPeriod: undefined, + [property]: value + }); + }; + + handlePeriodClick = (period?: string) => (e: Event & { target: HTMLElement }) => { + e.preventDefault(); + e.target.blur; + this.resetTo({ createdInLast: period }); + }; + + handleLeakPeriodClick = () => (e: Event & { target: HTMLElement }) => { + e.preventDefault(); + e.target.blur; + this.resetTo({ sinceLeakPeriod: true }); + }; renderBarChart() { const { createdBefore, stats } = this.props; @@ -123,9 +121,8 @@ export default class CreationDateFacet extends React.PureComponent { : createdBefore ? moment(createdBefore) : undefined; const endMoment = nextStartMoment && nextStartMoment.clone().subtract(1, 'days'); - let tooltip = formatMeasure(stats[startDate], 'SHORT_INT') + - '<br>' + - startMoment.format('LL'); + let tooltip = + formatMeasure(stats[startDate], 'SHORT_INT') + '<br>' + startMoment.format('LL'); if (endMoment) { const isSameDay = endMoment.diff(startMoment, 'days') <= 1; @@ -149,7 +146,7 @@ export default class CreationDateFacet extends React.PureComponent { const maxValue = max(data.map(d => d.y)); const format = this.props.facetMode === 'count' ? 'SHORT_INT' : 'SHORT_WORK_DUR'; - const xValues = data.map(d => d.y === maxValue ? formatMeasure(maxValue, format) : ''); + const xValues = data.map(d => (d.y === maxValue ? formatMeasure(maxValue, format) : '')); return ( <BarChart @@ -248,7 +245,8 @@ export default class CreationDateFacet extends React.PureComponent { } render() { - const hasValue = this.props.createdAfter.length > 0 || + const hasValue = + this.props.createdAfter.length > 0 || this.props.createdAt.length > 0 || this.props.createdBefore.length > 0 || this.props.createdInLast.length > 0 || diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js index 2b7046f69ef..960a5bb1739 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js @@ -72,13 +72,15 @@ export default class ProjectFacet extends React.PureComponent { label: component.name, organization: component.organization, value: component.refId - }))) + })) + ) : searchComponents({ ps: 50, q: query, qualifiers: 'TRK' }).then(response => response.components.map(component => ({ label: component.name, organization: component.organization, value: component.id - }))); + })) + ); }; handleSelect = (rule: string) => { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.js index ce5d5d49468..ae9879d59f2 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.js +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.js @@ -67,7 +67,8 @@ export default class RuleFacet extends React.PureComponent { languages: languages.length ? languages.join() : undefined, q: query }).then(response => - response.rules.map(rule => ({ label: `(${rule.langName}) ${rule.name}`, value: rule.key }))); + response.rules.map(rule => ({ label: `(${rule.langName}) ${rule.name}`, value: rule.key })) + ); }; handleSelect = (rule: string) => { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js index fd4c2c3f91c..613c3be57ed 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js @@ -63,8 +63,8 @@ export default class Sidebar extends React.PureComponent { render() { const { component, facets, openFacets, query } = this.props; - const displayProjectsFacet: boolean = component == null || - !['TRK', 'BRC', 'DIR', 'DEV_PRJ'].includes(component.qualifier); + const displayProjectsFacet: boolean = + component == null || !['TRK', 'BRC', 'DIR', 'DEV_PRJ'].includes(component.qualifier); const displayModulesFacet = component == null || component.qualifier !== 'DIR'; const displayDirectoriesFacet = component == null || component.qualifier !== 'DIR'; const displayAuthorFacet = component == null || component.qualifier !== 'DEV'; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js index cd6ab46e679..120eb8d890b 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js @@ -60,7 +60,8 @@ export default class TagFacet extends React.PureComponent { handleSearch = (query: string) => { return searchIssueTags({ ps: 50, q: query }).then(tags => - tags.map(tag => ({ label: tag, value: tag }))); + tags.map(tag => ({ label: tag, value: tag })) + ); }; handleSelect = (tag: string) => { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js b/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js index 94d512d195b..81feb40dbf1 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/components/FacetItem.js @@ -28,7 +28,7 @@ type Props = {| facetMode: string, halfWidth: boolean, name: string | React.Element<*>, - onClick: (string) => void, + onClick: string => void, stat: ?number, value: string |}; @@ -55,7 +55,8 @@ export default class FacetItem extends React.PureComponent { 'search-navigator-facet-half': this.props.halfWidth }); - const formattedStat = stat && + const formattedStat = + stat && formatMeasure(stat, this.props.facetMode === 'effort' ? 'SHORT_WORK_DUR' : 'SHORT_INT'); return this.props.disabled diff --git a/server/sonar-web/src/main/js/apps/issues/utils.js b/server/sonar-web/src/main/js/apps/issues/utils.js index 3c9d8a235ed..b37344e37d5 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.js +++ b/server/sonar-web/src/main/js/apps/issues/utils.js @@ -56,14 +56,14 @@ export type Paging = { }; const parseAsBoolean = (value: ?string, defaultValue: boolean = true): boolean => - value === 'false' ? false : value === 'true' ? true : defaultValue; + (value === 'false' ? false : value === 'true' ? true : defaultValue); const parseAsString = (value: ?string): string => value || ''; -const parseAsStringArray = (value: ?string): Array<string> => value ? value.split(',') : []; +const parseAsStringArray = (value: ?string): Array<string> => (value ? value.split(',') : []); const parseAsFacetMode = (facetMode: string) => - facetMode === 'debt' || facetMode === 'effort' ? 'effort' : 'count'; + (facetMode === 'debt' || facetMode === 'effort' ? 'effort' : 'count'); export const parseQuery = (query: RawQuery): Query => ({ assigned: parseAsBoolean(query.assigned), @@ -96,7 +96,7 @@ export const areMyIssuesSelected = (query: RawQuery): boolean => query.myIssues const serializeString = (value: string): ?string => value || undefined; -const serializeValue = (value: Array<string>): ?string => value.length ? value.join() : undefined; +const serializeValue = (value: Array<string>): ?string => (value.length ? value.join() : undefined); export const serializeQuery = (query: Query): RawQuery => { const filter = { @@ -151,9 +151,9 @@ export const areQueriesEqual = (a: RawQuery, b: RawQuery) => { return keysA.every( key => - Array.isArray(parsedA[key]) && Array.isArray(parsedB[key]) + (Array.isArray(parsedA[key]) && Array.isArray(parsedB[key]) ? areArraysEqual(parsedA[key], parsedB[key]) - : parsedA[key] === parsedB[key] + : parsedA[key] === parsedB[key]) ); }; @@ -217,7 +217,8 @@ export const searchAssignees = (query: string, component?: Component) => { avatar: user.avatar, label: user.name, value: user.login - }))) + })) + ) : searchUsers(query, 50).then(response => response.users.map(user => ({ // TODO this WS returns no avatar @@ -225,5 +226,6 @@ export const searchAssignees = (query: string, component?: Component) => { email: user.email, label: user.name, value: user.login - }))); + })) + ); }; diff --git a/server/sonar-web/src/main/js/apps/maintenance/main-view.js b/server/sonar-web/src/main/js/apps/maintenance/main-view.js index 064ac731f10..68b234721bf 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/main-view.js +++ b/server/sonar-web/src/main/js/apps/maintenance/main-view.js @@ -34,12 +34,9 @@ export default Marionette.ItemView.extend({ type: 'GET', url: window.baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') }; - this.pollingInternal = setInterval( - () => { - this.refresh(); - }, - 5000 - ); + this.pollingInternal = setInterval(() => { + this.refresh(); + }, 5000); this.wasStarting = false; }, @@ -84,12 +81,9 @@ export default Marionette.ItemView.extend({ }, goHome() { - setInterval( - () => { - window.location = window.baseUrl + '/'; - }, - 2500 - ); + setInterval(() => { + window.location = window.baseUrl + '/'; + }, 2500); }, serializeData() { diff --git a/server/sonar-web/src/main/js/apps/metrics/routes.js b/server/sonar-web/src/main/js/apps/metrics/routes.js index a7b1354ecf4..6cbe20ddab9 100644 --- a/server/sonar-web/src/main/js/apps/metrics/routes.js +++ b/server/sonar-web/src/main/js/apps/metrics/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/MetricsAppContainer').default })); + callback(null, { component: require('./components/MetricsAppContainer').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/organizations/actions.js b/server/sonar-web/src/main/js/apps/organizations/actions.js index 4765ec0d5aa..d8401044cad 100644 --- a/server/sonar-web/src/main/js/apps/organizations/actions.js +++ b/server/sonar-web/src/main/js/apps/organizations/actions.js @@ -32,75 +32,69 @@ import type { Member } from '../../store/organizationsMembers/actions'; const PAGE_SIZE = 50; -const onRejected = (dispatch: Function) => - (error: Object) => { - onFail(dispatch)(error); - return Promise.reject(); - }; +const onRejected = (dispatch: Function) => (error: Object) => { + onFail(dispatch)(error); + return Promise.reject(); +}; -const onMembersFail = (organization: string, dispatch: Function) => - (error: Object) => { - onFail(dispatch)(error); - dispatch(membersActions.updateState(organization, { loading: false })); - }; +const onMembersFail = (organization: string, dispatch: Function) => (error: Object) => { + onFail(dispatch)(error); + dispatch(membersActions.updateState(organization, { loading: false })); +}; -export const fetchOrganization = (key: string): Function => - (dispatch: Function): Promise<*> => { - const onFulfilled = ([organization, navigation]) => { - if (organization) { - const organizationWithPermissions = { ...organization, ...navigation }; - dispatch(actions.receiveOrganizations([organizationWithPermissions])); - } - }; - - return Promise.all([api.getOrganization(key), api.getOrganizationNavigation(key)]).then( - onFulfilled, - onFail(dispatch) - ); +export const fetchOrganization = (key: string): Function => (dispatch: Function): Promise<*> => { + const onFulfilled = ([organization, navigation]) => { + if (organization) { + const organizationWithPermissions = { ...organization, ...navigation }; + dispatch(actions.receiveOrganizations([organizationWithPermissions])); + } }; -export const fetchOrganizationGroups = (organization: string): Function => - (dispatch: Function): Promise<*> => { - return searchUsersGroups({ organization }).then( - response => { - dispatch(actions.receiveOrganizationGroups(organization, response.groups)); - }, - onFail(dispatch) - ); - }; + return Promise.all([api.getOrganization(key), api.getOrganizationNavigation(key)]).then( + onFulfilled, + onFail(dispatch) + ); +}; -export const createOrganization = (fields: {}): Function => - (dispatch: Function): Promise<*> => { - const onFulfilled = (organization: Organization) => { - dispatch(actions.createOrganization(organization)); - dispatch( - addGlobalSuccessMessage(translateWithParameters('organization.created', organization.name)) - ); - }; +export const fetchOrganizationGroups = (organization: string): Function => ( + dispatch: Function +): Promise<*> => { + return searchUsersGroups({ organization }).then(response => { + dispatch(actions.receiveOrganizationGroups(organization, response.groups)); + }, onFail(dispatch)); +}; - return api.createOrganization(fields).then(onFulfilled, onRejected(dispatch)); +export const createOrganization = (fields: {}): Function => (dispatch: Function): Promise<*> => { + const onFulfilled = (organization: Organization) => { + dispatch(actions.createOrganization(organization)); + dispatch( + addGlobalSuccessMessage(translateWithParameters('organization.created', organization.name)) + ); }; -export const updateOrganization = (key: string, changes: {}): Function => - (dispatch: Function): Promise<*> => { - const onFulfilled = () => { - dispatch(actions.updateOrganization(key, changes)); - dispatch(addGlobalSuccessMessage(translate('organization.updated'))); - }; + return api.createOrganization(fields).then(onFulfilled, onRejected(dispatch)); +}; - return api.updateOrganization(key, changes).then(onFulfilled, onFail(dispatch)); +export const updateOrganization = (key: string, changes: {}): Function => ( + dispatch: Function +): Promise<*> => { + const onFulfilled = () => { + dispatch(actions.updateOrganization(key, changes)); + dispatch(addGlobalSuccessMessage(translate('organization.updated'))); }; -export const deleteOrganization = (key: string): Function => - (dispatch: Function): Promise<*> => { - const onFulfilled = () => { - dispatch(actions.deleteOrganization(key)); - dispatch(addGlobalSuccessMessage(translate('organization.deleted'))); - }; + return api.updateOrganization(key, changes).then(onFulfilled, onFail(dispatch)); +}; - return api.deleteOrganization(key).then(onFulfilled, onFail(dispatch)); +export const deleteOrganization = (key: string): Function => (dispatch: Function): Promise<*> => { + const onFulfilled = () => { + dispatch(actions.deleteOrganization(key)); + dispatch(addGlobalSuccessMessage(translate('organization.deleted'))); }; + return api.deleteOrganization(key).then(onFulfilled, onFail(dispatch)); +}; + const fetchMembers = ( dispatch: Function, receiveAction: Function, @@ -119,71 +113,69 @@ const fetchMembers = ( if (query) { data.q = query; } - return api.searchMembers(data).then( - response => { - dispatch( - receiveAction(key, response.users, { - loading: false, - total: response.paging.total, - pageIndex: response.paging.pageIndex, - query: query || null - }) - ); - }, - onMembersFail(key, dispatch) - ); + return api.searchMembers(data).then(response => { + dispatch( + receiveAction(key, response.users, { + loading: false, + total: response.paging.total, + pageIndex: response.paging.pageIndex, + query: query || null + }) + ); + }, onMembersFail(key, dispatch)); }; -export const fetchOrganizationMembers = (key: string, query?: string) => - (dispatch: Function) => fetchMembers(dispatch, membersActions.receiveMembers, key, query); - -export const fetchMoreOrganizationMembers = (key: string, query?: string) => - (dispatch: Function, getState: Function) => - fetchMembers( - dispatch, - membersActions.receiveMoreMembers, - key, - query, - getOrganizationMembersState(getState(), key).pageIndex + 1 - ); +export const fetchOrganizationMembers = (key: string, query?: string) => (dispatch: Function) => + fetchMembers(dispatch, membersActions.receiveMembers, key, query); -export const addOrganizationMember = (key: string, member: Member) => - (dispatch: Function) => { - return api - .addMember({ login: member.login, organization: key }) - .then(user => dispatch(membersActions.addMember(key, user)), onFail(dispatch)); - }; +export const fetchMoreOrganizationMembers = (key: string, query?: string) => ( + dispatch: Function, + getState: Function +) => + fetchMembers( + dispatch, + membersActions.receiveMoreMembers, + key, + query, + getOrganizationMembersState(getState(), key).pageIndex + 1 + ); -export const removeOrganizationMember = (key: string, member: Member) => - (dispatch: Function) => { - dispatch(membersActions.removeMember(key, member)); - return api.removeMember({ login: member.login, organization: key }).catch((error: Object) => { - onFail(dispatch)(error); - dispatch(membersActions.addMember(key, member)); - }); - }; +export const addOrganizationMember = (key: string, member: Member) => (dispatch: Function) => { + return api + .addMember({ login: member.login, organization: key }) + .then(user => dispatch(membersActions.addMember(key, user)), onFail(dispatch)); +}; + +export const removeOrganizationMember = (key: string, member: Member) => (dispatch: Function) => { + dispatch(membersActions.removeMember(key, member)); + return api.removeMember({ login: member.login, organization: key }).catch((error: Object) => { + onFail(dispatch)(error); + dispatch(membersActions.addMember(key, member)); + }); +}; export const updateOrganizationMemberGroups = ( organization: Organization, member: Member, add: Array<string>, remove: Array<string> -) => - (dispatch: Function) => { - dispatch( - receiveUser({ - ...member, - groupCount: (member.groupCount || 0) + add.length - remove.length - }) - ); - const promises = [ - ...add.map(name => - addUserToGroup({ name, login: member.login, organization: organization.key })), - ...remove.map(name => - removeUserFromGroup({ name, login: member.login, organization: organization.key })) - ]; - return Promise.all(promises).catch(error => { - dispatch(receiveUser(member)); - onFail(dispatch)(error); - }); - }; +) => (dispatch: Function) => { + dispatch( + receiveUser({ + ...member, + groupCount: (member.groupCount || 0) + add.length - remove.length + }) + ); + const promises = [ + ...add.map(name => + addUserToGroup({ name, login: member.login, organization: organization.key }) + ), + ...remove.map(name => + removeUserFromGroup({ name, login: member.login, organization: organization.key }) + ) + ]; + return Promise.all(promises).catch(error => { + dispatch(receiveUser(member)); + onFail(dispatch)(error); + }); +}; diff --git a/server/sonar-web/src/main/js/apps/organizations/components/MembersList.js b/server/sonar-web/src/main/js/apps/organizations/components/MembersList.js index 9d1f87512f2..c4996144eae 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/MembersList.js +++ b/server/sonar-web/src/main/js/apps/organizations/components/MembersList.js @@ -27,7 +27,7 @@ type Props = { members: Array<Member>, organizationGroups: Array<OrgGroup>, organization: Organization, - removeMember: (Member) => void, + removeMember: Member => void, updateMemberGroups: (member: Member, add: Array<string>, remove: Array<string>) => void }; diff --git a/server/sonar-web/src/main/js/apps/organizations/components/MembersListItem.js b/server/sonar-web/src/main/js/apps/organizations/components/MembersListItem.js index a3465c60a52..751b92275ac 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/MembersListItem.js +++ b/server/sonar-web/src/main/js/apps/organizations/components/MembersListItem.js @@ -31,7 +31,7 @@ type Props = { member: Member, organization: Organization, organizationGroups: Array<OrgGroup>, - removeMember: (Member) => void, + removeMember: Member => void, updateMemberGroups: (member: Member, add: Array<string>, remove: Array<string>) => void }; diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js index 9e8af35cf0f..be7b726a7f4 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.js @@ -34,9 +34,9 @@ class OrganizationDelete extends React.PureComponent { name: string }, router: { - replace: (string) => void + replace: string => void }, - deleteOrganization: (string) => Promise<*> + deleteOrganization: string => Promise<*> }; state = { diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js index 2175d7dbc6a..7955b3c82fd 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.js @@ -38,7 +38,7 @@ class OrganizationPage extends React.PureComponent { location: Object, organization: null | Organization, params: { organizationKey: string }, - fetchOrganization: (string) => Promise<*> + fetchOrganization: string => Promise<*> }; state = { diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js index 3c0494351c2..d00979a8431 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.js @@ -131,11 +131,13 @@ export default class OrganizationNavigation extends React.PureComponent { render() { const { organization, location } = this.props; - const isHomeActive = location.pathname === `organizations/${organization.key}/projects` || + const isHomeActive = + location.pathname === `organizations/${organization.key}/projects` || location.pathname === `organizations/${organization.key}/projects/favorite`; const adminActive = ADMIN_PATHS.some(path => - location.pathname.endsWith(`organizations/${organization.key}/${path}`)); + location.pathname.endsWith(`organizations/${organization.key}/${path}`) + ); const moreActive = !adminActive && location.pathname.includes('/extension/'); diff --git a/server/sonar-web/src/main/js/apps/overview/actions.js b/server/sonar-web/src/main/js/apps/overview/actions.js index 24e403ebb4e..892cea5e498 100644 --- a/server/sonar-web/src/main/js/apps/overview/actions.js +++ b/server/sonar-web/src/main/js/apps/overview/actions.js @@ -24,11 +24,10 @@ import { onFail } from '../../store/rootActions'; const PAGE_SIZE = 5; -export const fetchRecentProjectActivity = (project: string) => - (dispatch: Function) => - api - .getProjectActivity(project, { pageSize: PAGE_SIZE }) - .then( - ({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), - onFail(dispatch) - ); +export const fetchRecentProjectActivity = (project: string) => (dispatch: Function) => + api + .getProjectActivity(project, { pageSize: PAGE_SIZE }) + .then( + ({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), + onFail(dispatch) + ); diff --git a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js index 9075797656f..517678a906f 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js +++ b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js @@ -95,7 +95,8 @@ export default class OverviewApp extends React.PureComponent { componentDidUpdate(prevProps) { if (this.props.component.key !== prevProps.component.key) { this.loadMeasures(this.props.component.key).then(() => - this.loadHistory(this.props.component)); + this.loadHistory(this.props.component) + ); } } diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js index 5ee7797c2b2..a6e95459670 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js @@ -52,7 +52,8 @@ class MetaQualityProfiles extends React.PureComponent { loadDeprecatedRules() { const requests = this.props.profiles.map(profile => - this.loadDeprecatedRulesForProfile(profile.key)); + this.loadDeprecatedRulesForProfile(profile.key) + ); Promise.all(requests).then(responses => { if (this.mounted) { const deprecatedByKey = {}; diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.js b/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.js index 6b2509eab90..6ae8f29baa7 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.js +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaTags.js @@ -103,15 +103,15 @@ export default class MetaTags extends React.PureComponent { if (this.canUpdateTags()) { return ( - <div className="overview-meta-card overview-meta-tags" ref={card => this.card = card}> + <div className="overview-meta-card overview-meta-tags" ref={card => (this.card = card)}> <button className="button-link" onClick={this.handleClick} - ref={tagsList => this.tagsList = tagsList}> + ref={tagsList => (this.tagsList = tagsList)}> <TagsList tags={tags.length ? tags : [translate('no_tags')]} allowUpdate={true} /> </button> {popupOpen && - <div ref={tagsSelector => this.tagsSelector = tagsSelector}> + <div ref={tagsSelector => (this.tagsSelector = tagsSelector)}> <ProjectTagsSelectorContainer position={popupPosition} project={key} diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js index eba9b2a268f..60be2bd664a 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.js @@ -50,7 +50,8 @@ export default class QualityGateConditions extends React.PureComponent { componentDidUpdate(prevProps) { if ( - prevProps.conditions !== this.props.conditions || prevProps.component !== this.props.component + prevProps.conditions !== this.props.conditions || + prevProps.component !== this.props.component ) { this.loadFailedMeasures(); } diff --git a/server/sonar-web/src/main/js/apps/overview/routes.js b/server/sonar-web/src/main/js/apps/overview/routes.js index 755ec975fd6..7af0479bb25 100644 --- a/server/sonar-web/src/main/js/apps/overview/routes.js +++ b/server/sonar-web/src/main/js/apps/overview/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/AppContainer').default })); + callback(null, { component: require('./components/AppContainer').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.js b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.js index 5b837056713..782bb4129c3 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.js @@ -124,7 +124,8 @@ export default class ActionsCell extends React.PureComponent { this.renderSetDefaultLink( qualifier, <span>{translate('permission_templates.set_default')}</span> - )); + ) + ); } renderIfMultipleTopQualifiers(availableQualifiers) { @@ -138,7 +139,8 @@ export default class ActionsCell extends React.PureComponent { {' '} {translate('qualifiers', qualifier)} </span> - )); + ) + ); } render() { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js index e9a566c8af7..90f68390c3d 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js @@ -153,11 +153,11 @@ class Template extends React.PureComponent { const isFiltered = store.filter !== 'all'; - const matchQuery = !store.query || - CREATOR_NAME.toLocaleLowerCase().includes(store.query.toLowerCase()); + const matchQuery = + !store.query || CREATOR_NAME.toLocaleLowerCase().includes(store.query.toLowerCase()); - const matchPermission = store.selectedPermission == null || - creatorPermissions.includes(store.selectedPermission); + const matchPermission = + store.selectedPermission == null || creatorPermissions.includes(store.selectedPermission); return !isFiltered && matchQuery && matchPermission; } diff --git a/server/sonar-web/src/main/js/apps/permission-templates/views/GroupsView.js b/server/sonar-web/src/main/js/apps/permission-templates/views/GroupsView.js index 94b35091d54..8c91e8784a7 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/views/GroupsView.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/views/GroupsView.js @@ -22,8 +22,10 @@ import Template from '../templates/permission-templates-groups.hbs'; import '../../../components/SelectList'; function getSearchUrl(permission, permissionTemplate) { - return `${window.baseUrl}/api/permissions/template_groups?` + - `ps=100&permission=${permission.key}&templateId=${permissionTemplate.id}`; + return ( + `${window.baseUrl}/api/permissions/template_groups?` + + `ps=100&permission=${permission.key}&templateId=${permissionTemplate.id}` + ); } export default Modal.extend({ diff --git a/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js b/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js index 24674f744a7..6dde7ba5d71 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/views/UsersView.js @@ -53,7 +53,8 @@ export default Modal.extend({ onRender() { Modal.prototype.onRender.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); - const searchUrl = window.baseUrl + + const searchUrl = + window.baseUrl + '/api/permissions/template_users?ps=100&permission=' + this.options.permission.key + '&templateId=' + diff --git a/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js index 64c80c2b924..19a153e8b4c 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js @@ -38,121 +38,125 @@ import { getPermissionsAppSelectedPermission } from '../../../../store/rootReducer'; -type Dispatch = (Object) => void; +type Dispatch = Object => void; type GetState = () => Object; -export const loadHolders = (organization?: string) => - (dispatch: Dispatch, getState: GetState) => { - const query = getPermissionsAppQuery(getState()); - const filter = getPermissionsAppFilter(getState()); - const selectedPermission = getPermissionsAppSelectedPermission(getState()); +export const loadHolders = (organization?: string) => (dispatch: Dispatch, getState: GetState) => { + const query = getPermissionsAppQuery(getState()); + const filter = getPermissionsAppFilter(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); - dispatch({ type: REQUEST_HOLDERS, query }); + dispatch({ type: REQUEST_HOLDERS, query }); - const requests = []; + const requests = []; - if (filter !== 'groups') { - requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'groups') { + requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); + } else { + requests.push(Promise.resolve([])); + } - if (filter !== 'users') { - requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'users') { + requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); + } else { + requests.push(Promise.resolve([])); + } - return Promise.all(requests) - .then(responses => - dispatch({ - type: RECEIVE_HOLDERS_SUCCESS, - users: responses[0], - groups: responses[1], - query - })) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; - -export const updateQuery = (query: string = '', organization?: string) => - (dispatch: Dispatch) => { - dispatch({ type: UPDATE_QUERY, query }); - if (query.length === 0 || query.length > 2) { - dispatch(loadHolders(organization)); - } - }; + return Promise.all(requests) + .then(responses => + dispatch({ + type: RECEIVE_HOLDERS_SUCCESS, + users: responses[0], + groups: responses[1], + query + }) + ) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; -export const updateFilter = (filter: string, organization?: string) => - (dispatch: Dispatch) => { - dispatch({ type: UPDATE_FILTER, filter }); +export const updateQuery = (query: string = '', organization?: string) => (dispatch: Dispatch) => { + dispatch({ type: UPDATE_QUERY, query }); + if (query.length === 0 || query.length > 2) { dispatch(loadHolders(organization)); - }; + } +}; -export const selectPermission = (permission: string, organization?: string) => - (dispatch: Dispatch, getState: GetState) => { - const selectedPermission = getPermissionsAppSelectedPermission(getState()); - if (selectedPermission !== permission) { - dispatch({ type: SELECT_PERMISSION, permission }); - } else { - dispatch({ type: SELECT_PERMISSION, permission: null }); - } - dispatch(loadHolders(organization)); - }; +export const updateFilter = (filter: string, organization?: string) => (dispatch: Dispatch) => { + dispatch({ type: UPDATE_FILTER, filter }); + dispatch(loadHolders(organization)); +}; -export const grantToUser = (login: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .grantPermissionToUser(null, login, permission, organization) - .then(() => { - dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; +export const selectPermission = (permission: string, organization?: string) => ( + dispatch: Dispatch, + getState: GetState +) => { + const selectedPermission = getPermissionsAppSelectedPermission(getState()); + if (selectedPermission !== permission) { + dispatch({ type: SELECT_PERMISSION, permission }); + } else { + dispatch({ type: SELECT_PERMISSION, permission: null }); + } + dispatch(loadHolders(organization)); +}; -export const revokeFromUser = (login: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .revokePermissionFromUser(null, login, permission, organization) - .then(() => { - dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; +export const grantToUser = (login: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .grantPermissionToUser(null, login, permission, organization) + .then(() => { + dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; -export const grantToGroup = (groupName: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .grantPermissionToGroup(null, groupName, permission, organization) - .then(() => { - dispatch({ - type: GRANT_PERMISSION_TO_GROUP, - groupName, - permission - }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); +export const revokeFromUser = (login: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .revokePermissionFromUser(null, login, permission, organization) + .then(() => { + dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; + +export const grantToGroup = (groupName: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .grantPermissionToGroup(null, groupName, permission, organization) + .then(() => { + dispatch({ + type: GRANT_PERMISSION_TO_GROUP, + groupName, + permission }); - }; + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; -export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .revokePermissionFromGroup(null, groupName, permission, organization) - .then(() => { - dispatch({ - type: REVOKE_PERMISSION_FROM_GROUP, - groupName, - permission - }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); +export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .revokePermissionFromGroup(null, groupName, permission, organization) + .then(() => { + dispatch({ + type: REVOKE_PERMISSION_FROM_GROUP, + groupName, + permission }); - }; + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js index 36ce09f2218..2615d72517a 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js @@ -51,8 +51,8 @@ class PageHeader extends React.PureComponent { render() { const configuration = this.props.project.configuration; - const canApplyPermissionTemplate = configuration != null && - configuration.canApplyPermissionTemplate; + const canApplyPermissionTemplate = + configuration != null && configuration.canApplyPermissionTemplate; const description = ['VW', 'SVW'].includes(this.props.project.qualifier) ? translate('roles.page.description_portfolio') diff --git a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js index 4536851bfa7..b29f3e4d481 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js @@ -38,145 +38,148 @@ import { getPermissionsAppSelectedPermission } from '../../../../store/rootReducer'; -type Dispatch = (Object) => void; +type Dispatch = Object => void; type GetState = () => Object; -export const loadHolders = (project: string, organization?: string) => - (dispatch: Dispatch, getState: GetState) => { - const query = getPermissionsAppQuery(getState()); - const filter = getPermissionsAppFilter(getState()); - const selectedPermission = getPermissionsAppSelectedPermission(getState()); +export const loadHolders = (project: string, organization?: string) => ( + dispatch: Dispatch, + getState: GetState +) => { + const query = getPermissionsAppQuery(getState()); + const filter = getPermissionsAppFilter(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); - dispatch({ type: REQUEST_HOLDERS, query }); + dispatch({ type: REQUEST_HOLDERS, query }); - const requests = []; + const requests = []; - if (filter !== 'groups') { - requests.push( - api.getPermissionsUsersForComponent(project, query, selectedPermission, organization) - ); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'groups') { + requests.push( + api.getPermissionsUsersForComponent(project, query, selectedPermission, organization) + ); + } else { + requests.push(Promise.resolve([])); + } - if (filter !== 'users') { - requests.push( - api.getPermissionsGroupsForComponent(project, query, selectedPermission, organization) - ); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'users') { + requests.push( + api.getPermissionsGroupsForComponent(project, query, selectedPermission, organization) + ); + } else { + requests.push(Promise.resolve([])); + } - return Promise.all(requests) - .then(responses => - dispatch({ - type: RECEIVE_HOLDERS_SUCCESS, - users: responses[0], - groups: responses[1], - query - })) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; - -export const updateQuery = (project: string, query: string, organization?: string) => - (dispatch: Dispatch) => { - dispatch({ type: UPDATE_QUERY, query }); - if (query.length === 0 || query.length > 2) { - dispatch(loadHolders(project, organization)); - } - }; + return Promise.all(requests) + .then(responses => + dispatch({ + type: RECEIVE_HOLDERS_SUCCESS, + users: responses[0], + groups: responses[1], + query + }) + ) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; -export const updateFilter = (project: string, filter: string, organization?: string) => - (dispatch: Dispatch) => { - dispatch({ type: UPDATE_FILTER, filter }); +export const updateQuery = (project: string, query: string, organization?: string) => ( + dispatch: Dispatch +) => { + dispatch({ type: UPDATE_QUERY, query }); + if (query.length === 0 || query.length > 2) { dispatch(loadHolders(project, organization)); - }; + } +}; -export const selectPermission = (project: string, permission: string, organization?: string) => - (dispatch: Dispatch, getState: GetState) => { - const selectedPermission = getPermissionsAppSelectedPermission(getState()); - if (selectedPermission !== permission) { - dispatch({ type: SELECT_PERMISSION, permission }); - } else { - dispatch({ type: SELECT_PERMISSION, permission: null }); - } - dispatch(loadHolders(project, organization)); - }; +export const updateFilter = (project: string, filter: string, organization?: string) => ( + dispatch: Dispatch +) => { + dispatch({ type: UPDATE_FILTER, filter }); + dispatch(loadHolders(project, organization)); +}; + +export const selectPermission = (project: string, permission: string, organization?: string) => ( + dispatch: Dispatch, + getState: GetState +) => { + const selectedPermission = getPermissionsAppSelectedPermission(getState()); + if (selectedPermission !== permission) { + dispatch({ type: SELECT_PERMISSION, permission }); + } else { + dispatch({ type: SELECT_PERMISSION, permission: null }); + } + dispatch(loadHolders(project, organization)); +}; export const grantToUser = ( project: string, login: string, permission: string, organization?: string -) => - (dispatch: Dispatch) => { - api - .grantPermissionToUser(project, login, permission, organization) - .then(() => { - dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; +) => (dispatch: Dispatch) => { + api + .grantPermissionToUser(project, login, permission, organization) + .then(() => { + dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; export const revokeFromUser = ( project: string, login: string, permission: string, organization?: string -) => - (dispatch: Dispatch) => { - api - .revokePermissionFromUser(project, login, permission, organization) - .then(() => { - dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; +) => (dispatch: Dispatch) => { + api + .revokePermissionFromUser(project, login, permission, organization) + .then(() => { + dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; export const grantToGroup = ( project: string, groupName: string, permission: string, organization?: string -) => - (dispatch: Dispatch) => { - api - .grantPermissionToGroup(project, groupName, permission, organization) - .then(() => { - dispatch({ - type: GRANT_PERMISSION_TO_GROUP, - groupName, - permission - }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); +) => (dispatch: Dispatch) => { + api + .grantPermissionToGroup(project, groupName, permission, organization) + .then(() => { + dispatch({ + type: GRANT_PERMISSION_TO_GROUP, + groupName, + permission }); - }; + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; export const revokeFromGroup = ( project: string, groupName: string, permission: string, organization?: string -) => - (dispatch: Dispatch) => { - api - .revokePermissionFromGroup(project, groupName, permission, organization) - .then(() => { - dispatch({ - type: REVOKE_PERMISSION_FROM_GROUP, - groupName, - permission - }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); +) => (dispatch: Dispatch) => { + api + .revokePermissionFromGroup(project, groupName, permission, organization) + .then(() => { + dispatch({ + type: REVOKE_PERMISSION_FROM_GROUP, + groupName, + permission }); - }; + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; diff --git a/server/sonar-web/src/main/js/apps/permissions/routes.js b/server/sonar-web/src/main/js/apps/permissions/routes.js index 00de5223f65..d96aaf4ed2f 100644 --- a/server/sonar-web/src/main/js/apps/permissions/routes.js +++ b/server/sonar-web/src/main/js/apps/permissions/routes.js @@ -34,7 +34,8 @@ export const projectPermissionsRoutes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./project/components/App').default })); + callback(null, { component: require('./project/components/App').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/utils.js b/server/sonar-web/src/main/js/apps/project-admin/key/utils.js index bc5f8221bcd..e2761221054 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/utils.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/utils.js @@ -18,10 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ export const reloadUpdateKeyPage = componentKey => { - setTimeout( - () => { - window.location = window.baseUrl + '/project/key?id=' + encodeURIComponent(componentKey); - }, - 3000 - ); + setTimeout(() => { + window.location = window.baseUrl + '/project/key?id=' + encodeURIComponent(componentKey); + }, 3000); }; diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/actions.js b/server/sonar-web/src/main/js/apps/project-admin/store/actions.js index d3f66e9af6c..8fa84ac1d97 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/store/actions.js +++ b/server/sonar-web/src/main/js/apps/project-admin/store/actions.js @@ -47,19 +47,18 @@ export const receiveProjectProfiles = (projectKey, profiles) => ({ profiles }); -export const fetchProjectProfiles = (projectKey, organization) => - dispatch => { - Promise.all([ - organization ? getQualityProfiles({ organization }) : getQualityProfiles(), - organization - ? getQualityProfiles({ organization, projectKey }) - : getQualityProfiles({ projectKey }) - ]).then(responses => { - const [allProfiles, projectProfiles] = responses; - dispatch(receiveProfiles(allProfiles)); - dispatch(receiveProjectProfiles(projectKey, projectProfiles)); - }); - }; +export const fetchProjectProfiles = (projectKey, organization) => dispatch => { + Promise.all([ + organization ? getQualityProfiles({ organization }) : getQualityProfiles(), + organization + ? getQualityProfiles({ organization, projectKey }) + : getQualityProfiles({ projectKey }) + ]).then(responses => { + const [allProfiles, projectProfiles] = responses; + dispatch(receiveProfiles(allProfiles)); + dispatch(receiveProjectProfiles(projectKey, projectProfiles)); + }); +}; export const SET_PROJECT_PROFILE = 'projectAdmin/SET_PROJECT_PROFILE'; const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ @@ -69,26 +68,25 @@ const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ newProfileKey }); -export const setProjectProfile = (projectKey, oldKey, newKey) => - (dispatch, getState) => { - const state = getState(); - const newProfile = getProjectAdminProfileByKey(state, newKey); - const request = newProfile.isDefault - ? dissociateProject(oldKey, projectKey) - : associateProject(newKey, projectKey); - - request.then(() => { - dispatch(setProjectProfileAction(projectKey, oldKey, newKey)); - dispatch( - addGlobalSuccessMessage( - translateWithParameters( - 'project_quality_profile.successfully_updated', - newProfile.languageName - ) +export const setProjectProfile = (projectKey, oldKey, newKey) => (dispatch, getState) => { + const state = getState(); + const newProfile = getProjectAdminProfileByKey(state, newKey); + const request = newProfile.isDefault + ? dissociateProject(oldKey, projectKey) + : associateProject(newKey, projectKey); + + request.then(() => { + dispatch(setProjectProfileAction(projectKey, oldKey, newKey)); + dispatch( + addGlobalSuccessMessage( + translateWithParameters( + 'project_quality_profile.successfully_updated', + newProfile.languageName ) - ); - }); - }; + ) + ); + }); +}; export const RECEIVE_GATES = 'projectAdmin/RECEIVE_GATES'; export const receiveGates = gates => ({ @@ -103,14 +101,13 @@ export const receiveProjectGate = (projectKey, gate) => ({ gate }); -export const fetchProjectGate = projectKey => - dispatch => { - Promise.all([fetchQualityGates(), getGateForProject(projectKey)]).then(responses => { - const [allGates, projectGate] = responses; - dispatch(receiveGates(allGates)); - dispatch(receiveProjectGate(projectKey, projectGate)); - }); - }; +export const fetchProjectGate = projectKey => dispatch => { + Promise.all([fetchQualityGates(), getGateForProject(projectKey)]).then(responses => { + const [allGates, projectGate] = responses; + dispatch(receiveGates(allGates)); + dispatch(receiveProjectGate(projectKey, projectGate)); + }); +}; export const SET_PROJECT_GATE = 'projectAdmin/SET_PROJECT_GATE'; const setProjectGateAction = (projectKey, gateId) => ({ @@ -119,17 +116,16 @@ const setProjectGateAction = (projectKey, gateId) => ({ gateId }); -export const setProjectGate = (projectKey, oldId, newId) => - dispatch => { - const request = newId != null - ? associateGateWithProject(newId, projectKey) - : dissociateGateWithProject(oldId, projectKey); +export const setProjectGate = (projectKey, oldId, newId) => dispatch => { + const request = newId != null + ? associateGateWithProject(newId, projectKey) + : dissociateGateWithProject(oldId, projectKey); - request.then(() => { - dispatch(setProjectGateAction(projectKey, newId)); - dispatch(addGlobalSuccessMessage(translate('project_quality_gate.successfully_updated'))); - }); - }; + request.then(() => { + dispatch(setProjectGateAction(projectKey, newId)); + dispatch(addGlobalSuccessMessage(translate('project_quality_gate.successfully_updated'))); + }); +}; export const RECEIVE_PROJECT_LINKS = 'projectAdmin/RECEIVE_PROJECT_LINKS'; export const receiveProjectLinks = (projectKey, links) => ({ @@ -138,12 +134,11 @@ export const receiveProjectLinks = (projectKey, links) => ({ links }); -export const fetchProjectLinks = projectKey => - dispatch => { - getProjectLinks(projectKey).then(links => { - dispatch(receiveProjectLinks(projectKey, links)); - }); - }; +export const fetchProjectLinks = projectKey => dispatch => { + getProjectLinks(projectKey).then(links => { + dispatch(receiveProjectLinks(projectKey, links)); + }); +}; export const ADD_PROJECT_LINK = 'projectAdmin/ADD_PROJECT_LINK'; const addProjectLink = (projectKey, link) => ({ @@ -152,12 +147,11 @@ const addProjectLink = (projectKey, link) => ({ link }); -export const createProjectLink = (projectKey, name, url) => - dispatch => { - return createLink(projectKey, name, url).then(link => { - dispatch(addProjectLink(projectKey, link)); - }); - }; +export const createProjectLink = (projectKey, name, url) => dispatch => { + return createLink(projectKey, name, url).then(link => { + dispatch(addProjectLink(projectKey, link)); + }); +}; export const DELETE_PROJECT_LINK = 'projectAdmin/DELETE_PROJECT_LINK'; export const deleteProjectLink = (projectKey, linkId) => ({ @@ -173,13 +167,12 @@ const receiveProjectModules = (projectKey, modules) => ({ modules }); -export const fetchProjectModules = projectKey => - dispatch => { - const options = { qualifiers: 'BRC', s: 'name', ps: 500 }; - getTree(projectKey, options).then(r => { - dispatch(receiveProjectModules(projectKey, r.components)); - }); - }; +export const fetchProjectModules = projectKey => dispatch => { + const options = { qualifiers: 'BRC', s: 'name', ps: 500 }; + getTree(projectKey, options).then(r => { + dispatch(receiveProjectModules(projectKey, r.components)); + }); +}; export const CHANGE_KEY = 'projectAdmin/CHANGE_KEY'; const changeKeyAction = (key, newKey) => ({ @@ -188,7 +181,6 @@ const changeKeyAction = (key, newKey) => ({ newKey }); -export const changeKey = (key, newKey) => - dispatch => { - return changeKeyApi(key, newKey).then(() => dispatch(changeKeyAction(key, newKey))); - }; +export const changeKey = (key, newKey) => dispatch => { + return changeKeyApi(key, newKey).then(() => dispatch(changeKeyAction(key, newKey))); +}; diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js b/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js index fabf41003ec..4eb6dec8e0e 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js +++ b/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js @@ -50,7 +50,8 @@ export const getAllProfiles = state => nextGetAllProfiles(state.profiles); export const getProjectProfiles = (state, projectKey) => getProfiles(state.profilesByProject, projectKey).map(profileKey => - getProfileByKey(state, profileKey)); + getProfileByKey(state, profileKey) + ); export const getGateById = (state, gateId) => getGate(state.gates, gateId); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/actions.js b/server/sonar-web/src/main/js/apps/projectActivity/actions.js index 8b1851e6959..60a2dbcb480 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/actions.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/actions.js @@ -30,67 +30,69 @@ import { import { onFail } from '../../store/rootActions'; import { getProjectActivity } from '../../store/rootReducer'; -const rejectOnFail = (dispatch: Function) => - (error: Object) => { - onFail(dispatch)(error); - return Promise.reject(); - }; +const rejectOnFail = (dispatch: Function) => (error: Object) => { + onFail(dispatch)(error); + return Promise.reject(); +}; -export const fetchProjectActivity = (project: string, filter: ?string) => - (dispatch: Function): void => { - api - .getProjectActivity(project, { category: filter }) - .then( - ({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), - onFail(dispatch) - ); - }; +export const fetchProjectActivity = (project: string, filter: ?string) => ( + dispatch: Function +): void => { + api + .getProjectActivity(project, { category: filter }) + .then( + ({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), + onFail(dispatch) + ); +}; -export const fetchMoreProjectActivity = (project: string, filter: ?string) => - (dispatch: Function, getState: Function): void => { - const projectActivity = getProjectActivity(getState()); - const { pageIndex } = getPaging(projectActivity, project); +export const fetchMoreProjectActivity = (project: string, filter: ?string) => ( + dispatch: Function, + getState: Function +): void => { + const projectActivity = getProjectActivity(getState()); + const { pageIndex } = getPaging(projectActivity, project); - api - .getProjectActivity(project, { category: filter, pageIndex: pageIndex + 1 }) - .then( - ({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), - onFail(dispatch) - ); - }; + api + .getProjectActivity(project, { category: filter, pageIndex: pageIndex + 1 }) + .then( + ({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), + onFail(dispatch) + ); +}; -export const addCustomEvent = (analysis: string, name: string, category?: string) => - (dispatch: Function): Promise<*> => { - return api - .createEvent(analysis, name, category) - .then( - ({ analysis, ...event }) => dispatch(addEvent(analysis, event)), - rejectOnFail(dispatch) - ); - }; +export const addCustomEvent = (analysis: string, name: string, category?: string) => ( + dispatch: Function +): Promise<*> => { + return api + .createEvent(analysis, name, category) + .then(({ analysis, ...event }) => dispatch(addEvent(analysis, event)), rejectOnFail(dispatch)); +}; -export const deleteEvent = (analysis: string, event: string) => - (dispatch: Function): Promise<*> => { - return api - .deleteEvent(event) - .then(() => dispatch(deleteEventAction(analysis, event)), rejectOnFail(dispatch)); - }; +export const deleteEvent = (analysis: string, event: string) => ( + dispatch: Function +): Promise<*> => { + return api + .deleteEvent(event) + .then(() => dispatch(deleteEventAction(analysis, event)), rejectOnFail(dispatch)); +}; -export const addVersion = (analysis: string, version: string) => - (dispatch: Function): Promise<*> => { - return dispatch(addCustomEvent(analysis, version, 'VERSION')); - }; +export const addVersion = (analysis: string, version: string) => ( + dispatch: Function +): Promise<*> => { + return dispatch(addCustomEvent(analysis, version, 'VERSION')); +}; -export const changeEvent = (event: string, name: string) => - (dispatch: Function): Promise<*> => { - return api - .changeEvent(event, name) - .then(() => dispatch(changeEventAction(event, { name })), rejectOnFail(dispatch)); - }; +export const changeEvent = (event: string, name: string) => (dispatch: Function): Promise<*> => { + return api + .changeEvent(event, name) + .then(() => dispatch(changeEventAction(event, { name })), rejectOnFail(dispatch)); +}; -export const deleteAnalysis = (project: string, analysis: string) => - (dispatch: Function): Promise<*> => { - return api - .deleteAnalysis(analysis) - .then(() => dispatch(deleteAnalysisAction(project, analysis)), rejectOnFail(dispatch)); - }; +export const deleteAnalysis = (project: string, analysis: string) => ( + dispatch: Function +): Promise<*> => { + return api + .deleteAnalysis(analysis) + .then(() => dispatch(deleteAnalysisAction(project, analysis)), rejectOnFail(dispatch)); +}; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js index 1902f12fc68..6697449dc5d 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js @@ -78,8 +78,8 @@ export default class Event extends React.PureComponent { render() { const { event, canAdmin } = this.props; const canChange = ['OTHER', 'VERSION'].includes(event.category); - const canDelete = event.category === 'OTHER' || - (event.category === 'VERSION' && !this.props.isFirst); + const canDelete = + event.category === 'OTHER' || (event.category === 'VERSION' && !this.props.isFirst); const showActions = canAdmin && (canChange || canDelete); return ( diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js index 6779c389924..36a931422a5 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js @@ -34,7 +34,7 @@ export default function Events(props: Props) { const sortedEvents: Array<EventType> = sortBy( props.events, // versions first - (event: EventType) => event.category === 'VERSION' ? 0 : 1, + (event: EventType) => (event.category === 'VERSION' ? 0 : 1), // then the rest sorted by category 'category' ); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/routes.js b/server/sonar-web/src/main/js/apps/projectActivity/routes.js index 3b2ed907d49..3c5a57d10ec 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/routes.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/ProjectActivityApp').default })); + callback(null, { component: require('./components/ProjectActivityApp').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/projects-admin/search.js b/server/sonar-web/src/main/js/apps/projects-admin/search.js index c4b8c62c34e..2e7d3def391 100644 --- a/server/sonar-web/src/main/js/apps/projects-admin/search.js +++ b/server/sonar-web/src/main/js/apps/projects-admin/search.js @@ -70,9 +70,10 @@ export default class Search extends React.PureComponent { }; renderCheckbox = () => { - const isAllChecked = this.props.projects.length > 0 && - this.props.selection.length === this.props.projects.length; - const thirdState = this.props.projects.length > 0 && + const isAllChecked = + this.props.projects.length > 0 && this.props.selection.length === this.props.projects.length; + const thirdState = + this.props.projects.length > 0 && this.props.selection.length > 0 && this.props.selection.length < this.props.projects.length; const checked = isAllChecked || thirdState; diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js index 61a9bba24ab..67bc0accfff 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js @@ -24,7 +24,7 @@ import { translate } from '../../../helpers/l10n'; type Props = { loading: boolean, - onViewChange: (string) => void, + onViewChange: string => void, total?: number, view: string }; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.js index 34666b11fad..018b753affc 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.js @@ -53,7 +53,8 @@ export default class ProjectCard extends React.PureComponent { const isProjectAnalyzed = project.analysisDate != null; // check reliability_rating because only some measures can be loaded // if coming from visualizations tab - const areProjectMeasuresLoaded = !isProjectAnalyzed || + const areProjectMeasuresLoaded = + !isProjectAnalyzed || (this.props.measures != null && this.props.measures['reliability_rating'] != null && this.props.measures['sqale_rating'] != null); diff --git a/server/sonar-web/src/main/js/apps/projects/components/ViewSelect.js b/server/sonar-web/src/main/js/apps/projects/components/ViewSelect.js index c672a377f9e..429b88e2a9f 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ViewSelect.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ViewSelect.js @@ -24,7 +24,7 @@ import { translate } from '../../../helpers/l10n'; export default class ViewSelect extends React.PureComponent { props: { - onChange: (string) => void, + onChange: string => void, view: string }; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js index 28f508b25fa..1f8677e3ee7 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js @@ -57,9 +57,9 @@ export default class Filter extends React.PureComponent { } highlightUnder(option) { - return this.props.highlightUnder != null && - option !== null && - option > this.props.highlightUnder; + return ( + this.props.highlightUnder != null && option !== null && option > this.props.highlightUnder + ); } getPath(option) { diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js index b9292ab1874..0a13f40b228 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js @@ -28,8 +28,8 @@ type Props = { query: {}, options: [{ label: string, value: string }], router: { push: ({ pathname: string, query?: {} }) => void }, - onInputChange?: (string) => void, - onOpen?: (void) => void, + onInputChange?: string => void, + onOpen?: void => void, isLoading?: boolean, isFavorite?: boolean, organization?: {} diff --git a/server/sonar-web/src/main/js/apps/projects/routes.js b/server/sonar-web/src/main/js/apps/projects/routes.js index 8eccdcd0ccc..e2307b12175 100644 --- a/server/sonar-web/src/main/js/apps/projects/routes.js +++ b/server/sonar-web/src/main/js/apps/projects/routes.js @@ -28,7 +28,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/DefaultPageSelector').default })); + callback(null, { component: require('./components/DefaultPageSelector').default }) + ); } }, { @@ -42,7 +43,8 @@ const routes = [ path: 'favorite', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./components/FavoriteProjectsContainer').default)); + callback(null, require('./components/FavoriteProjectsContainer').default) + ); } } ] diff --git a/server/sonar-web/src/main/js/apps/projects/store/actions.js b/server/sonar-web/src/main/js/apps/projects/store/actions.js index b57ce5dda28..48ec5a6d1a7 100644 --- a/server/sonar-web/src/main/js/apps/projects/store/actions.js +++ b/server/sonar-web/src/main/js/apps/projects/store/actions.js @@ -68,37 +68,34 @@ const FACETS = [ 'tags' ]; -const onFail = dispatch => - error => { - parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); - dispatch(updateState({ loading: false })); - }; +const onFail = dispatch => error => { + parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); + dispatch(updateState({ loading: false })); +}; -const onReceiveMeasures = (dispatch, expectedProjectKeys) => - response => { - const byComponentKey = groupBy(response.measures, 'component'); +const onReceiveMeasures = (dispatch, expectedProjectKeys) => response => { + const byComponentKey = groupBy(response.measures, 'component'); - const toStore = {}; + const toStore = {}; - // fill store with empty objects for expected projects - // this is required to not have "null"s for provisioned projects - expectedProjectKeys.forEach(projectKey => toStore[projectKey] = {}); + // fill store with empty objects for expected projects + // this is required to not have "null"s for provisioned projects + expectedProjectKeys.forEach(projectKey => (toStore[projectKey] = {})); - Object.keys(byComponentKey).forEach(componentKey => { - const measures = {}; - byComponentKey[componentKey].forEach(measure => { - measures[measure.metric] = measure.value; - }); - toStore[componentKey] = measures; + Object.keys(byComponentKey).forEach(componentKey => { + const measures = {}; + byComponentKey[componentKey].forEach(measure => { + measures[measure.metric] = measure.value; }); + toStore[componentKey] = measures; + }); - dispatch(receiveComponentsMeasures(toStore)); - }; + dispatch(receiveComponentsMeasures(toStore)); +}; -const onReceiveOrganizations = dispatch => - response => { - dispatch(receiveOrganizations(response.organizations)); - }; +const onReceiveOrganizations = dispatch => response => { + dispatch(receiveOrganizations(response.organizations)); +}; const defineMetrics = query => { if (query.view === 'visualizations') { @@ -108,32 +105,30 @@ const defineMetrics = query => { } }; -const fetchProjectMeasures = (projects, query) => - dispatch => { - if (!projects.length) { - return Promise.resolve(); - } - - const projectKeys = projects.map(project => project.key); - const metrics = defineMetrics(query); - return getMeasuresForProjects(projectKeys, metrics).then( - onReceiveMeasures(dispatch, projectKeys), - onFail(dispatch) - ); - }; - -const fetchProjectOrganizations = projects => - dispatch => { - if (!projects.length) { - return Promise.resolve(); - } - - const organizationKeys = uniq(projects.map(project => project.organization)); - return getOrganizations(organizationKeys).then( - onReceiveOrganizations(dispatch), - onFail(dispatch) - ); - }; +const fetchProjectMeasures = (projects, query) => dispatch => { + if (!projects.length) { + return Promise.resolve(); + } + + const projectKeys = projects.map(project => project.key); + const metrics = defineMetrics(query); + return getMeasuresForProjects(projectKeys, metrics).then( + onReceiveMeasures(dispatch, projectKeys), + onFail(dispatch) + ); +}; + +const fetchProjectOrganizations = projects => dispatch => { + if (!projects.length) { + return Promise.resolve(); + } + + const organizationKeys = uniq(projects.map(project => project.organization)); + return getOrganizations(organizationKeys).then( + onReceiveOrganizations(dispatch), + onFail(dispatch) + ); +}; const handleFavorites = (dispatch, projects) => { const toAdd = projects.filter(project => project.isFavorite); @@ -143,70 +138,65 @@ const handleFavorites = (dispatch, projects) => { } }; -const onReceiveProjects = (dispatch, query) => - response => { - dispatch(receiveComponents(response.components)); - dispatch(receiveProjects(response.components, response.facets)); - handleFavorites(dispatch, response.components); - Promise.all([ - dispatch(fetchProjectMeasures(response.components, query)), - dispatch(fetchProjectOrganizations(response.components)) - ]).then(() => { - dispatch(updateState({ loading: false })); - }); - dispatch( - updateState({ - total: response.paging.total, - pageIndex: response.paging.pageIndex - }) - ); - }; - -const onReceiveMoreProjects = (dispatch, query) => - response => { - dispatch(receiveComponents(response.components)); - dispatch(receiveMoreProjects(response.components)); - handleFavorites(dispatch, response.components); - Promise.all([ - dispatch(fetchProjectMeasures(response.components, query)), - dispatch(fetchProjectOrganizations(response.components)) - ]).then(() => { - dispatch(updateState({ loading: false })); - }); - dispatch(updateState({ pageIndex: response.paging.pageIndex })); - }; - -export const fetchProjects = (query, isFavorite, organization) => - dispatch => { - dispatch(updateState({ loading: true })); - const ps = query.view === 'visualizations' ? PAGE_SIZE_VISUALIZATIONS : PAGE_SIZE; - const data = convertToQueryData(query, isFavorite, organization, { - ps, - facets: FACETS.join(), - f: 'analysisDate' - }); - return searchProjects(data).then(onReceiveProjects(dispatch, query), onFail(dispatch)); - }; - -export const fetchMoreProjects = (query, isFavorite, organization) => - (dispatch, getState) => { - dispatch(updateState({ loading: true })); - const state = getState(); - const { pageIndex } = getProjectsAppState(state); - const data = convertToQueryData(query, isFavorite, organization, { - ps: PAGE_SIZE, - p: pageIndex + 1, - f: 'analysisDate' - }); - return searchProjects(data).then(onReceiveMoreProjects(dispatch, query), onFail(dispatch)); - }; - -export const setProjectTags = (project, tags) => - (dispatch, getState) => { - const previousTags = getComponent(getState(), project).tags; - dispatch(receiveProjectTags(project, tags)); - return apiSetProjectTags({ project, tags: tags.join(',') }).then(null, error => { - dispatch(receiveProjectTags(project, previousTags)); - onFail(dispatch)(error); - }); - }; +const onReceiveProjects = (dispatch, query) => response => { + dispatch(receiveComponents(response.components)); + dispatch(receiveProjects(response.components, response.facets)); + handleFavorites(dispatch, response.components); + Promise.all([ + dispatch(fetchProjectMeasures(response.components, query)), + dispatch(fetchProjectOrganizations(response.components)) + ]).then(() => { + dispatch(updateState({ loading: false })); + }); + dispatch( + updateState({ + total: response.paging.total, + pageIndex: response.paging.pageIndex + }) + ); +}; + +const onReceiveMoreProjects = (dispatch, query) => response => { + dispatch(receiveComponents(response.components)); + dispatch(receiveMoreProjects(response.components)); + handleFavorites(dispatch, response.components); + Promise.all([ + dispatch(fetchProjectMeasures(response.components, query)), + dispatch(fetchProjectOrganizations(response.components)) + ]).then(() => { + dispatch(updateState({ loading: false })); + }); + dispatch(updateState({ pageIndex: response.paging.pageIndex })); +}; + +export const fetchProjects = (query, isFavorite, organization) => dispatch => { + dispatch(updateState({ loading: true })); + const ps = query.view === 'visualizations' ? PAGE_SIZE_VISUALIZATIONS : PAGE_SIZE; + const data = convertToQueryData(query, isFavorite, organization, { + ps, + facets: FACETS.join(), + f: 'analysisDate' + }); + return searchProjects(data).then(onReceiveProjects(dispatch, query), onFail(dispatch)); +}; + +export const fetchMoreProjects = (query, isFavorite, organization) => (dispatch, getState) => { + dispatch(updateState({ loading: true })); + const state = getState(); + const { pageIndex } = getProjectsAppState(state); + const data = convertToQueryData(query, isFavorite, organization, { + ps: PAGE_SIZE, + p: pageIndex + 1, + f: 'analysisDate' + }); + return searchProjects(data).then(onReceiveMoreProjects(dispatch, query), onFail(dispatch)); +}; + +export const setProjectTags = (project, tags) => (dispatch, getState) => { + const previousTags = getComponent(getState(), project).tags; + dispatch(receiveProjectTags(project, tags)); + return apiSetProjectTags({ project, tags: tags.join(',') }).then(null, error => { + dispatch(receiveProjectTags(project, previousTags)); + onFail(dispatch)(error); + }); +}; diff --git a/server/sonar-web/src/main/js/apps/projects/store/utils.js b/server/sonar-web/src/main/js/apps/projects/store/utils.js index 18a20aad6cb..23424ee23ac 100644 --- a/server/sonar-web/src/main/js/apps/projects/store/utils.js +++ b/server/sonar-web/src/main/js/apps/projects/store/utils.js @@ -48,7 +48,7 @@ const getAsArray = (values, elementGetter) => { return values.split(',').map(elementGetter); }; -const getView = rawValue => rawValue === 'visualizations' ? rawValue : undefined; +const getView = rawValue => (rawValue === 'visualizations' ? rawValue : undefined); const getVisualization = value => { return VISUALIZATIONS.includes(value) ? value : null; diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js index 633aadb6ab9..4180c119b40 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js @@ -32,7 +32,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; export default class Visualizations extends React.PureComponent { props: { displayOrganizations: boolean, - onVisualizationChange: (string) => void, + onVisualizationChange: string => void, projects?: Array<*>, sort?: string, total?: number, diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/VisualizationsHeader.js b/server/sonar-web/src/main/js/apps/projects/visualizations/VisualizationsHeader.js index 4d17b60df31..4821c24fe6a 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/VisualizationsHeader.js +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/VisualizationsHeader.js @@ -25,7 +25,7 @@ import { VISUALIZATIONS } from '../utils'; export default class VisualizationsHeader extends React.PureComponent { props: { - onVisualizationChange: (string) => void, + onVisualizationChange: string => void, visualization: string }; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js index 0831488c196..55cf486fbbd 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js @@ -20,9 +20,14 @@ import React from 'react'; import { translate } from '../../../helpers/l10n'; -export default function DetailsHeader( - { qualityGate, edit, onRename, onCopy, onSetAsDefault, onDelete } -) { +export default function DetailsHeader({ + qualityGate, + edit, + onRename, + onCopy, + onSetAsDefault, + onDelete +}) { function handleRenameClick(e) { e.preventDefault(); onRename(); diff --git a/server/sonar-web/src/main/js/apps/quality-gates/routes.js b/server/sonar-web/src/main/js/apps/quality-gates/routes.js index 7db41853db8..495278f0d0a 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/routes.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/routes.js @@ -21,20 +21,23 @@ const routes = [ { getComponent(_, callback) { require.ensure([], require => - callback(null, require('./containers/QualityGatesAppContainer').default)); + callback(null, require('./containers/QualityGatesAppContainer').default) + ); }, childRoutes: [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/Intro').default })); + callback(null, { component: require('./components/Intro').default }) + ); } }, { path: 'show/:id', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./containers/DetailsContainer').default)); + callback(null, require('./containers/DetailsContainer').default) + ); } } ] diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js index 0996a1d7ce4..87b52056f88 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js @@ -46,7 +46,8 @@ export default class Changelog extends React.PureComponent { const rows = this.props.events.map((event, index) => { const prev = index > 0 ? this.props.events[index - 1] : null; const isSameDate = prev != null && moment(prev.date).diff(event.date, 'seconds') < 10; - const isBulkChange = prev != null && + const isBulkChange = + prev != null && isSameDate && prev.authorName === event.authorName && prev.action === event.action; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js index 119c4bd52be..a8d4fea6593 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js @@ -162,7 +162,8 @@ export default class ChangelogContainer extends React.PureComponent { render() { const { query } = this.props.location; - const shouldDisplayFooter = this.state.events != null && + const shouldDisplayFooter = + this.state.events != null && this.state.total != null && this.state.events.length < this.state.total; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.js index a99f64b2186..4f3d4870fea 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.js @@ -26,7 +26,7 @@ import type { Profile } from '../propTypes'; type Props = { profile: Profile, profiles: Array<Profile>, - onCompare: (string) => void, + onCompare: string => void, withKey: string }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.js index aacbe90c428..ec8f51ee0a0 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.js @@ -95,9 +95,8 @@ export default class ProfileActions extends React.PureComponent { const { profile, canAdmin } = this.props; // FIXME use org, name and lang - const backupUrl = window.baseUrl + - '/api/qualityprofiles/backup?profileKey=' + - encodeURIComponent(profile.key); + const backupUrl = + window.baseUrl + '/api/qualityprofiles/backup?profileKey=' + encodeURIComponent(profile.key); const activateMoreUrl = getRulesUrl( { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.js index ea38598bd65..cc8a8a9f535 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.js @@ -93,7 +93,8 @@ export default class ProfileInheritance extends React.PureComponent { }; render() { - const highlightCurrent = !this.state.loading && + const highlightCurrent = + !this.state.loading && this.state.ancestors != null && this.state.children != null && (this.state.ancestors.length > 0 || this.state.children.length > 0); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/utils.js b/server/sonar-web/src/main/js/apps/quality-profiles/utils.js index 97ff96be524..cfb6f7d84e6 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/utils.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/utils.js @@ -67,7 +67,7 @@ export function isStagnant(profile: Profile) { } export const getProfilesPath = (organization: ?string) => - organization ? `/organizations/${organization}/quality_profiles` : '/profiles'; + (organization ? `/organizations/${organization}/quality_profiles` : '/profiles'); export const getProfilesForLanguagePath = (language: string, organization: ?string) => ({ pathname: getProfilesPath(organization), diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js b/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js index c08cc80a8cf..9e9fc5d79f3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/views/ChangeProjectsView.js @@ -34,9 +34,8 @@ export default ModalFormView.extend({ const { key } = this.options.profile; - const searchUrl = window.baseUrl + - '/api/qualityprofiles/projects?key=' + - encodeURIComponent(key); + const searchUrl = + window.baseUrl + '/api/qualityprofiles/projects?key=' + encodeURIComponent(key); new window.SelectList({ searchUrl, 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]; } diff --git a/server/sonar-web/src/main/js/apps/update-center/plugin.js b/server/sonar-web/src/main/js/apps/update-center/plugin.js index c4b6fac39dd..3bbfe655277 100644 --- a/server/sonar-web/src/main/js/apps/update-center/plugin.js +++ b/server/sonar-web/src/main/js/apps/update-center/plugin.js @@ -33,9 +33,11 @@ export default Backbone.Model.extend({ }, match(query) { - return this._matchAttribute('name', query) || + return ( + this._matchAttribute('name', query) || this._matchAttribute('category', query) || - this._matchAttribute('description', query); + this._matchAttribute('description', query) + ); }, _action(options) { diff --git a/server/sonar-web/src/main/js/apps/update-center/routes.js b/server/sonar-web/src/main/js/apps/update-center/routes.js index 46327c282d3..e4d9cb18015 100644 --- a/server/sonar-web/src/main/js/apps/update-center/routes.js +++ b/server/sonar-web/src/main/js/apps/update-center/routes.js @@ -21,35 +21,40 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/UpdateCenterAppContainer').default })); + callback(null, { component: require('./components/UpdateCenterAppContainer').default }) + ); } }, { path: 'installed', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./components/UpdateCenterAppContainer').default)); + callback(null, require('./components/UpdateCenterAppContainer').default) + ); } }, { path: 'updates', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./components/UpdateCenterAppContainer').default)); + callback(null, require('./components/UpdateCenterAppContainer').default) + ); } }, { path: 'available', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./components/UpdateCenterAppContainer').default)); + callback(null, require('./components/UpdateCenterAppContainer').default) + ); } }, { path: 'system', getComponent(_, callback) { require.ensure([], require => - callback(null, require('./components/UpdateCenterAppContainer').default)); + callback(null, require('./components/UpdateCenterAppContainer').default) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/update-center/search-view.js b/server/sonar-web/src/main/js/apps/update-center/search-view.js index eb899c7f58c..a181e17a44c 100644 --- a/server/sonar-web/src/main/js/apps/update-center/search-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/search-view.js @@ -84,12 +84,9 @@ export default Marionette.ItemView.extend({ focusSearch() { const that = this; - setTimeout( - () => { - that.$('#update-center-search-query').focus(); - }, - 0 - ); + setTimeout(() => { + that.$('#update-center-search-query').focus(); + }, 0); }, onFilter(model) { diff --git a/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.js b/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.js index 96cc5da6e53..007a6e05138 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.js +++ b/server/sonar-web/src/main/js/apps/users/components/UsersSelectSearch.js @@ -37,7 +37,7 @@ export type Option = { type Props = { autoFocus?: boolean, excludedUsers: Array<string>, - handleValueChange: (Option) => void, + handleValueChange: Option => void, searchUsers: (string, number) => Promise<*>, selectedUser?: Option }; diff --git a/server/sonar-web/src/main/js/apps/users/routes.js b/server/sonar-web/src/main/js/apps/users/routes.js index 0a52028e543..e83f23c64b5 100644 --- a/server/sonar-web/src/main/js/apps/users/routes.js +++ b/server/sonar-web/src/main/js/apps/users/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/UsersAppContainer').default })); + callback(null, { component: require('./components/UsersAppContainer').default }) + ); } } ]; diff --git a/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js b/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js index 87e242a676d..7f9c5869e7a 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.js @@ -41,7 +41,8 @@ export default class ResponseExample extends React.PureComponent { fetchResponseExample() { const { domain, action } = this.props; fetchResponseExampleApi(domain.path, action.key).then(responseExample => - this.setState({ responseExample })); + this.setState({ responseExample }) + ); } render() { diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Search.js b/server/sonar-web/src/main/js/apps/web-api/components/Search.js index ee6c8e46456..c43163ed951 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Search.js +++ b/server/sonar-web/src/main/js/apps/web-api/components/Search.js @@ -27,7 +27,7 @@ import { translate } from '../../../helpers/l10n'; type Props = { showDeprecated: boolean, showInternal: boolean, - onSearch: (string) => void, + onSearch: string => void, onToggleInternal: () => void, onToggleDeprecated: () => void }; diff --git a/server/sonar-web/src/main/js/apps/web-api/routes.js b/server/sonar-web/src/main/js/apps/web-api/routes.js index 040d8dad6ab..a27df0a1e5c 100644 --- a/server/sonar-web/src/main/js/apps/web-api/routes.js +++ b/server/sonar-web/src/main/js/apps/web-api/routes.js @@ -21,7 +21,8 @@ const routes = [ { getIndexRoute(_, callback) { require.ensure([], require => - callback(null, { component: require('./components/WebApiApp').default })); + callback(null, { component: require('./components/WebApiApp').default }) + ); } }, { |