diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-08-14 15:15:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-14 15:15:26 +0200 |
commit | 90306cb436e4fadceda6c106adc407618674f0d0 (patch) | |
tree | 4884373f2827b3fb59adb4516aa63bc4c4b1ae47 /server/sonar-web/src/main/js/apps/quality-profiles | |
parent | ffff02cbed3e5f94bbf0c1718425d66e19ac3901 (diff) | |
download | sonarqube-90306cb436e4fadceda6c106adc407618674f0d0.tar.gz sonarqube-90306cb436e4fadceda6c106adc407618674f0d0.zip |
comment flow annotations (#2335)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles')
45 files changed, 295 insertions, 166 deletions
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 01ae2464b8e..7eeb76ee8f8 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 @@ -25,6 +25,7 @@ import ChangesList from './ChangesList'; import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; +/*:: type Props = { events: Array<{ action: string, @@ -36,9 +37,10 @@ type Props = { }>, organization: ?string }; +*/ export default class Changelog extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { let isEvenRow = false; 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 d7088601445..6bca8f58b0f 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 @@ -26,8 +26,9 @@ import ChangelogEmpty from './ChangelogEmpty'; import { getProfileChangelog } from '../../../api/quality-profiles'; import { translate } from '../../../helpers/l10n'; import { getProfileChangelogPath } from '../utils'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { location: { query: { @@ -38,23 +39,26 @@ type Props = { organization: ?string, profile: Profile }; +*/ +/*:: type State = { events?: Array<*>, loading: boolean, page?: number, total?: number }; +*/ export default class ChangelogContainer extends React.PureComponent { - mounted: boolean; - props: Props; + /*:: mounted: boolean; */ + /*:: props: Props; */ static contextTypes = { router: PropTypes.object }; - state: State = { + state /*: State */ = { loading: true }; @@ -63,7 +67,7 @@ export default class ChangelogContainer extends React.PureComponent { this.loadChangelog(); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.location !== this.props.location) { this.loadChangelog(); } @@ -76,7 +80,7 @@ export default class ChangelogContainer extends React.PureComponent { loadChangelog() { this.setState({ loading: true }); const { query } = this.props.location; - const data: Object = { profileKey: this.props.profile.key }; + const data /*: Object */ = { profileKey: this.props.profile.key }; if (query.since) { data.since = query.since; } @@ -96,13 +100,13 @@ export default class ChangelogContainer extends React.PureComponent { }); } - loadMore(e: SyntheticInputEvent) { + loadMore(e /*: SyntheticInputEvent */) { e.preventDefault(); e.target.blur(); this.setState({ loading: true }); const { query } = this.props.location; - const data: Object = { + const data /*: Object */ = { profileKey: this.props.profile.key, p: this.state.page + 1 }; @@ -125,7 +129,7 @@ export default class ChangelogContainer extends React.PureComponent { }); } - handleFromDateChange = (fromDate?: string) => { + handleFromDateChange = (fromDate /*: string | void */) => { const path = getProfileChangelogPath( this.props.profile.name, this.props.profile.language, @@ -138,7 +142,7 @@ export default class ChangelogContainer extends React.PureComponent { this.context.router.push(path); }; - handleToDateChange = (toDate?: string) => { + handleToDateChange = (toDate /*: string | void */) => { const path = getProfileChangelogPath( this.props.profile.name, this.props.profile.language, diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.js index 89d2099a229..c0abdb0155a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.js @@ -22,6 +22,7 @@ import React from 'react'; import DateInput from '../../../components/controls/DateInput'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { fromDate?: string, toDate?: string, @@ -29,11 +30,12 @@ type Props = { onReset: () => void, onToDateChange: () => void }; +*/ export default class ChangelogSearch extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleResetClick(e: SyntheticInputEvent) { + handleResetClick(e /*: SyntheticInputEvent */) { e.preventDefault(); e.target.blur(); this.props.onReset(); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.js index f905a86df53..c910ebb54ab 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.js @@ -22,12 +22,14 @@ import React from 'react'; import SeverityChange from './SeverityChange'; import ParameterChange from './ParameterChange'; +/*:: type Props = { changes: { [string]: ?string } }; +*/ export default class ChangesList extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { const { changes } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js index d4e01d55b72..9ee9d2bd80f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js @@ -21,13 +21,15 @@ import React from 'react'; import { translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { name: string, value: ?string }; +*/ export default class ParameterChange extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { const { name, value } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.js index d1ead07091a..546c46610c2 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.js @@ -22,12 +22,14 @@ import React from 'react'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { severity: ?string }; +*/ export default class SeverityChange extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { return ( diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.js index a7258bce199..718d80dcc3d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.js @@ -24,15 +24,18 @@ import ComparisonForm from './ComparisonForm'; import ComparisonResults from './ComparisonResults'; import { compareProfiles } from '../../../api/quality-profiles'; import { getProfileComparePath } from '../utils'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { location: { query: { withKey?: string } }, organization: ?string, profile: Profile, profiles: Array<Profile> }; +*/ +/*:: type State = { loading: boolean, left?: { name: string }, @@ -41,17 +44,18 @@ type State = { inRight?: Array<*>, modified?: Array<*> }; +*/ export default class ComparisonContainer extends React.PureComponent { - mounted: boolean; - props: Props; - state: State; + /*:: mounted: boolean; */ + /*:: props: Props; */ + /*:: state: State; */ static contextTypes = { router: PropTypes.object }; - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = { loading: false }; } @@ -61,7 +65,7 @@ export default class ComparisonContainer extends React.PureComponent { this.loadResults(); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.profile !== this.props.profile || prevProps.location !== this.props.location) { this.loadResults(); } @@ -93,7 +97,7 @@ export default class ComparisonContainer extends React.PureComponent { }); } - handleCompare = (withKey: string) => { + handleCompare = (withKey /*: string */) => { const path = getProfileComparePath( this.props.profile.name, this.props.profile.language, 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 4f3d4870fea..c0a0086f006 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 @@ -21,19 +21,21 @@ import React from 'react'; import Select from 'react-select'; import { translate } from '../../../helpers/l10n'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { profile: Profile, profiles: Array<Profile>, onCompare: string => void, withKey: string }; +*/ export default class ComparisonForm extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleChange(option: { value: string }) { + handleChange(option /*: { value: string } */) { this.props.onCompare(option.value); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.js index 208346cc636..b13c88ecace 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.js @@ -25,8 +25,11 @@ import SeverityIcon from '../../../components/shared/SeverityIcon'; import { translateWithParameters } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; +/*:: type Params = { [string]: string }; +*/ +/*:: type Props = { left: { name: string }, right: { name: string }, @@ -35,11 +38,12 @@ type Props = { modified: Array<*>, organization: ?string }; +*/ export default class ComparisonResults extends React.PureComponent { - props: Props; + /*:: props: Props; */ - renderRule(rule: { key: string, name: string }, severity: string) { + renderRule(rule /*: { key: string, name: string } */, severity /*: string */) { return ( <div> <SeverityIcon severity={severity} />{' '} @@ -48,7 +52,7 @@ export default class ComparisonResults extends React.PureComponent { ); } - renderParameters(params: Params) { + renderParameters(params /*: Params */) { if (!params) { return null; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.js index 81cb730053a..b0f80ee623b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.js @@ -23,9 +23,10 @@ import { searchQualityProfiles, getExporters } from '../../../api/quality-profil import { sortProfiles } from '../utils'; import { translate } from '../../../helpers/l10n'; import OrganizationHelmet from '../../../components/common/OrganizationHelmet'; -import type { Exporter } from '../propTypes'; +/*:: import type { Exporter } from '../propTypes'; */ import '../styles.css'; +/*:: type Props = { children: React.Element<*>, currentUser: { permissions: { global: Array<string> } }, @@ -33,17 +34,20 @@ type Props = { onRequestFail: Object => void, organization: { name: string, canAdmin?: boolean, key: string } | null }; +*/ +/*:: type State = { loading: boolean, exporters?: Array<Exporter>, profiles?: Array<*> }; +*/ export default class App extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { loading: true }; + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { loading: true }; componentWillMount() { const html = document.querySelector('html'); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js index 1e85d72c473..fa2e1635620 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js @@ -23,12 +23,14 @@ import classNames from 'classnames'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = {| className?: string, tooltip?: boolean |}; +*/ -export default function BuiltInBadge(props: Props) { +export default function BuiltInBadge(props /*: Props */) { const badge = ( <div className={classNames('outline-badge', props.className)}> {translate('quality_profiles.built_in')} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.js index ca7cf6363e3..4ad268e4982 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.js @@ -20,26 +20,30 @@ // @flow import React from 'react'; import Modal from 'react-modal'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ import { copyProfile } from '../../../api/quality-profiles'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { onClose: () => void, onCopy: string => void, onRequestFail: Object => void, profile: Profile }; +*/ +/*:: type State = { loading: boolean, name: ?string }; +*/ export default class CopyProfileForm extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { loading: false, name: null }; + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { loading: false, name: null }; componentDidMount() { this.mounted = true; @@ -49,16 +53,16 @@ export default class CopyProfileForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event: Event) => { + handleCancelClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; - handleNameChange = (event: { currentTarget: HTMLInputElement }) => { + handleNameChange = (event /*: { currentTarget: HTMLInputElement } */) => { this.setState({ name: event.currentTarget.value }); }; - handleFormSubmit = (event: Event) => { + handleFormSubmit = (event /*: Event */) => { event.preventDefault(); const { name } = this.state; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.js index d83588a3baa..975ca0a32db 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.js @@ -20,25 +20,29 @@ // @flow import React from 'react'; import Modal from 'react-modal'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ import { deleteProfile } from '../../../api/quality-profiles'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { onClose: () => void, onDelete: () => void, onRequestFail: Object => void, profile: Profile }; +*/ +/*:: type State = { loading: boolean }; +*/ export default class DeleteProfileForm extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { loading: false, name: null }; + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { loading: false, name: null }; componentDidMount() { this.mounted = true; @@ -48,12 +52,12 @@ export default class DeleteProfileForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event: Event) => { + handleCancelClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; - handleFormSubmit = (event: Event) => { + handleFormSubmit = (event /*: Event */) => { event.preventDefault(); this.setState({ loading: true }); deleteProfile(this.props.profile.key).then(this.props.onDelete, error => { 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 723a283b51c..8a2b2f805f0 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 @@ -28,8 +28,9 @@ import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; import { setDefaultProfile } from '../../../api/quality-profiles'; import { getProfilePath, getProfileComparePath, getProfilesPath } from '../utils'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, fromList: boolean, @@ -38,16 +39,19 @@ type Props = { profile: Profile, updateProfiles: () => Promise<*> }; +*/ +/*:: type State = { copyFormOpen: boolean, deleteFormOpen: boolean, renameFormOpen: boolean }; +*/ export default class ProfileActions extends React.PureComponent { - props: Props; - state: State; + /*:: props: Props; */ + /*:: state: State; */ static defaultProps = { fromList: false @@ -57,7 +61,7 @@ export default class ProfileActions extends React.PureComponent { router: PropTypes.object }; - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = { copyFormOpen: false, @@ -66,12 +70,12 @@ export default class ProfileActions extends React.PureComponent { }; } - handleRenameClick = (event: Event) => { + handleRenameClick = (event /*: Event */) => { event.preventDefault(); this.setState({ renameFormOpen: true }); }; - handleProfileRename = (name: string) => { + handleProfileRename = (name /*: string */) => { this.closeRenameForm(); this.props.updateProfiles().then(() => { if (!this.props.fromList) { @@ -86,12 +90,12 @@ export default class ProfileActions extends React.PureComponent { this.setState({ renameFormOpen: false }); }; - handleCopyClick = (event: Event) => { + handleCopyClick = (event /*: Event */) => { event.preventDefault(); this.setState({ copyFormOpen: true }); }; - handleProfileCopy = (name: string) => { + handleProfileCopy = (name /*: string */) => { this.props.updateProfiles().then(() => { this.context.router.push( getProfilePath(name, this.props.profile.language, this.props.organization) @@ -103,12 +107,12 @@ export default class ProfileActions extends React.PureComponent { this.setState({ copyFormOpen: false }); }; - handleSetDefaultClick = (e: SyntheticInputEvent) => { + handleSetDefaultClick = (e /*: SyntheticInputEvent */) => { e.preventDefault(); setDefaultProfile(this.props.profile.key).then(this.props.updateProfiles); }; - handleDeleteClick = (event: Event) => { + handleDeleteClick = (event /*: Event */) => { event.preventDefault(); this.setState({ deleteFormOpen: true }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.js index 25ddb0e6391..f44f53c9e35 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.js @@ -22,8 +22,9 @@ import React from 'react'; import Helmet from 'react-helmet'; import ProfileNotFound from './ProfileNotFound'; import ProfileHeader from '../details/ProfileHeader'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, children: React.Element<*>, @@ -37,9 +38,10 @@ type Props = { router: { replace: ({}) => void }, updateProfiles: () => Promise<*> }; +*/ export default class ProfileContainer extends React.PureComponent { - props: Props; + /*:: props: Props; */ componentDidMount() { const { location, profiles, router } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.js index 67d3ad79a87..ae878a4ba6b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.js @@ -22,12 +22,14 @@ import React from 'react'; import moment from 'moment'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { date?: string }; +*/ export default class ProfileDate extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { const { date } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.js index 0eb92cb0105..2ff0534c108 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.js @@ -22,15 +22,17 @@ import React from 'react'; import { Link } from 'react-router'; import { getProfilePath } from '../utils'; +/*:: type Props = { children?: React.Element<*>, language: string, name: string, organization: ?string }; +*/ export default class ProfileLink extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { const { name, language, organization, children, ...other } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.js index 7401007841d..7dce1cc0ce1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.js @@ -23,12 +23,14 @@ import { IndexLink } from 'react-router'; import { translate } from '../../../helpers/l10n'; import { getProfilesPath } from '../utils'; +/*:: type Props = { organization: ?string }; +*/ export default class ProfileNotFound extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { return ( diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.js index a75ba8197ec..37d63394d21 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.js @@ -20,26 +20,30 @@ // @flow import React from 'react'; import Modal from 'react-modal'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ import { renameProfile } from '../../../api/quality-profiles'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { onClose: () => void, onRename: string => void, onRequestFail: Object => void, profile: Profile }; +*/ +/*:: type State = { loading: boolean, name: ?string }; +*/ export default class RenameProfileForm extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { loading: false, name: null }; + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { loading: false, name: null }; componentDidMount() { this.mounted = true; @@ -49,16 +53,16 @@ export default class RenameProfileForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event: Event) => { + handleCancelClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; - handleNameChange = (event: { currentTarget: HTMLInputElement }) => { + handleNameChange = (event /*: { currentTarget: HTMLInputElement } */) => { this.setState({ name: event.currentTarget.value }); }; - handleFormSubmit = (event: Event) => { + handleFormSubmit = (event /*: Event */) => { event.preventDefault(); const { name } = this.state; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.js index a14e64384b8..f7d019e63d8 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.js @@ -24,8 +24,9 @@ import Select from 'react-select'; import { sortBy } from 'lodash'; import { changeProfileParent } from '../../../api/quality-profiles'; import { translate } from '../../../helpers/l10n'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { onChange: () => void, onClose: () => void, @@ -33,16 +34,19 @@ type Props = { profile: Profile, profiles: Array<Profile> }; +*/ +/*:: type State = { loading: boolean, selected: ?string }; +*/ export default class ChangeParentForm extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { loading: false, selected: null }; @@ -55,16 +59,16 @@ export default class ChangeParentForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event: Event) => { + handleCancelClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; - handleSelectChange = (option: { value: string }) => { + handleSelectChange = (option /*: { value: string } */) => { this.setState({ selected: option.value }); }; - handleFormSubmit = (event: Event) => { + handleFormSubmit = (event /*: Event */) => { event.preventDefault(); const parent = this.state.selected; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.js index 821bb7c80e2..a3277635118 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.js @@ -21,21 +21,23 @@ import React from 'react'; import Modal from 'react-modal'; import escapeHtml from 'escape-html'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ import SelectList from '../../../components/SelectList'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { onClose: () => void, organization: ?string, profile: Profile }; +*/ export default class ChangeProjectsForm extends React.PureComponent { - container: HTMLElement; - props: Props; + /*:: container: HTMLElement; */ + /*:: props: Props; */ - handleCloseClick = (event: Event) => { + handleCloseClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js index 9417f4cf0c9..b157db49a68 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.js @@ -23,8 +23,9 @@ import ProfileRules from './ProfileRules'; import ProfileProjects from './ProfileProjects'; import ProfileInheritance from './ProfileInheritance'; import ProfileExporters from './ProfileExporters'; -import type { Profile, Exporter } from '../propTypes'; +/*:: import type { Profile, Exporter } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, exporters: Array<Exporter>, @@ -34,9 +35,10 @@ type Props = { profiles: Array<Profile>, updateProfiles: () => Promise<*> }; +*/ export default class ProfileDetails extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { return ( diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.js index 2d387eff92c..04f3c58df29 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.js @@ -21,22 +21,24 @@ import { stringify } from 'querystring'; import React from 'react'; import { translate } from '../../../helpers/l10n'; -import type { Profile, Exporter } from '../propTypes'; +/*:: import type { Profile, Exporter } from '../propTypes'; */ +/*:: type Props = { exporters: Array<Exporter>, organization: ?string, profile: Profile }; +*/ export default class ProfileExporters extends React.PureComponent { - props: Props; + /*:: props: Props; */ - getExportUrl(exporter: Exporter) { + getExportUrl(exporter /*: Exporter */) { const { organization, profile } = this.props; const path = '/api/qualityprofiles/export'; - const parameters: { [string]: string } = { + const parameters /*: { [string]: string } */ = { exporterKey: exporter.key, language: profile.language, name: profile.name diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js index 3f802ef13ee..f5691c5ccea 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.js @@ -31,8 +31,9 @@ import { getProfilesForLanguagePath, getProfileChangelogPath } from '../utils'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, onRequestFail: Object => void, @@ -40,9 +41,10 @@ type Props = { profile: Profile, updateProfiles: () => Promise<*> }; +*/ export default class ProfileHeader extends React.PureComponent { - props: Props; + /*:: props: Props; */ renderUpdateDate() { const { profile } = this.props; 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 d94b46b7680..9669bd0aa11 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 @@ -24,8 +24,9 @@ import ProfileInheritanceBox from './ProfileInheritanceBox'; import ChangeParentForm from './ChangeParentForm'; import { translate } from '../../../helpers/l10n'; import { getProfileInheritance } from '../../../api/quality-profiles'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, onRequestFail: Object => void, @@ -34,7 +35,9 @@ type Props = { profiles: Array<Profile>, updateProfiles: () => Promise<*> }; +*/ +/*:: type ProfileInheritanceDetails = { activeRuleCount: number, isBuiltIn: boolean, @@ -43,7 +46,9 @@ type ProfileInheritanceDetails = { name: string, overridingRuleCount?: number }; +*/ +/*:: type State = { ancestors?: Array<ProfileInheritanceDetails>, children?: Array<ProfileInheritanceDetails>, @@ -51,11 +56,12 @@ type State = { loading: boolean, profile?: ProfileInheritanceDetails }; +*/ export default class ProfileInheritance extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { formOpen: false, loading: true }; @@ -65,7 +71,7 @@ export default class ProfileInheritance extends React.PureComponent { this.loadData(); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.profile !== this.props.profile) { this.loadData(); } @@ -89,7 +95,7 @@ export default class ProfileInheritance extends React.PureComponent { }); } - handleChangeParentClick = (event: Event) => { + handleChangeParentClick = (event /*: Event */) => { event.preventDefault(); this.setState({ formOpen: true }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.js index 04a804cc869..1adf7c7322b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.js @@ -24,6 +24,7 @@ import BuiltInBadge from '../components/BuiltInBadge'; import Tooltip from '../../../components/controls/Tooltip'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = {| className?: string, depth: number, @@ -40,9 +41,10 @@ type Props = {| overridingRuleCount?: number } |}; +*/ export default class ProfileInheritanceBox extends React.PureComponent { - props: Props; + /*:: props: Props; */ static defaultProps = { displayLink: true diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.js index 0c59dec26be..984b7995b0f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.js @@ -24,26 +24,30 @@ import ChangeProjectsForm from './ChangeProjectsForm'; import QualifierIcon from '../../../components/shared/QualifierIcon'; import { getProfileProjects } from '../../../api/quality-profiles'; import { translate } from '../../../helpers/l10n'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, organization: ?string, profile: Profile, updateProfiles: () => Promise<*> }; +*/ +/*:: type State = { formOpen: boolean, loading: boolean, more?: boolean, projects: ?Array<*> }; +*/ export default class ProfileProjects extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { formOpen: false, loading: true, projects: null @@ -54,7 +58,7 @@ export default class ProfileProjects extends React.PureComponent { this.loadProjects(); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.profile !== this.props.profile) { this.loadProjects(); } @@ -81,7 +85,7 @@ export default class ProfileProjects extends React.PureComponent { }); } - handleChangeClick = (event: Event) => { + handleChangeClick = (event /*: Event */) => { event.preventDefault(); this.setState({ formOpen: true }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.js index fe68a8385d8..ceb3fbed7c1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.js @@ -29,16 +29,19 @@ import { searchRules, takeFacet } from '../../../api/rules'; import { getQualityProfiles } from '../../../api/quality-profiles'; import { getRulesUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ const TYPES = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; +/*:: type Props = { canAdmin: boolean, organization: ?string, profile: Profile }; +*/ +/*:: type State = { activatedTotal: ?number, activatedByType?: { [string]: ?{ val: string, count: ?number } }, @@ -47,11 +50,12 @@ type State = { loading: boolean, total: ?number }; +*/ export default class ProfileRules extends React.PureComponent { - mounted: boolean; - props: Props; - state: State = { + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { activatedTotal: null, activatedByType: keyBy(TYPES.map(t => ({ val: t, count: null })), 'val'), allByType: keyBy(TYPES.map(t => ({ val: t, count: null })), 'val'), @@ -65,7 +69,7 @@ export default class ProfileRules extends React.PureComponent { this.loadRules(); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.profile !== this.props.profile) { this.loadRules(); } @@ -123,13 +127,13 @@ export default class ProfileRules extends React.PureComponent { }); } - getRulesCountForType(type: string): ?number { + getRulesCountForType(type /*: string */) /*: ?number */ { return this.state.activatedByType && this.state.activatedByType[type] ? this.state.activatedByType[type].count : null; } - getRulesTotalForType(type: string): ?number { + getRulesTotalForType(type /*: string */) /*: ?number */ { return this.state.allByType && this.state.allByType[type] ? this.state.allByType[type].count : null; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.js index d50c81c227b..a74e0829787 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.js @@ -24,9 +24,11 @@ import Tooltip from '../../../components/controls/Tooltip'; import { getDeprecatedActiveRulesUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { activeDeprecatedRules: number, organization: ?string, profile: string }; +*/ -export default function ProfileRulesDeprecatedWarning(props: Props) { +export default function ProfileRulesDeprecatedWarning(props /*: Props */) { const url = getDeprecatedActiveRulesUrl({ qprofile: props.profile }, props.organization); return ( <div className="quality-profile-rules-deprecated clearfix"> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.js index e6e04e59627..a899b495348 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.js @@ -25,6 +25,7 @@ import { formatMeasure } from '../../../helpers/measures'; import { getRulesUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { count: ?number, organization: ?string, @@ -32,8 +33,9 @@ type Props = { total: ?number, type: string }; +*/ -export default function ProfileRulesRowOfType(props: Props) { +export default function ProfileRulesRowOfType(props /*: Props */) { const activeRulesUrl = getRulesUrl( { qprofile: props.qprofile, activation: 'true', types: props.type }, props.organization diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.js index f17bc2a8c86..1cb16d7623c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.js @@ -24,14 +24,16 @@ import { formatMeasure } from '../../../helpers/measures'; import { getRulesUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { count: ?number, organization: ?string, qprofile: string, total: ?number }; +*/ -export default function ProfileRulesRowTotal(props: Props) { +export default function ProfileRulesRowTotal(props /*: Props */) { const activeRulesUrl = getRulesUrl( { qprofile: props.qprofile, activation: 'true' }, props.organization diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js index 9dae0f2c518..1e4a4c27c46 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js @@ -24,6 +24,7 @@ import Tooltip from '../../../components/controls/Tooltip'; import { getRulesUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { language: string, organization: ?string, @@ -31,8 +32,9 @@ type Props = { sonarway: string, sonarWayMissingRules: number }; +*/ -export default function ProfileRulesSonarWayComparison(props: Props) { +export default function ProfileRulesSonarWayComparison(props /*: Props */) { const url = getRulesUrl( { qprofile: props.profile, diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.js index 895fc4ca6c4..d95984ce033 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.js @@ -25,6 +25,7 @@ import { sortBy } from 'lodash'; import { getImporters, createQualityProfile } from '../../../api/quality-profiles'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { languages: Array<{ key: string, name: string }>, onClose: () => void, @@ -32,7 +33,9 @@ type Props = { onRequestFail: Object => void, organization: ?string }; +*/ +/*:: type State = { importers: Array<{ key: string, languages: Array<string>, name: string }>, language?: string, @@ -40,12 +43,13 @@ type State = { name: string, preloading: boolean }; +*/ export default class CreateProfileForm extends React.PureComponent { - form: HTMLFormElement; - mounted: boolean; - props: Props; - state: State = { importers: [], loading: false, name: '', preloading: true }; + /*:: form: HTMLFormElement; */ + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { importers: [], loading: false, name: '', preloading: true }; componentDidMount() { this.mounted = true; @@ -64,20 +68,20 @@ export default class CreateProfileForm extends React.PureComponent { }); } - handleCancelClick = (event: Event) => { + handleCancelClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; - handleNameChange = (event: { currentTarget: HTMLInputElement }) => { + handleNameChange = (event /*: { currentTarget: HTMLInputElement } */) => { this.setState({ name: event.currentTarget.value }); }; - handleLanguageChange = (option: { value: string }) => { + handleLanguageChange = (option /*: { value: string } */) => { this.setState({ language: option.value }); }; - handleFormSubmit = (event: Event) => { + handleFormSubmit = (event /*: Event */) => { event.preventDefault(); this.setState({ loading: true }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.js index eca194a8209..4be28f3dd04 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.js @@ -22,15 +22,17 @@ import React from 'react'; import EvolutionDeprecated from './EvolutionDeprecated'; import EvolutionStagnant from './EvolutionStagnant'; import EvolutionRules from './EvolutionRules'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { organization: ?string, profiles: Array<Profile> }; +*/ export default class Evolution extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { const { organization, profiles } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.js index 239d492b8b8..a3eaef27bd2 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.js @@ -24,15 +24,17 @@ import { sortBy } from 'lodash'; import ProfileLink from '../components/ProfileLink'; import { getDeprecatedActiveRulesUrl } from '../../../helpers/urls'; import { translateWithParameters, translate } from '../../../helpers/l10n'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { organization: ?string, profiles: Array<Profile> }; +*/ export default class EvolutionDeprecated extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { const profilesWithDeprecations = this.props.profiles.filter( diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js index 54c74a6febd..042c04a73b6 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.js @@ -39,13 +39,15 @@ function parseRules(r) { }); } +/*:: type Props = { organization: ?string }; +*/ export default class EvolutionRules extends React.PureComponent { - mounted: boolean; - props: Props; + /*:: mounted: boolean; */ + /*:: props: Props; */ state = {}; componentDidMount() { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.js index 8e65b78868f..1eda4c0b8e3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.js @@ -23,15 +23,17 @@ import moment from 'moment'; import ProfileLink from '../components/ProfileLink'; import { translate } from '../../../helpers/l10n'; import { isStagnant } from '../utils'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { organization: ?string, profiles: Array<Profile> }; +*/ export default class EvolutionStagnant extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { // TODO filter built-in out diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.js index 70389154ed4..95f63d8cd4c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.js @@ -22,8 +22,9 @@ import React from 'react'; import PageHeader from './PageHeader'; import Evolution from './Evolution'; import ProfilesList from './ProfilesList'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, languages: Array<{ key: string, name: string }>, @@ -33,9 +34,10 @@ type Props = { profiles: Array<Profile>, updateProfiles: () => Promise<*> }; +*/ export default class HomeContainer extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { return ( diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.js index 734dbde494b..44ba30feeb7 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.js @@ -22,10 +22,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import CreateProfileForm from './CreateProfileForm'; import RestoreProfileForm from './RestoreProfileForm'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ import { getProfilePath } from '../utils'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { canAdmin: boolean, languages: Array<{ key: string, name: string }>, @@ -33,31 +34,34 @@ type Props = { organization: ?string, updateProfiles: () => Promise<*> }; +*/ +/*:: type State = { createFormOpen: boolean, restoreFormOpen: boolean }; +*/ export default class PageHeader extends React.PureComponent { - props: Props; + /*:: props: Props; */ static contextTypes = { router: PropTypes.object }; - state: State = { + state /*: State */ = { createFormOpen: false, restoreFormOpen: false }; - handleCreateClick = (event: Event & { currentTarget: HTMLButtonElement }) => { + handleCreateClick = (event /*: Event & { currentTarget: HTMLButtonElement } */) => { event.preventDefault(); event.currentTarget.blur(); this.setState({ createFormOpen: true }); }; - handleCreate = (profile: Profile) => { + handleCreate = (profile /*: Profile */) => { this.props.updateProfiles().then(() => { this.context.router.push( getProfilePath(profile.name, profile.language, this.props.organization) @@ -69,7 +73,7 @@ export default class PageHeader extends React.PureComponent { this.setState({ createFormOpen: false }); }; - handleRestoreClick = (event: Event) => { + handleRestoreClick = (event /*: Event */) => { event.preventDefault(); this.setState({ restoreFormOpen: true }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.js index baf66452149..b912a9662a5 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.js @@ -24,8 +24,9 @@ import ProfilesListRow from './ProfilesListRow'; import ProfilesListHeader from './ProfilesListHeader'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, languages: Array<{ key: string, name: string }>, @@ -35,11 +36,12 @@ type Props = { profiles: Array<Profile>, updateProfiles: () => Promise<*> }; +*/ export default class ProfilesList extends React.PureComponent { - props: Props; + /*:: props: Props; */ - renderProfiles(profiles: Array<Profile>) { + renderProfiles(profiles /*: Array<Profile> */) { return profiles.map(profile => <ProfilesListRow canAdmin={this.props.canAdmin} @@ -52,7 +54,7 @@ export default class ProfilesList extends React.PureComponent { ); } - renderHeader(languageKey: string, profilesCount: number) { + renderHeader(languageKey /*: string */, profilesCount /*: number */) { const language = this.props.languages.find(l => l.key === languageKey); if (!language) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.js index b05b6ff01c8..ab76d1a4df3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.js @@ -23,14 +23,16 @@ import { IndexLink } from 'react-router'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getProfilesPath, getProfilesForLanguagePath } from '../utils'; +/*:: type Props = { currentFilter?: string, languages: Array<{ key: string, name: string }>, organization: ?string }; +*/ export default class ProfilesListHeader extends React.PureComponent { - props: Props; + /*:: props: Props; */ renderFilterToggle() { const { languages, currentFilter } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js index afdebe740a4..f9d18056d2e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.js @@ -27,8 +27,9 @@ import BuiltInBadge from '../components/BuiltInBadge'; import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; import { isStagnant } from '../utils'; -import type { Profile } from '../propTypes'; +/*:: import type { Profile } from '../propTypes'; */ +/*:: type Props = { canAdmin: boolean, onRequestFail: Object => void, @@ -36,9 +37,10 @@ type Props = { profile: Profile, updateProfiles: () => Promise<*> }; +*/ export default class ProfilesListRow extends React.PureComponent { - props: Props; + /*:: props: Props; */ renderName() { const { profile } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.js index 973e2947bff..26411abb34c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.js @@ -23,25 +23,29 @@ import Modal from 'react-modal'; import { restoreQualityProfile } from '../../../api/quality-profiles'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { onClose: () => void, onRequestFail: Object => void, onRestore: Function, organization: ?string }; +*/ +/*:: type State = { loading: boolean, profile?: { name: string }, ruleFailures?: number, ruleSuccesses?: number }; +*/ export default class RestoreProfileForm extends React.PureComponent { - form: HTMLFormElement; - mounted: boolean; - props: Props; - state: State = { loading: false }; + /*:: form: HTMLFormElement; */ + /*:: mounted: boolean; */ + /*:: props: Props; */ + state /*: State */ = { loading: false }; componentDidMount() { this.mounted = true; @@ -51,12 +55,12 @@ export default class RestoreProfileForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event: Event) => { + handleCancelClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; - handleFormSubmit = (event: Event) => { + handleFormSubmit = (event /*: Event */) => { event.preventDefault(); this.setState({ loading: true }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js b/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js index bdc59bbecc0..dbf1364fca2 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js @@ -20,6 +20,7 @@ // @flow import { shape, string, number, bool, arrayOf } from 'prop-types'; +/*:: export type Profile = { key: string, name: string, @@ -39,12 +40,15 @@ export type Profile = { depth: number, childrenCount: number }; +*/ +/*:: export type Exporter = { key: string, name: string, languages: Array<string> }; +*/ export const ProfileType = shape({ key: string.isRequired, 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 a98b28b9acb..60ec46e6572 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 @@ -20,9 +20,9 @@ // @flow import { sortBy } from 'lodash'; import moment from 'moment'; -import type { Profile } from './propTypes'; +/*:: import type { Profile } from './propTypes'; */ -export function sortProfiles(profiles: Array<Profile>) { +export function sortProfiles(profiles /*: Array<Profile> */) { const result = []; const sorted = sortBy(profiles, 'name'); @@ -51,7 +51,7 @@ export function sortProfiles(profiles: Array<Profile>) { return result; } -export function createFakeProfile(overrides: {}) { +export function createFakeProfile(overrides /*: {} */) { return { key: 'key', name: 'name', @@ -66,30 +66,37 @@ export function createFakeProfile(overrides: {}) { }; } -export function isStagnant(profile: Profile) { +export function isStagnant(profile /*: Profile */) { return moment().diff(moment(profile.userUpdatedAt), 'years') >= 1; } -export const getProfilesPath = (organization: ?string) => +export const getProfilesPath = (organization /*: ?string */) => organization ? `/organizations/${organization}/quality_profiles` : '/profiles'; -export const getProfilesForLanguagePath = (language: string, organization: ?string) => ({ +export const getProfilesForLanguagePath = ( + language /*: string */, + organization /*: ?string */ +) => ({ pathname: getProfilesPath(organization), query: { language } }); -export const getProfilePath = (name: string, language: string, organization: ?string) => ({ +export const getProfilePath = ( + name /*: string */, + language /*: string */, + organization /*: ?string */ +) => ({ pathname: getProfilesPath(organization) + '/show', query: { name, language } }); export const getProfileComparePath = ( - name: string, - language: string, - organization: ?string, - withKey?: string + name /*: string */, + language /*: string */, + organization /*: ?string */, + withKey /*: ?string */ ) => { - const query: Object = { language, name }; + const query /*: Object */ = { language, name }; if (withKey) { Object.assign(query, { withKey }); } @@ -100,12 +107,12 @@ export const getProfileComparePath = ( }; export const getProfileChangelogPath = ( - name: string, - language: string, - organization: ?string, - filter?: { since?: string, to?: string } + name /*: string */, + language /*: string */, + organization /*: ?string */, + filter /*: ?{ since?: string, to?: string } */ ) => { - const query: Object = { language, name }; + const query /*: Object */ = { language, name }; if (filter) { if (filter.since) { Object.assign(query, { since: filter.since }); |