diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-08-29 13:05:49 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-09-13 13:53:58 +0200 |
commit | 361d9c3e6c2f2dbf10b1412789bed2095f25edcc (patch) | |
tree | 532480cb28ec553e89b9fe9d53dd001f8a68dc58 /server/sonar-web/src/main/js/components/shared | |
parent | 77bd653967bee376b0e3ff3be0e6f7a5be32699e (diff) | |
download | sonarqube-361d9c3e6c2f2dbf10b1412789bed2095f25edcc.tar.gz sonarqube-361d9c3e6c2f2dbf10b1412789bed2095f25edcc.zip |
rewrite projects app
Diffstat (limited to 'server/sonar-web/src/main/js/components/shared')
-rw-r--r-- | server/sonar-web/src/main/js/components/shared/Organization.tsx (renamed from server/sonar-web/src/main/js/components/shared/Organization.js) | 72 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/components/shared/__tests__/Organization-test.tsx (renamed from server/sonar-web/src/main/js/components/shared/__tests__/Organization-test.js) | 2 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/components/shared/__tests__/__snapshots__/Organization-test.tsx.snap (renamed from server/sonar-web/src/main/js/components/shared/__tests__/__snapshots__/Organization-test.js.snap) | 0 |
3 files changed, 30 insertions, 44 deletions
diff --git a/server/sonar-web/src/main/js/components/shared/Organization.js b/server/sonar-web/src/main/js/components/shared/Organization.tsx index 1c3d5abf574..f411de59496 100644 --- a/server/sonar-web/src/main/js/components/shared/Organization.js +++ b/server/sonar-web/src/main/js/components/shared/Organization.tsx @@ -17,62 +17,48 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import { connect } from 'react-redux'; import { getOrganizationByKey, areThereCustomOrganizations } from '../../store/rootReducer'; import OrganizationLink from '../ui/OrganizationLink'; -/*:: -type OwnProps = { - organizationKey: string -}; -*/ - -/*:: -type Props = { - link?: boolean, - linkClassName?: string, - organizationKey: string, - organization: { key: string, name: string } | null, - shouldBeDisplayed: boolean -}; -*/ - -class Organization extends React.PureComponent { - /*:: props: Props; */ - - static defaultProps = { - link: true - }; +interface OwnProps { + organizationKey: string; +} - render() { - const { organization, shouldBeDisplayed } = this.props; +interface Props { + link?: boolean; + linkClassName?: string; + organization: { key: string; name: string } | null; + shouldBeDisplayed: boolean; +} - if (!shouldBeDisplayed || !organization) { - return null; - } +function Organization(props: Props) { + const { link = true, organization, shouldBeDisplayed } = props; - return ( - <span> - {this.props.link ? ( - <OrganizationLink className={this.props.linkClassName} organization={organization}> - {organization.name} - </OrganizationLink> - ) : ( - organization.name - )} - <span className="slash-separator" /> - </span> - ); + if (!shouldBeDisplayed || !organization) { + return null; } + + return ( + <span> + {link ? ( + <OrganizationLink className={props.linkClassName} organization={organization}> + {organization.name} + </OrganizationLink> + ) : ( + organization.name + )} + <span className="slash-separator" /> + </span> + ); } -const mapStateToProps = (state, ownProps /*: OwnProps */) => ({ +const mapStateToProps = (state: any, ownProps: OwnProps) => ({ organization: getOrganizationByKey(state, ownProps.organizationKey), shouldBeDisplayed: areThereCustomOrganizations(state) }); -export default connect(mapStateToProps)(Organization); +export default connect<any, any, any>(mapStateToProps)(Organization); export const UnconnectedOrganization = Organization; diff --git a/server/sonar-web/src/main/js/components/shared/__tests__/Organization-test.js b/server/sonar-web/src/main/js/components/shared/__tests__/Organization-test.tsx index 7bb6ae80476..34f6ace01b2 100644 --- a/server/sonar-web/src/main/js/components/shared/__tests__/Organization-test.js +++ b/server/sonar-web/src/main/js/components/shared/__tests__/Organization-test.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React from 'react'; +import * as React from 'react'; import { shallow } from 'enzyme'; import { UnconnectedOrganization } from '../Organization'; diff --git a/server/sonar-web/src/main/js/components/shared/__tests__/__snapshots__/Organization-test.js.snap b/server/sonar-web/src/main/js/components/shared/__tests__/__snapshots__/Organization-test.tsx.snap index 72ffd1b6d84..72ffd1b6d84 100644 --- a/server/sonar-web/src/main/js/components/shared/__tests__/__snapshots__/Organization-test.js.snap +++ b/server/sonar-web/src/main/js/components/shared/__tests__/__snapshots__/Organization-test.tsx.snap |