@@ -800,6 +800,7 @@ export default class App extends React.PureComponent<Props, State> { | |||
<Checkbox | |||
checked={isChecked} | |||
className="spacer-right vertical-middle" | |||
disabled={issues.length === 0} | |||
id="issues-selection" | |||
onCheck={this.onCheckAll} | |||
thirdState={thirdState} | |||
@@ -827,7 +828,10 @@ export default class App extends React.PureComponent<Props, State> { | |||
</Button> | |||
</Dropdown> | |||
) : ( | |||
<Button id="issues-bulk-change" onClick={this.handleBulkChangeClick}> | |||
<Button | |||
disabled={issues.length === 0} | |||
id="issues-bulk-change" | |||
onClick={this.handleBulkChangeClick}> | |||
{translate('bulk_change')} | |||
</Button> | |||
)} |
@@ -511,12 +511,15 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> { | |||
{this.renderTagsField('removeTags', 'issue.remove_tags', false)} | |||
{this.renderTransitionsField()} | |||
{this.renderCommentField()} | |||
{this.renderNotificationsField()} | |||
{issues.length > 0 && this.renderNotificationsField()} | |||
{issues.length === 0 && ( | |||
<span className="alert alert-warning">{translate('issue_bulk_change.no_match')}</span> | |||
)} | |||
</div> | |||
<div className="modal-foot"> | |||
{submitting && <i className="spinner spacer-right" />} | |||
<SubmitButton disabled={submitting} id="bulk-change-submit"> | |||
<SubmitButton disabled={submitting || issues.length === 0} id="bulk-change-submit"> | |||
{translate('apply')} | |||
</SubmitButton> | |||
{this.renderCancelButton()} |
@@ -0,0 +1,85 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2018 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 * as React from 'react'; | |||
import { shallow } from 'enzyme'; | |||
import BulkChangeModal from '../BulkChangeModal'; | |||
import { waitAndUpdate } from '../../../../helpers/testUtils'; | |||
import { Issue } from '../../../../app/types'; | |||
jest.mock('../../../../api/issues', () => ({ | |||
searchIssueTags: () => Promise.resolve([undefined, []]) | |||
})); | |||
it('should display error message when no issues available', async () => { | |||
const wrapper = getWrapper([]); | |||
await waitAndUpdate(wrapper); | |||
expect(wrapper).toMatchSnapshot(); | |||
}); | |||
it('should display form when issues are present', async () => { | |||
const wrapper = getWrapper([ | |||
{ | |||
component: 'foo', | |||
componentLongName: 'foo', | |||
componentQualifier: 'foo', | |||
componentUuid: 'foo', | |||
creationDate: 'foo', | |||
key: 'foo', | |||
flows: [], | |||
fromHotspot: false, | |||
message: 'foo', | |||
organization: 'foo', | |||
project: 'foo', | |||
projectName: 'foo', | |||
projectOrganization: 'foo', | |||
projectUuid: 'foo', | |||
rule: 'foo', | |||
ruleName: 'foo', | |||
secondaryLocations: [], | |||
severity: 'foo', | |||
status: 'foo', | |||
type: 'foo' | |||
} | |||
]); | |||
await waitAndUpdate(wrapper); | |||
expect(wrapper).toMatchSnapshot(); | |||
}); | |||
const getWrapper = (issues: Issue[]) => { | |||
return shallow( | |||
<BulkChangeModal | |||
component={undefined} | |||
currentUser={{ isLoggedIn: true }} | |||
fetchIssues={() => | |||
Promise.resolve({ | |||
issues, | |||
paging: { | |||
pageIndex: 0, | |||
pageSize: 0, | |||
total: 0 | |||
} | |||
}) | |||
} | |||
onClose={() => {}} | |||
onDone={() => {}} | |||
organization={undefined} | |||
/> | |||
); | |||
}; |
@@ -0,0 +1,102 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`should display error message when no issues available 1`] = ` | |||
<Modal | |||
contentLabel="modal" | |||
onRequestClose={[Function]} | |||
> | |||
<form | |||
id="bulk-change-form" | |||
onSubmit={[Function]} | |||
> | |||
<div | |||
className="modal-head" | |||
> | |||
<h2> | |||
issue_bulk_change.form.title.0 | |||
</h2> | |||
</div> | |||
<div | |||
className="modal-body" | |||
> | |||
<span | |||
className="alert alert-warning" | |||
> | |||
issue_bulk_change.no_match | |||
</span> | |||
</div> | |||
<div | |||
className="modal-foot" | |||
> | |||
<SubmitButton | |||
disabled={true} | |||
id="bulk-change-submit" | |||
> | |||
apply | |||
</SubmitButton> | |||
<a | |||
href="#" | |||
id="bulk-change-cancel" | |||
onClick={[Function]} | |||
> | |||
cancel | |||
</a> | |||
</div> | |||
</form> | |||
</Modal> | |||
`; | |||
exports[`should display form when issues are present 1`] = ` | |||
<Modal | |||
contentLabel="modal" | |||
onRequestClose={[Function]} | |||
> | |||
<form | |||
id="bulk-change-form" | |||
onSubmit={[Function]} | |||
> | |||
<div | |||
className="modal-head" | |||
> | |||
<h2> | |||
issue_bulk_change.form.title.1 | |||
</h2> | |||
</div> | |||
<div | |||
className="modal-body" | |||
> | |||
<div | |||
className="modal-field" | |||
> | |||
<label | |||
htmlFor="send-notifications" | |||
> | |||
issue.send_notifications | |||
</label> | |||
<Checkbox | |||
checked={false} | |||
onCheck={[Function]} | |||
thirdState={false} | |||
/> | |||
</div> | |||
</div> | |||
<div | |||
className="modal-foot" | |||
> | |||
<SubmitButton | |||
disabled={false} | |||
id="bulk-change-submit" | |||
> | |||
apply | |||
</SubmitButton> | |||
<a | |||
href="#" | |||
id="bulk-change-cancel" | |||
onClick={[Function]} | |||
> | |||
cancel | |||
</a> | |||
</div> | |||
</form> | |||
</Modal> | |||
`; |
@@ -717,7 +717,7 @@ issue_bulk_change.form.title=Change {0} issues | |||
issue_bulk_change.comment.help=This comment will be applied only to issues that will effectively be modified | |||
issue_bulk_change.max_issues_reached=As too many issues have been selected, only the first {0} issues will be updated. | |||
issue_bulk_change.x_issues={0} issues | |||
issue_bulk_change.no_match=There is no issue matching your filter selection | |||
#------------------------------------------------------------------------------ |