aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/hoc
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2020-12-16 18:18:11 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:37 +0000
commitd83e1ab9825c2c14256a6680bf44d75c13ea4d5a (patch)
tree97d6e51f3823f1988fb7509d5dc8f0562ef2f40f /server/sonar-web/src/main/js/components/hoc
parentd30fb63f3535dd0a4643f5123f38b5755d34de53 (diff)
downloadsonarqube-d83e1ab9825c2c14256a6680bf44d75c13ea4d5a.tar.gz
sonarqube-d83e1ab9825c2c14256a6680bf44d75c13ea4d5a.zip
SONAR-13999 Drop frontend organizations leftovers
Diffstat (limited to 'server/sonar-web/src/main/js/components/hoc')
-rw-r--r--server/sonar-web/src/main/js/components/hoc/__tests__/__snapshots__/withNotifications-test.tsx.snap3
-rw-r--r--server/sonar-web/src/main/js/components/hoc/__tests__/withNotifications-test.tsx9
-rw-r--r--server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx51
-rw-r--r--server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx53
4 files changed, 3 insertions, 113 deletions
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<void>;
- userOrganizations: T.Organization[];
-}> {
- render() {
- return <div />;
- }
-}
-
-const UnderTest = withUserOrganizations(X);
-
-it('should pass user organizations and logged in user', () => {
- const org = { key: 'my-org', name: 'My Organization' };
- const wrapper = shallow(<UnderTest />, {
- 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<void>;
- userOrganizations: T.Organization[];
-}
-
-export function withUserOrganizations<P>(
- WrappedComponent: React.ComponentType<P & Partial<OwnProps>>
-) {
- class Wrapper extends React.Component<P & OwnProps> {
- static displayName = getWrappedDisplayName(WrappedComponent, 'withUserOrganizations');
-
- componentDidMount() {
- this.props.fetchMyOrganizations();
- }
-
- render() {
- return <WrappedComponent {...this.props} />;
- }
- }
-
- const mapDispatchToProps = { fetchMyOrganizations: fetchMyOrganizations as any };
-
- function mapStateToProps(state: Store) {
- return { userOrganizations: getMyOrganizations(state) };
- }
-
- return connect(mapStateToProps, mapDispatchToProps)(Wrapper);
-}