From d30fb63f3535dd0a4643f5123f38b5755d34de53 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 16 Dec 2020 17:00:29 +0100 Subject: [PATCH] SONAR-13999 Drop orgs from Components --- .../main/js/app/components/AdminContainer.tsx | 5 +- .../js/app/components/ComponentContainer.tsx | 9 +-- .../__tests__/AdminContainer-test.tsx | 3 +- .../__tests__/ComponentContainer-test.tsx | 3 +- .../AdminContainer-test.tsx.snap | 1 - .../components/nav/settings/SettingsNav.tsx | 64 ++++++++----------- .../settings/__tests__/SettingsNav-test.tsx | 2 - .../components/__tests__/App-test.tsx | 1 - .../__tests__/Projects-test.tsx | 2 - 9 files changed, 31 insertions(+), 59 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx index 232a9fa9722..29a6a0ceb67 100644 --- a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx @@ -32,7 +32,7 @@ import AdminContext, { defaultPendingPlugins, defaultSystemStatus } from './Admi import SettingsNav from './nav/settings/SettingsNav'; interface Props { - appState: Pick; + appState: Pick; location: {}; setAdminPages: (adminPages: T.Extension[]) => void; } @@ -109,7 +109,7 @@ export class AdminContainer extends React.PureComponent { }; render() { - const { adminPages, organizationsEnabled } = this.props.appState; + const { adminPages } = this.props.appState; // Check that the adminPages are loaded if (!adminPages) { @@ -127,7 +127,6 @@ export class AdminContainer extends React.PureComponent { fetchPendingPlugins={this.fetchPendingPlugins} fetchSystemStatus={this.fetchSystemStatus} location={this.props.location} - organizationsEnabled={organizationsEnabled} pendingPlugins={pendingPlugins} systemStatus={systemStatus} /> diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index 02ac49bfea0..e32bd7bf28a 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -32,11 +32,7 @@ import { isPullRequest } from '../../helpers/branch-like'; import { getPortfolioUrl } from '../../helpers/urls'; -import { - fetchOrganization, - registerBranchStatus, - requireAuthorization -} from '../../store/rootActions'; +import { registerBranchStatus, requireAuthorization } from '../../store/rootActions'; import { BranchLike } from '../../types/branch-like'; import { isPortfolioLike } from '../../types/component'; import { Task, TaskStatuses, TaskWarning } from '../../types/tasks'; @@ -47,7 +43,6 @@ import ComponentNav from './nav/component/ComponentNav'; interface Props { children: React.ReactElement; - fetchOrganization: (organization: string) => void; location: Pick; registerBranchStatus: (branchLike: BranchLike, component: string, status: T.Status) => void; requireAuthorization: (router: Pick) => void; @@ -379,6 +374,6 @@ export class ComponentContainer extends React.PureComponent { } } -const mapDispatchToProps = { fetchOrganization, registerBranchStatus, requireAuthorization }; +const mapDispatchToProps = { registerBranchStatus, requireAuthorization }; export default withRouter(connect(null, mapDispatchToProps)(ComponentContainer)); diff --git a/server/sonar-web/src/main/js/app/components/__tests__/AdminContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/AdminContainer-test.tsx index 803e3a4d186..47d8301038e 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/AdminContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/AdminContainer-test.tsx @@ -32,8 +32,7 @@ function shallowRender(props: Partial = {}) { { it('fetches status', async () => { (getComponentData as jest.Mock).mockResolvedValueOnce({ - component: { organization: 'org' } + component: {} }); shallowRender(); @@ -293,7 +293,6 @@ it('should correctly reload last task warnings if anything got dismissed', async function shallowRender(props: Partial = {}) { return shallow( void; fetchSystemStatus: () => void; location: {}; - organizationsEnabled?: boolean; pendingPlugins: PendingPluginResult; systemStatus: T.SysStatus; } @@ -87,7 +86,6 @@ export default class SettingsNav extends React.PureComponent { }; renderConfigurationTab() { - const { organizationsEnabled } = this.props; const extensionsWithoutSupport = this.props.extensions.filter( extension => extension.key !== 'license/support' ); @@ -110,13 +108,11 @@ export default class SettingsNav extends React.PureComponent { {translate('custom_metrics.page')} - {!organizationsEnabled && ( -
  • - - {translate('webhooks.page')} - -
  • - )} +
  • + + {translate('webhooks.page')} + +
  • {extensionsWithoutSupport.map(this.renderExtension)} } @@ -146,18 +142,15 @@ export default class SettingsNav extends React.PureComponent { } renderProjectsTab() { - const { organizationsEnabled } = this.props; return ( - {!organizationsEnabled && ( -
  • - - {translate('management')} - -
  • - )} +
  • + + {translate('management')} + +
  • {translate('background_tasks.page')} @@ -182,7 +175,6 @@ export default class SettingsNav extends React.PureComponent { } renderSecurityTab() { - const { organizationsEnabled } = this.props; return ( { {translate('users.page')}
  • - {!organizationsEnabled && ( -
  • - - {translate('user_groups.page')} - -
  • - )} - {!organizationsEnabled && ( -
  • - - {translate('global_permissions.page')} - -
  • - )} - {!organizationsEnabled && ( -
  • - - {translate('permission_templates')} - -
  • - )} +
  • + + {translate('user_groups.page')} + +
  • +
  • + + {translate('global_permissions.page')} + +
  • +
  • + + {translate('permission_templates')} + +
  • } tagName="li"> diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/SettingsNav-test.tsx b/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/SettingsNav-test.tsx index ae23f2088ac..49fc38aa205 100644 --- a/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/SettingsNav-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/SettingsNav-test.tsx @@ -29,7 +29,6 @@ it('should work with extensions', () => { it('should display a pending plugin notif', () => { const wrapper = shallowRender({ - organizationsEnabled: false, pendingPlugins: { installing: [ { @@ -58,7 +57,6 @@ function shallowRender(props: Partial = {}) { fetchPendingPlugins={jest.fn()} fetchSystemStatus={jest.fn()} location={{}} - organizationsEnabled={false} pendingPlugins={{ installing: [], removing: [], updating: [] }} systemStatus="UP" {...props} diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx index 9951d9473f2..c1c069d13fe 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx @@ -30,7 +30,6 @@ const component = { analysisDate: '2016-01-01', breadcrumbs: [], name: 'Foo', - organization: 'org', qualifier: 'TRK', version: '0.0.1' }; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx index c87551e1ca3..76d80bb2450 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx @@ -21,7 +21,6 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import Projects from '../Projects'; -const organization = { key: 'org', name: 'org', projectVisibility: 'public' }; const projects = [ { key: 'a', name: 'A', qualifier: 'TRK', visibility: 'public' }, { key: 'b', name: 'B', qualifier: 'TRK', visibility: 'public' } @@ -56,7 +55,6 @@ function shallowRender(props?: any) { currentUser={{ login: 'foo' }} onProjectDeselected={jest.fn()} onProjectSelected={jest.fn()} - organization={organization} selection={[]} {...props} /> -- 2.39.5