diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-04-20 11:10:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 11:10:13 +0200 |
commit | f6e90fdc19e222b3b238f0f5995a8039b7db158e (patch) | |
tree | 69c22415cb50a650b046ce4b9a9ac99e57695dfd /server/sonar-web/src/main/js/apps/issues | |
parent | 36c9fa041018d7eed91f1d22e0c5eda075737ebc (diff) | |
download | sonarqube-f6e90fdc19e222b3b238f0f5995a8039b7db158e.tar.gz sonarqube-f6e90fdc19e222b3b238f0f5995a8039b7db158e.zip |
upgrade prettier (#1954)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues')
17 files changed, 105 insertions, 107 deletions
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 - }))); + })) + ); }; |