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/permissions | |
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/permissions')
8 files changed, 79 insertions, 47 deletions
diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js index 231992c4b73..f340d7e27c1 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js @@ -112,11 +112,13 @@ const mapStateToProps = state => ({ selectedPermission: getPermissionsAppSelectedPermission(state) }); +/*:: type OwnProps = { organization?: { key: string } }; +*/ -const mapDispatchToProps = (dispatch: Function, ownProps: OwnProps) => { +const mapDispatchToProps = (dispatch /*: Function */, ownProps /*: OwnProps */) => { const organizationKey = ownProps.organization ? ownProps.organization.key : undefined; return { loadHolders: () => dispatch(loadHolders(organizationKey)), diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/App.js b/server/sonar-web/src/main/js/apps/permissions/global/components/App.js index da906b66606..4b7ea9f15e1 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/App.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/App.js @@ -26,7 +26,7 @@ import PageError from '../../shared/components/PageError'; import { translate } from '../../../../helpers/l10n'; import '../../styles.css'; -export default function App(props: { organization?: {} }) { +export default function App(props /*: { organization?: {} } */) { return ( <div className="page page-limited"> <Helmet title={translate('global_permissions.permission')} /> diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js index 933fbb7421e..940c1cb731b 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js @@ -23,10 +23,11 @@ import { translate } from '../../../../helpers/l10n'; import { isPermissionsAppLoading } from '../../../../store/rootReducer'; class PageHeader extends React.PureComponent { - props: { + /*:: props: { loading?: boolean, organization?: {} }; +*/ static defaultProps = { loading: false 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 19a153e8b4c..639097378a0 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,10 +38,17 @@ import { getPermissionsAppSelectedPermission } from '../../../../store/rootReducer'; +/*:: type Dispatch = Object => void; +*/ +/*:: type GetState = () => Object; +*/ -export const loadHolders = (organization?: string) => (dispatch: Dispatch, getState: GetState) => { +export const loadHolders = (organization /*: ?string */) => ( + dispatch /*: Dispatch */, + getState /*: GetState */ +) => { const query = getPermissionsAppQuery(getState()); const filter = getPermissionsAppFilter(getState()); const selectedPermission = getPermissionsAppSelectedPermission(getState()); @@ -76,21 +83,25 @@ export const loadHolders = (organization?: string) => (dispatch: Dispatch, getSt }); }; -export const updateQuery = (query: string = '', organization?: string) => (dispatch: Dispatch) => { +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 updateFilter = (filter: string, organization?: string) => (dispatch: Dispatch) => { +export const updateFilter = (filter /*: string */, organization /*: ?string */) => ( + dispatch /*: Dispatch */ +) => { dispatch({ type: UPDATE_FILTER, filter }); dispatch(loadHolders(organization)); }; -export const selectPermission = (permission: string, organization?: string) => ( - dispatch: Dispatch, - getState: GetState +export const selectPermission = (permission /*: string */, organization /*: ?string */) => ( + dispatch /*: Dispatch */, + getState /*: GetState */ ) => { const selectedPermission = getPermissionsAppSelectedPermission(getState()); if (selectedPermission !== permission) { @@ -101,9 +112,11 @@ export const selectPermission = (permission: string, organization?: string) => ( dispatch(loadHolders(organization)); }; -export const grantToUser = (login: string, permission: string, organization?: string) => ( - dispatch: Dispatch -) => { +export const grantToUser = ( + login /*: string */, + permission /*: string */, + organization /*: ?string */ +) => (dispatch /*: Dispatch */) => { api .grantPermissionToUser(null, login, permission, organization) .then(() => { @@ -114,9 +127,11 @@ export const grantToUser = (login: string, permission: string, organization?: st }); }; -export const revokeFromUser = (login: string, permission: string, organization?: string) => ( - dispatch: Dispatch -) => { +export const revokeFromUser = ( + login /*: string */, + permission /*: string */, + organization /*: ?string */ +) => (dispatch /*: Dispatch */) => { api .revokePermissionFromUser(null, login, permission, organization) .then(() => { @@ -127,9 +142,11 @@ export const revokeFromUser = (login: string, permission: string, organization?: }); }; -export const grantToGroup = (groupName: string, permission: string, organization?: string) => ( - dispatch: Dispatch -) => { +export const grantToGroup = ( + groupName /*: string */, + permission /*: string */, + organization /*: ?string */ +) => (dispatch /*: Dispatch */) => { api .grantPermissionToGroup(null, groupName, permission, organization) .then(() => { @@ -144,9 +161,11 @@ export const grantToGroup = (groupName: string, permission: string, organization }); }; -export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => ( - dispatch: Dispatch -) => { +export const revokeFromGroup = ( + groupName /*: string */, + permission /*: string */, + organization /*: ?string */ +) => (dispatch /*: Dispatch */) => { api .revokePermissionFromGroup(null, groupName, permission, organization) .then(() => { diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js index f91e5f9c39f..7cd6a7a54e0 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js @@ -25,6 +25,7 @@ import HoldersList from '../../shared/components/HoldersList'; import { translate } from '../../../../helpers/l10n'; import { PERMISSIONS_ORDER_BY_QUALIFIER } from '../constants'; +/*:: type Props = {| component: { configuration?: { @@ -57,11 +58,12 @@ type Props = {| permissions: Array<string> }> |}; +*/ export default class AllHoldersList extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleToggleUser = (user: Object, permission: string) => { + handleToggleUser = (user /*: Object */, permission /*: string */) => { const hasPermission = user.permissions.includes(permission); if (hasPermission) { @@ -71,7 +73,7 @@ export default class AllHoldersList extends React.PureComponent { } }; - handleToggleGroup = (group: Object, permission: string) => { + handleToggleGroup = (group /*: Object */, permission /*: string */) => { const hasPermission = group.permissions.includes(permission); if (hasPermission) { @@ -81,7 +83,7 @@ export default class AllHoldersList extends React.PureComponent { } }; - handleSelectPermission = (permission?: string) => { + handleSelectPermission = (permission /*: string | void */) => { this.props.onPermissionSelect(permission); }; diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js index 13d1290f721..c3e2fd8f5aa 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js @@ -31,6 +31,7 @@ import * as api from '../../../../api/permissions'; import { translate } from '../../../../helpers/l10n'; import '../../styles.css'; +/*:: export type Props = {| component: { configuration?: { @@ -46,7 +47,9 @@ export type Props = {| onComponentChange: (changes: {}) => void, onRequestFail: Object => void |}; +*/ +/*:: export type State = {| disclaimer: boolean, filter: string, @@ -63,13 +66,14 @@ export type State = {| permissions: Array<string> }> |}; +*/ export default class App extends React.PureComponent { - mounted: boolean; - props: Props; - state: State; + /*:: mounted: boolean; */ + /*:: props: Props; */ + /*:: state: State; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = { disclaimer: false, @@ -139,13 +143,13 @@ export default class App extends React.PureComponent { } }; - handleFilterChange = (filter: string) => { + handleFilterChange = (filter /*: string */) => { if (this.mounted) { this.setState({ filter }, this.loadHolders); } }; - handleQueryChange = (query: string) => { + handleQueryChange = (query /*: string */) => { if (this.mounted) { this.setState({ query }, () => { if (query.length === 0 || query.length > 2) { @@ -155,10 +159,10 @@ export default class App extends React.PureComponent { } }; - handlePermissionSelect = (selectedPermission?: string) => { + handlePermissionSelect = (selectedPermission /*: ?string */) => { if (this.mounted) { this.setState( - (state: State) => ({ + (state /*: State */) => ({ selectedPermission: state.selectedPermission === selectedPermission ? undefined : selectedPermission }), @@ -167,7 +171,7 @@ export default class App extends React.PureComponent { } }; - addPermissionToGroup = (group: string, permission: string) => + addPermissionToGroup = (group /*: string */, permission /*: string */) => this.state.groups.map( candidate => candidate.name === group @@ -175,7 +179,7 @@ export default class App extends React.PureComponent { : candidate ); - addPermissionToUser = (user: string, permission: string) => + addPermissionToUser = (user /*: string */, permission /*: string */) => this.state.users.map( candidate => candidate.login === user @@ -183,7 +187,7 @@ export default class App extends React.PureComponent { : candidate ); - removePermissionFromGroup = (group: string, permission: string) => + removePermissionFromGroup = (group /*: string */, permission /*: string */) => this.state.groups.map( candidate => candidate.name === group @@ -191,7 +195,7 @@ export default class App extends React.PureComponent { : candidate ); - removePermissionFromUser = (user: string, permission: string) => + removePermissionFromUser = (user /*: string */, permission /*: string */) => this.state.users.map( candidate => candidate.login === user @@ -199,7 +203,7 @@ export default class App extends React.PureComponent { : candidate ); - grantPermissionToGroup = (group: string, permission: string) => { + grantPermissionToGroup = (group /*: string */, permission /*: string */) => { if (this.mounted) { this.setState({ loading: true, groups: this.addPermissionToGroup(group, permission) }); api @@ -221,7 +225,7 @@ export default class App extends React.PureComponent { } }; - grantPermissionToUser = (user: string, permission: string) => { + grantPermissionToUser = (user /*: string */, permission /*: string */) => { if (this.mounted) { this.setState({ loading: true, users: this.addPermissionToUser(user, permission) }); api @@ -243,7 +247,7 @@ export default class App extends React.PureComponent { } }; - revokePermissionFromGroup = (group: string, permission: string) => { + revokePermissionFromGroup = (group /*: string */, permission /*: string */) => { if (this.mounted) { this.setState({ loading: true, groups: this.removePermissionFromGroup(group, permission) }); api @@ -265,7 +269,7 @@ export default class App extends React.PureComponent { } }; - revokePermissionFromUser = (user: string, permission: string) => { + revokePermissionFromUser = (user /*: string */, permission /*: string */) => { if (this.mounted) { this.setState({ loading: true, users: this.removePermissionFromUser(user, permission) }); api @@ -287,7 +291,7 @@ export default class App extends React.PureComponent { } }; - handleVisibilityChange = (visibility: string) => { + handleVisibilityChange = (visibility /*: string */) => { if (visibility === 'public') { this.openDisclaimer(); } else { 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 2cbe207fabb..62c5eff5ffb 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 @@ -22,6 +22,7 @@ import React from 'react'; import { translate } from '../../../../helpers/l10n'; import ApplyTemplateView from '../views/ApplyTemplateView'; +/*:: type Props = {| component: { configuration?: { @@ -35,11 +36,12 @@ type Props = {| loadHolders: () => void, loading: boolean |}; +*/ export default class PageHeader extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleApplyTemplate = (e: Event & { target: HTMLButtonElement }) => { + handleApplyTemplate = (e /*: Event & { target: HTMLButtonElement } */) => { e.preventDefault(); e.target.blur(); const { component, loadHolders } = this.props; diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PublicProjectDisclaimer.js b/server/sonar-web/src/main/js/apps/permissions/project/components/PublicProjectDisclaimer.js index ed5ee186b7b..b74b802b673 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PublicProjectDisclaimer.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PublicProjectDisclaimer.js @@ -22,6 +22,7 @@ import React from 'react'; import Modal from 'react-modal'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; +/*:: type Props = { component: { name: string @@ -29,16 +30,17 @@ type Props = { onClose: () => void, onConfirm: () => void }; +*/ export default class PublicProjectDisclaimer extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleCancelClick = (event: Event) => { + handleCancelClick = (event /*: Event */) => { event.preventDefault(); this.props.onClose(); }; - handleConfirmClick = (event: Event) => { + handleConfirmClick = (event /*: Event */) => { event.preventDefault(); this.props.onConfirm(); this.props.onClose(); |