diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-12-05 17:32:18 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-12-05 20:20:59 +0100 |
commit | 41c98779d38bda9fdfdca182a5f20c73fcff9a84 (patch) | |
tree | d895a9f8bfd0276aee5ffacf7bb33a0109436cbd /server/sonar-web/src/main/js/apps/organizationMembers | |
parent | a9c22c1185c5fd8c8dc4c9388f4a3b967e3f463d (diff) | |
download | sonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.tar.gz sonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.zip |
create global type definitions (#1017)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/organizationMembers')
8 files changed, 36 insertions, 41 deletions
diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx index 2617234955e..f5d802f3e63 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx @@ -23,17 +23,16 @@ import { searchMembers } from '../../api/organizations'; import Modal from '../../components/controls/Modal'; import { translate } from '../../helpers/l10n'; import { SubmitButton, ResetButtonLink, Button } from '../../components/ui/buttons'; -import { Organization, OrganizationMember } from '../../app/types'; interface Props { - addMember: (member: OrganizationMember) => void; - organization: Organization; + addMember: (member: T.OrganizationMember) => void; + organization: T.Organization; memberLogins: string[]; } interface State { open: boolean; - selectedMember?: OrganizationMember; + selectedMember?: T.OrganizationMember; } export default class AddMemberForm extends React.PureComponent<Props, State> { @@ -65,7 +64,7 @@ export default class AddMemberForm extends React.PureComponent<Props, State> { } }; - selectedMemberChange = (member: OrganizationMember) => { + selectedMemberChange = (member: T.OrganizationMember) => { this.setState({ selectedMember: member }); }; diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx index 6d92e7fce8b..132bab70289 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx @@ -24,14 +24,13 @@ import Modal from '../../components/controls/Modal'; import { translate, translateWithParameters } from '../../helpers/l10n'; import OrganizationGroupCheckbox from '../organizations/components/OrganizationGroupCheckbox'; import { SubmitButton, ResetButtonLink } from '../../components/ui/buttons'; -import { Organization, OrganizationMember, Group } from '../../app/types'; interface Props { onClose: () => void; - member: OrganizationMember; - organization: Organization; - organizationGroups: Group[]; - updateMemberGroups: (member: OrganizationMember, add: string[], remove: string[]) => void; + member: T.OrganizationMember; + organization: T.Organization; + organizationGroups: T.Group[]; + updateMemberGroups: (member: T.OrganizationMember, add: string[], remove: string[]) => void; } interface State { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx index 676478bbbff..ae87c282014 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx @@ -20,16 +20,15 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import MembersListItem from './MembersListItem'; -import { Group, Organization, OrganizationMember } from '../../app/types'; import { translate } from '../../helpers/l10n'; interface Props { - members: OrganizationMember[]; - organizationGroups: Group[]; - organization: Organization; - removeMember: (member: OrganizationMember) => void; + members: T.OrganizationMember[]; + organizationGroups: T.Group[]; + organization: T.Organization; + removeMember: (member: T.OrganizationMember) => void; updateMemberGroups: ( - member: OrganizationMember, + member: T.OrganizationMember, add: Array<string>, remove: Array<string> ) => void; diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx index 4b586b366d9..75c43550d7c 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx @@ -27,14 +27,13 @@ import ActionsDropdown, { ActionsDropdownDivider, ActionsDropdownItem } from '../../components/controls/ActionsDropdown'; -import { Group, Organization, OrganizationMember } from '../../app/types'; interface Props { - member: OrganizationMember; - organization: Organization; - organizationGroups: Group[]; - removeMember: (member: OrganizationMember) => void; - updateMemberGroups: (member: OrganizationMember, add: string[], remove: string[]) => void; + member: T.OrganizationMember; + organization: T.Organization; + organizationGroups: T.Group[]; + removeMember: (member: T.OrganizationMember) => void; + updateMemberGroups: (member: T.OrganizationMember, add: string[], remove: string[]) => void; } interface State { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx index 1769a76333a..ab567cda6b7 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx @@ -27,19 +27,18 @@ import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import ListFooter from '../../components/controls/ListFooter'; import DocTooltip from '../../components/docs/DocTooltip'; import { translate } from '../../helpers/l10n'; -import { Group, Organization, OrganizationMember, Paging } from '../../app/types'; import { searchMembers, addMember, removeMember } from '../../api/organizations'; import { searchUsersGroups, addUserToGroup, removeUserFromGroup } from '../../api/user_groups'; interface Props { - organization: Organization; + organization: T.Organization; } interface State { - groups: Group[]; + groups: T.Group[]; loading: boolean; - members?: OrganizationMember[]; - paging?: Paging; + members?: T.OrganizationMember[]; + paging?: T.Paging; query: string; } @@ -123,7 +122,7 @@ export default class OrganizationMembers extends React.PureComponent<Props, Stat }, this.stopLoading); }; - handleAddMember = ({ login }: OrganizationMember) => { + handleAddMember = ({ login }: T.OrganizationMember) => { // TODO optimistic update addMember({ login, organization: this.props.organization.key }).then( member => { @@ -138,7 +137,7 @@ export default class OrganizationMembers extends React.PureComponent<Props, Stat ); }; - handleRemoveMember = ({ login }: OrganizationMember) => { + handleRemoveMember = ({ login }: T.OrganizationMember) => { // TODO optimistic update removeMember({ login, organization: this.props.organization.key }).then( () => { @@ -153,13 +152,16 @@ export default class OrganizationMembers extends React.PureComponent<Props, Stat ); }; - updateGroup = (login: string, updater: (member: OrganizationMember) => OrganizationMember) => { + updateGroup = ( + login: string, + updater: (member: T.OrganizationMember) => T.OrganizationMember + ) => { this.setState(({ members }) => ({ members: members && members.map(member => (member.login === login ? updater(member) : member)) })); }; - updateMemberGroups = ({ login }: OrganizationMember, add: string[], remove: string[]) => { + updateMemberGroups = ({ login }: T.OrganizationMember, add: string[], remove: string[]) => { // TODO optimistic update const promises = [ ...add.map(name => diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx index c2b0821b83e..86db8266dc3 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx @@ -19,7 +19,6 @@ */ import { connect } from 'react-redux'; import OrganizationMembers from './OrganizationMembers'; -import { Organization } from '../../app/types'; import { getOrganizationByKey, Store } from '../../store/rootReducer'; interface OwnProps { @@ -27,7 +26,7 @@ interface OwnProps { } interface StateProps { - organization: Organization; + organization: T.Organization; } const mapStateToProps = (state: Store, ownProps: OwnProps): StateProps => { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx index 636ae892a31..ec6494d4fbc 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import Modal from '../../components/controls/Modal'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { SubmitButton, ResetButtonLink } from '../../components/ui/buttons'; -import { Organization, OrganizationMember } from '../../app/types'; interface Props { onClose: () => void; - member: OrganizationMember; - organization: Organization; - removeMember: (member: OrganizationMember) => void; + member: T.OrganizationMember; + organization: T.Organization; + removeMember: (member: T.OrganizationMember) => void; } export default class RemoveMemberForm extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx index 429e6d34767..b99236cd1a0 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx @@ -23,7 +23,6 @@ import OrganizationMembers from '../OrganizationMembers'; import { waitAndUpdate } from '../../../helpers/testUtils'; import { searchMembers, addMember, removeMember } from '../../../api/organizations'; import { searchUsersGroups, addUserToGroup, removeUserFromGroup } from '../../../api/user_groups'; -import { OrganizationMember } from '../../../app/types'; jest.mock('../../../api/organizations', () => ({ addMember: jest.fn().mockResolvedValue({ login: 'bar', name: 'Bar', groupCount: 1 }), @@ -103,7 +102,7 @@ it('should add new member', async () => { expect( wrapper .find('MembersList') - .prop<OrganizationMember[]>('members') + .prop<T.OrganizationMember[]>('members') .find(m => m.login === 'bar') ).toBeDefined(); expect(wrapper.find('ListFooter').prop('total')).toEqual(4); @@ -120,7 +119,7 @@ it('should remove member', async () => { expect( wrapper .find('MembersList') - .prop<OrganizationMember[]>('members') + .prop<T.OrganizationMember[]>('members') .find(m => m.login === 'john') ).toBeUndefined(); expect(wrapper.find('ListFooter').prop('total')).toEqual(2); @@ -140,7 +139,7 @@ it('should update groups', async () => { await waitAndUpdate(wrapper); const john = wrapper .find('MembersList') - .prop<OrganizationMember[]>('members') + .prop<T.OrganizationMember[]>('members') .find(m => m.login === 'john'); expect(john && john.groupCount).toBe(2); expect(addUserToGroup).toHaveBeenCalledTimes(2); |