]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13999 Drop orgs from Quality Profiles
authorJeremy Davis <jeremy.davis@sonarsource.com>
Wed, 9 Dec 2020 13:43:36 +0000 (14:43 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 22 Dec 2020 20:09:35 +0000 (20:09 +0000)
83 files changed:
server/sonar-web/src/main/js/api/quality-profiles.ts
server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/BulkChange-test.tsx.snap
server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap
server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap
server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/__snapshots__/ProjectQualityProfilesAppRenderer-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx
server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx
server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/__snapshots__/ChangelogContainer-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx
server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx
server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/ExtendProfileForm.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/App-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ExtendProfileForm-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsGroup.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ChangeProjectsForm-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileDetails-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileHeader-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritance-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritanceBox-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesDeprecatedWarning-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowOfType-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowTotal-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesSonarWayComparison-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileDetails-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileExporters-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileHeader-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileInheritance-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfilePermissions-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRules-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap [new file with mode: 0644]
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap
server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap
server/sonar-web/src/main/js/helpers/testMocks.ts

index a19c067ea5b37a6e2b57c4ec759c1627a190e50e..66f9292c6551e9e139eb8ac22c47f61c12a69745 100644 (file)
@@ -50,7 +50,6 @@ export interface Profile {
   rulesUpdatedAt?: string;
   lastUsed?: string;
   userUpdatedAt?: string;
-  organization: string;
   isBuiltIn?: boolean;
   projectCount?: number;
 }
@@ -58,7 +57,6 @@ export interface Profile {
 export interface SearchQualityProfilesParameters {
   defaults?: boolean;
   language?: string;
-  organization?: string;
   project?: string;
   qualityProfile?: string;
 }
@@ -107,8 +105,7 @@ export function getProfileProjects(
 
 export function getProfileInheritance({
   language,
-  name: qualityProfile,
-  organization
+  name: qualityProfile
 }: Profile): Promise<{
   ancestors: T.ProfileInheritanceDetails[];
   children: T.ProfileInheritanceDetails[];
@@ -116,16 +113,14 @@ export function getProfileInheritance({
 }> {
   return getJSON('/api/qualityprofiles/inheritance', {
     language,
-    qualityProfile,
-    organization
+    qualityProfile
   }).catch(throwGlobalError);
 }
 
-export function setDefaultProfile({ language, name: qualityProfile, organization }: Profile) {
+export function setDefaultProfile({ language, name: qualityProfile }: Profile) {
   return post('/api/qualityprofiles/set_default', {
     language,
-    qualityProfile,
-    organization
+    qualityProfile
   });
 }
 
@@ -137,30 +132,23 @@ export function copyProfile(fromKey: string, toName: string): Promise<any> {
   return postJSON('/api/qualityprofiles/copy', { fromKey, toName }).catch(throwGlobalError);
 }
 
-export function deleteProfile({ language, name: qualityProfile, organization }: Profile) {
-  return post('/api/qualityprofiles/delete', { language, qualityProfile, organization }).catch(
-    throwGlobalError
-  );
+export function deleteProfile({ language, name: qualityProfile }: Profile) {
+  return post('/api/qualityprofiles/delete', { language, qualityProfile }).catch(throwGlobalError);
 }
 
 export function changeProfileParent(
-  { language, name: qualityProfile, organization }: Profile,
+  { language, name: qualityProfile }: Profile,
   parentProfile?: Profile
 ) {
   return post('/api/qualityprofiles/change_parent', {
     language,
     qualityProfile,
-    organization,
     parentQualityProfile: parentProfile ? parentProfile.name : undefined
   }).catch(throwGlobalError);
 }
 
-export function getQualityProfileBackupUrl({
-  language,
-  name: qualityProfile,
-  organization
-}: Profile) {
-  const queryParams = Object.entries({ language, qualityProfile, organization })
+export function getQualityProfileBackupUrl({ language, name: qualityProfile }: Profile) {
+  const queryParams = Object.entries({ language, qualityProfile })
     .map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
     .join('&');
   return `/api/qualityprofiles/backup?${queryParams}`;
@@ -168,9 +156,9 @@ export function getQualityProfileBackupUrl({
 
 export function getQualityProfileExporterUrl(
   { key: exporterKey }: Exporter,
-  { language, name: qualityProfile, organization }: Profile
+  { language, name: qualityProfile }: Profile
 ) {
-  const queryParams = Object.entries({ exporterKey, language, qualityProfile, organization })
+  const queryParams = Object.entries({ exporterKey, language, qualityProfile })
     .map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
     .join('&');
   return `/api/qualityprofiles/export?${queryParams}`;
@@ -189,7 +177,7 @@ export function getExporters(): Promise<any> {
 export function getProfileChangelog(
   since: any,
   to: any,
-  { language, name: qualityProfile, organization }: Profile,
+  { language, name: qualityProfile }: Profile,
   page?: number
 ): Promise<{
   events: ProfileChangelogEvent[];
@@ -202,7 +190,6 @@ export function getProfileChangelog(
     to,
     language,
     qualityProfile,
-    organization,
     p: page
   });
 }
@@ -224,26 +211,18 @@ export function compareProfiles(leftKey: string, rightKey: string): Promise<Comp
   return getJSON('/api/qualityprofiles/compare', { leftKey, rightKey });
 }
 
-export function associateProject(
-  { language, name: qualityProfile, organization }: Profile,
-  project: string
-) {
+export function associateProject({ language, name: qualityProfile }: Profile, project: string) {
   return post('/api/qualityprofiles/add_project', {
     language,
     qualityProfile,
-    organization,
     project
   }).catch(throwGlobalError);
 }
 
-export function dissociateProject(
-  { language, name: qualityProfile, organization }: Profile,
-  project: string
-) {
+export function dissociateProject({ language, name: qualityProfile }: Profile, project: string) {
   return post('/api/qualityprofiles/remove_project', {
     language,
     qualityProfile,
-    organization,
     project
   }).catch(throwGlobalError);
 }
@@ -279,7 +258,6 @@ export function searchGroups(
 export interface AddRemoveUserParameters {
   language: string;
   login: string;
-  organization?: string;
   qualityProfile: string;
 }
 
index fb335dddd5cdde61ff48cd0f55d817a04b999748..fe7e71086935d562bfe7049badaa15bf12062f8b 100644 (file)
@@ -324,7 +324,7 @@ export class App extends React.PureComponent<Props, State> {
   fetchQualityProfiles = () => {
     const { currentUser, organization, userOrganizations } = this.props;
     if (hasPrivateAccess(currentUser, organization, userOrganizations)) {
-      return searchQualityProfiles({ organization: organization && organization.key });
+      return searchQualityProfiles();
     }
     return { profiles: [] };
   };
index 9e04281ed3b0b8e8279681215530cd58a1225004..89150cbd13d492b5aba8026ac8cb543aa1a09c19 100644 (file)
@@ -39,7 +39,6 @@ exports[`should display BulkChangeModal 1`] = `
         "language": "js",
         "languageName": "JavaScript",
         "name": "name",
-        "organization": "foo",
         "projectCount": 3,
       },
     }
index 605d9606fdd36da40bc18ac187d62b8a9c00b211..e7230ad913a51710873db39bae9dd406ccca6d0b 100644 (file)
@@ -118,7 +118,6 @@ exports[`should render correctly: loaded 1`] = `
             "language": "js",
             "languageName": "JavaScript",
             "name": "name",
-            "organization": "foo",
             "projectCount": 3,
           },
         }
index fce5093c87a37503817d87867bee32a603f49df8..b14e698cb93e269aeccde797507c535647db6b06 100644 (file)
@@ -65,7 +65,6 @@ exports[`renderActions should render the activate button 1`] = `
           "language": "js",
           "languageName": "JavaScript",
           "name": "name",
-          "organization": "foo",
           "projectCount": 3,
         },
       ]
index 57513807f5862341b5ecddbff4879541485944ab..0c32a1f07d360945dab1188cee92cfbf86a6e636 100644 (file)
@@ -261,7 +261,6 @@ exports[`should render correctly: add language 1`] = `
                 "language": "css",
                 "languageName": "JavaScript",
                 "name": "name",
-                "organization": "foo",
                 "projectCount": 3,
               },
             ],
@@ -278,7 +277,6 @@ exports[`should render correctly: add language 1`] = `
                 "language": "html",
                 "languageName": "JavaScript",
                 "name": "name",
-                "organization": "foo",
                 "projectCount": 3,
               },
             ],
@@ -295,7 +293,6 @@ exports[`should render correctly: add language 1`] = `
                 "language": "js",
                 "languageName": "JavaScript",
                 "name": "name",
-                "organization": "foo",
                 "projectCount": 3,
               },
             ],
@@ -903,7 +900,6 @@ exports[`should render correctly: open profile 1`] = `
               "language": "js",
               "languageName": "JavaScript",
               "name": "name",
-              "organization": "foo",
               "projectCount": 3,
             },
           ]
@@ -944,7 +940,6 @@ exports[`should render correctly: open profile 1`] = `
             "language": "js",
             "languageName": "JavaScript",
             "name": "name",
-            "organization": "foo",
             "projectCount": 3,
           }
         }
index 46ad79220e9735967f45ba872b186a92b9d6a2f9..266fe9449217b47d8bf80c632164996104b0c63c 100644 (file)
@@ -30,7 +30,6 @@ import ChangesList from './ChangesList';
 
 interface Props {
   events: ProfileChangelogEvent[];
-  organization: string | null;
 }
 
 export default function Changelog(props: Props) {
index add7cd632a05477d8bc7d60f08dffa8af3c80e0a..9a99212ca7737b272c603a85076cacfa5542ec46 100644 (file)
@@ -30,7 +30,6 @@ import ChangelogEmpty from './ChangelogEmpty';
 import ChangelogSearch from './ChangelogSearch';
 
 interface Props extends Pick<WithRouterProps, 'router' | 'location'> {
-  organization: string | null;
   profile: Profile;
 }
 
@@ -152,7 +151,7 @@ export class ChangelogContainer extends React.PureComponent<Props, State> {
         {this.state.events != null && this.state.events.length === 0 && <ChangelogEmpty />}
 
         {this.state.events != null && this.state.events.length > 0 && (
-          <Changelog events={this.state.events} organization={this.props.organization} />
+          <Changelog events={this.state.events} />
         )}
 
         {shouldDisplayFooter && (
index 267646c73d31adfa58e8d5937432272dc38f0b8f..39c438c59c448a744c06c3d461f04803fa194c76 100644 (file)
@@ -37,44 +37,44 @@ function createEvent(overrides?: Partial<ProfileChangelogEvent>): ProfileChangel
 
 it('should render events', () => {
   const events = [createEvent(), createEvent()];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   expect(changelog.find('tbody').find('tr').length).toBe(2);
 });
 
 it('should render event date', () => {
   const events = [createEvent()];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   expect(changelog.find('DateTimeFormatter')).toHaveLength(1);
 });
 
 it('should render author', () => {
   const events = [createEvent()];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   expect(changelog.text()).toContain('John');
 });
 
 it('should render system author', () => {
   const events = [createEvent({ authorName: undefined })];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   expect(changelog.text()).toContain('System');
 });
 
 it('should render action', () => {
   const events = [createEvent()];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   expect(changelog.text()).toContain('ACTIVATED');
 });
 
 it('should render rule', () => {
   const events = [createEvent()];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   expect(changelog.find('Link').prop('to')).toHaveProperty('query', { rule_key: 'squid1234' });
 });
 
 it('should render ChangesList', () => {
   const params = { severity: 'BLOCKER' };
   const events = [createEvent({ params })];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   const changesList = changelog.find(ChangesList);
   expect(changesList.length).toBe(1);
   expect(changesList.prop('changes')).toBe(params);
@@ -87,7 +87,7 @@ it('should render events sorted by time and action', () => {
     createEvent({ date: '2019-02-07T14:03:14', action: 'ACTIVATED' }),
     createEvent({ date: '2019-02-07T14:03:07', action: 'ACTIVATED' })
   ];
-  const changelog = shallow(<Changelog events={events} organization={null} />);
+  const changelog = shallow(<Changelog events={events} />);
   const rows = changelog.find('tbody').find('tr');
 
   const getAction = (index: number) =>
index 176cda52f04bfa9df256a7f91bae13f6e0a5053b..a076bacd1bc99a6cc838495f7404606b968e3df0 100644 (file)
@@ -71,7 +71,6 @@ function shallowRender() {
   return shallow<ChangelogContainer>(
     <ChangelogContainer
       location={mockLocation()}
-      organization="TEST"
       profile={mockQualityProfile()}
       router={mockRouter()}
     />
index 788ec9aa5f6eb96504c69026484ab92ad5d3a781..2029636a14c146c8db36985da851bcb87f717922 100644 (file)
@@ -50,7 +50,6 @@ exports[`should render correctly 1`] = `
         },
       ]
     }
-    organization="TEST"
   />
   <footer
     className="text-center spacer-top small"
index bb0f4f290bc9e8b030c1be169e7b3889e6cf12eb..a2605732a1d83ff495dba158875605cd42abe601 100644 (file)
@@ -26,7 +26,6 @@ import ComparisonForm from './ComparisonForm';
 import ComparisonResults from './ComparisonResults';
 
 interface Props extends WithRouterProps {
-  organization?: string;
   profile: Profile;
   profiles: Profile[];
 }
@@ -113,7 +112,6 @@ class ComparisonContainer extends React.PureComponent<Props, State> {
               left={this.state.left}
               leftProfile={profile}
               modified={this.state.modified}
-              organization={this.props.organization}
               refresh={this.loadResults}
               right={this.state.right}
               rightProfile={profiles.find(p => p.key === withKey)}
index 372feb8805fd62fa75414edd3551a095e37bca5e..7d19333bf23fd6a77b2f51af9a2f04dd663748e1 100644 (file)
@@ -32,7 +32,6 @@ const ActivationFormModal = lazyLoadComponent(
 
 interface Props {
   onDone: () => Promise<void>;
-  organization?: string;
   profile: Profile;
   ruleKey: string;
 }
@@ -56,7 +55,7 @@ export default class ComparisonResultActivation extends React.PureComponent<Prop
 
   handleButtonClick = () => {
     this.setState({ state: 'opening' });
-    getRuleDetails({ key: this.props.ruleKey, organization: this.props.organization }).then(
+    getRuleDetails({ key: this.props.ruleKey }).then(
       ({ rule }) => {
         if (this.mounted) {
           this.setState({ rule, state: 'open' });
index 40fc7548ab3aabc915b536b23ae98f6a7317249e..444b4d41448cb89ba9254359ab66936eb191b5e0 100644 (file)
@@ -31,7 +31,6 @@ import ComparisonResultActivation from './ComparisonResultActivation';
 type Params = T.Dict<string>;
 
 interface Props extends CompareResponse {
-  organization?: string;
   leftProfile: Profile;
   refresh: () => Promise<void>;
   rightProfile?: Profile;
@@ -92,7 +91,6 @@ export default class ComparisonResults extends React.PureComponent<Props> {
                 <ComparisonResultActivation
                   key={rule.key}
                   onDone={this.props.refresh}
-                  organization={this.props.organization || undefined}
                   profile={this.props.rightProfile}
                   ruleKey={rule.key}>
                   <ChevronRightIcon />
@@ -129,7 +127,6 @@ export default class ComparisonResults extends React.PureComponent<Props> {
               <ComparisonResultActivation
                 key={rule.key}
                 onDone={this.props.refresh}
-                organization={this.props.organization || undefined}
                 profile={this.props.leftProfile}
                 ruleKey={rule.key}>
                 <ChevronLeftIcon />
index 5ef3289f82a499ac3a0a0c85d9792181dc0ee9d4..51b2f5d6eb3f32e152f9f28c3ccc209658d0061f 100644 (file)
@@ -29,7 +29,6 @@ import { sortProfiles } from '../utils';
 interface Props {
   children: React.ReactElement<any>;
   languages: T.Languages;
-  organization: { name: string; key: string } | undefined;
 }
 
 interface State {
@@ -53,9 +52,7 @@ export default class App extends React.PureComponent<Props, State> {
   }
 
   fetchProfiles() {
-    const { organization } = this.props;
-    const data = organization ? { organization: organization.key } : {};
-    return searchQualityProfiles(data);
+    return searchQualityProfiles();
   }
 
   loadData() {
@@ -92,7 +89,6 @@ export default class App extends React.PureComponent<Props, State> {
     if (this.state.loading) {
       return <i className="spinner" />;
     }
-    const { organization } = this.props;
     const finalLanguages = Object.values(this.props.languages);
 
     return React.cloneElement(this.props.children, {
@@ -100,8 +96,7 @@ export default class App extends React.PureComponent<Props, State> {
       profiles: this.state.profiles || [],
       languages: finalLanguages,
       exporters: this.state.exporters,
-      updateProfiles: this.updateProfiles,
-      organization: organization ? organization.key : null
+      updateProfiles: this.updateProfiles
     });
   }
 
index 8db4ab6151018b864f92e636ffaf05ae5efa1ccb..436238c44ee1ef2c74e89d76c64a1f997d2fbfcf 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { connect } from 'react-redux';
-import { getLanguages, getOrganizationByKey, Store } from '../../../store/rootReducer';
+import { getLanguages, Store } from '../../../store/rootReducer';
 import App from './App';
 
-const mapStateToProps = (state: Store, ownProps: any) => ({
-  languages: getLanguages(state),
-  organization: ownProps.params.organizationKey
-    ? getOrganizationByKey(state, ownProps.params.organizationKey)
-    : undefined
+const mapStateToProps = (state: Store) => ({
+  languages: getLanguages(state)
 });
 
 export default connect(mapStateToProps)(App);
index 6510941c396ad6dd40fc129f7ba9b6de14ae397a..90dfcf4a50b6d1ab8647b24e1f177f774d4a7a99 100644 (file)
@@ -28,7 +28,6 @@ import { Profile } from '../types';
 interface Props {
   onClose: () => void;
   onExtend: (name: string) => void;
-  organization: string | null;
   profile: Profile;
 }
 
@@ -62,7 +61,7 @@ export default class ExtendProfileForm extends React.PureComponent<Props, State>
   handleFormSubmit = async (event: React.SyntheticEvent<HTMLFormElement>) => {
     event.preventDefault();
     if (this.canSubmit(this.state)) {
-      const { organization, profile: parentProfile } = this.props;
+      const { profile: parentProfile } = this.props;
       const { name } = this.state;
 
       const data = new FormData();
@@ -70,10 +69,6 @@ export default class ExtendProfileForm extends React.PureComponent<Props, State>
       data.append('language', parentProfile.language);
       data.append('name', name);
 
-      if (organization) {
-        data.append('organization', organization);
-      }
-
       this.setState({ loading: true });
 
       try {
index 97cc0ce6048522283118d14c7d1fad0960018a46..c9ba3d0887e2cca45cedfe80af035351da952c07 100644 (file)
@@ -37,7 +37,6 @@ import RenameProfileForm from './RenameProfileForm';
 interface Props {
   className?: string;
   fromList?: boolean;
-  organization: string | null;
   profile: Profile;
   router: Pick<Router, 'push' | 'replace'>;
   updateProfiles: () => Promise<void>;
@@ -209,7 +208,6 @@ export class ProfileActions extends React.PureComponent<Props, State> {
           <ExtendProfileForm
             onClose={this.closeExtendForm}
             onExtend={this.handleProfileExtend}
-            organization={this.props.organization}
             profile={profile}
           />
         )}
index 0d5c32e155bd205d3e8cf10d95ad6c889d1960fa..4dba8fd508506153c08679cf1ccaca8ac173229d 100644 (file)
@@ -26,11 +26,6 @@ import ProfileNotFound from './ProfileNotFound';
 
 interface Props {
   children: React.ReactElement<any>;
-  location: {
-    pathname: string;
-    query: { key?: string; language: string; name: string };
-  };
-  organization: string | null;
   profiles: Profile[];
   updateProfiles: () => Promise<void>;
 }
@@ -53,7 +48,7 @@ export default class ProfileContainer extends React.PureComponent<Props & WithRo
   }
 
   render() {
-    const { organization, profiles, location, ...other } = this.props;
+    const { profiles, location, ...other } = this.props;
     const { key, language, name } = location.query;
 
     if (key) {
@@ -74,7 +69,6 @@ export default class ProfileContainer extends React.PureComponent<Props & WithRo
     }
 
     const child = React.cloneElement(this.props.children, {
-      organization,
       profile,
       profiles,
       ...other
@@ -83,11 +77,7 @@ export default class ProfileContainer extends React.PureComponent<Props & WithRo
     return (
       <div id="quality-profile">
         <Helmet defer={false} title={profile.name} />
-        <ProfileHeader
-          organization={organization}
-          profile={profile}
-          updateProfiles={this.props.updateProfiles}
-        />
+        <ProfileHeader profile={profile} updateProfiles={this.props.updateProfiles} />
         {child}
       </div>
     );
index d93c398f7aaa440499734c0d4fa3920122b25ba8..b43a6f83f4cad2027c356e0051cbbec40281054a 100644 (file)
@@ -28,7 +28,7 @@ it('should render correctly', () => {
 
 function shallowRender(props: Partial<App['props']> = {}) {
   return shallow<App>(
-    <App languages={{}} organization={undefined} {...props}>
+    <App languages={{}} {...props}>
       <div />
     </App>
   );
index f8874ff1fed837a28aa56d7f5671a00804036ee1..d21dcbfe36e860a1f41491e0de45031cd02cc030 100644 (file)
@@ -36,9 +36,8 @@ it('should render correctly', () => {
 
 it('should correctly create a new profile and extend the existing one', async () => {
   const profile = mockQualityProfile();
-  const organization = 'org';
   const name = 'New name';
-  const wrapper = shallowRender({ organization, profile });
+  const wrapper = shallowRender({ profile });
 
   expect(wrapper.find('SubmitButton').props().disabled).toBe(true);
 
@@ -49,7 +48,6 @@ it('should correctly create a new profile and extend the existing one', async ()
   const data = new FormData();
   data.append('language', profile.language);
   data.append('name', name);
-  data.append('organization', organization);
   expect(createQualityProfile).toHaveBeenCalledWith(data);
   expect(changeProfileParent).toHaveBeenCalledWith({ key: 'new-profile' }, profile);
 });
@@ -59,7 +57,6 @@ function shallowRender(props: Partial<ExtendProfileForm['props']> = {}) {
     <ExtendProfileForm
       onClose={jest.fn()}
       onExtend={jest.fn()}
-      organization="foo"
       profile={mockQualityProfile()}
       {...props}
     />
index c809cba18c3ef3b73b906f3006434c276185ca89..f7f9e824163c3ea0135c8b451ff01ac95dbf2488 100644 (file)
@@ -126,12 +126,6 @@ it('should delete profile properly', async () => {
 function shallowRender(props: Partial<ProfileActions['props']> = {}) {
   const router = mockRouter();
   return shallow<ProfileActions>(
-    <ProfileActions
-      organization="org"
-      profile={PROFILE}
-      router={router}
-      updateProfiles={jest.fn()}
-      {...props}
-    />
+    <ProfileActions profile={PROFILE} router={router} updateProfiles={jest.fn()} {...props} />
   );
 }
index e028d15bb4b7f1716b7e6f02e75d07ce55be1920..b9b5635f47642aaec7f2146abd2afb3d081471a7 100644 (file)
@@ -21,27 +21,19 @@ import { shallow } from 'enzyme';
 import * as React from 'react';
 import { Helmet } from 'react-helmet-async';
 import { WithRouterProps } from 'react-router';
-import { mockQualityProfile } from '../../../../helpers/testMocks';
+import { mockLocation, mockQualityProfile, mockRouter } from '../../../../helpers/testMocks';
 import ProfileHeader from '../../details/ProfileHeader';
 import ProfileContainer from '../ProfileContainer';
 import ProfileNotFound from '../ProfileNotFound';
 
-const routerProps = { router: {} } as WithRouterProps;
-
 it('should render ProfileHeader', () => {
   const targetProfile = mockQualityProfile({ name: 'fake' });
   const profiles = [targetProfile, mockQualityProfile({ name: 'another' })];
   const updateProfiles = jest.fn();
-  const output = shallow(
-    <ProfileContainer
-      location={{ pathname: '', query: { language: 'js', name: 'fake' } }}
-      organization={null}
-      profiles={profiles}
-      updateProfiles={updateProfiles}
-      {...routerProps}>
-      <div />
-    </ProfileContainer>
-  );
+  const location = mockLocation({ pathname: '', query: { language: 'js', name: 'fake' } });
+
+  const output = shallowRender({ profiles, updateProfiles, location });
+
   const header = output.find(ProfileHeader);
   expect(header.length).toBe(1);
   expect(header.prop('profile')).toBe(targetProfile);
@@ -50,16 +42,10 @@ it('should render ProfileHeader', () => {
 
 it('should render ProfileNotFound', () => {
   const profiles = [mockQualityProfile({ name: 'fake' }), mockQualityProfile({ name: 'another' })];
-  const output = shallow(
-    <ProfileContainer
-      location={{ pathname: '', query: { language: 'js', name: 'random' } }}
-      organization={null}
-      profiles={profiles}
-      updateProfiles={jest.fn()}
-      {...routerProps}>
-      <div />
-    </ProfileContainer>
-  );
+  const location = mockLocation({ pathname: '', query: { language: 'js', name: 'random' } });
+
+  const output = shallowRender({ profiles, location });
+
   expect(output.is(ProfileNotFound)).toBe(true);
 });
 
@@ -67,17 +53,21 @@ it('should render Helmet', () => {
   const name = 'First Profile';
   const profiles = [mockQualityProfile({ name })];
   const updateProfiles = jest.fn();
-  const output = shallow(
-    <ProfileContainer
-      location={{ pathname: '', query: { language: 'js', name } }}
-      organization={null}
-      profiles={profiles}
-      updateProfiles={updateProfiles}
-      {...routerProps}>
-      <div />
-    </ProfileContainer>
-  );
+  const location = mockLocation({ pathname: '', query: { language: 'js', name } });
+
+  const output = shallowRender({ profiles, updateProfiles, location });
+
   const helmet = output.find(Helmet);
   expect(helmet.length).toBe(1);
   expect(helmet.prop('title')).toContain(name);
 });
+
+function shallowRender(overrides: Partial<ProfileContainer['props']> = {}) {
+  const routerProps = { router: mockRouter(), ...overrides } as WithRouterProps;
+
+  return shallow(
+    <ProfileContainer profiles={[]} updateProfiles={jest.fn()} {...routerProps} {...overrides}>
+      <div />
+    </ProfileContainer>
+  );
+}
index 91ce05a8387ca477ed0d97638429c5775c101e7b..f59b868a8710d86893b4d3b6bd8dc9f629bd290c 100644 (file)
@@ -22,7 +22,7 @@ exports[`renders with all permissions 1`] = `
     </ActionsDropdownItem>
     <ActionsDropdownItem
       download="key.xml"
-      to="/api/qualityprofiles/backup?language=js&qualityProfile=name&organization=foo"
+      to="/api/qualityprofiles/backup?language=js&qualityProfile=name"
     >
       <span
         data-test="quality-profiles__backup"
@@ -103,7 +103,7 @@ exports[`renders with no permissions 1`] = `
   <ActionsDropdown>
     <ActionsDropdownItem
       download="key.xml"
-      to="/api/qualityprofiles/backup?language=js&qualityProfile=name&organization=foo"
+      to="/api/qualityprofiles/backup?language=js&qualityProfile=name"
     >
       <span
         data-test="quality-profiles__backup"
@@ -154,7 +154,7 @@ exports[`renders with permission to edit only 1`] = `
     </ActionsDropdownItem>
     <ActionsDropdownItem
       download="key.xml"
-      to="/api/qualityprofiles/backup?language=js&qualityProfile=name&organization=foo"
+      to="/api/qualityprofiles/backup?language=js&qualityProfile=name"
     >
       <span
         data-test="quality-profiles__backup"
index 12c84232e411e3e4e9430f22bc888a77a6029729..d543297af1f5b167bd1302834c93a219ea731583 100644 (file)
@@ -35,7 +35,6 @@ import { Profile } from '../types';
 
 interface Props {
   onClose: () => void;
-  organization: string | null;
   profile: Profile;
 }
 
@@ -71,7 +70,6 @@ export default class ChangeProjectsForm extends React.PureComponent<Props, State
   fetchProjects = (searchParams: SelectListSearchParams) =>
     getProfileProjects({
       key: this.props.profile.key,
-      organization: this.props.organization,
       p: searchParams.page,
       ps: searchParams.pageSize,
       q: searchParams.query !== '' ? searchParams.query : undefined,
index 13cd29a00fd2d0fd30433e81733a158503b88b97..6d84fc2ad47a300bec7c5e02e921b963922abf88 100644 (file)
@@ -27,36 +27,30 @@ import ProfileRules from './ProfileRules';
 
 interface Props {
   exporters: Exporter[];
-  organization: string | null;
   profile: Profile;
   profiles: Profile[];
   updateProfiles: () => Promise<void>;
 }
 
 export default function ProfileDetails(props: Props) {
-  const { organization, profile } = props;
+  const { profile } = props;
   return (
     <div>
       <div className="quality-profile-grid">
         <div className="quality-profile-grid-left">
-          <ProfileRules organization={organization} profile={profile} />
-          <ProfileExporters
-            exporters={props.exporters}
-            organization={organization}
-            profile={profile}
-          />
+          <ProfileRules profile={profile} />
+          <ProfileExporters exporters={props.exporters} profile={profile} />
           {profile.actions && profile.actions.edit && !profile.isBuiltIn && (
-            <ProfilePermissions organization={organization || undefined} profile={profile} />
+            <ProfilePermissions profile={profile} />
           )}
         </div>
         <div className="quality-profile-grid-right">
           <ProfileInheritance
-            organization={organization}
             profile={profile}
             profiles={props.profiles}
             updateProfiles={props.updateProfiles}
           />
-          <ProfileProjects organization={organization} profile={profile} />
+          <ProfileProjects profile={profile} />
         </div>
       </div>
     </div>
index 381a7c3ad70ea87a0b536bfaeb76ec5f0b29b8ad..0532cc97ecda382165b1c8ccd99c38421ec0bea7 100644 (file)
@@ -25,7 +25,6 @@ import { Exporter, Profile } from '../types';
 
 interface Props {
   exporters: Exporter[];
-  organization: string | null;
   profile: Profile;
 }
 
index d31cede4577037169d4740601a28b769e385e315..ecd50a91dc1ebc1132bcca78cfe5b9f21a2d00fb 100644 (file)
@@ -29,13 +29,12 @@ import { getProfileChangelogPath, getProfilesForLanguagePath, PROFILE_PATH } fro
 
 interface Props {
   profile: Profile;
-  organization: string | null;
   updateProfiles: () => Promise<void>;
 }
 
 export default class ProfileHeader extends React.PureComponent<Props> {
   render() {
-    const { organization, profile } = this.props;
+    const { profile } = this.props;
 
     return (
       <header className="page-header quality-profile-header">
@@ -74,7 +73,6 @@ export default class ProfileHeader extends React.PureComponent<Props> {
             <li>
               <ProfileActions
                 className="pull-left"
-                organization={organization}
                 profile={profile}
                 updateProfiles={this.props.updateProfiles}
               />
index dd733cf51bda8020e1331affc1c4bec252870017..c509343770be17226f21e6669cb4dc36610299d4 100644 (file)
@@ -27,7 +27,6 @@ import ChangeParentForm from './ChangeParentForm';
 import ProfileInheritanceBox from './ProfileInheritanceBox';
 
 interface Props {
-  organization: string | null;
   profile: Profile;
   profiles: Profile[];
   updateProfiles: () => Promise<void>;
@@ -143,7 +142,6 @@ export default class ProfileInheritance extends React.PureComponent<Props, State
                       depth={index}
                       key={ancestor.key}
                       language={profile.language}
-                      organization={this.props.organization}
                       profile={ancestor}
                       type="ancestor"
                     />
@@ -158,7 +156,6 @@ export default class ProfileInheritance extends React.PureComponent<Props, State
                     displayLink={false}
                     extendsBuiltIn={extendsBuiltIn}
                     language={profile.language}
-                    organization={this.props.organization}
                     profile={this.state.profile}
                   />
                 )}
@@ -169,7 +166,6 @@ export default class ProfileInheritance extends React.PureComponent<Props, State
                       depth={ancestors ? ancestors.length + 1 : 0}
                       key={child.key}
                       language={profile.language}
-                      organization={this.props.organization}
                       profile={child}
                       type="child"
                     />
index 5e0286d83cebaa3c630a1a4ae5e5632389cfe354..402b2082e8b5b6bfc7feecd6762432114ad1c882 100644 (file)
@@ -29,7 +29,6 @@ interface Props {
   displayLink?: boolean;
   extendsBuiltIn?: boolean;
   language: string;
-  organization: string | null;
   profile: T.ProfileInheritanceDetails;
   type?: string;
 }
index 3e7bfd59bf7565c7666f6e6fa126b9634763efa7..0d4e62d0146f09cf3b01fd534e466f8822926024 100644 (file)
@@ -36,7 +36,6 @@ export interface Group {
 }
 
 interface Props {
-  organization?: string;
   profile: Pick<Profile, 'key' | 'language' | 'name'>;
 }
 
@@ -57,10 +56,7 @@ export default class ProfilePermissions extends React.PureComponent<Props, State
   }
 
   componentDidUpdate(prevProps: Props) {
-    if (
-      prevProps.organization !== this.props.organization ||
-      prevProps.profile.key !== this.props.profile.key
-    ) {
+    if (prevProps.profile.key !== this.props.profile.key) {
       this.fetchUsersAndGroups();
     }
   }
@@ -71,10 +67,9 @@ export default class ProfilePermissions extends React.PureComponent<Props, State
 
   fetchUsersAndGroups() {
     this.setState({ loading: true });
-    const { organization, profile } = this.props;
+    const { profile } = this.props;
     const parameters: SearchUsersGroupsParameters = {
       language: profile.language,
-      organization,
       qualityProfile: profile.name,
       selected: 'selected'
     };
@@ -158,7 +153,6 @@ export default class ProfilePermissions extends React.PureComponent<Props, State
                   <ProfilePermissionsUser
                     key={user.login}
                     onDelete={this.handleUserDelete}
-                    organization={this.props.organization}
                     profile={this.props.profile}
                     user={user}
                   />
@@ -169,7 +163,6 @@ export default class ProfilePermissions extends React.PureComponent<Props, State
                     group={group}
                     key={group.name}
                     onDelete={this.handleGroupDelete}
-                    organization={this.props.organization}
                     profile={this.props.profile}
                   />
                 ))}
@@ -187,7 +180,6 @@ export default class ProfilePermissions extends React.PureComponent<Props, State
             onClose={this.handleAddUserFormClose}
             onGroupAdd={this.handleGroupAdd}
             onUserAdd={this.handleUserAdd}
-            organization={this.props.organization}
             profile={this.props.profile}
           />
         )}
index 31f7df2d32580719fdda16ff38e03638b7cd9a7a..05e3a88463550b7e1980e2ec29ea94a1a3b4e959 100644 (file)
@@ -35,7 +35,6 @@ interface Props {
   onClose: () => void;
   onGroupAdd: (group: Group) => void;
   onUserAdd: (user: T.UserSelected) => void;
-  organization?: string;
   profile: { language: string; name: string };
 }
 
@@ -64,26 +63,22 @@ export default class ProfilePermissionsForm extends React.PureComponent<Props, S
 
   handleUserAdd = (user: T.UserSelected) => {
     const {
-      profile: { language, name },
-      organization
+      profile: { language, name }
     } = this.props;
     addUser({
       language,
       login: user.login,
-      organization,
       qualityProfile: name
     }).then(() => this.props.onUserAdd(user), this.stopSubmitting);
   };
 
   handleGroupAdd = (group: Group) => {
     const {
-      profile: { language, name },
-      organization
+      profile: { language, name }
     } = this.props;
     addGroup({
       group: group.name,
       language,
-      organization,
       qualityProfile: name
     }).then(() => this.props.onGroupAdd(group), this.stopSubmitting);
   };
@@ -102,10 +97,9 @@ export default class ProfilePermissionsForm extends React.PureComponent<Props, S
   };
 
   handleSearch = (q: string) => {
-    const { organization, profile } = this.props;
+    const { profile } = this.props;
     const parameters: SearchUsersGroupsParameters = {
       language: profile.language,
-      organization,
       q,
       qualityProfile: profile.name,
       selected: 'deselected'
index 009d2ca6b506983d43e0ff9fe1cf801ce03f9866..56a2a0120be2940bffd317dc54e7e49900690be6 100644 (file)
@@ -29,7 +29,6 @@ import { Group } from './ProfilePermissions';
 interface Props {
   group: Group;
   onDelete: (group: Group) => void;
-  organization?: string;
   profile: { language: string; name: string };
 }
 
@@ -60,12 +59,11 @@ export default class ProfilePermissionsGroup extends React.PureComponent<Props,
   };
 
   handleDelete = () => {
-    const { group, organization, profile } = this.props;
+    const { group, profile } = this.props;
 
     return removeGroup({
       group: group.name,
       language: profile.language,
-      organization,
       qualityProfile: profile.name
     }).then(() => {
       this.handleDeleteModalClose();
index 95874f72f39b6053bfa11d78bb557a6fbfa220be..7e1bb3044ad30a78ffff5e0f8bc2d0369ceb0017 100644 (file)
@@ -31,7 +31,6 @@ import Avatar from '../../../components/ui/Avatar';
 
 interface Props {
   onDelete: (user: T.UserSelected) => void;
-  organization?: string;
   profile: { language: string; name: string };
   user: T.UserSelected;
 }
@@ -63,12 +62,11 @@ export default class ProfilePermissionsUser extends React.PureComponent<Props, S
   };
 
   handleDelete = () => {
-    const { organization, profile, user } = this.props;
+    const { profile, user } = this.props;
 
     return removeUser({
       language: profile.language,
       login: user.login,
-      organization,
       qualityProfile: profile.name
     }).then(() => {
       this.handleDeleteModalClose();
index 74a9a425c928b5c3c94665aa4b9a272f8ad3b608..aa3c4992aacb5732bb134c8098440a1478e77aa2 100644 (file)
@@ -29,7 +29,6 @@ import { Profile } from '../types';
 import ChangeProjectsForm from './ChangeProjectsForm';
 
 interface Props {
-  organization: string | null;
   profile: Profile;
 }
 
@@ -178,13 +177,7 @@ export default class ProfileProjects extends React.PureComponent<Props, State> {
           {profile.isDefault ? this.renderDefault() : this.renderProjects()}
         </div>
 
-        {this.state.formOpen && (
-          <ChangeProjectsForm
-            onClose={this.closeForm}
-            organization={this.props.organization}
-            profile={profile}
-          />
-        )}
+        {this.state.formOpen && <ChangeProjectsForm onClose={this.closeForm} profile={profile} />}
       </div>
     );
   }
index be27679c1093e6394b37adbbd55e37a6ed53e5da..06d1695b18592f6de30fcb4df0e7fbb65d3cf8cc 100644 (file)
@@ -35,7 +35,6 @@ import ProfileRulesSonarWayComparison from './ProfileRulesSonarWayComparison';
 const TYPES = ['BUG', 'VULNERABILITY', 'CODE_SMELL', 'SECURITY_HOTSPOT'];
 
 interface Props {
-  organization: string | null;
   profile: Profile;
 }
 
@@ -98,7 +97,6 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
     return searchRules({
       languages: this.props.profile.language,
       facets: 'types',
-      organization: this.props.organization || undefined,
       ps: 1
     });
   }
@@ -107,14 +105,13 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
     return searchRules({
       activation: 'true',
       facets: 'types',
-      organization: this.props.organization || undefined,
       ps: 1,
       qprofile: this.props.profile.key
     });
   }
 
   loadRules() {
-    Promise.all([this.loadAllRules(), this.loadActivatedRules(), this.loadProfile()]).then(
+    return Promise.all([this.loadAllRules(), this.loadActivatedRules(), this.loadProfile()]).then(
       responses => {
         if (this.mounted) {
           const [allRules, activatedRules, showProfile] = responses;
@@ -143,7 +140,7 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
   }
 
   render() {
-    const { organization, profile } = this.props;
+    const { profile } = this.props;
     const { compareToSonarWay } = this.state;
     const activateMoreUrl = getRulesUrl({ qprofile: profile.key, activation: 'false' });
     const { actions = {} } = profile;
@@ -164,7 +161,6 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
             <tbody>
               <ProfileRulesRowTotal
                 count={this.state.activatedTotal}
-                organization={organization}
                 qprofile={profile.key}
                 total={this.state.total}
               />
@@ -172,7 +168,6 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
                 <ProfileRulesRowOfType
                   count={this.getRulesCountForType(type)}
                   key={type}
-                  organization={organization}
                   qprofile={profile.key}
                   total={this.getRulesTotalForType(type)}
                   type={type}
@@ -189,7 +184,7 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
             </div>
           )}
 
-          {/* if a user is allowed to `copy` a profile if they are a global or organization admin */}
+          {/* if a user is allowed to `copy` a profile if they are a global admin */}
           {/* this user could potentially active more rules if the profile was not built-in */}
           {/* in such cases it's better to show the button but disable it with a tooltip */}
           {actions.copy && profile.isBuiltIn && (
@@ -205,14 +200,12 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
         {profile.activeDeprecatedRuleCount > 0 && (
           <ProfileRulesDeprecatedWarning
             activeDeprecatedRules={profile.activeDeprecatedRuleCount}
-            organization={organization}
             profile={profile.key}
           />
         )}
         {compareToSonarWay != null && compareToSonarWay.missingRuleCount > 0 && (
           <ProfileRulesSonarWayComparison
             language={profile.language}
-            organization={organization}
             profile={profile.key}
             sonarWayMissingRules={compareToSonarWay.missingRuleCount}
             sonarway={compareToSonarWay.profile}
index abb61aef348ead826448cd33b491a16235709a9b..543127f531d878dd4aa78a5c217de826214f0c57 100644 (file)
@@ -25,7 +25,6 @@ import { getDeprecatedActiveRulesUrl } from '../../../helpers/urls';
 
 interface Props {
   activeDeprecatedRules: number;
-  organization: string | null;
   profile: string;
 }
 
index 29d56d4352eb7bfff0c370277a113c683d16eb74..26c398a6acb6e5edab9ae645d23e80e296bbe087 100644 (file)
@@ -26,7 +26,6 @@ import { getRulesUrl } from '../../../helpers/urls';
 
 interface Props {
   count: number | null;
-  organization: string | null;
   qprofile: string;
   total: number | null;
   type: string;
index 545657afa812d77d5f2231bdf2183e43cccd1062..79687519030828d0e998d90d86d1f898524cf775 100644 (file)
@@ -25,7 +25,6 @@ import { getRulesUrl } from '../../../helpers/urls';
 
 interface Props {
   count: number | null;
-  organization: string | null;
   qprofile: string;
   total: number | null;
 }
index 451bd52c5596ca440932066dcbf7b04ccfb068a8..2e1e24b051c6ab8ecd7539391f4c8ec2d1f5cd5c 100644 (file)
@@ -25,7 +25,6 @@ import { getRulesUrl } from '../../../helpers/urls';
 
 interface Props {
   language: string;
-  organization: string | null;
   profile: string;
   sonarway: string;
   sonarWayMissingRules: number;
index c0a2fe2b999d0ad7fef8ac2770739f269ce61984..cc1c0a2b38332cbb555cbe1671d4aa15f57df253 100644 (file)
@@ -29,7 +29,6 @@ import {
 import ChangeProjectsForm from '../ChangeProjectsForm';
 
 const profile: any = { key: 'profFile_key' };
-const organization = 'TEST';
 
 jest.mock('../../../../api/quality-profiles', () => ({
   getProfileProjects: jest.fn().mockResolvedValue({
@@ -69,7 +68,6 @@ it('should render correctly', async () => {
   expect(getProfileProjects).toHaveBeenCalledWith(
     expect.objectContaining({
       key: profile.key,
-      organization,
       p: 1,
       ps: 100,
       q: undefined,
@@ -110,11 +108,6 @@ it('should close modal properly', () => {
 
 function shallowRender(props: Partial<ChangeProjectsForm['props']> = {}) {
   return shallow<ChangeProjectsForm>(
-    <ChangeProjectsForm
-      onClose={jest.fn()}
-      organization={organization}
-      profile={profile}
-      {...props}
-    />
+    <ChangeProjectsForm onClose={jest.fn()} profile={profile} {...props} />
   );
 }
index 253430506d480b61dda8da3c7ebfa7da6992d437..3d3263369d772ea1db2390be8e1651a98d091b7c 100644 (file)
@@ -27,7 +27,6 @@ it('renders without permissions', () => {
     shallow(
       <ProfileDetails
         exporters={[]}
-        organization="org"
         profile={{} as Profile}
         profiles={[]}
         updateProfiles={jest.fn()}
@@ -41,7 +40,6 @@ it('renders with edit permission', () => {
     shallow(
       <ProfileDetails
         exporters={[]}
-        organization="org"
         profile={{ actions: { edit: true } } as Profile}
         profiles={[]}
         updateProfiles={jest.fn()}
index e3485a32162c7622d9108904efc91ac646d5a5b3..8a6bc391ea9b58fccbc330d79dee6d17093c7b3e 100644 (file)
@@ -32,7 +32,6 @@ function shallowRender(props: Partial<ProfileExporters['props']> = {}) {
   return shallow<ProfileExporters>(
     <ProfileExporters
       exporters={[mockQualityProfileExporter({ languages: [profile.language] })]}
-      organization="test-org"
       profile={profile}
       {...props}
     />
index 89b9e40e4a316706dc2497ddf0da58f83ce6b13f..8da271fd65e88fb02354c266df1e9582be19f1c3 100644 (file)
@@ -28,11 +28,6 @@ it('should render correctly', () => {
 
 function shallowRender(props: Partial<ProfileHeader['props']> = {}) {
   return shallow(
-    <ProfileHeader
-      organization="foo"
-      profile={mockQualityProfile()}
-      updateProfiles={jest.fn()}
-      {...props}
-    />
+    <ProfileHeader profile={mockQualityProfile()} updateProfiles={jest.fn()} {...props} />
   );
 }
index f2746e7e6966ba778d4089072a538323f91bf424..4e2b8317e9b79d9e6822aef9d2e22d89cbb91647 100644 (file)
@@ -60,7 +60,6 @@ it('should handle parent change correctly', async () => {
 function shallowRender(props: Partial<ProfileInheritance['props']> = {}) {
   return shallow<ProfileInheritance>(
     <ProfileInheritance
-      organization={null}
       profile={mockQualityProfile()}
       profiles={[mockQualityProfile()]}
       updateProfiles={jest.fn()}
index 43dbd3cf151249e50d5961a626a57e44f6581380..1637b32f6461af1d3e011024262b244c2b556f50 100644 (file)
@@ -42,7 +42,6 @@ function shallowRender(props = {}) {
     <ProfileInheritanceBox
       depth={1}
       language="foo"
-      organization={null}
       profile={mockQualityProfileInheritance()}
       {...props}
     />
index c99a3938557b6ae97c03809e75e9b91d7183c69a..a4e2b0b79ea56f1fd369b1dfa84b85f5ef2e557c 100644 (file)
@@ -20,6 +20,7 @@
 import { mount, shallow } from 'enzyme';
 import * as React from 'react';
 import { click, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { searchGroups, searchUsers } from '../../../../api/quality-profiles';
 import ProfilePermissions from '../ProfilePermissions';
 
 jest.mock('../../../../api/quality-profiles', () => ({
@@ -27,33 +28,36 @@ jest.mock('../../../../api/quality-profiles', () => ({
   searchGroups: jest.fn(() => Promise.resolve([]))
 }));
 
-const searchUsers = require('../../../../api/quality-profiles').searchUsers as jest.Mock<any>;
-const searchGroups = require('../../../../api/quality-profiles').searchGroups as jest.Mock<any>;
-
-const profile = { key: 'sonar-way', name: 'Sonar way', language: 'js' };
-
 beforeEach(() => {
-  searchUsers.mockClear();
-  searchGroups.mockClear();
+  jest.clearAllMocks();
 });
 
 it('renders', () => {
-  const wrapper = shallow(<ProfilePermissions profile={profile} />);
+  const wrapper = shallowRender();
   expect(wrapper).toMatchSnapshot();
 
   wrapper.setState({
     groups: [{ name: 'Lambda' }],
     loading: false,
-    users: [{ login: 'luke', name: 'Luke Skywalker' }]
+    users: [{ login: 'luke', name: 'Luke Skywalker', selected: false }]
   });
   expect(wrapper).toMatchSnapshot();
 });
 
+it('should update correctly', () => {
+  const wrapper = shallowRender();
+
+  wrapper.setProps({ profile: { key: 'otherKey', name: 'new profile', language: 'js' } });
+
+  expect(searchGroups).toBeCalledTimes(2);
+  expect(searchUsers).toBeCalledTimes(2);
+});
+
 it('opens add users form', async () => {
-  searchUsers.mockImplementationOnce(() =>
+  (searchUsers as jest.Mock).mockImplementationOnce(() =>
     Promise.resolve({ users: [{ login: 'luke', name: 'Luke Skywalker' }] })
   );
-  const wrapper = shallow(<ProfilePermissions profile={profile} />);
+  const wrapper = shallowRender();
   expect(searchUsers).toHaveBeenCalled();
   await waitAndUpdate(wrapper);
   expect(wrapper.find('ProfilePermissionsForm').exists()).toBe(false);
@@ -67,11 +71,14 @@ it('opens add users form', async () => {
 });
 
 it('removes user', () => {
-  const wrapper = shallow(<ProfilePermissions profile={profile} />);
+  const wrapper = shallowRender();
   (wrapper.instance() as ProfilePermissions).mounted = true;
 
-  const joda = { login: 'joda', name: 'Joda' };
-  wrapper.setState({ loading: false, users: [{ login: 'luke', name: 'Luke Skywalker' }, joda] });
+  const joda = { login: 'joda', name: 'Joda', selected: false };
+  wrapper.setState({
+    loading: false,
+    users: [{ login: 'luke', name: 'Luke Skywalker', selected: false }, joda]
+  });
   expect(wrapper.find('ProfilePermissionsUser')).toHaveLength(2);
 
   wrapper
@@ -83,7 +90,7 @@ it('removes user', () => {
 });
 
 it('removes group', () => {
-  const wrapper = shallow(<ProfilePermissions profile={profile} />);
+  const wrapper = shallowRender();
   (wrapper.instance() as ProfilePermissions).mounted = true;
 
   const lambda = { name: 'Lambda' };
@@ -99,17 +106,20 @@ it('removes group', () => {
 });
 
 it('fetches users and groups on mount', () => {
-  mount(<ProfilePermissions organization="org" profile={profile} />);
+  mount(<ProfilePermissions profile={{ key: 'sonar-way', name: 'Sonar way', language: 'js' }} />);
   expect(searchUsers).toBeCalledWith({
     language: 'js',
-    organization: 'org',
     qualityProfile: 'Sonar way',
     selected: 'selected'
   });
   expect(searchGroups).toBeCalledWith({
     language: 'js',
-    organization: 'org',
     qualityProfile: 'Sonar way',
     selected: 'selected'
   });
 });
+
+function shallowRender(overrides: Partial<{ key: string; name: string; language: string }> = {}) {
+  const profile = { key: 'sonar-way', name: 'Sonar way', language: 'js', ...overrides };
+  return shallow<ProfilePermissions>(<ProfilePermissions profile={profile} />);
+}
index 182b1f454b43ba37b846170daf941dcf55432c66..180294f20abe1524650fa7969335a9db77b97654 100644 (file)
@@ -45,12 +45,7 @@ it('renders', () => {
 it('removes user', async () => {
   const onDelete = jest.fn();
   const wrapper = shallow(
-    <ProfilePermissionsGroup
-      group={group}
-      onDelete={onDelete}
-      organization="org"
-      profile={profile}
-    />
+    <ProfilePermissionsGroup group={group} onDelete={onDelete} profile={profile} />
   );
   (wrapper.instance() as ProfilePermissionsGroup).mounted = true;
   expect(wrapper.find('SimpleModal').exists()).toBe(false);
@@ -62,7 +57,6 @@ it('removes user', async () => {
   expect(removeGroup).toBeCalledWith({
     group: 'lambda',
     language: 'js',
-    organization: 'org',
     qualityProfile: 'Sonar way'
   });
 
index 7d5888bccd794b3b6712150e3e935a871ad8d39f..f47a3dae3aac3dfcd2216b8bf7ba12cf646f0c4a 100644 (file)
@@ -43,7 +43,7 @@ it('renders', () => {
 it('removes user', async () => {
   const onDelete = jest.fn();
   const wrapper = shallow(
-    <ProfilePermissionsUser onDelete={onDelete} organization="org" profile={profile} user={user} />
+    <ProfilePermissionsUser onDelete={onDelete} profile={profile} user={user} />
   );
   (wrapper.instance() as ProfilePermissionsUser).mounted = true;
   expect(wrapper.find('SimpleModal').exists()).toBe(false);
@@ -55,7 +55,6 @@ it('removes user', async () => {
   expect(removeUser).toBeCalledWith({
     language: 'js',
     login: 'luke',
-    organization: 'org',
     qualityProfile: 'Sonar way'
   });
 
index f6ae788c248c3d3892bb8d29bab31fe155a1974d..2094be66a747c2ab5c33745994c9a5658e565b89 100644 (file)
@@ -21,6 +21,7 @@ import { shallow } from 'enzyme';
 import * as React from 'react';
 import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
 import { mockQualityProfile } from '../../../../helpers/testMocks';
+import ChangeProjectsForm from '../ChangeProjectsForm';
 import ProfileProjects from '../ProfileProjects';
 
 jest.mock('../../../../api/quality-profiles', () => ({
@@ -45,10 +46,20 @@ it('should render correctly', async () => {
   expect(wrapper).toMatchSnapshot();
 });
 
+it('should open and close the form', async () => {
+  const wrapper = shallowRender();
+  await waitAndUpdate(wrapper);
+
+  wrapper.instance().handleChangeClick();
+  expect(wrapper.find(ChangeProjectsForm).exists()).toBe(true);
+
+  wrapper.instance().closeForm();
+  expect(wrapper.find(ChangeProjectsForm).exists()).toBe(false);
+});
+
 function shallowRender(props: Partial<ProfileProjects['props']> = {}) {
-  return shallow(
+  return shallow<ProfileProjects>(
     <ProfileProjects
-      organization="foo"
       profile={mockQualityProfile({ actions: { associateProjects: true } })}
       {...props}
     />
index b4c0d8911d451618ccd16a01d393c0d225711b1b..0e08c3b19c13166245b6a9ff01a5508880c0437d 100644 (file)
@@ -30,7 +30,6 @@ const PROFILE = mockQualityProfile({
   activeDeprecatedRuleCount: 0,
   depth: 0,
   language: 'js',
-  organization: 'org',
   rulesUpdatedAt: '2017-06-28T12:58:44+0000'
 });
 
@@ -79,7 +78,7 @@ const apiResponseActive = {
   });
 
 it('should render the quality profiles rules with sonarway comparison', async () => {
-  const wrapper = shallow(<ProfileRules organization="foo" profile={PROFILE} />);
+  const wrapper = shallow(<ProfileRules profile={PROFILE} />);
   const instance = wrapper.instance() as any;
   instance.mounted = true;
   instance.loadRules();
@@ -89,42 +88,32 @@ it('should render the quality profiles rules with sonarway comparison', async ()
 });
 
 it('should show a button to activate more rules for admins', () => {
-  const wrapper = shallow(<ProfileRules organization="foo" profile={EDITABLE_PROFILE} />);
+  const wrapper = shallow(<ProfileRules profile={EDITABLE_PROFILE} />);
   expect(wrapper.find('.js-activate-rules')).toMatchSnapshot();
 });
 
 it('should show a disabled button to activate more rules for built-in profiles', () => {
   const wrapper = shallow(
-    <ProfileRules
-      organization={null}
-      profile={{ ...EDITABLE_PROFILE, actions: { copy: true }, isBuiltIn: true }}
-    />
+    <ProfileRules profile={{ ...EDITABLE_PROFILE, actions: { copy: true }, isBuiltIn: true }} />
   );
   expect(wrapper.find('.js-activate-rules')).toMatchSnapshot();
 });
 
 it('should show a deprecated rules warning message', () => {
   const wrapper = shallow(
-    <ProfileRules
-      organization="foo"
-      profile={{ ...EDITABLE_PROFILE, activeDeprecatedRuleCount: 8 }}
-    />
+    <ProfileRules profile={{ ...EDITABLE_PROFILE, activeDeprecatedRuleCount: 8 }} />
   );
   expect(wrapper.find('ProfileRulesDeprecatedWarning')).toMatchSnapshot();
 });
 
 it('should not show a button to activate more rules on built in profiles', () => {
-  const wrapper = shallow(
-    <ProfileRules organization={null} profile={{ ...EDITABLE_PROFILE, isBuiltIn: true }} />
-  );
+  const wrapper = shallow(<ProfileRules profile={{ ...EDITABLE_PROFILE, isBuiltIn: true }} />);
   expect(wrapper.find('.js-activate-rules').exists()).toBe(false);
 });
 
 it('should not show sonarway comparison for built in profiles', async () => {
   (apiQP as any).getQualityProfile = jest.fn(() => Promise.resolve());
-  const wrapper = shallow(
-    <ProfileRules organization={null} profile={{ ...PROFILE, isBuiltIn: true }} />
-  );
+  const wrapper = shallow(<ProfileRules profile={{ ...PROFILE, isBuiltIn: true }} />);
   await new Promise(setImmediate);
   wrapper.update();
   expect(apiQP.getQualityProfile).toHaveBeenCalledTimes(0);
@@ -141,7 +130,7 @@ it('should not show sonarway comparison if there is no missing rules', async ()
       }
     })
   );
-  const wrapper = shallow(<ProfileRules organization={null} profile={PROFILE} />);
+  const wrapper = shallow(<ProfileRules profile={PROFILE} />);
   await waitAndUpdate(wrapper);
   expect(apiQP.getQualityProfile).toHaveBeenCalledTimes(1);
   expect(wrapper.find('ProfileRulesSonarWayComparison')).toHaveLength(0);
index 9661851cad713d48701fd3067aaf825d26047920..6ba7efc90542fa389a7faf90947aae4835b12ac3 100644 (file)
@@ -23,8 +23,6 @@ import ProfileRulesDeprecatedWarning from '../ProfileRulesDeprecatedWarning';
 
 it('should render correctly', () => {
   expect(
-    shallow(
-      <ProfileRulesDeprecatedWarning activeDeprecatedRules={18} organization="foo" profile="bar" />
-    )
+    shallow(<ProfileRulesDeprecatedWarning activeDeprecatedRules={18} profile="bar" />)
   ).toMatchSnapshot();
 });
index fce11e2eb29600f58e6080ce5468e39e42d7cc7f..156bf85864e2785d71ef8062f4e889df238e8663 100644 (file)
@@ -23,47 +23,21 @@ import ProfileRulesRowOfType from '../ProfileRulesRowOfType';
 
 it('should render correctly', () => {
   expect(
-    shallow(
-      <ProfileRulesRowOfType count={3} organization="foo" qprofile="bar" total={10} type="BUG" />
-    )
+    shallow(<ProfileRulesRowOfType count={3} qprofile="bar" total={10} type="BUG" />)
   ).toMatchSnapshot();
 });
 
 it('should render correctly if there is 0 rules', () => {
   expect(
-    shallow(
-      <ProfileRulesRowOfType
-        count={0}
-        organization={null}
-        qprofile="bar"
-        total={0}
-        type="VULNERABILITY"
-      />
-    )
+    shallow(<ProfileRulesRowOfType count={0} qprofile="bar" total={0} type="VULNERABILITY" />)
   ).toMatchSnapshot();
 });
 
 it('should render correctly if there is missing data', () => {
   expect(
-    shallow(
-      <ProfileRulesRowOfType
-        count={5}
-        organization={null}
-        qprofile="bar"
-        total={null}
-        type="VULNERABILITY"
-      />
-    )
+    shallow(<ProfileRulesRowOfType count={5} qprofile="bar" total={null} type="VULNERABILITY" />)
   ).toMatchSnapshot();
   expect(
-    shallow(
-      <ProfileRulesRowOfType
-        count={null}
-        organization={null}
-        qprofile="foo"
-        total={10}
-        type="VULNERABILITY"
-      />
-    )
+    shallow(<ProfileRulesRowOfType count={null} qprofile="foo" total={10} type="VULNERABILITY" />)
   ).toMatchSnapshot();
 });
index 51e44a9373844780684c404607ff9c4d4a7ea101..8ea9072bf896403b903aa60747bbbcaf358dcb3c 100644 (file)
@@ -22,22 +22,16 @@ import * as React from 'react';
 import ProfileRulesRowTotal from '../ProfileRulesRowTotal';
 
 it('should render correctly', () => {
-  expect(
-    shallow(<ProfileRulesRowTotal count={3} organization="foo" qprofile="bar" total={10} />)
-  ).toMatchSnapshot();
+  expect(shallow(<ProfileRulesRowTotal count={3} qprofile="bar" total={10} />)).toMatchSnapshot();
 });
 
 it('should render correctly if there is 0 rules', () => {
-  expect(
-    shallow(<ProfileRulesRowTotal count={0} organization={null} qprofile="bar" total={0} />)
-  ).toMatchSnapshot();
+  expect(shallow(<ProfileRulesRowTotal count={0} qprofile="bar" total={0} />)).toMatchSnapshot();
 });
 
 it('should render correctly if there is missing data', () => {
+  expect(shallow(<ProfileRulesRowTotal count={5} qprofile="bar" total={null} />)).toMatchSnapshot();
   expect(
-    shallow(<ProfileRulesRowTotal count={5} organization={null} qprofile="bar" total={null} />)
-  ).toMatchSnapshot();
-  expect(
-    shallow(<ProfileRulesRowTotal count={null} organization={null} qprofile="foo" total={10} />)
+    shallow(<ProfileRulesRowTotal count={null} qprofile="foo" total={10} />)
   ).toMatchSnapshot();
 });
index 990b9cb0df6786ac2f5f3341454f3110b040e097..449b30603621f7daad132f3747a97a37749139fb 100644 (file)
@@ -26,7 +26,6 @@ it('should render correctly', () => {
     shallow(
       <ProfileRulesSonarWayComparison
         language="Java"
-        organization="foo"
         profile="bar"
         sonarWayMissingRules={158}
         sonarway="baz"
index 42299aa5648849e2eaf20fd750e7e0cf18ce5b19..0dcae2b693e83ae505f42ef66c1642e3b5dfb052 100644 (file)
@@ -9,7 +9,6 @@ exports[`renders with edit permission 1`] = `
       className="quality-profile-grid-left"
     >
       <ProfileRules
-        organization="org"
         profile={
           Object {
             "actions": Object {
@@ -20,7 +19,6 @@ exports[`renders with edit permission 1`] = `
       />
       <ProfileExporters
         exporters={Array []}
-        organization="org"
         profile={
           Object {
             "actions": Object {
@@ -30,7 +28,6 @@ exports[`renders with edit permission 1`] = `
         }
       />
       <ProfilePermissions
-        organization="org"
         profile={
           Object {
             "actions": Object {
@@ -44,7 +41,6 @@ exports[`renders with edit permission 1`] = `
       className="quality-profile-grid-right"
     >
       <ProfileInheritance
-        organization="org"
         profile={
           Object {
             "actions": Object {
@@ -56,7 +52,6 @@ exports[`renders with edit permission 1`] = `
         updateProfiles={[MockFunction]}
       />
       <ProfileProjects
-        organization="org"
         profile={
           Object {
             "actions": Object {
@@ -79,12 +74,10 @@ exports[`renders without permissions 1`] = `
       className="quality-profile-grid-left"
     >
       <ProfileRules
-        organization="org"
         profile={Object {}}
       />
       <ProfileExporters
         exporters={Array []}
-        organization="org"
         profile={Object {}}
       />
     </div>
@@ -92,13 +85,11 @@ exports[`renders without permissions 1`] = `
       className="quality-profile-grid-right"
     >
       <ProfileInheritance
-        organization="org"
         profile={Object {}}
         profiles={Array []}
         updateProfiles={[MockFunction]}
       />
       <ProfileProjects
-        organization="org"
         profile={Object {}}
       />
     </div>
index 5f17cbf43d9fa5820a06f0cb72d2a31d4156c1f8..c21ba396ab166c171c455f2071bb8ab6dd01f537 100644 (file)
@@ -16,7 +16,7 @@ exports[`should render correctly 1`] = `
         key="exporter-key"
       >
         <a
-          href="/api/qualityprofiles/export?exporterKey=exporter-key&language=js&qualityProfile=name&organization=foo"
+          href="/api/qualityprofiles/export?exporterKey=exporter-key&language=js&qualityProfile=name"
           rel="noopener noreferrer"
           target="_blank"
         >
index 98639139637ec4b5e48f1fac7c1dd24fd5ad0596..f5232cfdeee8ef9bca8d96f77a4c4ba0403c5356 100644 (file)
@@ -89,7 +89,6 @@ exports[`should render correctly 1`] = `
       <li>
         <withRouter(ProfileActions)
           className="pull-left"
-          organization="foo"
           profile={
             Object {
               "activeDeprecatedRuleCount": 2,
@@ -103,7 +102,6 @@ exports[`should render correctly 1`] = `
               "language": "js",
               "languageName": "JavaScript",
               "name": "name",
-              "organization": "foo",
               "projectCount": 3,
             }
           }
index f3e83c49c72b44a5efce67a0e38893bdac431193..ed912ef964bcf7f93958b1b123bb776ee5ce4d29 100644 (file)
@@ -22,7 +22,6 @@ exports[`should render correctly 1`] = `
           depth={0}
           key="foo"
           language="js"
-          organization={null}
           profile={
             Object {
               "activeRuleCount": 4,
@@ -38,7 +37,6 @@ exports[`should render correctly 1`] = `
           depth={2}
           key="foo"
           language="js"
-          organization={null}
           profile={
             Object {
               "activeRuleCount": 4,
@@ -78,7 +76,6 @@ exports[`should render modal correctly 1`] = `
           depth={0}
           key="foo"
           language="js"
-          organization={null}
           profile={
             Object {
               "activeRuleCount": 4,
@@ -94,7 +91,6 @@ exports[`should render modal correctly 1`] = `
           depth={2}
           key="foo"
           language="js"
-          organization={null}
           profile={
             Object {
               "activeRuleCount": 4,
@@ -125,7 +121,6 @@ exports[`should render modal correctly 1`] = `
         "language": "js",
         "languageName": "JavaScript",
         "name": "name",
-        "organization": "foo",
         "projectCount": 3,
       }
     }
@@ -143,7 +138,6 @@ exports[`should render modal correctly 1`] = `
           "language": "js",
           "languageName": "JavaScript",
           "name": "name",
-          "organization": "foo",
           "projectCount": 3,
         },
       ]
index 2615ccaeaa80821b9b2121eff1950d2a826771a2..6784f829bc2fdd666913b2da2bff1260199a4fe2 100644 (file)
@@ -58,6 +58,7 @@ exports[`renders 2`] = `
           Object {
             "login": "luke",
             "name": "Luke Skywalker",
+            "selected": false,
           }
         }
       />
index 640d9cecb708189ebb54e2f0f0ceff47b459f81e..c2af3488e985f23d8077ff205eac9d34573cf1f8 100644 (file)
@@ -28,14 +28,12 @@ exports[`should render the quality profiles rules with sonarway comparison 1`] =
       <tbody>
         <ProfileRulesRowTotal
           count={68}
-          organization="foo"
           qprofile="key"
           total={253}
         />
         <ProfileRulesRowOfType
           count={68}
           key="BUG"
-          organization="foo"
           qprofile="key"
           total={68}
           type="BUG"
@@ -43,7 +41,6 @@ exports[`should render the quality profiles rules with sonarway comparison 1`] =
         <ProfileRulesRowOfType
           count={0}
           key="VULNERABILITY"
-          organization="foo"
           qprofile="key"
           total={7}
           type="VULNERABILITY"
@@ -51,7 +48,6 @@ exports[`should render the quality profiles rules with sonarway comparison 1`] =
         <ProfileRulesRowOfType
           count={0}
           key="CODE_SMELL"
-          organization="foo"
           qprofile="key"
           total={168}
           type="CODE_SMELL"
@@ -59,7 +55,6 @@ exports[`should render the quality profiles rules with sonarway comparison 1`] =
         <ProfileRulesRowOfType
           count={0}
           key="SECURITY_HOTSPOT"
-          organization="foo"
           qprofile="key"
           total={10}
           type="SECURITY_HOTSPOT"
@@ -69,7 +64,6 @@ exports[`should render the quality profiles rules with sonarway comparison 1`] =
   </div>
   <ProfileRulesSonarWayComparison
     language="js"
-    organization="foo"
     profile="key"
     sonarWayMissingRules={4}
     sonarway="sonarway"
@@ -99,7 +93,6 @@ exports[`should show a button to activate more rules for admins 1`] = `
 exports[`should show a deprecated rules warning message 1`] = `
 <ProfileRulesDeprecatedWarning
   activeDeprecatedRules={8}
-  organization="foo"
   profile="key"
 />
 `;
index 4ac543498ede21a2dfb58f8a6d81d7233debce3f..ed24a597862193df11343817910fcf799c63a614 100644 (file)
@@ -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);
index 1386ced506890c3edc1c9afb34cb1e8c8d8a16d7..b2c3435c3ce273a6d6c1d03bb17573331c9151e6 100644 (file)
@@ -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>
   );
 }
index 03bbae3a26caf92897a63109970753bff6784ac1..424a3f33d9d8ac3b6cc195b0cd93bad171c33a1d 100644 (file)
@@ -26,7 +26,6 @@ import ProfileLink from '../components/ProfileLink';
 import { Profile } from '../types';
 
 interface Props {
-  organization: string | null;
   profiles: Profile[];
 }
 
index 8e5cf98a4adcb9483144fc6b35da44bac9029148..c5549b76fec05d6ca06f082e8a243e47eeca3b50 100644 (file)
@@ -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*/
+      }
     );
   }
 
index b474f52b6d81ccfbd2ae712159a33fae00a64afe..c28e359291aaad9de1cc8fa1c4ff2404a67f45a1 100644 (file)
@@ -25,7 +25,6 @@ import { Profile } from '../types';
 import { isStagnant } from '../utils';
 
 interface Props {
-  organization: string | null;
   profiles: Profile[];
 }
 
index df836bd583ed22622a3621f197541379659a5c0b..c6cdceeb83d7da449e9d342895baa6e09423c9b4 100644 (file)
@@ -29,7 +29,6 @@ interface Props {
   actions: Actions;
   languages: Array<{ key: string; name: string }>;
   location: Location;
-  organization: string | null;
   profiles: Profile[];
   updateProfiles: () => Promise<void>;
 }
index f1fce30d314323a662426fef8acf8dc20356471c..48265457269b842e90e2296262f587b2276fcdaf 100644 (file)
@@ -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}
           />
         )}
index 02958c6ce28840375e197c5bb21a7c119986aeeb..1983b2011040511fdf48d778c0157ed23213914d 100644 (file)
@@ -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}
       />
index 4d4776efbc9e576cdd9d7714cde78066346f3c24..5366ddae66576acf5ae6f6054d78545d312f3fa3 100644 (file)
@@ -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>
   );
index 9c6321f46676d97b0cac0eeff9a7fd7f9982da7c..400bb3e710069f9dd99c0e0270f591d02f5a8261 100644 (file)
@@ -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) => {
index 3d766f9c2749550f7c9f41fc64115cf632b64092..f0289064b4bdfc37640dcb390f5d4c13cbab27a6 100644 (file)
@@ -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 (file)
index 0000000..566708e
--- /dev/null
@@ -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} />);
+}
index 2c87c4146d5335a70ee590d7d5e04eebba99cf62..1298976da052e5c59974dbd43b7c31e31c1c7d29 100644 (file)
@@ -25,7 +25,6 @@ import EvolutionDeprecated from '../EvolutionDeprecated';
 it('should render correctly', () => {
   const wrapper = shallow(
     <EvolutionDeprecated
-      organization="foo"
       profiles={[
         mockQualityProfile({
           key: 'qp-1',
index d71b11092fb978ae1db306254a112ae6c492c7a5..804c7828d1bb2e2dc6fd746e1d7bef37a50a87a3 100644 (file)
@@ -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()}
index 4b5ae51f0b2ac02ef2a13e021e5eda3c47d7d85b..5da043e84014f79f7fdb82f5b91995be9ec2ef12 100644 (file)
@@ -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' })
index d0e7016a59c35ad5c4c9dd2794528188c97ce0f5..5a2c87fc28a25135794d404f409389d1f9b6d79d 100644 (file)
@@ -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}
index 45758a12dfe2c75a99b1a64f4d2a7f60f35d3a3a..3e809d231776073b89eba379c6498286a99596e0 100644 (file)
@@ -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 (file)
index 0000000..f3860f2
--- /dev/null
@@ -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>
+`;
index 7f1fec70c618b41e5b0576fac57470fe3d5e601c..d880cd231c88ca3b4e6ff1b6c7266892ee076379 100644 (file)
@@ -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>
 `;
index c146238494566115a70e2ff93a866fe37b21583c..e9091091c0f2e5319cbe4fa12961b463055c50ef 100644 (file)
@@ -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,
             }
           }
index 55b7bfdb8373e628d560ca8e68a8409d4c4651ec..25e5e98478b44179297a16234bc06d23b21bc412 100644 (file)
@@ -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,
         }
       }
index f1bf1cc7fcf512f453241a829a1aef8f215cf424..7715de8cf1e6808650dcb186c86efefc13511c45 100644 (file)
@@ -545,7 +545,6 @@ export function mockQualityProfile(overrides: Partial<Profile> = {}): Profile {
     languageName: 'JavaScript',
     name: 'name',
     projectCount: 3,
-    organization: 'foo',
     ...overrides
   };
 }