diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles')
5 files changed, 49 insertions, 41 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx index f7e7d5f2679..9cda74cbfe1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInQualityProfileBadge.tsx @@ -41,5 +41,11 @@ export default function BuiltInQualityProfileBadge({ className, tooltip = true } </span> ); - return tooltip ? <Tooltip overlay={overlay}>{badge}</Tooltip> : badge; + return tooltip ? ( + <Tooltip overlay={overlay} placement="right"> + {badge} + </Tooltip> + ) : ( + badge + ); } 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 0a2aff5cffb..0ed58dbb34c 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 @@ -137,15 +137,10 @@ export default class ProfileActions extends React.PureComponent<Props, State> { this.props.organization ); - const canActivateRules = actions.edit && !profile.isBuiltIn; - const canRename = actions.edit && !profile.isBuiltIn; - const canSetAsDefault = actions.setAsDefault && !profile.isDefault; - const canDelete = actions.edit && !profile.isDefault && !profile.isBuiltIn; - return ( <ActionsDropdown className={this.props.className}> - {canActivateRules && ( - <ActionsDropdownItem to={activateMoreUrl}> + {actions.edit && ( + <ActionsDropdownItem to={activateMoreUrl} id="quality-profile-activate-more-rules"> {translate('quality_profiles.activate_more_rules')} </ActionsDropdownItem> )} @@ -171,13 +166,13 @@ export default class ProfileActions extends React.PureComponent<Props, State> { </ActionsDropdownItem> )} - {canRename && ( + {actions.edit && ( <ActionsDropdownItem id="quality-profile-rename" onClick={this.handleRenameClick}> {translate('rename')} </ActionsDropdownItem> )} - {canSetAsDefault && ( + {actions.setAsDefault && ( <ActionsDropdownItem id="quality-profile-set-as-default" onClick={this.handleSetDefaultClick}> @@ -185,9 +180,9 @@ export default class ProfileActions extends React.PureComponent<Props, State> { </ActionsDropdownItem> )} - {canDelete && <ActionsDropdownDivider />} + {actions.delete && <ActionsDropdownDivider />} - {canDelete && ( + {actions.delete && ( <ActionsDropdownItem destructive={true} id="quality-profile-delete" 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 f54dde5ed08..ee33feb4d51 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 @@ -50,7 +50,7 @@ it('renders with no permissions', () => { ).toMatchSnapshot(); }); -it('renders with permission to edit', () => { +it('renders with permission to edit only', () => { expect( shallow( <ProfileActions @@ -69,7 +69,16 @@ it('renders with all permissions', () => { <ProfileActions onRequestFail={jest.fn()} organization="org" - profile={{ ...PROFILE, actions: { copy: true, edit: true, setAsDefault: true } }} + profile={{ + ...PROFILE, + actions: { + copy: true, + edit: true, + delete: true, + setAsDefault: true, + associateProjects: true + } + }} updateProfiles={jest.fn()} /> ) 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 ba760e5cb62..7e53929904b 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 @@ -3,6 +3,7 @@ exports[`renders with all permissions 1`] = ` <ActionsDropdown> <ActionsDropdownItem + id="quality-profile-activate-more-rules" to="/organizations/org/rules#qprofile=foo|activation=false" > quality_profiles.activate_more_rules @@ -83,9 +84,10 @@ exports[`renders with no permissions 1`] = ` </ActionsDropdown> `; -exports[`renders with permission to edit 1`] = ` +exports[`renders with permission to edit only 1`] = ` <ActionsDropdown> <ActionsDropdownItem + id="quality-profile-activate-more-rules" to="/organizations/org/rules#qprofile=foo|activation=false" > quality_profiles.activate_more_rules @@ -117,13 +119,5 @@ exports[`renders with permission to edit 1`] = ` > rename </ActionsDropdownItem> - <ActionsDropdownDivider /> - <ActionsDropdownItem - destructive={true} - id="quality-profile-delete" - onClick={[Function]} - > - delete - </ActionsDropdownItem> </ActionsDropdown> `; 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 9b1acd46c8e..66476d8c966 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 @@ -69,15 +69,18 @@ export default class ProfileProjects extends React.PureComponent<Props, State> { } const data = { key: this.props.profile.key }; - getProfileProjects(data).then((r: any) => { - if (this.mounted) { - this.setState({ - projects: r.results, - more: r.more, - loading: false - }); - } - }); + getProfileProjects(data).then( + (r: any) => { + if (this.mounted) { + this.setState({ + projects: r.results, + more: r.more, + loading: false + }); + } + }, + () => {} + ); } handleChangeClick = (event: React.SyntheticEvent<HTMLElement>) => { @@ -91,6 +94,10 @@ export default class ProfileProjects extends React.PureComponent<Props, State> { }; renderDefault() { + if (this.state.loading) { + return <i className="spinner" />; + } + return ( <div> <span className="badge spacer-right">{translate('default')}</span> @@ -100,6 +107,10 @@ export default class ProfileProjects extends React.PureComponent<Props, State> { } renderProjects() { + if (this.state.loading) { + return <i className="spinner" />; + } + const { projects } = this.state; if (projects == null) { @@ -130,8 +141,7 @@ export default class ProfileProjects extends React.PureComponent<Props, State> { return ( <div className="boxed-group quality-profile-projects"> {profile.actions && - profile.actions.edit && - !profile.isDefault && ( + profile.actions.associateProjects && ( <div className="boxed-group-actions"> <button className="js-change-projects" onClick={this.handleChangeClick}> {translate('quality_profiles.change_projects')} @@ -144,13 +154,7 @@ export default class ProfileProjects extends React.PureComponent<Props, State> { </header> <div className="boxed-group-inner"> - {this.state.loading ? ( - <i className="spinner" /> - ) : profile.isDefault ? ( - this.renderDefault() - ) : ( - this.renderProjects() - )} + {profile.isDefault ? this.renderDefault() : this.renderProjects()} </div> {this.state.formOpen && ( |