diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-03-17 09:10:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-17 09:10:48 +0100 |
commit | de4365079bad2df3bdee2133576dc913ffbf1ab2 (patch) | |
tree | a522ccb952f0d37f454e8188e13b3dec3f731912 /server/sonar-web/src/main/js/apps/permissions/global | |
parent | 6a03df65cc0c91a26150ea172a2c480e07326ea1 (diff) | |
download | sonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.tar.gz sonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.zip |
format code using prettier (#1774)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/permissions/global')
4 files changed, 130 insertions, 129 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 d94862233a2..1748d6dda1e 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 @@ -41,26 +41,16 @@ import { getPermissionsAppSelectedPermission } from '../../../../store/rootReducer'; -const PERMISSIONS_ORDER = [ - 'admin', - 'profileadmin', - 'gateadmin', - 'scan', - 'provisioning' -]; - -const PERMISSIONS_FOR_CUSTOM_ORG = [ - 'admin', - 'scan', - 'provisioning' -]; +const PERMISSIONS_ORDER = ['admin', 'profileadmin', 'gateadmin', 'scan', 'provisioning']; + +const PERMISSIONS_FOR_CUSTOM_ORG = ['admin', 'scan', 'provisioning']; class AllHoldersList extends React.Component { - componentDidMount () { + componentDidMount() { this.props.loadHolders(); } - handleToggleUser (user, permission) { + handleToggleUser(user, permission) { const hasPermission = user.permissions.includes(permission); if (hasPermission) { @@ -70,7 +60,7 @@ class AllHoldersList extends React.Component { } } - handleToggleGroup (group, permission) { + handleToggleGroup(group, permission) { const hasPermission = group.permissions.includes(permission); if (hasPermission) { @@ -80,10 +70,10 @@ class AllHoldersList extends React.Component { } } - render () { - const order = (this.props.organization && !this.props.organization.isDefault) ? - PERMISSIONS_FOR_CUSTOM_ORG : - PERMISSIONS_ORDER; + render() { + const order = this.props.organization && !this.props.organization.isDefault + ? PERMISSIONS_FOR_CUSTOM_ORG + : PERMISSIONS_ORDER; const l10nPrefix = this.props.organization ? 'organizations_permissions' : 'global_permissions'; @@ -94,22 +84,24 @@ class AllHoldersList extends React.Component { })); return ( - <HoldersList - permissions={permissions} - selectedPermission={this.props.selectedPermission} - users={this.props.users} - groups={this.props.groups} - onSelectPermission={this.props.onSelectPermission} - onToggleUser={this.handleToggleUser.bind(this)} - onToggleGroup={this.handleToggleGroup.bind(this)}> - - <SearchForm - query={this.props.query} - filter={this.props.filter} - onSearch={this.props.onSearch} - onFilter={this.props.onFilter}/> - - </HoldersList> + <HoldersList + permissions={permissions} + selectedPermission={this.props.selectedPermission} + users={this.props.users} + groups={this.props.groups} + onSelectPermission={this.props.onSelectPermission} + onToggleUser={this.handleToggleUser.bind(this)} + onToggleGroup={this.handleToggleGroup.bind(this)} + > + + <SearchForm + query={this.props.query} + filter={this.props.filter} + onSearch={this.props.onSearch} + onFilter={this.props.onFilter} + /> + + </HoldersList> ); } } @@ -134,17 +126,14 @@ const mapDispatchToProps = (dispatch, ownProps: OwnProps) => { onFilter: filter => dispatch(updateFilter(filter, organizationKey)), onSelectPermission: permission => dispatch(selectPermission(permission, organizationKey)), grantPermissionToUser: (login, permission) => - dispatch(grantToUser(login, permission, organizationKey)), + dispatch(grantToUser(login, permission, organizationKey)), revokePermissionFromUser: (login, permission) => - dispatch(revokeFromUser(login, permission, organizationKey)), + dispatch(revokeFromUser(login, permission, organizationKey)), grantPermissionToGroup: (groupName, permission) => - dispatch(grantToGroup(groupName, permission, organizationKey)), + dispatch(grantToGroup(groupName, permission, organizationKey)), revokePermissionFromGroup: (groupName, permission) => - dispatch(revokeFromGroup(groupName, permission, organizationKey)) + dispatch(revokeFromGroup(groupName, permission, organizationKey)) }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(AllHoldersList); +export default connect(mapStateToProps, mapDispatchToProps)(AllHoldersList); 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 265d5029adf..f0ee0912120 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 @@ -31,13 +31,13 @@ export default class App extends React.Component { organization?: {} }; - render () { + render() { return ( - <div className="page page-limited"> - <PageHeader organization={this.props.organization}/> - <PageError/> - <AllHoldersList organization={this.props.organization}/> - </div> + <div className="page page-limited"> + <PageHeader organization={this.props.organization} /> + <PageError /> + <AllHoldersList organization={this.props.organization} /> + </div> ); } } 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 7d58a7b12f6..4475144a332 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 @@ -32,25 +32,23 @@ class PageHeader extends React.Component { loading: false }; - render () { - const title = this.props.organization ? - translate('permissions.page') : - translate('global_permissions.page'); + render() { + const title = this.props.organization + ? translate('permissions.page') + : translate('global_permissions.page'); - const description = this.props.organization ? - translate('organization_permissions.page.description') : - translate('global_permissions.page.description'); + const description = this.props.organization + ? translate('organization_permissions.page.description') + : translate('global_permissions.page.description'); return ( - <header className="page-header"> - <h1 className="page-title">{title}</h1> + <header className="page-header"> + <h1 className="page-title">{title}</h1> - {this.props.loading && ( - <i className="spinner"/> - )} + {this.props.loading && <i className="spinner" />} - <div className="page-description">{description}</div> - </header> + <div className="page-description">{description}</div> + </header> ); } } @@ -59,6 +57,4 @@ const mapStateToProps = state => ({ loading: isPermissionsAppLoading(state) }); -export default connect( - mapStateToProps -)(PageHeader); +export default connect(mapStateToProps)(PageHeader); 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 f4e42e77f1c..64c80c2b924 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 @@ -41,102 +41,118 @@ import { type Dispatch = (Object) => void; type GetState = () => Object; -export const loadHolders = (organization?: string) => (dispatch: Dispatch, getState: GetState) => { - const query = getPermissionsAppQuery(getState()); - const filter = getPermissionsAppFilter(getState()); - const selectedPermission = getPermissionsAppSelectedPermission(getState()); +export const loadHolders = (organization?: string) => + (dispatch: Dispatch, getState: GetState) => { + const query = getPermissionsAppQuery(getState()); + const filter = getPermissionsAppFilter(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); - dispatch({ type: REQUEST_HOLDERS, query }); + dispatch({ type: REQUEST_HOLDERS, query }); - const requests = []; + const requests = []; - if (filter !== 'groups') { - requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'groups') { + requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); + } else { + requests.push(Promise.resolve([])); + } - if (filter !== 'users') { - requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'users') { + requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); + } else { + requests.push(Promise.resolve([])); + } - return Promise.all(requests).then(responses => ( - dispatch({ - type: RECEIVE_HOLDERS_SUCCESS, - users: responses[0], - groups: responses[1], - query - }) - )).catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); -}; + return Promise.all(requests) + .then(responses => + dispatch({ + type: RECEIVE_HOLDERS_SUCCESS, + users: responses[0], + groups: responses[1], + query + })) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); + }; -export const updateQuery = (query: string = '', organization?: string) => (dispatch: Dispatch) => { - dispatch({ type: UPDATE_QUERY, query }); - if (query.length === 0 || query.length > 2) { - dispatch(loadHolders(organization)); - } -}; +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) => { - dispatch({ type: UPDATE_FILTER, filter }); - dispatch(loadHolders(organization)); -}; +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) => { - const selectedPermission = getPermissionsAppSelectedPermission(getState()); - if (selectedPermission !== permission) { - dispatch({ type: SELECT_PERMISSION, permission }); - } else { - dispatch({ type: SELECT_PERMISSION, permission: null }); - } - dispatch(loadHolders(organization)); - }; + (dispatch: Dispatch, getState: GetState) => { + const selectedPermission = getPermissionsAppSelectedPermission(getState()); + if (selectedPermission !== permission) { + dispatch({ type: SELECT_PERMISSION, permission }); + } else { + dispatch({ type: SELECT_PERMISSION, permission: null }); + } + dispatch(loadHolders(organization)); + }; export const grantToUser = (login: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api.grantPermissionToUser(null, login, permission, organization).then(() => { + (dispatch: Dispatch) => { + api + .grantPermissionToUser(null, login, permission, organization) + .then(() => { dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); - }).catch(e => { + }) + .catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); - }; + }; export const revokeFromUser = (login: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api.revokePermissionFromUser(null, login, permission, organization).then(() => { + (dispatch: Dispatch) => { + api + .revokePermissionFromUser(null, login, permission, organization) + .then(() => { dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); - }).catch(e => { + }) + .catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); - }; + }; export const grantToGroup = (groupName: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api.grantPermissionToGroup(null, groupName, permission, organization).then(() => { + (dispatch: Dispatch) => { + api + .grantPermissionToGroup(null, groupName, permission, organization) + .then(() => { dispatch({ type: GRANT_PERMISSION_TO_GROUP, groupName, permission }); - }).catch(e => { + }) + .catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); - }; + }; export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api.revokePermissionFromGroup(null, groupName, permission, organization).then(() => { + (dispatch: Dispatch) => { + api + .revokePermissionFromGroup(null, groupName, permission, organization) + .then(() => { dispatch({ type: REVOKE_PERMISSION_FROM_GROUP, groupName, permission }); - }).catch(e => { + }) + .catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); - }; + }; |