diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2020-12-09 14:43:36 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-12-22 20:09:35 +0000 |
commit | 8556ba8e2bedb1591c9e8510606d75bfdedbdf3d (patch) | |
tree | 48b66893ef9422e42ad978d8711dce41d20612ee /server/sonar-web | |
parent | c73de56d4b6ab4c9fdb34a32f5f740bed672b586 (diff) | |
download | sonarqube-8556ba8e2bedb1591c9e8510606d75bfdedbdf3d.tar.gz sonarqube-8556ba8e2bedb1591c9e8510606d75bfdedbdf3d.zip |
SONAR-13999 Drop orgs from Quality Profiles
Diffstat (limited to 'server/sonar-web')
83 files changed, 201 insertions, 413 deletions
diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts index a19c067ea5b..66f9292c655 100644 --- a/server/sonar-web/src/main/js/api/quality-profiles.ts +++ b/server/sonar-web/src/main/js/api/quality-profiles.ts @@ -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; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx index fb335dddd5c..fe7e7108693 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx @@ -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: [] }; }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/BulkChange-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/BulkChange-test.tsx.snap index 9e04281ed3b..89150cbd13d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/BulkChange-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/BulkChange-test.tsx.snap @@ -39,7 +39,6 @@ exports[`should display BulkChangeModal 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, }, } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap index 605d9606fdd..e7230ad913a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap @@ -118,7 +118,6 @@ exports[`should render correctly: loaded 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, }, } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap index fce5093c87a..b14e698cb93 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap @@ -65,7 +65,6 @@ exports[`renderActions should render the activate button 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, }, ] diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/__snapshots__/ProjectQualityProfilesAppRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/__snapshots__/ProjectQualityProfilesAppRenderer-test.tsx.snap index 57513807f58..0c32a1f07d3 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/__snapshots__/ProjectQualityProfilesAppRenderer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/__snapshots__/ProjectQualityProfilesAppRenderer-test.tsx.snap @@ -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, } } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx index 46ad79220e9..266fe944921 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx @@ -30,7 +30,6 @@ import ChangesList from './ChangesList'; interface Props { events: ProfileChangelogEvent[]; - organization: string | null; } export default function Changelog(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx index add7cd632a0..9a99212ca77 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx @@ -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 && ( diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx index 267646c73d3..39c438c59c4 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx @@ -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) => diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx index 176cda52f04..a076bacd1bc 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogContainer-test.tsx @@ -71,7 +71,6 @@ function shallowRender() { return shallow<ChangelogContainer>( <ChangelogContainer location={mockLocation()} - organization="TEST" profile={mockQualityProfile()} router={mockRouter()} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/__snapshots__/ChangelogContainer-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/__snapshots__/ChangelogContainer-test.tsx.snap index 788ec9aa5f6..2029636a14c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/__snapshots__/ChangelogContainer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/__snapshots__/ChangelogContainer-test.tsx.snap @@ -50,7 +50,6 @@ exports[`should render correctly 1`] = ` }, ] } - organization="TEST" /> <footer className="text-center spacer-top small" diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx index bb0f4f290bc..a2605732a1d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx @@ -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)} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx index 372feb8805f..7d19333bf23 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx @@ -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' }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx index 40fc7548ab3..444b4d41448 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx @@ -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 /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx index 5ef3289f82a..51b2f5d6eb3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx @@ -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 }); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx index 8db4ab61510..436238c44ee 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx @@ -18,14 +18,11 @@ * 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); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ExtendProfileForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ExtendProfileForm.tsx index 6510941c396..90dfcf4a50b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ExtendProfileForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ExtendProfileForm.tsx @@ -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 { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx index 97cc0ce6048..c9ba3d0887e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx @@ -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} /> )} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx index 0d5c32e155b..4dba8fd5085 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx @@ -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> ); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/App-test.tsx index d93c398f7aa..b43a6f83f4c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/App-test.tsx @@ -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> ); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ExtendProfileForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ExtendProfileForm-test.tsx index f8874ff1fed..d21dcbfe36e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ExtendProfileForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ExtendProfileForm-test.tsx @@ -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} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx index c809cba18c3..f7f9e824163 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx @@ -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} /> ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx index e028d15bb4b..b9b5635f476 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx @@ -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> + ); +} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap index 91ce05a8387..f59b868a871 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap @@ -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" diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.tsx index 12c84232e41..d543297af1f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeProjectsForm.tsx @@ -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, diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.tsx index 13cd29a00fd..6d84fc2ad47 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileDetails.tsx @@ -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> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx index 381a7c3ad70..0532cc97ecd 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx @@ -25,7 +25,6 @@ import { Exporter, Profile } from '../types'; interface Props { exporters: Exporter[]; - organization: string | null; profile: Profile; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx index d31cede4577..ecd50a91dc1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx @@ -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} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx index dd733cf51bd..c509343770b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx @@ -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" /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx index 5e0286d83ce..402b2082e8b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx @@ -29,7 +29,6 @@ interface Props { displayLink?: boolean; extendsBuiltIn?: boolean; language: string; - organization: string | null; profile: T.ProfileInheritanceDetails; type?: string; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx index 3e7bfd59bf7..0d4e62d0146 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx @@ -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} /> )} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx index 31f7df2d325..05e3a884635 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx @@ -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' diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsGroup.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsGroup.tsx index 009d2ca6b50..56a2a0120be 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsGroup.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsGroup.tsx @@ -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(); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx index 95874f72f39..7e1bb3044ad 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx @@ -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(); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx index 74a9a425c92..aa3c4992aac 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileProjects.tsx @@ -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> ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx index be27679c109..06d1695b185 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx @@ -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} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.tsx index abb61aef348..543127f531d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesDeprecatedWarning.tsx @@ -25,7 +25,6 @@ import { getDeprecatedActiveRulesUrl } from '../../../helpers/urls'; interface Props { activeDeprecatedRules: number; - organization: string | null; profile: string; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.tsx index 29d56d4352e..26c398a6acb 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.tsx @@ -26,7 +26,6 @@ import { getRulesUrl } from '../../../helpers/urls'; interface Props { count: number | null; - organization: string | null; qprofile: string; total: number | null; type: string; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.tsx index 545657afa81..79687519030 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.tsx @@ -25,7 +25,6 @@ import { getRulesUrl } from '../../../helpers/urls'; interface Props { count: number | null; - organization: string | null; qprofile: string; total: number | null; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.tsx index 451bd52c559..2e1e24b051c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.tsx @@ -25,7 +25,6 @@ import { getRulesUrl } from '../../../helpers/urls'; interface Props { language: string; - organization: string | null; profile: string; sonarway: string; sonarWayMissingRules: number; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ChangeProjectsForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ChangeProjectsForm-test.tsx index c0a2fe2b999..cc1c0a2b383 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ChangeProjectsForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ChangeProjectsForm-test.tsx @@ -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} /> ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileDetails-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileDetails-test.tsx index 253430506d4..3d3263369d7 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileDetails-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileDetails-test.tsx @@ -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()} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx index e3485a32162..8a6bc391ea9 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx @@ -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} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileHeader-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileHeader-test.tsx index 89b9e40e4a3..8da271fd65e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileHeader-test.tsx @@ -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} /> ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritance-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritance-test.tsx index f2746e7e696..4e2b8317e9b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritance-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritance-test.tsx @@ -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()} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritanceBox-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritanceBox-test.tsx index 43dbd3cf151..1637b32f646 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritanceBox-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileInheritanceBox-test.tsx @@ -42,7 +42,6 @@ function shallowRender(props = {}) { <ProfileInheritanceBox depth={1} language="foo" - organization={null} profile={mockQualityProfileInheritance()} {...props} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx index c99a3938557..a4e2b0b79ea 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissions-test.tsx @@ -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} />); +} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx index 182b1f454b4..180294f20ab 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsGroup-test.tsx @@ -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' }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx index 7d5888bccd7..f47a3dae3aa 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx @@ -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' }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx index f6ae788c248..2094be66a74 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx @@ -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} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx index b4c0d8911d4..0e08c3b19c1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx @@ -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); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesDeprecatedWarning-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesDeprecatedWarning-test.tsx index 9661851cad7..6ba7efc9054 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesDeprecatedWarning-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesDeprecatedWarning-test.tsx @@ -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(); }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowOfType-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowOfType-test.tsx index fce11e2eb29..156bf85864e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowOfType-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowOfType-test.tsx @@ -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(); }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowTotal-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowTotal-test.tsx index 51e44a93738..8ea9072bf89 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowTotal-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesRowTotal-test.tsx @@ -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(); }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesSonarWayComparison-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesSonarWayComparison-test.tsx index 990b9cb0df6..449b3060362 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesSonarWayComparison-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesSonarWayComparison-test.tsx @@ -26,7 +26,6 @@ it('should render correctly', () => { shallow( <ProfileRulesSonarWayComparison language="Java" - organization="foo" profile="bar" sonarWayMissingRules={158} sonarway="baz" diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileDetails-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileDetails-test.tsx.snap index 42299aa5648..0dcae2b693e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileDetails-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileDetails-test.tsx.snap @@ -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> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileExporters-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileExporters-test.tsx.snap index 5f17cbf43d9..c21ba396ab1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileExporters-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileExporters-test.tsx.snap @@ -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" > diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileHeader-test.tsx.snap index 98639139637..f5232cfdeee 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileHeader-test.tsx.snap @@ -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, } } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileInheritance-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileInheritance-test.tsx.snap index f3e83c49c72..ed912ef964b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileInheritance-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileInheritance-test.tsx.snap @@ -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, }, ] diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfilePermissions-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfilePermissions-test.tsx.snap index 2615ccaeaa8..6784f829bc2 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfilePermissions-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfilePermissions-test.tsx.snap @@ -58,6 +58,7 @@ exports[`renders 2`] = ` Object { "login": "luke", "name": "Luke Skywalker", + "selected": false, } } /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRules-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRules-test.tsx.snap index 640d9cecb70..c2af3488e98 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRules-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRules-test.tsx.snap @@ -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" /> `; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx index 4ac543498ed..ed24a597862 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/CreateProfileForm.tsx @@ -37,7 +37,6 @@ interface Props { location: Location; onClose: () => void; onCreate: Function; - organization: string | null; profiles: Profile[]; } @@ -96,9 +95,6 @@ export default class CreateProfileForm extends React.PureComponent<Props, State> this.setState({ loading: true }); const data = new FormData(event.currentTarget); - if (this.props.organization) { - data.append('organization', this.props.organization); - } try { const { profile } = await createQualityProfile(data); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx index 1386ced5068..b2c3435c3ce 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/Evolution.tsx @@ -23,17 +23,16 @@ import EvolutionDeprecated from './EvolutionDeprecated'; import EvolutionRules from './EvolutionRules'; import EvolutionStagnant from './EvolutionStagnant'; -interface Props { - organization: string | null; +export interface EvolutionProps { profiles: Profile[]; } -export default function Evolution({ organization, profiles }: Props) { +export default function Evolution({ profiles }: EvolutionProps) { return ( <div className="quality-profiles-evolution"> - <EvolutionDeprecated organization={organization} profiles={profiles} /> - <EvolutionStagnant organization={organization} profiles={profiles} /> - <EvolutionRules organization={organization} /> + <EvolutionDeprecated profiles={profiles} /> + <EvolutionStagnant profiles={profiles} /> + <EvolutionRules /> </div> ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx index 03bbae3a26c..424a3f33d9d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx @@ -26,7 +26,6 @@ import ProfileLink from '../components/ProfileLink'; import { Profile } from '../types'; interface Props { - organization: string | null; profiles: Profile[]; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx index 8e5cf98a4ad..c5549b76fec 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx @@ -35,10 +35,6 @@ function parseRules(rules: T.Rule[], actives?: T.Dict<T.RuleActivation[]>): Exte }); } -interface Props { - organization: string | null; -} - interface ExtendedRule extends T.Rule { activations: number; } @@ -48,11 +44,11 @@ interface State { latestRulesTotal?: number; } -export default class EvolutionRules extends React.PureComponent<Props, State> { +export default class EvolutionRules extends React.PureComponent<{}, State> { periodStartDate: string; mounted = false; - constructor(props: Props) { + constructor(props: {}) { super(props); this.state = {}; const startDate = new Date(); @@ -74,7 +70,6 @@ export default class EvolutionRules extends React.PureComponent<Props, State> { asc: false, available_since: this.periodStartDate, f: 'name,langName,actives', - organization: this.props.organization || undefined, ps: RULES_LIMIT, s: 'createdAt' }; @@ -88,7 +83,9 @@ export default class EvolutionRules extends React.PureComponent<Props, State> { }); } }, - () => {} + () => { + /*noop*/ + } ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx index b474f52b6d8..c28e359291a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx @@ -25,7 +25,6 @@ import { Profile } from '../types'; import { isStagnant } from '../utils'; interface Props { - organization: string | null; profiles: Profile[]; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx index df836bd583e..c6cdceeb83d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/HomeContainer.tsx @@ -29,7 +29,6 @@ interface Props { actions: Actions; languages: Array<{ key: string; name: string }>; location: Location; - organization: string | null; profiles: Profile[]; updateProfiles: () => Promise<void>; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx index f1fce30d314..48265457269 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/PageHeader.tsx @@ -33,7 +33,6 @@ interface Props { actions: Actions; languages: Array<{ key: string; name: string }>; location: Location; - organization: string | null; profiles: Profile[]; router: Pick<Router, 'push'>; updateProfiles: () => Promise<void>; @@ -76,7 +75,7 @@ export class PageHeader extends React.PureComponent<Props, State> { }; render() { - const { actions, languages, location, organization, profiles } = this.props; + const { actions, languages, location, profiles } = this.props; return ( <header className="page-header"> <h1 className="page-title">{translate('quality_profiles.page')}</h1> @@ -121,7 +120,6 @@ export class PageHeader extends React.PureComponent<Props, State> { <RestoreProfileForm onClose={this.closeRestoreForm} onRestore={this.props.updateProfiles} - organization={organization} /> )} @@ -131,7 +129,6 @@ export class PageHeader extends React.PureComponent<Props, State> { location={location} onClose={this.closeCreateForm} onCreate={this.handleCreate} - organization={organization} profiles={profiles} /> )} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx index 02958c6ce28..1983b201104 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx @@ -30,7 +30,6 @@ import ProfilesListRow from './ProfilesListRow'; interface Props { languages: T.Language[]; location: Pick<Location, 'query'>; - organization: string | null; profiles: Profile[]; updateProfiles: () => Promise<void>; } @@ -40,7 +39,6 @@ export default class ProfilesList extends React.PureComponent<Props> { return profiles.map(profile => ( <ProfilesListRow key={profile.key} - organization={this.props.organization} profile={profile} updateProfiles={this.props.updateProfiles} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx index 4d4776efbc9..5366ddae665 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx @@ -29,13 +29,12 @@ import ProfileLink from '../components/ProfileLink'; import { Profile } from '../types'; export interface ProfilesListRowProps { - organization: string | null; profile: Profile; updateProfiles: () => Promise<void>; } export function ProfilesListRow(props: ProfilesListRowProps) { - const { organization, profile } = props; + const { profile } = props; const offset = 25 * (profile.depth - 1); const activeRulesUrl = getRulesUrl({ @@ -99,12 +98,7 @@ export function ProfilesListRow(props: ProfilesListRowProps) { </td> <td className="quality-profiles-table-actions thin nowrap text-middle text-right"> - <ProfileActions - fromList={true} - organization={organization} - profile={profile} - updateProfiles={props.updateProfiles} - /> + <ProfileActions fromList={true} profile={profile} updateProfiles={props.updateProfiles} /> </td> </tr> ); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx index 9c6321f4667..400bb3e7100 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/RestoreProfileForm.tsx @@ -27,7 +27,6 @@ import { restoreQualityProfile } from '../../../api/quality-profiles'; interface Props { onClose: () => void; onRestore: () => void; - organization: string | null; } interface State { @@ -55,9 +54,6 @@ export default class RestoreProfileForm extends React.PureComponent<Props, State this.setState({ loading: true }); const data = new FormData(event.currentTarget); - if (this.props.organization) { - data.append('organization', this.props.organization); - } restoreQualityProfile(data).then( (response: any) => { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx index 3d766f9c274..f0289064b4b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/CreateProfileForm-test.tsx @@ -83,7 +83,6 @@ function shallowRender(props?: Partial<CreateProfileForm['props']>) { location={mockLocation()} onClose={jest.fn()} onCreate={jest.fn()} - organization="org" profiles={[mockQualityProfile(), mockQualityProfile({ language: 'css' })]} {...props} /> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx new file mode 100644 index 00000000000..566708e978d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/Evolution-test.tsx @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { shallow } from 'enzyme'; +import * as React from 'react'; +import Evolution, { EvolutionProps } from '../Evolution'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender(props: Partial<EvolutionProps> = {}) { + return shallow(<Evolution profiles={[]} {...props} />); +} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx index 2c87c4146d5..1298976da05 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/EvolutionDeprecated-test.tsx @@ -25,7 +25,6 @@ import EvolutionDeprecated from '../EvolutionDeprecated'; it('should render correctly', () => { const wrapper = shallow( <EvolutionDeprecated - organization="foo" profiles={[ mockQualityProfile({ key: 'qp-1', diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx index d71b11092fb..804c7828d1b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/PageHeader-test.tsx @@ -52,7 +52,6 @@ function shallowRender(props: Partial<PageHeader['props']> = {}) { actions={{ create: false }} languages={[mockLanguage()]} location={mockLocation()} - organization="foo" profiles={[mockQualityProfile()]} router={mockRouter()} updateProfiles={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx index 4b5ae51f0b2..5da043e8401 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesList-test.tsx @@ -39,7 +39,6 @@ function shallowRender(props: Partial<ProfilesList['props']> = {}) { <ProfilesList languages={[mockLanguage(), mockLanguage({ key: 'js', name: 'JS' })]} location={mockLocation()} - organization="foo" profiles={[ mockQualityProfile(), mockQualityProfile({ language: 'css', languageName: 'CSS' }) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx index d0e7016a59c..5a2c87fc28a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/ProfilesListRow-test.tsx @@ -38,7 +38,6 @@ it('should render correctly', () => { function shallowRender(props: Partial<ProfilesListRowProps> = {}) { return shallow( <ProfilesListRow - organization={null} profile={mockQualityProfile({ activeDeprecatedRuleCount: 0 })} updateProfiles={jest.fn()} {...props} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx index 45758a12dfe..3e809d23177 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/RestoreProfileForm-test.tsx @@ -23,6 +23,6 @@ import RestoreProfileForm from '../RestoreProfileForm'; it('should render correctly', () => { expect( - shallow(<RestoreProfileForm onClose={jest.fn()} onRestore={jest.fn()} organization="org" />) + shallow(<RestoreProfileForm onClose={jest.fn()} onRestore={jest.fn()} />) ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap new file mode 100644 index 00000000000..f3860f2774d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/Evolution-test.tsx.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +<div + className="quality-profiles-evolution" +> + <EvolutionDeprecated + profiles={Array []} + /> + <EvolutionStagnant + profiles={Array []} + /> + <EvolutionRules /> +</div> +`; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap index 7f1fec70c61..d880cd231c8 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/PageHeader-test.tsx.snap @@ -207,7 +207,6 @@ exports[`should show a create form 1`] = ` } onClose={[Function]} onCreate={[Function]} - organization="foo" profiles={ Array [ Object { @@ -222,7 +221,6 @@ exports[`should show a create form 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, }, ] @@ -281,7 +279,6 @@ exports[`should show a restore form 1`] = ` <RestoreProfileForm onClose={[Function]} onRestore={[MockFunction]} - organization="foo" /> </header> `; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap index c1462384945..e9091091c0f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesList-test.tsx.snap @@ -69,7 +69,6 @@ exports[`should render correctly 1`] = ` <tbody> <Memo(ProfilesListRow) key="key" - organization="foo" profile={ Object { "activeDeprecatedRuleCount": 2, @@ -83,7 +82,6 @@ exports[`should render correctly 1`] = ` "language": "css", "languageName": "CSS", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -145,7 +143,6 @@ exports[`should render correctly 1`] = ` <tbody> <Memo(ProfilesListRow) key="key" - organization="foo" profile={ Object { "activeDeprecatedRuleCount": 2, @@ -159,7 +156,6 @@ exports[`should render correctly 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -241,7 +237,6 @@ exports[`should render correctly 2`] = ` <tbody> <Memo(ProfilesListRow) key="key" - organization="foo" profile={ Object { "activeDeprecatedRuleCount": 2, @@ -255,7 +250,6 @@ exports[`should render correctly 2`] = ` "language": "css", "languageName": "CSS", "name": "name", - "organization": "foo", "projectCount": 3, } } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap index 55b7bfdb837..25e5e98478b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/__tests__/__snapshots__/ProfilesListRow-test.tsx.snap @@ -98,7 +98,6 @@ exports[`should render correctly: built-in profile 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 2, @@ -112,7 +111,6 @@ exports[`should render correctly: built-in profile 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -192,7 +190,6 @@ exports[`should render correctly: default 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 0, @@ -206,7 +203,6 @@ exports[`should render correctly: default 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -317,7 +313,6 @@ exports[`should render correctly: default profile 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 2, @@ -331,7 +326,6 @@ exports[`should render correctly: default profile 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } @@ -436,7 +430,6 @@ exports[`should render correctly: with deprecated rules 1`] = ` > <withRouter(ProfileActions) fromList={true} - organization={null} profile={ Object { "activeDeprecatedRuleCount": 10, @@ -450,7 +443,6 @@ exports[`should render correctly: with deprecated rules 1`] = ` "language": "js", "languageName": "JavaScript", "name": "name", - "organization": "foo", "projectCount": 3, } } diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index f1bf1cc7fcf..7715de8cf1e 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -545,7 +545,6 @@ export function mockQualityProfile(overrides: Partial<Profile> = {}): Profile { languageName: 'JavaScript', name: 'name', projectCount: 3, - organization: 'foo', ...overrides }; } |