public QualityProfilePage shouldAllowToChangeProjects() {
Selenide.$(".js-change-projects").shouldBe(Condition.visible).click();
- Selenide.$("#profile-projects .select-list-list").shouldBe(Condition.visible);
+ Selenide.$("#profile-projects .select-list-list-container").shouldBe(Condition.visible);
+ return this;
+ }
+
+ public QualityProfilePage shouldNotAllowToChangeProjects() {
+ Selenide.$(".js-change-projects").shouldNot(Condition.exist);
+ return this;
+ }
+
+ public QualityProfilePage shouldNotAllowToEdit() {
+ Selenide.$("button.dropdown-toggle").should(Condition.exist).click();
+ Selenide.$("#quality-profile-rename").shouldNot(Condition.exist);
+ Selenide.$("#quality-profile-activate-more-rules").shouldNot(Condition.exist);
return this;
}
}
import throwGlobalError from '../app/utils/throwGlobalError';
export interface ProfileActions {
+ associateProjects?: boolean;
copy?: boolean;
+ delete?: boolean;
edit?: boolean;
setAsDefault?: boolean;
}
}
export function getProfileProjects(data: RequestData): Promise<any> {
- return getJSON('/api/qualityprofiles/projects', data);
+ return getJSON('/api/qualityprofiles/projects', data).catch(throwGlobalError);
}
export function getProfileInheritance(profileKey: string): Promise<any> {
</span>
);
- return tooltip ? <Tooltip overlay={overlay}>{badge}</Tooltip> : badge;
+ return tooltip ? (
+ <Tooltip overlay={overlay} placement="right">
+ {badge}
+ </Tooltip>
+ ) : (
+ badge
+ );
}
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>
)}
</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}>
</ActionsDropdownItem>
)}
- {canDelete && <ActionsDropdownDivider />}
+ {actions.delete && <ActionsDropdownDivider />}
- {canDelete && (
+ {actions.delete && (
<ActionsDropdownItem
destructive={true}
id="quality-profile-delete"
).toMatchSnapshot();
});
-it('renders with permission to edit', () => {
+it('renders with permission to edit only', () => {
expect(
shallow(
<ProfileActions
<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()}
/>
)
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
</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
>
rename
</ActionsDropdownItem>
- <ActionsDropdownDivider />
- <ActionsDropdownItem
- destructive={true}
- id="quality-profile-delete"
- onClick={[Function]}
- >
- delete
- </ActionsDropdownItem>
</ActionsDropdown>
`;
}
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>) => {
};
renderDefault() {
+ if (this.state.loading) {
+ return <i className="spinner" />;
+ }
+
return (
<div>
<span className="badge spacer-right">{translate('default')}</span>
}
renderProjects() {
+ if (this.state.loading) {
+ return <i className="spinner" />;
+ }
+
const { projects } = this.state;
if (projects == null) {
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')}
</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 && (
$(".js-profile-comparison .Select-control").click();
}
+ @Test
+ public void testBuiltIn() {
+ Navigation nav = tester.openBrowser().logIn().submitCredentials(user.getLogin());
+ nav.openQualityProfile("xoo", "Sonar way", "test-org")
+ .shouldNotAllowToEdit()
+ .shouldAllowToChangeProjects();
+ nav.openQualityProfile("xoo", "Basic", "test-org")
+ .shouldNotAllowToEdit()
+ .shouldNotAllowToChangeProjects();
+ }
+
@Test
public void testCreation() {
Selenese.runSelenese(orchestrator, "/organization/OrganizationQualityProfilesUiTest/should_create.html");