From d83e1ab9825c2c14256a6680bf44d75c13ea4d5a Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 16 Dec 2020 18:18:11 +0100 Subject: SONAR-13999 Drop frontend organizations leftovers --- .../__snapshots__/withNotifications-test.tsx.snap | 3 -- .../hoc/__tests__/withNotifications-test.tsx | 9 ++-- .../hoc/__tests__/withUserOrganizations-test.tsx | 51 --------------------- .../js/components/hoc/withUserOrganizations.tsx | 53 ---------------------- 4 files changed, 3 insertions(+), 113 deletions(-) delete mode 100644 server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx delete mode 100644 server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx (limited to 'server/sonar-web/src/main/js/components/hoc') diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/__snapshots__/withNotifications-test.tsx.snap b/server/sonar-web/src/main/js/components/hoc/__tests__/__snapshots__/withNotifications-test.tsx.snap index 4af5332cd6c..0307ad1d8ac 100644 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/__snapshots__/withNotifications-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/hoc/__tests__/__snapshots__/withNotifications-test.tsx.snap @@ -20,21 +20,18 @@ exports[`should fetch notifications and render 1`] = ` Array [ Object { "channel": "channel1", - "organization": "org", "project": "foo", "projectName": "Foo", "type": "type-global", }, Object { "channel": "channel1", - "organization": "org", "project": "bar", "projectName": "Bar", "type": "type-common", }, Object { "channel": "channel2", - "organization": "org", "project": "qux", "projectName": "Qux", "type": "type-common", diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/withNotifications-test.tsx b/server/sonar-web/src/main/js/components/hoc/__tests__/withNotifications-test.tsx index 7b5d0f79d22..0062f7108aa 100644 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/withNotifications-test.tsx +++ b/server/sonar-web/src/main/js/components/hoc/__tests__/withNotifications-test.tsx @@ -34,22 +34,19 @@ jest.mock('../../../api/notifications', () => ({ channel: 'channel1', type: 'type-global', project: 'foo', - projectName: 'Foo', - organization: 'org' + projectName: 'Foo' }, { channel: 'channel1', type: 'type-common', project: 'bar', - projectName: 'Bar', - organization: 'org' + projectName: 'Bar' }, { channel: 'channel2', type: 'type-common', project: 'qux', - projectName: 'Qux', - organization: 'org' + projectName: 'Qux' } ], perProjectTypes: ['type-common'] diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx b/server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx deleted file mode 100644 index 3644742c9df..00000000000 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockStore } from '../../../helpers/testMocks'; -import { withUserOrganizations } from '../withUserOrganizations'; - -jest.mock('../../../api/organizations', () => ({ getOrganizations: jest.fn() })); - -class X extends React.Component<{ - fetchMyOrganizations: () => Promise; - userOrganizations: T.Organization[]; -}> { - render() { - return
; - } -} - -const UnderTest = withUserOrganizations(X); - -it('should pass user organizations and logged in user', () => { - const org = { key: 'my-org', name: 'My Organization' }; - const wrapper = shallow(, { - context: { - store: mockStore({ - organizations: { byKey: { 'my-org': org }, my: ['my-org'] } - }) - }, - disableLifecycleMethods: true - }); - const wrappedComponent = wrapper.dive(); - expect(wrappedComponent.type()).toBe(X); - expect(wrappedComponent.prop('userOrganizations')).toEqual([org]); -}); diff --git a/server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx b/server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx deleted file mode 100644 index a97150a3c3c..00000000000 --- a/server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as React from 'react'; -import { connect } from 'react-redux'; -import { fetchMyOrganizations } from '../../apps/account/organizations/actions'; -import { getMyOrganizations, Store } from '../../store/rootReducer'; -import { getWrappedDisplayName } from './utils'; - -interface OwnProps { - fetchMyOrganizations: () => Promise; - userOrganizations: T.Organization[]; -} - -export function withUserOrganizations

( - WrappedComponent: React.ComponentType

> -) { - class Wrapper extends React.Component

{ - static displayName = getWrappedDisplayName(WrappedComponent, 'withUserOrganizations'); - - componentDidMount() { - this.props.fetchMyOrganizations(); - } - - render() { - return ; - } - } - - const mapDispatchToProps = { fetchMyOrganizations: fetchMyOrganizations as any }; - - function mapStateToProps(state: Store) { - return { userOrganizations: getMyOrganizations(state) }; - } - - return connect(mapStateToProps, mapDispatchToProps)(Wrapper); -} -- cgit v1.2.3