From 8556ba8e2bedb1591c9e8510606d75bfdedbdf3d Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 9 Dec 2020 14:43:36 +0100 Subject: SONAR-13999 Drop orgs from Quality Profiles --- .../quality-profiles/home/CreateProfileForm.tsx | 4 --- .../js/apps/quality-profiles/home/Evolution.tsx | 11 ++++---- .../quality-profiles/home/EvolutionDeprecated.tsx | 1 - .../apps/quality-profiles/home/EvolutionRules.tsx | 13 ++++------ .../quality-profiles/home/EvolutionStagnant.tsx | 1 - .../apps/quality-profiles/home/HomeContainer.tsx | 1 - .../js/apps/quality-profiles/home/PageHeader.tsx | 5 +--- .../js/apps/quality-profiles/home/ProfilesList.tsx | 2 -- .../apps/quality-profiles/home/ProfilesListRow.tsx | 10 ++------ .../quality-profiles/home/RestoreProfileForm.tsx | 4 --- .../home/__tests__/CreateProfileForm-test.tsx | 1 - .../home/__tests__/Evolution-test.tsx | 30 ++++++++++++++++++++++ .../home/__tests__/EvolutionDeprecated-test.tsx | 1 - .../home/__tests__/PageHeader-test.tsx | 1 - .../home/__tests__/ProfilesList-test.tsx | 1 - .../home/__tests__/ProfilesListRow-test.tsx | 1 - .../home/__tests__/RestoreProfileForm-test.tsx | 2 +- .../__snapshots__/Evolution-test.tsx.snap | 15 +++++++++++ .../__snapshots__/PageHeader-test.tsx.snap | 3 --- .../__snapshots__/ProfilesList-test.tsx.snap | 6 ----- .../__snapshots__/ProfilesListRow-test.tsx.snap | 8 ------ 21 files changed, 59 insertions(+), 62 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap (limited to 'server/sonar-web/src/main/js/apps/quality-profiles/home') diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx index 4ac543498ed..ed24a597862 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx @@ -37,7 +37,6 @@ interface Props { location: Location; onClose: () => void; onCreate: Function; - organization: string | null; profiles: Profile[]; } @@ -96,9 +95,6 @@ export default class CreateProfileForm extends React.PureComponent this.setState({ loading: true }); const data = new FormData(event.currentTarget); - if (this.props.organization) { - data.append('organization', this.props.organization); - } try { const { profile } = await createQualityProfile(data); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx index 1386ced5068..b2c3435c3ce 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx @@ -23,17 +23,16 @@ import EvolutionDeprecated from './EvolutionDeprecated'; import EvolutionRules from './EvolutionRules'; import EvolutionStagnant from './EvolutionStagnant'; -interface Props { - organization: string | null; +export interface EvolutionProps { profiles: Profile[]; } -export default function Evolution({ organization, profiles }: Props) { +export default function Evolution({ profiles }: EvolutionProps) { return (
- - - + + +
); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx index 03bbae3a26c..424a3f33d9d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx @@ -26,7 +26,6 @@ import ProfileLink from '../components/ProfileLink'; import { Profile } from '../types'; interface Props { - organization: string | null; profiles: Profile[]; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx index 8e5cf98a4ad..c5549b76fec 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx @@ -35,10 +35,6 @@ function parseRules(rules: T.Rule[], actives?: T.Dict): Exte }); } -interface Props { - organization: string | null; -} - interface ExtendedRule extends T.Rule { activations: number; } @@ -48,11 +44,11 @@ interface State { latestRulesTotal?: number; } -export default class EvolutionRules extends React.PureComponent { +export default class EvolutionRules extends React.PureComponent<{}, State> { periodStartDate: string; mounted = false; - constructor(props: Props) { + constructor(props: {}) { super(props); this.state = {}; const startDate = new Date(); @@ -74,7 +70,6 @@ export default class EvolutionRules extends React.PureComponent { asc: false, available_since: this.periodStartDate, f: 'name,langName,actives', - organization: this.props.organization || undefined, ps: RULES_LIMIT, s: 'createdAt' }; @@ -88,7 +83,9 @@ export default class EvolutionRules extends React.PureComponent { }); } }, - () => {} + () => { + /*noop*/ + } ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx index b474f52b6d8..c28e359291a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx @@ -25,7 +25,6 @@ import { Profile } from '../types'; import { isStagnant } from '../utils'; interface Props { - organization: string | null; profiles: Profile[]; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx index df836bd583e..c6cdceeb83d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx @@ -29,7 +29,6 @@ interface Props { actions: Actions; languages: Array<{ key: string; name: string }>; location: Location; - organization: string | null; profiles: Profile[]; updateProfiles: () => Promise; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx index f1fce30d314..48265457269 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx @@ -33,7 +33,6 @@ interface Props { actions: Actions; languages: Array<{ key: string; name: string }>; location: Location; - organization: string | null; profiles: Profile[]; router: Pick; updateProfiles: () => Promise; @@ -76,7 +75,7 @@ export class PageHeader extends React.PureComponent { }; render() { - const { actions, languages, location, organization, profiles } = this.props; + const { actions, languages, location, profiles } = this.props; return (

{translate('quality_profiles.page')}

@@ -121,7 +120,6 @@ export class PageHeader extends React.PureComponent { )} @@ -131,7 +129,6 @@ export class PageHeader extends React.PureComponent { location={location} onClose={this.closeCreateForm} onCreate={this.handleCreate} - organization={organization} profiles={profiles} /> )} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx index 02958c6ce28..1983b201104 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx @@ -30,7 +30,6 @@ import ProfilesListRow from './ProfilesListRow'; interface Props { languages: T.Language[]; location: Pick; - organization: string | null; profiles: Profile[]; updateProfiles: () => Promise; } @@ -40,7 +39,6 @@ export default class ProfilesList extends React.PureComponent { return profiles.map(profile => ( diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx index 4d4776efbc9..5366ddae665 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx @@ -29,13 +29,12 @@ import ProfileLink from '../components/ProfileLink'; import { Profile } from '../types'; export interface ProfilesListRowProps { - organization: string | null; profile: Profile; updateProfiles: () => Promise; } export function ProfilesListRow(props: ProfilesListRowProps) { - const { organization, profile } = props; + const { profile } = props; const offset = 25 * (profile.depth - 1); const activeRulesUrl = getRulesUrl({ @@ -99,12 +98,7 @@ export function ProfilesListRow(props: ProfilesListRowProps) { - + ); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx index 9c6321f4667..400bb3e7100 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx @@ -27,7 +27,6 @@ import { restoreQualityProfile } from '../../../api/quality-profiles'; interface Props { onClose: () => void; onRestore: () => void; - organization: string | null; } interface State { @@ -55,9 +54,6 @@ export default class RestoreProfileForm extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx index 3d766f9c274..f0289064b4b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx @@ -83,7 +83,6 @@ function shallowRender(props?: Partial) { location={mockLocation()} onClose={jest.fn()} onCreate={jest.fn()} - organization="org" profiles={[mockQualityProfile(), mockQualityProfile({ language: 'css' })]} {...props} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx new file mode 100644 index 00000000000..566708e978d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx @@ -0,0 +1,30 @@ +/* + * 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 Evolution, { EvolutionProps } from '../Evolution'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow(); +} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx index 2c87c4146d5..1298976da05 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx @@ -25,7 +25,6 @@ import EvolutionDeprecated from '../EvolutionDeprecated'; it('should render correctly', () => { const wrapper = shallow( = {}) { actions={{ create: false }} languages={[mockLanguage()]} location={mockLocation()} - organization="foo" profiles={[mockQualityProfile()]} router={mockRouter()} updateProfiles={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx index 4b5ae51f0b2..5da043e8401 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx @@ -39,7 +39,6 @@ function shallowRender(props: Partial = {}) { { function shallowRender(props: Partial = {}) { return shallow( { expect( - shallow() + shallow() ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap new file mode 100644 index 00000000000..f3860f2774d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
+ + + +
+`; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap index 7f1fec70c61..d880cd231c8 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap @@ -207,7 +207,6 @@ exports[`should show a create form 1`] = ` } onClose={[Function]} onCreate={[Function]} - organization="foo" profiles={ Array [ Object { @@ -222,7 +221,6 @@ exports[`should show a create form 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, }, ] @@ -281,7 +279,6 @@ exports[`should show a restore form 1`] = `
`; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap index c1462384945..e9091091c0f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap @@ -69,7 +69,6 @@ exports[`should render correctly 1`] = `