diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2020-12-09 14:43:36 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-12-22 20:09:35 +0000 |
commit | 8556ba8e2bedb1591c9e8510606d75bfdedbdf3d (patch) | |
tree | 48b66893ef9422e42ad978d8711dce41d20612ee /server/sonar-web/src/main/js/apps/quality-profiles/home | |
parent | c73de56d4b6ab4c9fdb34a32f5f740bed672b586 (diff) | |
download | sonarqube-8556ba8e2bedb1591c9e8510606d75bfdedbdf3d.tar.gz sonarqube-8556ba8e2bedb1591c9e8510606d75bfdedbdf3d.zip |
SONAR-13999 Drop orgs from Quality Profiles
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles/home')
21 files changed, 59 insertions, 62 deletions
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<Props, State> 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 ( <div className="quality-profiles-evolution"> - <EvolutionDeprecated organization={organization} profiles={profiles} /> - <EvolutionStagnant organization={organization} profiles={profiles} /> - <EvolutionRules organization={organization} /> + <EvolutionDeprecated profiles={profiles} /> + <EvolutionStagnant profiles={profiles} /> + <EvolutionRules /> </div> ); } 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<T.RuleActivation[]>): 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<Props, State> { +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<Props, State> { 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<Props, State> { }); } }, - () => {} + () => { + /*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<void>; } 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<Router, 'push'>; updateProfiles: () => Promise<void>; @@ -76,7 +75,7 @@ export class PageHeader extends React.PureComponent<Props, State> { }; render() { - const { actions, languages, location, organization, profiles } = this.props; + const { actions, languages, location, profiles } = this.props; return ( <header className="page-header"> <h1 className="page-title">{translate('quality_profiles.page')}</h1> @@ -121,7 +120,6 @@ export class PageHeader extends React.PureComponent<Props, State> { <RestoreProfileForm onClose={this.closeRestoreForm} onRestore={this.props.updateProfiles} - organization={organization} /> )} @@ -131,7 +129,6 @@ export class PageHeader extends React.PureComponent<Props, State> { 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<Location, 'query'>; - organization: string | null; profiles: Profile[]; updateProfiles: () => Promise<void>; } @@ -40,7 +39,6 @@ export default class ProfilesList extends React.PureComponent<Props> { return profiles.map(profile => ( <ProfilesListRow key={profile.key} - organization={this.props.organization} profile={profile} updateProfiles={this.props.updateProfiles} /> 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<void>; } 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) { </td> <td className="quality-profiles-table-actions thin nowrap text-middle text-right"> - <ProfileActions - fromList={true} - organization={organization} - profile={profile} - updateProfiles={props.updateProfiles} - /> + <ProfileActions fromList={true} profile={profile} updateProfiles={props.updateProfiles} /> </td> </tr> ); 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<Props, State this.setState({ loading: true }); const data = new FormData(event.currentTarget); - if (this.props.organization) { - data.append('organization', this.props.organization); - } restoreQualityProfile(data).then( (response: any) => { 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<CreateProfileForm['props']>) { 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<EvolutionProps> = {}) { + return shallow(<Evolution profiles={[]} {...props} />); +} 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( <EvolutionDeprecated - organization="foo" profiles={[ mockQualityProfile({ key: 'qp-1', diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx index d71b11092fb..804c7828d1b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx @@ -52,7 +52,6 @@ function shallowRender(props: Partial<PageHeader['props']> = {}) { 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<ProfilesList['props']> = {}) { <ProfilesList languages={[mockLanguage(), mockLanguage({ key: 'js', name: 'JS' })]} location={mockLocation()} - organization="foo" profiles={[ mockQualityProfile(), mockQualityProfile({ language: 'css', languageName: 'CSS' }) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx index d0e7016a59c..5a2c87fc28a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx @@ -38,7 +38,6 @@ it('should render correctly', () => { function shallowRender(props: Partial<ProfilesListRowProps> = {}) { return shallow( <ProfilesListRow - organization={null} profile={mockQualityProfile({ activeDeprecatedRuleCount: 0 })} updateProfiles={jest.fn()} {...props} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx index 45758a12dfe..3e809d23177 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx @@ -23,6 +23,6 @@ import RestoreProfileForm from '../RestoreProfileForm'; it('should render correctly', () => { expect( - shallow(<RestoreProfileForm onClose={jest.fn()} onRestore={jest.fn()} organization="org" />) + shallow(<RestoreProfileForm onClose={jest.fn()} onRestore={jest.fn()} />) ).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`] = ` +<div + className="quality-profiles-evolution" +> + <EvolutionDeprecated + profiles={Array []} + /> + <EvolutionStagnant + profiles={Array []} + /> + <EvolutionRules /> +</div> +`; 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`] = ` <RestoreProfileForm onClose={[Function]} onRestore={[MockFunction]} - organization="foo" /> </header> `; 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`] = ` <tbody> <Memo(ProfilesListRow) key="key" - organization="foo" profile={ Object { "activeDeprecatedRuleCount": 2, @@ -83,7 +82,6 @@ exports[`should render correctly 1`] = ` "language": "css", "languageName": "CSS", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -145,7 +143,6 @@ exports[`should render correctly 1`] = ` <tbody> <Memo(ProfilesListRow) key="key" - organization="foo" profile={ Object { "activeDeprecatedRuleCount": 2, @@ -159,7 +156,6 @@ exports[`should render correctly 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -241,7 +237,6 @@ exports[`should render correctly 2`] = ` <tbody> <Memo(ProfilesListRow) key="key" - organization="foo" profile={ Object { "activeDeprecatedRuleCount": 2, @@ -255,7 +250,6 @@ exports[`should render correctly 2`] = ` "language": "css", "languageName": "CSS", "name": "name", - "organization": "foo", "projectCount": 3, } } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap index 55b7bfdb837..25e5e98478b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap @@ -98,7 +98,6 @@ exports[`should render correctly: built-in profile 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 2, @@ -112,7 +111,6 @@ exports[`should render correctly: built-in profile 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -192,7 +190,6 @@ exports[`should render correctly: default 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 0, @@ -206,7 +203,6 @@ exports[`should render correctly: default 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -317,7 +313,6 @@ exports[`should render correctly: default profile 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 2, @@ -331,7 +326,6 @@ exports[`should render correctly: default profile 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -436,7 +430,6 @@ exports[`should render correctly: with deprecated rules 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 10, @@ -450,7 +443,6 @@ exports[`should render correctly: with deprecated rules 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } |