diff options
Diffstat (limited to 'server/sonar-web/src/main/js')
204 files changed, 1424 insertions, 1446 deletions
diff --git a/server/sonar-web/src/main/js/api/issues.js b/server/sonar-web/src/main/js/api/issues.js index ae316d8c228..92e3c94912d 100644 --- a/server/sonar-web/src/main/js/api/issues.js +++ b/server/sonar-web/src/main/js/api/issues.js @@ -72,7 +72,7 @@ export function getTags(query: {}): Promise<*> { export function extractAssignees(facet: Array<{ val: string }>, response: IssuesResponse) { return facet.map(item => { - const user = response.users ? response.users.find(user => user.login = item.val) : null; + const user = response.users ? response.users.find(user => user.login === item.val) : null; return { ...item, user }; }); } diff --git a/server/sonar-web/src/main/js/api/quality-gates.js b/server/sonar-web/src/main/js/api/quality-gates.js index ca20a0f97d0..7c60f3a2a24 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.js +++ b/server/sonar-web/src/main/js/api/quality-gates.js @@ -34,7 +34,8 @@ export function fetchQualityGates() { ...qualityGate, isDefault: qualityGate.id === r.default }; - })); + }) + ); } export function fetchQualityGate(id) { diff --git a/server/sonar-web/src/main/js/api/system.js b/server/sonar-web/src/main/js/api/system.js index dc02de9b717..2d0420b05c0 100644 --- a/server/sonar-web/src/main/js/api/system.js +++ b/server/sonar-web/src/main/js/api/system.js @@ -43,20 +43,17 @@ export function restart() { const POLLING_INTERVAL = 2000; function pollStatus(cb) { - setTimeout( - () => { - getSystemStatus() - .then(r => { - if (r.status === 'UP') { - cb(); - } else { - pollStatus(cb); - } - }) - .catch(() => pollStatus(cb)); - }, - POLLING_INTERVAL - ); + setTimeout(() => { + getSystemStatus() + .then(r => { + if (r.status === 'UP') { + cb(); + } else { + pollStatus(cb); + } + }) + .catch(() => pollStatus(cb)); + }, POLLING_INTERVAL); } function promiseStatus() { diff --git a/server/sonar-web/src/main/js/api/web-api.js b/server/sonar-web/src/main/js/api/web-api.js index 73299248b18..270759ad1f7 100644 --- a/server/sonar-web/src/main/js/api/web-api.js +++ b/server/sonar-web/src/main/js/api/web-api.js @@ -66,7 +66,8 @@ export function fetchWebApi(showInternal: boolean = true): Promise<Array<Domain> const internal = !domain.actions.find(action => !action.internal); return { ...domain, deprecated, internal }; - })); + }) + ); } export function fetchResponseExample(domain: string, action: string): Promise<{ example: string }> { diff --git a/server/sonar-web/src/main/js/app/components/App.js b/server/sonar-web/src/main/js/app/components/App.js index 578556bbb3f..f2c392bc4ef 100644 --- a/server/sonar-web/src/main/js/app/components/App.js +++ b/server/sonar-web/src/main/js/app/components/App.js @@ -49,7 +49,8 @@ class App extends React.PureComponent { this.props.fetchAppState(), this.props.fetchOrganizations(), this.props.fetchLanguages() - ])) + ]) + ) .then(this.finishLoading, this.finishLoading); } diff --git a/server/sonar-web/src/main/js/app/components/Landing.js b/server/sonar-web/src/main/js/app/components/Landing.js index 42a3bd47a77..9cd07a0d4ba 100644 --- a/server/sonar-web/src/main/js/app/components/Landing.js +++ b/server/sonar-web/src/main/js/app/components/Landing.js @@ -25,10 +25,8 @@ import { getCurrentUser } from '../../store/rootReducer'; class Landing extends React.PureComponent { static propTypes = { - currentUser: React.PropTypes.oneOfType([ - React.PropTypes.bool, - React.PropTypes.object - ]).isRequired + currentUser: React.PropTypes.oneOfType([React.PropTypes.bool, React.PropTypes.object]) + .isRequired }; componentDidMount() { diff --git a/server/sonar-web/src/main/js/app/components/ProjectContainer.js b/server/sonar-web/src/main/js/app/components/ProjectContainer.js index 3023b1a7628..7277845431b 100644 --- a/server/sonar-web/src/main/js/app/components/ProjectContainer.js +++ b/server/sonar-web/src/main/js/app/components/ProjectContainer.js @@ -38,7 +38,7 @@ class ProjectContainer extends React.PureComponent { configuration: {}, qualifier: string }, - fetchProject: (string) => Promise<*> + fetchProject: string => Promise<*> }; componentDidMount() { this.fetchProject(); diff --git a/server/sonar-web/src/main/js/app/components/extensions/Extension.js b/server/sonar-web/src/main/js/app/components/extensions/Extension.js index 1013c2c2823..f5d145918b1 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/Extension.js +++ b/server/sonar-web/src/main/js/app/components/extensions/Extension.js @@ -33,7 +33,7 @@ type Props = { key: string, title: string }, - onFail: (string) => void, + onFail: string => void, options?: {}, router: Object }; @@ -86,7 +86,7 @@ class Extension extends React.PureComponent { render() { return ( <div> - <div ref={container => this.container = container} /> + <div ref={container => (this.container = container)} /> </div> ); } diff --git a/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.js b/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.js index 9e01ad26655..2b271712002 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.js +++ b/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.js @@ -41,7 +41,8 @@ type Props = { function ProjectAdminPageExtension(props: Props) { const { extensionKey, pluginKey } = props.params; const { component } = props; - const extension = component.configuration && + const extension = + component.configuration && component.configuration.extensions.find(p => p.key === `${pluginKey}/${extensionKey}`); return extension ? <Extension extension={extension} options={{ component }} /> diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js index 63246b7407b..6fe26c1cbb4 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.js @@ -26,7 +26,8 @@ export default class ComponentNavMeta extends React.PureComponent { render() { const metaList = []; const canSeeBackgroundTasks = this.props.conf.showBackgroundTasks; - const backgroundTasksUrl = window.baseUrl + + const backgroundTasksUrl = + window.baseUrl + `/project/background_tasks?id=${encodeURIComponent(this.props.component.key)}`; if (this.props.isInProgress) { diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js index 996391f2fd0..168ab4f188a 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js @@ -39,8 +39,8 @@ class GlobalNavBranding extends React.PureComponent { render() { const homeController = this.props.currentUser.isLoggedIn ? '/projects' : '/about'; - const homeLinkClassName = 'navbar-brand' + - (this.props.customLogoUrl ? ' navbar-brand-custom' : ''); + const homeLinkClassName = + 'navbar-brand' + (this.props.customLogoUrl ? ' navbar-brand-custom' : ''); return ( <div className="navbar-header"> <Link to={homeController} className={homeLinkClassName}>{this.renderLogo()}</Link> diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.js index 004d3c20eb2..c84707129f4 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.js @@ -30,7 +30,7 @@ class GlobalNavUser extends React.PureComponent { name: string }, location: Object, - router: { push: (string) => void } + router: { push: string => void } }; handleLogin = e => { @@ -38,8 +38,8 @@ class GlobalNavUser extends React.PureComponent { const shouldReturnToCurrentPage = window.location.pathname !== `${window.baseUrl}/about`; if (shouldReturnToCurrentPage) { const returnTo = encodeURIComponent(window.location.pathname + window.location.search); - window.location = window.baseUrl + - `/sessions/new?return_to=${returnTo}${window.location.hash}`; + window.location = + window.baseUrl + `/sessions/new?return_to=${returnTo}${window.location.hash}`; } else { window.location = `${window.baseUrl}/sessions/new`; } diff --git a/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js b/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js index 9277cb5acb5..f0aecd4d887 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js @@ -126,12 +126,9 @@ export default Marionette.LayoutView.extend({ onRender() { const that = this; this.resultsRegion.show(this.resultsView); - setTimeout( - () => { - that.$('.js-search-input').focus(); - }, - 0 - ); + setTimeout(() => { + that.$('.js-search-input').focus(); + }, 0); }, onKeyDown(e) { @@ -191,7 +188,8 @@ export default Marionette.LayoutView.extend({ const recentHistory = RecentHistory.get(); const customOrganizations = areThereCustomOrganizations(); const history = recentHistory.map((historyItem, index) => { - const url = window.baseUrl + + const url = + window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) + window.dashboardParameters(true); @@ -229,7 +227,8 @@ export default Marionette.LayoutView.extend({ const collection = []; r.results.forEach(({ items, q }) => { items.forEach((item, index) => { - const showOrganization = customOrganizations && + const showOrganization = + customOrganizations && item.organization != null && SHOW_ORGANIZATION_FOR_QUALIFIERS.includes(q); const organization = showOrganization ? getOrganization(item.organization) : null; diff --git a/server/sonar-web/src/main/js/app/utils/configureLocale.js b/server/sonar-web/src/main/js/app/utils/configureLocale.js index 3b5346d2c59..fb001d49965 100644 --- a/server/sonar-web/src/main/js/app/utils/configureLocale.js +++ b/server/sonar-web/src/main/js/app/utils/configureLocale.js @@ -20,7 +20,7 @@ import moment from 'moment'; const getPreferredLanguage = () => - window.navigator.languages ? window.navigator.languages[0] : window.navigator.language; + (window.navigator.languages ? window.navigator.languages[0] : window.navigator.language); const configureLocale = () => { moment.locale(getPreferredLanguage()); diff --git a/server/sonar-web/src/main/js/app/utils/getHistory.js b/server/sonar-web/src/main/js/app/utils/getHistory.js index 3a0f42b0d5d..ce1c57eb9a9 100644 --- a/server/sonar-web/src/main/js/app/utils/getHistory.js +++ b/server/sonar-web/src/main/js/app/utils/getHistory.js @@ -30,4 +30,4 @@ const ensureHistory = () => { return history; }; -export default () => history ? history : ensureHistory(); +export default () => (history ? history : ensureHistory()); diff --git a/server/sonar-web/src/main/js/app/utils/getStore.js b/server/sonar-web/src/main/js/app/utils/getStore.js index 16796124e8f..63a550810b0 100644 --- a/server/sonar-web/src/main/js/app/utils/getStore.js +++ b/server/sonar-web/src/main/js/app/utils/getStore.js @@ -28,4 +28,4 @@ const createStore = () => { return store; }; -export default () => store ? store : createStore(); +export default () => (store ? store : createStore()); diff --git a/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js b/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js index f468cab3149..c0e6302c8a9 100644 --- a/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js +++ b/server/sonar-web/src/main/js/app/utils/startAjaxMonitoring.js @@ -55,7 +55,8 @@ const Process = Backbone.Model.extend({ let msg = message || translate('process.fail'); if (msg === 'process.fail') { // no translation - msg = 'An error happened, some parts of the page might not render correctly. ' + + msg = + 'An error happened, some parts of the page might not render correctly. ' + 'Please contact the administrator if you keep on experiencing this error.'; } clearInterval(this.get('timer')); @@ -64,12 +65,9 @@ const Process = Backbone.Model.extend({ message: msg }); this.set('state', 'failed'); - setTimeout( - () => { - that.finish({ force: true }); - }, - 5000 - ); + setTimeout(() => { + that.finish({ force: true }); + }, 5000); } }); @@ -123,12 +121,9 @@ function addBackgroundProcess() { const uid = uniqueId('process'); const process = new Process({ id: uid, - timer: setTimeout( - () => { - process.timeout(); - }, - defaults.timeout - ) + timer: setTimeout(() => { + process.timeout(); + }, defaults.timeout) }); processes.add(process); return uid; 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 }) + ); } }, { diff --git a/server/sonar-web/src/main/js/components/SelectList/index.js b/server/sonar-web/src/main/js/components/SelectList/index.js index 00f59f2855c..07beda9b92a 100644 --- a/server/sonar-web/src/main/js/components/SelectList/index.js +++ b/server/sonar-web/src/main/js/components/SelectList/index.js @@ -108,12 +108,9 @@ const SelectListItemView = Backbone.View.extend({ if (postpone) { const that = this; that.$el.addClass(this.model.get('selected') ? 'added' : 'removed'); - setTimeout( - function() { - Backbone.View.prototype.remove.call(that, arguments); - }, - 500 - ); + setTimeout(function() { + Backbone.View.prototype.remove.call(that, arguments); + }, 500); } else { Backbone.View.prototype.remove.call(this, arguments); } @@ -219,12 +216,9 @@ const SelectListView = Backbone.View.extend({ .on('search', debounce(keyup, 250)); if (this.settings.focusSearch) { - setTimeout( - () => { - searchInput.focus(); - }, - 250 - ); + setTimeout(() => { + searchInput.focus(); + }, 250); } this.listItemViews = []; @@ -284,7 +278,7 @@ const SelectListView = Backbone.View.extend({ filterBySelection(filter) { const that = this; - filter = (this.currentFilter = filter || this.currentFilter); + filter = this.currentFilter = filter || this.currentFilter; if (filter != null) { this.$('.select-list-check-control').toggleClass('disabled', false); @@ -361,7 +355,8 @@ const SelectListView = Backbone.View.extend({ }, scroll() { - const scrollBottom = this.$listContainer.scrollTop() >= + const scrollBottom = + this.$listContainer.scrollTop() >= this.$list[0].scrollHeight - this.$listContainer.outerHeight(); if (scrollBottom && this.collection.more) { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js index 41517e76d50..0e70dfb09f9 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js @@ -24,19 +24,20 @@ import { receiveFavorites } from '../../store/favorites/duck'; const mapStateToProps = null; -const onReceiveComponent = (component: { key: string, canMarkAsFavorite: boolean, fav: boolean }) => - dispatch => { - if (component.canMarkAsFavorite) { - const favorites = []; - const notFavorites = []; - if (component.fav) { - favorites.push({ key: component.key }); - } else { - notFavorites.push({ key: component.key }); - } - dispatch(receiveFavorites(favorites, notFavorites)); +const onReceiveComponent = ( + component: { key: string, canMarkAsFavorite: boolean, fav: boolean } +) => dispatch => { + if (component.canMarkAsFavorite) { + const favorites = []; + const notFavorites = []; + if (component.fav) { + favorites.push({ key: component.key }); + } else { + notFavorites.push({ key: component.key }); } - }; + dispatch(receiveFavorites(favorites, notFavorites)); + } +}; const mapDispatchToProps = { onReceiveComponent }; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js index a1e842b1629..e8eac0e1f19 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js @@ -66,12 +66,12 @@ type Props = { displayAllIssues: boolean, filterLine?: (line: SourceLine) => boolean, highlightedLine?: number, - loadComponent: (string) => Promise<*>, + loadComponent: string => Promise<*>, loadIssues: (string, number, number) => Promise<*>, loadSources: (string, number, number) => Promise<*>, onLoaded?: (component: Object, sources: Array<*>, issues: Array<*>) => void, - onIssueChange?: (Issue) => void, - onIssueSelect?: (string) => void, + onIssueChange?: Issue => void, + onIssueSelect?: string => void, onIssueUnselect?: () => void, onReceiveComponent: ({ canMarkAsFavorite: boolean, fav: boolean, key: string }) => void, selectedIssue?: string @@ -532,7 +532,9 @@ export default class SourceViewerBase extends React.PureComponent { handleIssueChange = (issue: Issue) => { this.setState(state => { - const issues = state.issues.map(candidate => candidate.key === issue.key ? issue : candidate); + const issues = state.issues.map( + candidate => (candidate.key === issue.key ? issue : candidate) + ); return { issues, issuesByLine: issuesByLine(issues) }; }); if (this.props.onIssueChange) { @@ -613,7 +615,7 @@ export default class SourceViewerBase extends React.PureComponent { : null; return ( - <div className={className} ref={node => this.node = node}> + <div className={className} ref={node => (this.node = node)}> <SourceViewerHeader component={this.state.component} openNewWindow={this.openNewWindow} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js index 64aeedd5ba6..97d72edf3d4 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js @@ -45,7 +45,7 @@ export default class SourceViewerCode extends React.PureComponent { duplications?: Array<Duplication>, duplicationsByLine: { [number]: Array<number> }, duplicatedFiles?: Array<{ key: string }>, - filterLine?: (SourceLine) => boolean, + filterLine?: SourceLine => boolean, hasSourcesAfter: boolean, hasSourcesBefore: boolean, highlightedLine: number | null, @@ -62,15 +62,15 @@ export default class SourceViewerCode extends React.PureComponent { loadingSourcesBefore: boolean, onCoverageClick: (SourceLine, HTMLElement) => void, onDuplicationClick: (number, number) => void, - onIssueChange: (Issue) => void, - onIssueSelect: (string) => void, + onIssueChange: Issue => void, + onIssueSelect: string => void, onIssueUnselect: () => void, - onIssuesOpen: (SourceLine) => void, - onIssuesClose: (SourceLine) => void, + onIssuesOpen: SourceLine => void, + onIssuesClose: SourceLine => void, onLineClick: (SourceLine, HTMLElement) => void, onSCMClick: (SourceLine, HTMLElement) => void, onLocationSelect: (flowIndex: number, locationIndex: number) => void, - onSymbolClick: (Array<string>) => void, + onSymbolClick: Array<string> => void, openIssuesByLine: { [number]: boolean }, selectedIssue: string | null, selectedIssueLocation: IndexedIssueLocation | null, @@ -228,14 +228,8 @@ export default class SourceViewerCode extends React.PureComponent { hasIssues )} {sources.map((line, index) => - this.renderLine( - line, - index, - hasCoverage, - hasDuplications, - displayFiltered, - hasIssues - ))} + this.renderLine(line, index, hasCoverage, hasDuplications, displayFiltered, hasIssues) + )} </tbody> </table> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js index 523ceeb192f..d97bc5a3b4a 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js @@ -83,8 +83,8 @@ export default class SourceViewerHeader extends React.PureComponent { const isUnitTest = q === 'UTS'; // TODO check if source viewer is displayed inside workspace const workspace = false; - const rawSourcesLink = window.baseUrl + - `/api/sources/raw?key=${encodeURIComponent(this.props.component.key)}`; + const rawSourcesLink = + window.baseUrl + `/api/sources/raw?key=${encodeURIComponent(this.props.component.key)}`; // TODO favorite return ( diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js index 776fad074e1..e0270d5e6c6 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js @@ -217,8 +217,9 @@ export default class SourceViewerIssueLocations extends React.PureComponent { if (selectedLocation == null) { return false; } else { - return selectedLocation.flowIndex === flowIndex && - selectedLocation.locationIndex === locationIndex; + return ( + selectedLocation.flowIndex === flowIndex && selectedLocation.locationIndex === locationIndex + ); } } @@ -240,7 +241,7 @@ export default class SourceViewerIssueLocations extends React.PureComponent { const selected = this.isLocationSelected(flowIndex, locations.length - locationIndex - 1); return ( - <li key={key} ref={node => this.locations[key] = node} className="spacer-bottom"> + <li key={key} ref={node => (this.locations[key] = node)} className="spacer-bottom"> {line != null && <code className="source-issue-locations-line">L{line}</code>} <a className={classNames('issue-location-message', 'flash', 'flash-heavy', { @@ -270,11 +271,11 @@ export default class SourceViewerIssueLocations extends React.PureComponent { <AutoSizer disableHeight={true}> {({ width }) => ( <div - ref={node => this.rootNode = node} + ref={node => (this.rootNode = node)} className="source-issue-locations" style={{ width, height }}> <div - ref={node => this.fixedNode = node} + ref={node => (this.fixedNode = node)} className={className} style={{ width, height }}> <header className="source-issue-locations-header" /> @@ -288,14 +289,15 @@ export default class SourceViewerIssueLocations extends React.PureComponent { {translate('source_viewer.to_navigate_issue_locations')} </div> <ul - ref={node => this.node = node} + ref={node => (this.node = node)} className="source-issue-locations-list" style={{ height: height - 15 }}> {flows.map( (flow, flowIndex) => flow.locations != null && this.reverseLocations(flow.locations).map((location, locationIndex) => - this.renderLocation(location, flowIndex, locationIndex, flow.locations || [])) + this.renderLocation(location, flowIndex, locationIndex, flow.locations || []) + ) )} </ul> <DraggableCore axis="y" onDrag={this.handleDrag} offsetParent={document.body}> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js index b1d051389a5..eb20dce7d2e 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js @@ -55,14 +55,14 @@ type Props = {| onClick: (SourceLine, HTMLElement) => void, onCoverageClick: (SourceLine, HTMLElement) => void, onDuplicationClick: (number, number) => void, - onIssueChange: (Issue) => void, - onIssueSelect: (string) => void, + onIssueChange: Issue => void, + onIssueSelect: string => void, onIssueUnselect: () => void, - onIssuesOpen: (SourceLine) => void, - onIssuesClose: (SourceLine) => void, + onIssuesOpen: SourceLine => void, + onIssuesClose: SourceLine => void, onSCMClick: (SourceLine, HTMLElement) => void, onLocationSelect: (flowIndex: number, locationIndex: number) => void, - onSymbolClick: (Array<string>) => void, + onSymbolClick: Array<string> => void, openIssues: boolean, previousLine?: SourceLine, selectedIssue: string | null, diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js index 6b18e06791b..9d2d0b74688 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js @@ -41,10 +41,10 @@ type Props = {| issues: Array<Issue>, issueLocations: Array<LinearIssueLocation>, line: SourceLine, - onIssueChange: (Issue) => void, + onIssueChange: Issue => void, onIssueSelect: (issueKey: string) => void, onLocationSelect: (flowIndex: number, locationIndex: number) => void, - onSymbolClick: (Array<string>) => void, + onSymbolClick: Array<string> => void, // $FlowFixMe secondaryIssueLocations: Array<IndexedIssueLocation>, secondaryIssueLocationMessages: Array<IndexedIssueLocationMessage>, @@ -131,8 +131,10 @@ export default class LineCode extends React.PureComponent { if (selectedIssueLocation == null) { return false; } else { - return selectedIssueLocation.flowIndex === location.flowIndex && - selectedIssueLocation.locationIndex === location.locationIndex; + return ( + selectedIssueLocation.flowIndex === location.flowIndex && + selectedIssueLocation.locationIndex === location.locationIndex + ); } } @@ -141,7 +143,7 @@ export default class LineCode extends React.PureComponent { selected: this.isSecondaryIssueLocationSelected(location) }); - const limitString = (str: string) => str.length > 30 ? str.substr(0, 30) + '...' : str; + const limitString = (str: string) => (str.length > 30 ? str.substr(0, 30) + '...' : str); return ( <a @@ -193,7 +195,8 @@ export default class LineCode extends React.PureComponent { tokens = highlightIssueLocations(tokens, secondaryIssueLocations, 'issue-location'); if (selectedIssueLocation != null) { const x = secondaryIssueLocations.find(location => - this.isSecondaryIssueLocationSelected(location)); + this.isSecondaryIssueLocationSelected(location) + ); if (x) { tokens = highlightIssueLocations(tokens, [x], 'selected'); } @@ -209,7 +212,10 @@ export default class LineCode extends React.PureComponent { return ( <td className={className} data-line-number={line.line}> <div className="source-line-code-inner"> - <pre ref={node => this.codeNode = node} dangerouslySetInnerHTML={{ __html: finalCode }} /> + <pre + ref={node => (this.codeNode = node)} + dangerouslySetInnerHTML={{ __html: finalCode }} + /> {secondaryIssueLocationMessages != null && secondaryIssueLocationMessages.length > 0 && this.renderSecondaryIssueLocationMessages(secondaryIssueLocationMessages)} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js index 87a4a52a3ce..73b0da7db15 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js @@ -37,7 +37,8 @@ export default class LineCoverage extends React.PureComponent { render() { const { line } = this.props; - const className = 'source-meta source-line-coverage' + + const className = + 'source-meta source-line-coverage' + (line.coverageStatus != null ? ` source-line-${line.coverageStatus}` : ''); const title = line.coverageStatus != null ? translate('source_viewer.tooltip', line.coverageStatus) diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js index bff245af97c..97bc6e99501 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js @@ -24,7 +24,7 @@ import type { Issue as IssueType } from '../../issue/types'; type Props = { issues: Array<IssueType>, - onIssueChange: (IssueType) => void, + onIssueChange: IssueType => void, onIssueClick: (issueKey: string) => void, selectedIssue: string | null }; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js b/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js index 8bba53b8755..2cbc450f768 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js @@ -49,9 +49,9 @@ export const highlightSymbol = (tokens: Tokens, symbol: string): Tokens => { const symbolRegExp = new RegExp(`\\b${symbol}\\b`); return tokens.map( token => - symbolRegExp.test(token.className) + (symbolRegExp.test(token.className) ? { ...token, className: `${token.className} highlighted` } - : token + : token) ); }; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js index 3a9d00566ce..0e56ceab7b9 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js @@ -45,7 +45,8 @@ export const loadPage = ( p: page, ps: pageSize }).then(r => - r.issues.map(issue => parseIssueFromResponse(issue, r.components, r.users, r.rules))); + r.issues.map(issue => parseIssueFromResponse(issue, r.components, r.users, r.rules)) + ); }; export const loadPageAndNext = ( diff --git a/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js b/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js index 219f1723073..31b02a53419 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js @@ -30,8 +30,8 @@ export default Popup.extend({ getPermalink(e) { e.preventDefault(); const { component, line } = this.options; - const url = window.baseUrl + - `/component/index?id=${encodeURIComponent(component.key)}&line=${line}`; + const url = + window.baseUrl + `/component/index?id=${encodeURIComponent(component.key)}&line=${line}`; const windowParams = 'resizable=1,scrollbars=1,status=1'; window.open(url, component.name, windowParams); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js b/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js index 4be08ed6802..8628d22773a 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js @@ -103,7 +103,8 @@ export default ModalView.extend({ }, calcAdditionalMeasures(measures) { - measures.issuesRemediationEffort = (Number(measures.sqale_index_raw) || 0) + + measures.issuesRemediationEffort = + (Number(measures.sqale_index_raw) || 0) + (Number(measures.reliability_remediation_effort_raw) || 0) + (Number(measures.security_remediation_effort_raw) || 0); @@ -167,7 +168,8 @@ export default ModalView.extend({ const severitiesFacet = data.facets.find(facet => facet.property === 'severities').values; const sortedSeveritiesFacet = sortBy(severitiesFacet, facet => - window.severityComparator(facet.val)); + window.severityComparator(facet.val) + ); const tagsFacet = data.facets.find(facet => facet.property === 'tags').values; diff --git a/server/sonar-web/src/main/js/components/charts/BubbleChart.js b/server/sonar-web/src/main/js/components/charts/BubbleChart.js index 1dbd80470dc..2d740b2dfe5 100644 --- a/server/sonar-web/src/main/js/components/charts/BubbleChart.js +++ b/server/sonar-web/src/main/js/components/charts/BubbleChart.js @@ -29,7 +29,7 @@ import { TooltipsContainer } from '../mixins/tooltips-mixin'; type Scale = { (number): number, range: () => [number, number], - ticks: (number) => Array<number> + ticks: number => Array<number> }; const TICKS_COUNT = 5; @@ -38,7 +38,7 @@ export class Bubble extends React.PureComponent { props: { color?: string, link?: string, - onClick: (?string) => void, + onClick: ?string => void, r: number, tooltip?: string, x: number, @@ -99,9 +99,9 @@ export default class BubbleChart extends React.PureComponent { displayYTicks: boolean, height: number, padding: [number, number, number, number], - formatXTick: (number) => string, - formatYTick: (number) => string, - onBubbleClick?: (?string) => void, + formatXTick: number => string, + formatYTick: number => string, + onBubbleClick?: ?string => void, xDomain?: [number, number], yDomain?: [number, number] |}; @@ -133,7 +133,7 @@ export default class BubbleChart extends React.PureComponent { return [availableHeight - dMaxY, dMinY]; } - getTicks(scale: Scale, format: (number) => string) { + getTicks(scale: Scale, format: number => string) { const ticks = scale.ticks(TICKS_COUNT).map(tick => format(tick)); const uniqueTicksCount = uniq(ticks).length; const ticksCount = uniqueTicksCount < TICKS_COUNT ? uniqueTicksCount - 1 : TICKS_COUNT; diff --git a/server/sonar-web/src/main/js/components/charts/bar-chart.js b/server/sonar-web/src/main/js/components/charts/bar-chart.js index 4e1d336dc0d..95b3fd32dd7 100644 --- a/server/sonar-web/src/main/js/components/charts/bar-chart.js +++ b/server/sonar-web/src/main/js/components/charts/bar-chart.js @@ -150,7 +150,8 @@ export const BarChart = React.createClass({ const availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3]; const availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2]; - const innerPadding = (availableWidth - this.props.barsWidth * this.props.data.length) / + const innerPadding = + (availableWidth - this.props.barsWidth * this.props.data.length) / (this.props.data.length - 1); const relativeInnerPadding = innerPadding / (innerPadding + this.props.barsWidth); diff --git a/server/sonar-web/src/main/js/components/common/BubblePopupHelper.js b/server/sonar-web/src/main/js/components/common/BubblePopupHelper.js index 2873b55e9ce..81923c806ba 100644 --- a/server/sonar-web/src/main/js/components/common/BubblePopupHelper.js +++ b/server/sonar-web/src/main/js/components/common/BubblePopupHelper.js @@ -30,7 +30,7 @@ type Props = { }, popup: Object, position: 'bottomleft' | 'bottomright', - togglePopup: (?boolean) => void + togglePopup: ?boolean => void }; type State = { @@ -92,13 +92,13 @@ export default class BubblePopupHelper extends React.PureComponent { return ( <div className={classNames(this.props.className, 'bubble-popup-helper')} - ref={container => this.container = container} + ref={container => (this.container = container)} onClick={this.handleClick} tabIndex={0} role="tooltip"> {this.props.children} {this.props.isOpen && - <div ref={popupContainer => this.popupContainer = popupContainer}> + <div ref={popupContainer => (this.popupContainer = popupContainer)}> {React.cloneElement(this.props.popup, { popupPosition: this.state.position })} diff --git a/server/sonar-web/src/main/js/components/common/MultiSelect.js b/server/sonar-web/src/main/js/components/common/MultiSelect.js index 2faa0f2ef81..2c75904d706 100644 --- a/server/sonar-web/src/main/js/components/common/MultiSelect.js +++ b/server/sonar-web/src/main/js/components/common/MultiSelect.js @@ -27,10 +27,10 @@ type Props = { selectedElements: Array<string>, elements: Array<string>, listSize: number, - onSearch: (string) => void, - onSelect: (string) => void, - onUnselect: (string) => void, - validateSearchInput: (string) => string + onSearch: string => void, + onSelect: string => void, + onUnselect: string => void, + validateSearchInput: string => string }; type State = { @@ -225,7 +225,7 @@ export default class MultiSelect extends React.PureComponent { const activeElement = this.getAllElements(this.props, this.state)[activeIdx]; return ( - <div className="multi-select" ref={div => this.container = div}> + <div className="multi-select" ref={div => (this.container = div)}> <div className="search-box menu-search"> <button className="search-box-submit button-clean"> <i className="icon-search-new" /> @@ -237,7 +237,7 @@ export default class MultiSelect extends React.PureComponent { placeholder={translate('search_verb')} onChange={this.handleSearchChange} autoComplete="off" - ref={input => this.searchInput = input} + ref={input => (this.searchInput = input)} /> </div> <ul className="menu"> diff --git a/server/sonar-web/src/main/js/components/common/MultiSelectOption.js b/server/sonar-web/src/main/js/components/common/MultiSelectOption.js index 0699f3e72d0..02291254fc1 100644 --- a/server/sonar-web/src/main/js/components/common/MultiSelectOption.js +++ b/server/sonar-web/src/main/js/components/common/MultiSelectOption.js @@ -27,7 +27,7 @@ type Props = { custom: boolean, active: boolean, onSelectChange: (string, boolean) => void, - onHover: (string) => void + onHover: string => void }; export default class MultiSelectOption extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/common/SelectList.js b/server/sonar-web/src/main/js/components/common/SelectList.js index bec5c2e6712..d5695f82a22 100644 --- a/server/sonar-web/src/main/js/components/common/SelectList.js +++ b/server/sonar-web/src/main/js/components/common/SelectList.js @@ -27,7 +27,7 @@ type Props = { children?: SelectListItem, items: Array<string>, currentItem: string, - onSelect: (string) => void + onSelect: string => void }; type State = { diff --git a/server/sonar-web/src/main/js/components/common/SelectListItem.js b/server/sonar-web/src/main/js/components/common/SelectListItem.js index 44dbf517296..e5bc30cdca6 100644 --- a/server/sonar-web/src/main/js/components/common/SelectListItem.js +++ b/server/sonar-web/src/main/js/components/common/SelectListItem.js @@ -26,8 +26,8 @@ type Props = { active?: string, children?: React.Element<*>, item: string, - onSelect?: (string) => void, - onHover?: (string) => void, + onSelect?: string => void, + onHover?: string => void, title?: string }; diff --git a/server/sonar-web/src/main/js/components/common/modal-form.js b/server/sonar-web/src/main/js/components/common/modal-form.js index dc766b2188a..2629ce5b077 100644 --- a/server/sonar-web/src/main/js/components/common/modal-form.js +++ b/server/sonar-web/src/main/js/components/common/modal-form.js @@ -37,12 +37,9 @@ export default ModalView.extend({ onRender() { ModalView.prototype.onRender.apply(this, arguments); const that = this; - setTimeout( - () => { - that.$(':tabbable').first().focus(); - }, - 0 - ); + setTimeout(() => { + that.$(':tabbable').first().focus(); + }, 0); }, onInputKeydown(e) { diff --git a/server/sonar-web/src/main/js/components/common/modals.js b/server/sonar-web/src/main/js/components/common/modals.js index a86a262d40c..7e8da099663 100644 --- a/server/sonar-web/src/main/js/components/common/modals.js +++ b/server/sonar-web/src/main/js/components/common/modals.js @@ -53,13 +53,10 @@ export default Marionette.ItemView.extend({ show() { const that = this; - setTimeout( - () => { - that.$el.addClass('in'); - $('.' + that.overlayClassName).addClass('in'); - }, - 0 - ); + setTimeout(() => { + that.$el.addClass('in'); + $('.' + that.overlayClassName).addClass('in'); + }, 0); }, onDestroy() { diff --git a/server/sonar-web/src/main/js/components/controls/DateInput.js b/server/sonar-web/src/main/js/components/controls/DateInput.js index 45acfbc26eb..16bab132de3 100644 --- a/server/sonar-web/src/main/js/components/controls/DateInput.js +++ b/server/sonar-web/src/main/js/components/controls/DateInput.js @@ -80,9 +80,7 @@ export default class DateInput extends React.PureComponent { /> <span className="date-input-control-icon"> <svg width="14" height="14" viewBox="0 0 16 16"> - <path - d="M5.5 6h2v2h-2V6zm3 0h2v2h-2V6zm3 0h2v2h-2V6zm-9 6h2v2h-2v-2zm3 0h2v2h-2v-2zm3 0h2v2h-2v-2zm-3-3h2v2h-2V9zm3 0h2v2h-2V9zm3 0h2v2h-2V9zm-9 0h2v2h-2V9zm11-9v1h-2V0h-7v1h-2V0h-2v16h15V0h-2zm1 15h-13V4h13v11z" - /> + <path d="M5.5 6h2v2h-2V6zm3 0h2v2h-2V6zm3 0h2v2h-2V6zm-9 6h2v2h-2v-2zm3 0h2v2h-2v-2zm3 0h2v2h-2v-2zm-3-3h2v2h-2V9zm3 0h2v2h-2V9zm3 0h2v2h-2V9zm-9 0h2v2h-2V9zm11-9v1h-2V0h-7v1h-2V0h-2v16h15V0h-2zm1 15h-13V4h13v11z" /> </svg> </span> </span> diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteBase.js b/server/sonar-web/src/main/js/components/controls/FavoriteBase.js index 8518e646fcb..648fe040bc0 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteBase.js +++ b/server/sonar-web/src/main/js/components/controls/FavoriteBase.js @@ -71,9 +71,7 @@ export default class FavoriteBase extends React.PureComponent { /* eslint max-len: 0 */ return ( <svg width="16" height="16"> - <path - d="M15.4275,5.77678C15.4275,5.90773 15.3501,6.05059 15.1953,6.20536L11.9542,9.36608L12.7221,13.8304C12.728,13.872 12.731,13.9316 12.731,14.0089C12.731,14.1339 12.6998,14.2396 12.6373,14.3259C12.5748,14.4122 12.484,14.4554 12.3649,14.4554C12.2518,14.4554 12.1328,14.4197 12.0078,14.3482L7.99888,12.2411L3.98995,14.3482C3.85901,14.4197 3.73996,14.4554 3.63281,14.4554C3.50781,14.4554 3.41406,14.4122 3.35156,14.3259C3.28906,14.2396 3.25781,14.1339 3.25781,14.0089C3.25781,13.9732 3.26377,13.9137 3.27567,13.8304L4.04353,9.36608L0.793531,6.20536C0.644719,6.04464 0.570313,5.90178 0.570313,5.77678C0.570313,5.55654 0.736979,5.41964 1.07031,5.36606L5.55245,4.71428L7.56138,0.651781C7.67447,0.407729 7.8203,0.285703 7.99888,0.285703C8.17745,0.285703 8.32328,0.407729 8.43638,0.651781L10.4453,4.71428L14.9274,5.36606C15.2608,5.41964 15.4274,5.55654 15.4274,5.77678L15.4275,5.77678Z" - /> + <path d="M15.4275,5.77678C15.4275,5.90773 15.3501,6.05059 15.1953,6.20536L11.9542,9.36608L12.7221,13.8304C12.728,13.872 12.731,13.9316 12.731,14.0089C12.731,14.1339 12.6998,14.2396 12.6373,14.3259C12.5748,14.4122 12.484,14.4554 12.3649,14.4554C12.2518,14.4554 12.1328,14.4197 12.0078,14.3482L7.99888,12.2411L3.98995,14.3482C3.85901,14.4197 3.73996,14.4554 3.63281,14.4554C3.50781,14.4554 3.41406,14.4122 3.35156,14.3259C3.28906,14.2396 3.25781,14.1339 3.25781,14.0089C3.25781,13.9732 3.26377,13.9137 3.27567,13.8304L4.04353,9.36608L0.793531,6.20536C0.644719,6.04464 0.570313,5.90178 0.570313,5.77678C0.570313,5.55654 0.736979,5.41964 1.07031,5.36606L5.55245,4.71428L7.56138,0.651781C7.67447,0.407729 7.8203,0.285703 7.99888,0.285703C8.17745,0.285703 8.32328,0.407729 8.43638,0.651781L10.4453,4.71428L14.9274,5.36606C15.2608,5.41964 15.4274,5.55654 15.4274,5.77678L15.4275,5.77678Z" /> </svg> ); } diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js b/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js index f20f26f8967..b59055482bd 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js +++ b/server/sonar-web/src/main/js/components/controls/FavoriteBaseStateless.js @@ -41,9 +41,7 @@ export default class FavoriteBaseStateless extends React.PureComponent { /* eslint max-len: 0 */ return ( <svg width="16" height="16"> - <path - d="M15.4275,5.77678C15.4275,5.90773 15.3501,6.05059 15.1953,6.20536L11.9542,9.36608L12.7221,13.8304C12.728,13.872 12.731,13.9316 12.731,14.0089C12.731,14.1339 12.6998,14.2396 12.6373,14.3259C12.5748,14.4122 12.484,14.4554 12.3649,14.4554C12.2518,14.4554 12.1328,14.4197 12.0078,14.3482L7.99888,12.2411L3.98995,14.3482C3.85901,14.4197 3.73996,14.4554 3.63281,14.4554C3.50781,14.4554 3.41406,14.4122 3.35156,14.3259C3.28906,14.2396 3.25781,14.1339 3.25781,14.0089C3.25781,13.9732 3.26377,13.9137 3.27567,13.8304L4.04353,9.36608L0.793531,6.20536C0.644719,6.04464 0.570313,5.90178 0.570313,5.77678C0.570313,5.55654 0.736979,5.41964 1.07031,5.36606L5.55245,4.71428L7.56138,0.651781C7.67447,0.407729 7.8203,0.285703 7.99888,0.285703C8.17745,0.285703 8.32328,0.407729 8.43638,0.651781L10.4453,4.71428L14.9274,5.36606C15.2608,5.41964 15.4274,5.55654 15.4274,5.77678L15.4275,5.77678Z" - /> + <path d="M15.4275,5.77678C15.4275,5.90773 15.3501,6.05059 15.1953,6.20536L11.9542,9.36608L12.7221,13.8304C12.728,13.872 12.731,13.9316 12.731,14.0089C12.731,14.1339 12.6998,14.2396 12.6373,14.3259C12.5748,14.4122 12.484,14.4554 12.3649,14.4554C12.2518,14.4554 12.1328,14.4197 12.0078,14.3482L7.99888,12.2411L3.98995,14.3482C3.85901,14.4197 3.73996,14.4554 3.63281,14.4554C3.50781,14.4554 3.41406,14.4122 3.35156,14.3259C3.28906,14.2396 3.25781,14.1339 3.25781,14.0089C3.25781,13.9732 3.26377,13.9137 3.27567,13.8304L4.04353,9.36608L0.793531,6.20536C0.644719,6.04464 0.570313,5.90178 0.570313,5.77678C0.570313,5.55654 0.736979,5.41964 1.07031,5.36606L5.55245,4.71428L7.56138,0.651781C7.67447,0.407729 7.8203,0.285703 7.99888,0.285703C8.17745,0.285703 8.32328,0.407729 8.43638,0.651781L10.4453,4.71428L14.9274,5.36606C15.2608,5.41964 15.4274,5.55654 15.4274,5.77678L15.4275,5.77678Z" /> </svg> ); } diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js b/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js index ace5cc92000..372cb3b182e 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js +++ b/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js @@ -25,25 +25,23 @@ import * as api from '../../api/favorites'; import { addGlobalErrorMessage } from '../../store/globalMessages/duck'; import { parseError } from '../../apps/code/utils'; -const addFavorite = componentKey => - dispatch => { - // optimistic update - dispatch(actionCreators.addFavorite(componentKey)); - api.addFavorite(componentKey).catch(error => { - dispatch(actionCreators.removeFavorite(componentKey)); - parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); - }); - }; - -const removeFavorite = componentKey => - dispatch => { - // optimistic update +const addFavorite = componentKey => dispatch => { + // optimistic update + dispatch(actionCreators.addFavorite(componentKey)); + api.addFavorite(componentKey).catch(error => { dispatch(actionCreators.removeFavorite(componentKey)); - api.removeFavorite(componentKey).catch(error => { - dispatch(actionCreators.addFavorite(componentKey)); - parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); - }); - }; + parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); + }); +}; + +const removeFavorite = componentKey => dispatch => { + // optimistic update + dispatch(actionCreators.removeFavorite(componentKey)); + api.removeFavorite(componentKey).catch(error => { + dispatch(actionCreators.addFavorite(componentKey)); + parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); + }); +}; const mapStateToProps = (state, ownProps) => ({ favorite: isFavorite(state, ownProps.componentKey) diff --git a/server/sonar-web/src/main/js/components/issue/Issue.js b/server/sonar-web/src/main/js/components/issue/Issue.js index 471a62e04f0..f45671c6f74 100644 --- a/server/sonar-web/src/main/js/components/issue/Issue.js +++ b/server/sonar-web/src/main/js/components/issue/Issue.js @@ -28,9 +28,9 @@ import type { Issue } from './types'; type Props = {| checked?: boolean, issue: Issue, - onChange: (Issue) => void, - onCheck?: (string) => void, - onClick: (string) => void, + onChange: Issue => void, + onCheck?: string => void, + onClick: string => void, onFilter?: (property: string, issue: Issue) => void, selected: boolean |}; diff --git a/server/sonar-web/src/main/js/components/issue/IssueView.js b/server/sonar-web/src/main/js/components/issue/IssueView.js index 3d959f26573..f7690db0625 100644 --- a/server/sonar-web/src/main/js/components/issue/IssueView.js +++ b/server/sonar-web/src/main/js/components/issue/IssueView.js @@ -31,14 +31,14 @@ type Props = {| checked?: boolean, currentPopup: string, issue: Issue, - onAssign: (string) => void, - onChange: (Issue) => void, - onCheck?: (string) => void, - onClick: (string) => void, - onFail: (Error) => void, + onAssign: string => void, + onChange: Issue => void, + onCheck?: string => void, + onClick: string => void, + onFail: Error => void, onFilter?: (property: string, issue: Issue) => void, selected: boolean, - togglePopup: (string) => void + togglePopup: string => void |}; export default class IssueView extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/actions.js b/server/sonar-web/src/main/js/components/issue/actions.js index a44430520bd..46acb282549 100644 --- a/server/sonar-web/src/main/js/components/issue/actions.js +++ b/server/sonar-web/src/main/js/components/issue/actions.js @@ -23,7 +23,7 @@ import { parseIssueFromResponse } from '../../helpers/issues'; import type { Issue } from './types'; export const updateIssue = ( - onChange: (Issue) => void, + onChange: Issue => void, resultPromise: Promise<*>, oldIssue?: Issue, newIssue?: Issue diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js index 9006cd9a19e..9a7bcf803a7 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js @@ -32,10 +32,10 @@ import type { Issue } from '../types'; type Props = { issue: Issue, currentPopup: string, - onAssign: (string) => void, - onChange: (Issue) => void, - onFail: (Error) => void, - togglePopup: (string) => void + onAssign: string => void, + onChange: Issue => void, + onFail: Error => void, + togglePopup: string => void }; type State = { @@ -58,7 +58,7 @@ export default class IssueActionsBar extends React.PureComponent { setIssueProperty = ( property: string, popup: string, - apiCall: (Object) => Promise<*>, + apiCall: Object => Promise<*>, value: string ) => { const { issue } = this.props; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js index 836ef6a5a8c..55c84072696 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js @@ -29,9 +29,9 @@ type Props = { isOpen: boolean, issue: Issue, canAssign: boolean, - onAssign: (string) => void, - onFail: (Error) => void, - togglePopup: (string) => void + onAssign: string => void, + onFail: Error => void, + togglePopup: string => void }; export default class IssueAssign extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js index 864886af959..c1e77f71801 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js @@ -28,8 +28,8 @@ type Props = { isOpen: boolean, issue: Issue, creationDate: string, - togglePopup: (string) => void, - onFail: (Error) => void + togglePopup: string => void, + onFail: Error => void }; export default class IssueChangelog extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js index 8111815e942..32df39c5b61 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js @@ -30,7 +30,7 @@ type Props = {| commentPlaceholder: string, currentPopup: string, issueKey: string, - onChange: (Issue) => void, + onChange: Issue => void, toggleComment: (open?: boolean, placeholder?: string) => void |}; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js index 6e2b9595997..c82e8c4a0d9 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js @@ -28,7 +28,7 @@ import type { IssueComment } from '../types'; type Props = { comment: IssueComment, - onDelete: (string) => void, + onDelete: string => void, onEdit: (string, string) => void }; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js index 7e52e538742..f4e46db81e3 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js @@ -30,7 +30,7 @@ type Props = { isOpen: boolean, issue: Issue, setIssueProperty: (string, string, apiCall: (Object) => Promise<*>, string) => void, - togglePopup: (string) => void + togglePopup: string => void }; export default class IssueSeverity extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTags.js b/server/sonar-web/src/main/js/components/issue/components/IssueTags.js index c7cebdf74d7..c634406c5f6 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTags.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTags.js @@ -31,9 +31,9 @@ type Props = {| canSetTags: boolean, isOpen: boolean, issue: Issue, - onChange: (Issue) => void, - onFail: (Error) => void, - togglePopup: (string) => void + onChange: Issue => void, + onFail: Error => void, + togglePopup: string => void |}; export default class IssueTags extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js index 55ef295f55d..901ae80febf 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js @@ -30,9 +30,9 @@ import type { Issue } from '../types'; type Props = {| issue: Issue, currentPopup: string, - onFail: (Error) => void, + onFail: Error => void, onFilter?: (property: string, issue: Issue) => void, - togglePopup: (string) => void + togglePopup: string => void |}; const stopPropagation = (event: Event) => event.stopPropagation(); diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js index 24e3625d529..509d58ddb31 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js @@ -30,8 +30,8 @@ type Props = { hasTransitions: boolean, isOpen: boolean, issue: Issue, - onChange: (Issue) => void, - togglePopup: (string) => void + onChange: Issue => void, + togglePopup: string => void }; export default class IssueTransition extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueType.js b/server/sonar-web/src/main/js/components/issue/components/IssueType.js index df1d8740031..952d481c1b1 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueType.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueType.js @@ -31,7 +31,7 @@ type Props = { isOpen: boolean, issue: Issue, setIssueProperty: (string, string, apiCall: (Object) => Promise<*>, string) => void, - togglePopup: (string) => void + togglePopup: string => void }; export default class IssueType extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js index c28593d7c89..bf80c555101 100644 --- a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js +++ b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js @@ -27,8 +27,8 @@ import type { Issue } from '../types'; type Props = {| isOpen: boolean, issue: Issue, - togglePopup: (string) => void, - onFail: (Error) => void, + togglePopup: string => void, + onFail: Error => void, onFilter: (property: string, issue: Issue) => void |}; diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js index 608112423d5..446dc8bcea4 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js @@ -28,11 +28,10 @@ const issue = { creationDate: '2017-03-01T09:36:01+0100' }; -jest.mock('moment', () => - () => ({ - format: () => 'March 1, 2017 9:36 AM', - fromNow: () => 'a month ago' - })); +jest.mock('moment', () => () => ({ + format: () => 'March 1, 2017 9:36 AM', + fromNow: () => 'a month ago' +})); it('should render correctly', () => { const element = shallow( diff --git a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js index 49bdee8218e..501f4b2b612 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js @@ -38,7 +38,7 @@ type Changelog = { type Props = { issue: Issue, - onFail: (Error) => void, + onFail: Error => void, popupPosition?: {} }; @@ -63,14 +63,11 @@ export default class ChangelogPopup extends React.PureComponent { } loadChangelog() { - getIssueChangelog(this.props.issue.key).then( - changelogs => { - if (this.mounted) { - this.setState({ changelogs }); - } - }, - this.props.onFail - ); + getIssueChangelog(this.props.issue.key).then(changelogs => { + if (this.mounted) { + this.setState({ changelogs }); + } + }, this.props.onFail); } render() { diff --git a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js index cb079327d53..befea8fef19 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js @@ -28,8 +28,8 @@ import type { IssueComment } from '../types'; type Props = { comment?: IssueComment, customClass?: string, - onComment: (string) => void, - toggleComment: (boolean) => void, + onComment: string => void, + toggleComment: boolean => void, placeholder: string, popupPosition?: {} }; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js index c700c3a341f..df38baef06a 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.js @@ -42,8 +42,8 @@ type User = { type Props = { issue: Issue, - onFail: (Error) => void, - onSelect: (string) => void, + onFail: Error => void, + onSelect: string => void, popupPosition?: {} }; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetIssueTagsPopup.js b/server/sonar-web/src/main/js/components/issue/popups/SetIssueTagsPopup.js index f8584f59f07..04b1a31ae28 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetIssueTagsPopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/SetIssueTagsPopup.js @@ -25,9 +25,9 @@ import { searchIssueTags } from '../../../api/issues'; type Props = { popupPosition?: {}, - onFail: (Error) => void, + onFail: Error => void, selectedTags: Array<string>, - setTags: (Array<string>) => void + setTags: Array<string> => void }; type State = { @@ -54,12 +54,9 @@ export default class SetIssueTagsPopup extends React.PureComponent { searchIssueTags({ q: query || '', ps: Math.min(this.props.selectedTags.length - 1 + LIST_SIZE, 100) - }).then( - (tags: Array<string>) => { - this.setState({ searchResult: tags }); - }, - this.props.onFail - ); + }).then((tags: Array<string>) => { + this.setState({ searchResult: tags }); + }, this.props.onFail); }; onSelect = (tag: string) => { diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.js b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.js index bef971615d5..be89f2120b9 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.js @@ -28,7 +28,7 @@ import type { Issue } from '../types'; type Props = { issue: Issue, - onSelect: (string) => void, + onSelect: string => void, popupPosition?: {} }; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.js b/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.js index d1c83099551..dc1703d15ec 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.js @@ -26,7 +26,7 @@ import { translate } from '../../../helpers/l10n'; type Props = { transitions: Array<string>, - onSelect: (string) => void, + onSelect: string => void, popupPosition?: {} }; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.js b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.js index 7bd10d57ede..1f1864307a7 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.js @@ -28,7 +28,7 @@ import type { Issue } from '../types'; type Props = { issue: Issue, - onSelect: (string) => void, + onSelect: string => void, popupPosition?: {} }; diff --git a/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js b/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js index 8ed623b343e..3fceee85f6b 100644 --- a/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js +++ b/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js @@ -80,12 +80,9 @@ export default Marionette.ItemView.extend({ flashPagination() { const flashElement = this.$('.search-navigator-header-pagination'); flashElement.addClass('in'); - setTimeout( - () => { - flashElement.removeClass('in'); - }, - 2000 - ); + setTimeout(() => { + flashElement.removeClass('in'); + }, 2000); }, serializeData() { diff --git a/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js b/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js index b7b35b539c5..12a087bba97 100644 --- a/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js +++ b/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js @@ -119,9 +119,8 @@ export default Marionette.CompositeView.extend({ const selectedView = this.children.findByModel(selected); const parentTopOffset = this.$el.offset().top; const viewTop = selectedView.$el.offset().top - parentTopOffset; - const viewBottom = selectedView.$el.offset().top + - selectedView.$el.outerHeight() + - BOTTOM_OFFSET; + const viewBottom = + selectedView.$el.offset().top + selectedView.$el.outerHeight() + BOTTOM_OFFSET; const windowTop = $(window).scrollTop(); const windowBottom = windowTop + $(window).height(); if (viewTop < windowTop) { diff --git a/server/sonar-web/src/main/js/components/shared/StatusHelper.js b/server/sonar-web/src/main/js/components/shared/StatusHelper.js index 092e3524b70..07d7b81386b 100644 --- a/server/sonar-web/src/main/js/components/shared/StatusHelper.js +++ b/server/sonar-web/src/main/js/components/shared/StatusHelper.js @@ -25,8 +25,8 @@ import { translate } from '../../helpers/l10n'; export default function StatusHelper( props: { resolution?: string, status: string, className?: string } ) { - const resolution = props.resolution != null && - ` (${translate('issue.resolution', props.resolution)})`; + const resolution = + props.resolution != null && ` (${translate('issue.resolution', props.resolution)})`; return ( <span className={props.className}> <StatusIcon className="little-spacer-right" status={props.status} /> diff --git a/server/sonar-web/src/main/js/components/shared/pending-icon.js b/server/sonar-web/src/main/js/components/shared/pending-icon.js index 333f901965d..006eddd469c 100644 --- a/server/sonar-web/src/main/js/components/shared/pending-icon.js +++ b/server/sonar-web/src/main/js/components/shared/pending-icon.js @@ -25,9 +25,7 @@ export default class PendingIcon extends React.PureComponent { return ( <svg width="16" height="16" className="icon-pending"> <g transform="matrix(0.0364583,0,0,0.0364583,1,-0.166667)"> - <path - d="M224,136L224,248C224,250.333 223.25,252.25 221.75,253.75C220.25,255.25 218.333,256 216,256L136,256C133.667,256 131.75,255.25 130.25,253.75C128.75,252.25 128,250.333 128,248L128,232C128,229.667 128.75,227.75 130.25,226.25C131.75,224.75 133.667,224 136,224L192,224L192,136C192,133.667 192.75,131.75 194.25,130.25C195.75,128.75 197.667,128 200,128L216,128C218.333,128 220.25,128.75 221.75,130.25C223.25,131.75 224,133.667 224,136ZM328,224C328,199.333 321.917,176.583 309.75,155.75C297.583,134.917 281.083,118.417 260.25,106.25C239.417,94.083 216.667,88 192,88C167.333,88 144.583,94.083 123.75,106.25C102.917,118.417 86.417,134.917 74.25,155.75C62.083,176.583 56,199.333 56,224C56,248.667 62.083,271.417 74.25,292.25C86.417,313.083 102.917,329.583 123.75,341.75C144.583,353.917 167.333,360 192,360C216.667,360 239.417,353.917 260.25,341.75C281.083,329.583 297.583,313.083 309.75,292.25C321.917,271.417 328,248.667 328,224ZM384,224C384,258.833 375.417,290.958 358.25,320.375C341.083,349.792 317.792,373.083 288.375,390.25C258.958,407.417 226.833,416 192,416C157.167,416 125.042,407.417 95.625,390.25C66.208,373.083 42.917,349.792 25.75,320.375C8.583,290.958 0,258.833 0,224C0,189.167 8.583,157.042 25.75,127.625C42.917,98.208 66.208,74.917 95.625,57.75C125.042,40.583 157.167,32 192,32C226.833,32 258.958,40.583 288.375,57.75C317.792,74.917 341.083,98.208 358.25,127.625C375.417,157.042 384,189.167 384,224Z" - /> + <path d="M224,136L224,248C224,250.333 223.25,252.25 221.75,253.75C220.25,255.25 218.333,256 216,256L136,256C133.667,256 131.75,255.25 130.25,253.75C128.75,252.25 128,250.333 128,248L128,232C128,229.667 128.75,227.75 130.25,226.25C131.75,224.75 133.667,224 136,224L192,224L192,136C192,133.667 192.75,131.75 194.25,130.25C195.75,128.75 197.667,128 200,128L216,128C218.333,128 220.25,128.75 221.75,130.25C223.25,131.75 224,133.667 224,136ZM328,224C328,199.333 321.917,176.583 309.75,155.75C297.583,134.917 281.083,118.417 260.25,106.25C239.417,94.083 216.667,88 192,88C167.333,88 144.583,94.083 123.75,106.25C102.917,118.417 86.417,134.917 74.25,155.75C62.083,176.583 56,199.333 56,224C56,248.667 62.083,271.417 74.25,292.25C86.417,313.083 102.917,329.583 123.75,341.75C144.583,353.917 167.333,360 192,360C216.667,360 239.417,353.917 260.25,341.75C281.083,329.583 297.583,313.083 309.75,292.25C321.917,271.417 328,248.667 328,224ZM384,224C384,258.833 375.417,290.958 358.25,320.375C341.083,349.792 317.792,373.083 288.375,390.25C258.958,407.417 226.833,416 192,416C157.167,416 125.042,407.417 95.625,390.25C66.208,373.083 42.917,349.792 25.75,320.375C8.583,290.958 0,258.833 0,224C0,189.167 8.583,157.042 25.75,127.625C42.917,98.208 66.208,74.917 95.625,57.75C125.042,40.583 157.167,32 192,32C226.833,32 258.958,40.583 288.375,57.75C317.792,74.917 341.083,98.208 358.25,127.625C375.417,157.042 384,189.167 384,224Z" /> </g> </svg> ); diff --git a/server/sonar-web/src/main/js/components/tags/TagsSelector.js b/server/sonar-web/src/main/js/components/tags/TagsSelector.js index 68cde43cd82..2525ccd5733 100644 --- a/server/sonar-web/src/main/js/components/tags/TagsSelector.js +++ b/server/sonar-web/src/main/js/components/tags/TagsSelector.js @@ -28,13 +28,13 @@ type Props = { tags: Array<string>, selectedTags: Array<string>, listSize: number, - onSearch: (string) => void, - onSelect: (string) => void, - onUnselect: (string) => void + onSearch: string => void, + onSelect: string => void, + onUnselect: string => void }; export default class TagsSelector extends React.PureComponent { - validateTag: (string) => string; + validateTag: string => string; props: Props; validateTag(value: string) { diff --git a/server/sonar-web/src/main/js/components/widgets/barchart.js b/server/sonar-web/src/main/js/components/widgets/barchart.js index b84aa71d2e7..99f2695b599 100644 --- a/server/sonar-web/src/main/js/components/widgets/barchart.js +++ b/server/sonar-web/src/main/js/components/widgets/barchart.js @@ -84,7 +84,8 @@ $.fn.barchart = function(data) { .enter() .append('g') .attr('transform', (d, i) => - trans(xScale(i), Math.ceil(options.availableHeight - yScale(d.count)))); + trans(xScale(i), Math.ceil(options.availableHeight - yScale(d.count))) + ); barsEnter .append('rect') @@ -108,10 +109,12 @@ $.fn.barchart = function(data) { : options.endDate; if (ending) { const isSameDay = ending.diff(beginning, 'days') <= 1; - return d.text + + return ( + d.text + '<br>' + beginning.format('LL') + - (isSameDay ? '' : ' – ' + ending.format('LL')); + (isSameDay ? '' : ' – ' + ending.format('LL')) + ); } else { return d.text + '<br>' + beginning.format('LL'); } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/default.js b/server/sonar-web/src/main/js/helpers/handlebars/default.js index 4dd7a7d2f5a..04c87058262 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/default.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/default.js @@ -19,5 +19,5 @@ */ module.exports = function(...args) { const list = args.slice(0, -1); - return list.reduce((prev, current) => prev != null ? prev : current, null); + return list.reduce((prev, current) => (prev != null ? prev : current), null); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js index 567966a17b1..c461b7bb672 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js @@ -22,7 +22,8 @@ module.exports = function(source, line, options) { const prevLine = source.find(row => row.lineNumber === line - 1); let changed = true; if (currentLine && prevLine && currentLine.scm && prevLine.scm) { - changed = currentLine.scm.author !== prevLine.scm.author || + changed = + currentLine.scm.author !== prevLine.scm.author || currentLine.scm.date !== prevLine.scm.date || !prevLine.show; } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js index 7b43f90609a..b25a1a27550 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js @@ -20,8 +20,8 @@ module.exports = function(currentLine, prevLine, options) { let changed = true; if (currentLine && prevLine && currentLine.scmAuthor && prevLine.scmAuthor) { - changed = currentLine.scmAuthor !== prevLine.scmAuthor || - currentLine.scmDate !== prevLine.scmDate; + changed = + currentLine.scmAuthor !== prevLine.scmAuthor || currentLine.scmDate !== prevLine.scmDate; } return changed ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js b/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js index 8cc4a8b6980..02d67f35097 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js @@ -21,7 +21,8 @@ import Handlebars from 'handlebars/runtime'; import { translate, translateWithParameters } from '../../helpers/l10n'; module.exports = function(severity) { - const label = `<i class="icon-severity-${severity.toLowerCase()}"></i>` + + const label = + `<i class="icon-severity-${severity.toLowerCase()}"></i>` + ` ${translate('severity', severity)}`; const message = translateWithParameters('quality_profiles.severity_set_to_x', label); return new Handlebars.default.SafeString(message); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js b/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js index 7de025a8701..5201239f86b 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js @@ -21,7 +21,8 @@ import Handlebars from 'handlebars/runtime'; import { translate } from '../../helpers/l10n'; module.exports = function(status, resolution) { - let s = `<i class="icon-status-${status.toLowerCase()}"></i>` + + let s = + `<i class="icon-status-${status.toLowerCase()}"></i>` + ` ${translate('issue.status', status)}`; if (resolution != null) { s = s + ' (' + translate('issue.resolution', resolution) + ')'; diff --git a/server/sonar-web/src/main/js/helpers/l10n.js b/server/sonar-web/src/main/js/helpers/l10n.js index 08832e67dd7..74a35b57f60 100644 --- a/server/sonar-web/src/main/js/helpers/l10n.js +++ b/server/sonar-web/src/main/js/helpers/l10n.js @@ -58,7 +58,8 @@ function makeRequest(params) { case 304: return JSON.parse(localStorage.getItem('l10n.bundle') || '{}'); case 401: - window.location = window.baseUrl + + window.location = + window.baseUrl + '/sessions/new?return_to=' + encodeURIComponent( window.location.pathname + window.location.search + window.location.hash diff --git a/server/sonar-web/src/main/js/helpers/scrolling.js b/server/sonar-web/src/main/js/helpers/scrolling.js index e0ee20ab024..60b89079ad5 100644 --- a/server/sonar-web/src/main/js/helpers/scrolling.js +++ b/server/sonar-web/src/main/js/helpers/scrolling.js @@ -42,24 +42,21 @@ let smoothScrollTop = (y: number, parent) => { const step = Math.ceil(Math.abs(y - scrollTop) / SCROLLING_STEPS); let stepsDone = 0; - const interval = setInterval( - () => { - const scrollTop = getScrollPosition(parent); - if (scrollTop === y || SCROLLING_STEPS === stepsDone) { - clearInterval(interval); + const interval = setInterval(() => { + const scrollTop = getScrollPosition(parent); + if (scrollTop === y || SCROLLING_STEPS === stepsDone) { + clearInterval(interval); + } else { + let goal; + if (scrollingDown) { + goal = Math.min(y, scrollTop + step); } else { - let goal; - if (scrollingDown) { - goal = Math.min(y, scrollTop + step); - } else { - goal = Math.max(y, scrollTop - step); - } - stepsDone++; - scrollElement(parent, goal); + goal = Math.max(y, scrollTop - step); } - }, - SCROLLING_INTERVAL - ); + stepsDone++; + scrollElement(parent, goal); + } + }, SCROLLING_INTERVAL); }; smoothScrollTop = debounce(smoothScrollTop, SCROLLING_DURATION, { leading: true }); diff --git a/server/sonar-web/src/main/js/store/globalMessages/duck.js b/server/sonar-web/src/main/js/store/globalMessages/duck.js index ff028db274d..b8a1c1fd3cc 100644 --- a/server/sonar-web/src/main/js/store/globalMessages/duck.js +++ b/server/sonar-web/src/main/js/store/globalMessages/duck.js @@ -57,12 +57,11 @@ export const closeAllGlobalMessages = (id: string) => ({ id }); -const addGlobalMessage = (message: string, level: Level) => - (dispatch: Function) => { - const id = uniqueId('global-message-'); - dispatch(addGlobalMessageActionCreator(id, message, level)); - setTimeout(() => dispatch(closeGlobalMessage(id)), 5000); - }; +const addGlobalMessage = (message: string, level: Level) => (dispatch: Function) => { + const id = uniqueId('global-message-'); + dispatch(addGlobalMessageActionCreator(id, message, level)); + setTimeout(() => dispatch(closeGlobalMessage(id)), 5000); +}; export const addGlobalErrorMessage = (message: string) => addGlobalMessage(message, ERROR); diff --git a/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js b/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js index d5906cf3965..d1ceb15087d 100644 --- a/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js +++ b/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js @@ -28,7 +28,7 @@ export const getOrganizationMembersLogins = (state, organization) => { }; export const getOrganizationMembersState = (state, organization) => - organization && state[organization] ? state[organization] : {}; + (organization && state[organization] ? state[organization] : {}); const organizationMembers = (state = {}, action = {}) => { const members = state.members || []; diff --git a/server/sonar-web/src/main/js/store/rootActions.js b/server/sonar-web/src/main/js/store/rootActions.js index 58685e5cb27..ec276c40f29 100644 --- a/server/sonar-web/src/main/js/store/rootActions.js +++ b/server/sonar-web/src/main/js/store/rootActions.js @@ -29,59 +29,54 @@ import { parseError } from '../apps/code/utils'; import { setAppState } from './appState/duck'; import { receiveOrganizations } from './organizations/duck'; -export const onFail = dispatch => - error => parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); +export const onFail = dispatch => error => + parseError(error).then(message => dispatch(addGlobalErrorMessage(message))); -export const fetchAppState = () => - dispatch => - getGlobalNavigation().then(appState => dispatch(setAppState(appState)), onFail(dispatch)); +export const fetchAppState = () => dispatch => + getGlobalNavigation().then(appState => dispatch(setAppState(appState)), onFail(dispatch)); -export const fetchLanguages = () => - dispatch => { - return getLanguages().then( - languages => dispatch(receiveLanguages(languages)), - onFail(dispatch) - ); - }; +export const fetchLanguages = () => dispatch => { + return getLanguages().then(languages => dispatch(receiveLanguages(languages)), onFail(dispatch)); +}; -export const fetchOrganizations = (organizations?: Array<string>) => - dispatch => - getOrganizations(organizations).then( - r => dispatch(receiveOrganizations(r.organizations)), - onFail(dispatch) - ); +export const fetchOrganizations = (organizations?: Array<string>) => dispatch => + getOrganizations(organizations).then( + r => dispatch(receiveOrganizations(r.organizations)), + onFail(dispatch) + ); const addQualifier = project => ({ ...project, qualifier: project.breadcrumbs[project.breadcrumbs.length - 1].qualifier }); -export const fetchProject = key => - dispatch => - Promise.all([getComponentNavigation(key), getComponentTags(key)]).then(([component, tags]) => { - component.tags = tags; - dispatch(receiveComponents([addQualifier(component)])); - if (component.organization != null) { - dispatch(fetchOrganizations([component.organization])); - } - }); +export const fetchProject = key => dispatch => + Promise.all([getComponentNavigation(key), getComponentTags(key)]).then(([component, tags]) => { + component.tags = tags; + dispatch(receiveComponents([addQualifier(component)])); + if (component.organization != null) { + dispatch(fetchOrganizations([component.organization])); + } + }); -export const doLogin = (login, password) => dispatch => auth.login(login, password).then( - () => { - /* everything is fine */ - }, - () => { - dispatch(addGlobalErrorMessage('Authentication failed')); - return Promise.reject(); - } - ); +export const doLogin = (login, password) => dispatch => + auth.login(login, password).then( + () => { + /* everything is fine */ + }, + () => { + dispatch(addGlobalErrorMessage('Authentication failed')); + return Promise.reject(); + } + ); -export const doLogout = () => dispatch => auth.logout().then( - () => { - /* everything is fine */ - }, - () => { - dispatch(addGlobalErrorMessage('Logout failed')); - return Promise.reject(); - } - ); +export const doLogout = () => dispatch => + auth.logout().then( + () => { + /* everything is fine */ + }, + () => { + dispatch(addGlobalErrorMessage('Logout failed')); + return Promise.reject(); + } + ); diff --git a/server/sonar-web/src/main/js/store/users/actions.js b/server/sonar-web/src/main/js/store/users/actions.js index a0331d053f1..0183deee9b0 100644 --- a/server/sonar-web/src/main/js/store/users/actions.js +++ b/server/sonar-web/src/main/js/store/users/actions.js @@ -32,5 +32,5 @@ export const receiveUser = user => ({ user }); -export const fetchCurrentUser = () => - dispatch => getCurrentUser().then(user => dispatch(receiveCurrentUser(user))); +export const fetchCurrentUser = () => dispatch => + getCurrentUser().then(user => dispatch(receiveCurrentUser(user))); diff --git a/server/sonar-web/src/main/js/store/utils/generalReducers.js b/server/sonar-web/src/main/js/store/utils/generalReducers.js index a95b2bfa5bb..ab56c98b9e8 100644 --- a/server/sonar-web/src/main/js/store/utils/generalReducers.js +++ b/server/sonar-web/src/main/js/store/utils/generalReducers.js @@ -35,16 +35,15 @@ export const createValue = ( shouldReset = () => false, getValue = (state, action) => action.payload, defaultValue = null -) => - (state = defaultValue, action = {}) => { - if (shouldReset(state, action)) { - return defaultValue; - } - if (shouldUpdate(state, action)) { - return getValue(state, action); - } - return state; - }; +) => (state = defaultValue, action = {}) => { + if (shouldReset(state, action)) { + return defaultValue; + } + if (shouldUpdate(state, action)) { + return getValue(state, action); + } + return state; +}; /** * Creates a reducer that manages a map. @@ -94,13 +93,15 @@ export const createSet = ( * @param {bool} defaultValue * @returns {function(state, action)} */ -export const createFlag = (shouldTurnOn, shouldTurnOff, defaultValue = false) => - (state = defaultValue, action = {}) => { - if (shouldTurnOn(state, action)) { - return true; - } - if (shouldTurnOff(state, action)) { - return false; - } - return state; - }; +export const createFlag = (shouldTurnOn, shouldTurnOff, defaultValue = false) => ( + state = defaultValue, + action = {} +) => { + if (shouldTurnOn(state, action)) { + return true; + } + if (shouldTurnOff(state, action)) { + return false; + } + return state; +}; |