From 09b3d167fa8f399e18a37d56e7c8cbb61f68f97f Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 9 May 2018 09:17:16 +0200 Subject: SONAR-10664 Improve dropdown UI/UX consistency (#217) --- .../src/main/js/components/issue/IssueView.js | 20 +- .../js/components/issue/components/IssueAssign.js | 48 +++-- .../components/issue/components/IssueChangelog.js | 51 +++--- .../issue/components/IssueCommentAction.js | 31 ++-- .../issue/components/IssueCommentLine.js | 84 +++++---- .../js/components/issue/components/IssueMessage.js | 1 - .../components/issue/components/IssueSeverity.js | 41 +++-- .../js/components/issue/components/IssueTags.js | 52 +++--- .../components/issue/components/IssueTitleBar.js | 10 +- .../components/issue/components/IssueTransition.js | 49 ++--- .../js/components/issue/components/IssueType.js | 40 ++-- .../issue/components/SimilarIssuesFilter.js | 34 ++-- .../issue/components/__tests__/IssueAssign-test.js | 8 +- .../components/__tests__/IssueChangelog-test.js | 2 +- .../__tests__/IssueCommentAction-test.js | 6 +- .../components/__tests__/IssueCommentLine-test.js | 4 +- .../components/__tests__/IssueSeverity-test.js | 2 +- .../issue/components/__tests__/IssueTags-test.js | 2 +- .../components/__tests__/IssueTransition-test.js | 2 +- .../issue/components/__tests__/IssueType-test.js | 2 +- .../__snapshots__/IssueAssign-test.js.snap | 183 +++++++++---------- .../__snapshots__/IssueChangelog-test.js.snap | 142 +++++++------- .../__snapshots__/IssueCommentAction-test.js.snap | 42 ++--- .../__snapshots__/IssueCommentLine-test.js.snap | 203 +++++++++------------ .../__snapshots__/IssueSeverity-test.js.snap | 121 ++++++------ .../__tests__/__snapshots__/IssueTags-test.js.snap | 137 +++++++------- .../__snapshots__/IssueTitleBar-test.js.snap | 2 - .../__snapshots__/IssueTransition-test.js.snap | 190 +++++++++---------- .../__tests__/__snapshots__/IssueType-test.js.snap | 125 +++++++------ .../js/components/issue/popups/ChangelogPopup.js | 10 +- .../components/issue/popups/CommentDeletePopup.js | 13 +- .../js/components/issue/popups/CommentPopup.js | 64 ++++--- .../js/components/issue/popups/SetAssigneePopup.js | 10 +- .../components/issue/popups/SetIssueTagsPopup.tsx | 23 +-- .../js/components/issue/popups/SetSeverityPopup.js | 13 +- .../components/issue/popups/SetTransitionPopup.js | 13 +- .../js/components/issue/popups/SetTypePopup.js | 13 +- .../components/issue/popups/SimilarIssuesPopup.js | 11 +- .../popups/__tests__/CommentDeletePopup-test.js | 2 +- .../issue/popups/__tests__/CommentPopup-test.js | 18 +- .../popups/__tests__/SetIssueTagsPopup-test.tsx | 7 +- .../__snapshots__/ChangelogPopup-test.js.snap | 8 +- .../__snapshots__/CommentDeletePopup-test.js.snap | 12 +- .../__snapshots__/CommentPopup-test.js.snap | 138 +++++++------- .../__snapshots__/SetIssueTagsPopup-test.tsx.snap | 39 ++-- .../__snapshots__/SetSeverityPopup-test.js.snap | 6 +- .../__snapshots__/SetTransitionPopup-test.js.snap | 6 +- .../__snapshots__/SetTypePopup-test.js.snap | 6 +- 48 files changed, 1017 insertions(+), 1029 deletions(-) (limited to 'server/sonar-web/src/main/js/components/issue') diff --git a/server/sonar-web/src/main/js/components/issue/IssueView.js b/server/sonar-web/src/main/js/components/issue/IssueView.js index 5f814a5347e..0598c4f9f07 100644 --- a/server/sonar-web/src/main/js/components/issue/IssueView.js +++ b/server/sonar-web/src/main/js/components/issue/IssueView.js @@ -51,15 +51,14 @@ export default class IssueView extends React.PureComponent { handleCheck = (event /*: Event */) => { event.preventDefault(); - event.stopPropagation(); if (this.props.onCheck) { this.props.onCheck(this.props.issue.key, event); } }; handleClick = (event /*: Event & { target: HTMLElement } */) => { - event.preventDefault(); - if (this.props.onClick) { + if (!isClickable(event.target) && this.props.onClick) { + event.preventDefault(); this.props.onClick(this.props.issue.key); } }; @@ -100,12 +99,12 @@ export default class IssueView extends React.PureComponent { togglePopup={this.props.togglePopup} /> {issue.comments && issue.comments.length > 0 && ( @@ -114,8 +113,8 @@ export default class IssueView extends React.PureComponent { ))} @@ -137,3 +136,12 @@ export default class IssueView extends React.PureComponent { ); } } + +function isClickable(node /*: any */) { + if (!node) { + return false; + } + const clickableTags = ['A', 'BUTTON', 'INPUT', 'TEXTAREA']; + const tagName = (node.tagName || '').toUpperCase(); + return clickableTags.includes(tagName) || isClickable(node.parentNode); +} diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js index 3f7d5e84ac7..783fdec65b0 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.js @@ -19,9 +19,11 @@ */ // @flow import React from 'react'; -import Avatar from '../../../components/ui/Avatar'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import SetAssigneePopup from '../popups/SetAssigneePopup'; +import Avatar from '../../../components/ui/Avatar'; +import Toggler from '../../../components/controls/Toggler'; +import DropdownIcon from '../../../components/icons-components/DropdownIcon'; +import { Button } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; /*:: import type { Issue } from '../types'; */ @@ -43,6 +45,10 @@ export default class IssueAssign extends React.PureComponent { this.props.togglePopup('assign', open); }; + handleClose = () => { + this.toggleAssign(false); + }; + renderAssignee() { const { issue } = this.props; return ( @@ -67,24 +73,26 @@ export default class IssueAssign extends React.PureComponent { render() { if (this.props.canAssign) { return ( - - }> - - +
+ + }> + + +
); } else { return this.renderAssignee(); diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js index 43f5adc2d91..a70f6ca5a33 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.js @@ -19,11 +19,12 @@ */ // @flow import React from 'react'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import ChangelogPopup from '../popups/ChangelogPopup'; import DateFromNow from '../../../components/intl/DateFromNow'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; +import Toggler from '../../../components/controls/Toggler'; import Tooltip from '../../../components/controls/Tooltip'; +import { Button } from '../../../components/ui/buttons'; /*:: import type { Issue } from '../types'; */ /*:: @@ -39,35 +40,39 @@ type Props = { export default class IssueChangelog extends React.PureComponent { /*:: props: Props; */ - handleClick = (evt /*: SyntheticInputEvent */) => { - evt.preventDefault(); + toggleChangelog = (open /*: boolean | void */) => { + this.props.togglePopup('changelog', open); + }; + + handleClick = () => { this.toggleChangelog(); }; - toggleChangelog = (open /*: boolean | void */) => { - this.props.togglePopup('changelog', open); + handleClose = () => { + this.toggleChangelog(false); }; render() { return ( - }> - }> - - - +
+ }> + }> + + + +
); } } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js index 01ba1f984a1..814d4053cf4 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js @@ -20,7 +20,8 @@ // @flow import React from 'react'; import { updateIssue } from '../actions'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; +import Toggler from '../../../components/controls/Toggler'; +import { Button } from '../../../components/ui/buttons'; import CommentPopup from '../popups/CommentPopup'; import { addIssueComment } from '../../../api/issues'; import { translate } from '../../../helpers/l10n'; @@ -49,29 +50,33 @@ export default class IssueCommentAction extends React.PureComponent { this.props.toggleComment(false); }; - handleCommentClick = () => this.props.toggleComment(); + handleCommentClick = () => { + this.props.toggleComment(); + }; + + handleClose = () => { + this.props.toggleComment(false); + }; render() { return ( -
  • - + }> - - + +
  • ); } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js index 1773bd16a0c..3a0910f6552 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js @@ -20,7 +20,7 @@ // @flow import React from 'react'; import Avatar from '../../../components/ui/Avatar'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; +import Toggler from '../../../components/controls/Toggler'; import EditIcon from '../../../components/icons-components/EditIcon'; import { EditButton, DeleteButton } from '../../../components/ui/buttons'; import CommentDeletePopup from '../popups/CommentDeletePopup'; @@ -48,12 +48,6 @@ export default class IssueCommentLine extends React.PureComponent { openPopup: '' }; - handleCommentClick = (event /*: Event & {target: HTMLElement}*/) => { - if (event.target.tagName === 'A') { - event.stopPropagation(); - } - }; - handleEdit = (text /*: string */) => { this.props.onEdit(this.props.comment.key, text); this.toggleEditPopup(false); @@ -75,9 +69,17 @@ export default class IssueCommentLine extends React.PureComponent { }); }; - toggleDeletePopup = (force /*: ?boolean */) => this.togglePopup('delete', force); + toggleDeletePopup = (force /*: ?boolean */) => { + this.togglePopup('delete', force); + }; - toggleEditPopup = (force /*: ?boolean */) => this.togglePopup('edit', force); + toggleEditPopup = (force /*: ?boolean */) => { + this.togglePopup('edit', force); + }; + + closePopups = () => { + this.setState({ openPopup: '' }); + }; render() { const { comment } = this.props; @@ -95,49 +97,45 @@ export default class IssueCommentLine extends React.PureComponent {
    {comment.updatable && ( - + + }> + - }> - - + +
    )} {comment.updatable && ( - }> - - +
    + }> + + +
    )}
    diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.js b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.js index 888d7f2d521..1f8a9cb2ae5 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueMessage.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueMessage.js @@ -38,7 +38,6 @@ export default class IssueMessage extends React.PureComponent { handleClick = (e /*: MouseEvent */) => { e.preventDefault(); - e.stopPropagation(); this.context.workspace.openRule({ key: this.props.rule, organization: this.props.organization diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js index 326e64e64ab..f75e0e8f3c7 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.js @@ -19,10 +19,12 @@ */ // @flow import React from 'react'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import SetSeverityPopup from '../popups/SetSeverityPopup'; -import SeverityHelper from '../../../components/shared/SeverityHelper'; import { setIssueSeverity } from '../../../api/issues'; +import Toggler from '../../../components/controls/Toggler'; +import DropdownIcon from '../../../components/icons-components/DropdownIcon'; +import SeverityHelper from '../../../components/shared/SeverityHelper'; +import { Button } from '../../../components/ui/buttons'; /*:: import type { Issue } from '../types'; */ /*:: @@ -42,28 +44,31 @@ export default class IssueSeverity extends React.PureComponent { this.props.togglePopup('set-severity', open); }; - setSeverity = (severity /*: string */) => + setSeverity = (severity /*: string */) => { this.props.setIssueProperty('severity', 'set-severity', setIssueSeverity, severity); + }; + + handleClose = () => { + this.toggleSetSeverity(false); + }; render() { const { issue } = this.props; if (this.props.canSetSeverity) { return ( - }> - - +
    + }> + + +
    ); } else { return ; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTags.js b/server/sonar-web/src/main/js/components/issue/components/IssueTags.js index fb183a7f8b7..b9f1fcba0be 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTags.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTags.js @@ -20,10 +20,11 @@ // @flow import React from 'react'; import { updateIssue } from '../actions'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import SetIssueTagsPopup from '../popups/SetIssueTagsPopup'; -import TagsList from '../../../components/tags/TagsList'; import { setIssueTags } from '../../../api/issues'; +import Toggler from '../../../components/controls/Toggler'; +import TagsList from '../../../components/tags/TagsList'; +import { Button } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; /*:: import type { Issue } from '../types'; */ @@ -57,32 +58,39 @@ export default class IssueTags extends React.PureComponent { ); }; + handleClose = () => { + this.toggleSetTags(false); + }; + render() { const { issue } = this.props; const { tags = [] } = issue; if (this.props.canSetTags) { return ( - - } - position="bottomright" - togglePopup={this.toggleSetTags}> - - +
    + + }> + + +
    ); } else { return ( diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js index 0dad342b1b5..781eebd1f06 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js @@ -45,8 +45,6 @@ type Props = {| |}; */ -const stopPropagation = (event /*: Event */) => event.stopPropagation(); - export default function IssueTitleBar(props /*: Props */) { const { issue } = props; const hasSimilarIssuesFilter = props.onFilter != null; @@ -103,7 +101,7 @@ export default function IssueTitleBar(props /*: Props */) { {displayLocations && (
  • {props.displayLocationsLink ? ( - + {locationsBadge} ) : ( @@ -112,11 +110,7 @@ export default function IssueTitleBar(props /*: Props */) {
  • )}
  • - +
  • diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js index 28379cde1cd..3aced6f8685 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.js @@ -20,10 +20,12 @@ // @flow import React from 'react'; import { updateIssue } from '../actions'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import SetTransitionPopup from '../popups/SetTransitionPopup'; -import StatusHelper from '../../../components/shared/StatusHelper'; import { setIssueTransition } from '../../../api/issues'; +import Toggler from '../../../components/controls/Toggler'; +import DropdownIcon from '../../../components/icons-components/DropdownIcon'; +import StatusHelper from '../../../components/shared/StatusHelper'; +import { Button } from '../../../components/ui/buttons'; /*:: import type { Issue } from '../types'; */ /*:: @@ -53,36 +55,41 @@ export default class IssueTransition extends React.PureComponent { this.props.togglePopup('transition', open); }; + handleClose = () => { + this.toggleSetTransition(false); + }; + render() { const { issue } = this.props; if (this.props.hasTransitions) { return ( - - }> - - +
    + + }> + + +
    ); } else { return ( ); } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueType.js b/server/sonar-web/src/main/js/components/issue/components/IssueType.js index 60941288e4b..380e8668a32 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueType.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueType.js @@ -19,10 +19,12 @@ */ // @flow import React from 'react'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; -import IssueTypeIcon from '../../../components/ui/IssueTypeIcon'; import SetTypePopup from '../popups/SetTypePopup'; import { setIssueType } from '../../../api/issues'; +import Toggler from '../../../components/controls/Toggler'; +import DropdownIcon from '../../../components/icons-components/DropdownIcon'; +import { Button } from '../../../components/ui/buttons'; +import IssueTypeIcon from '../../../components/ui/IssueTypeIcon'; import { translate } from '../../../helpers/l10n'; /*:: import type { Issue } from '../types'; */ @@ -43,26 +45,32 @@ export default class IssueType extends React.PureComponent { this.props.togglePopup('set-type', open); }; - setType = (type /*: string */) => + setType = (type /*: string */) => { this.props.setIssueProperty('type', 'set-type', setIssueType, type); + }; + + handleClose = () => { + this.toggleSetType(false); + }; render() { const { issue } = this.props; if (this.props.canSetSeverity) { return ( - }> - - +
    + }> + + +
    ); } else { return ( diff --git a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js index b9da955025a..5b900ac2e48 100644 --- a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js +++ b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.js @@ -19,8 +19,10 @@ */ // @flow import React from 'react'; -import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import SimilarIssuesPopup from '../popups/SimilarIssuesPopup'; +import Toggler from '../../../components/controls/Toggler'; +import DropdownIcon from '../../../components/icons-components/DropdownIcon'; +import { Button } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; /*:: import type { Issue } from '../types'; */ @@ -51,20 +53,26 @@ export default class SimilarIssuesFilter extends React.PureComponent { this.props.togglePopup('similarIssues', open); }; + handleClose = () => { + this.togglePopup(false); + }; + render() { return ( - }> - - +
    + }> + + +
    ); } } diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueAssign-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueAssign-test.js index cdd7cfeb6f1..ad39643695e 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueAssign-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueAssign-test.js @@ -34,8 +34,8 @@ it('should render without the action when the correct rights are missing', () => canAssign={false} isOpen={false} issue={issue} - onFail={jest.fn()} onAssign={jest.fn()} + onFail={jest.fn()} togglePopup={jest.fn()} /> ); @@ -48,8 +48,8 @@ it('should render with the action', () => { canAssign={true} isOpen={false} issue={issue} - onFail={jest.fn()} onAssign={jest.fn()} + onFail={jest.fn()} togglePopup={jest.fn()} /> ); @@ -63,12 +63,12 @@ it('should open the popup when the button is clicked', () => { canAssign={true} isOpen={false} issue={issue} - onFail={jest.fn()} onAssign={jest.fn()} + onFail={jest.fn()} togglePopup={toggle} /> ); - click(element.find('button')); + click(element.find('Button')); expect(toggle.mock.calls).toMatchSnapshot(); element.setProps({ isOpen: true }); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js index 0b2b9071cd8..8e03fdef42a 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelog-test.js @@ -52,7 +52,7 @@ it('should open the popup when the button is clicked', () => { togglePopup={toggle} /> ); - click(element.find('button')); + click(element.find('Button')); expect(toggle.mock.calls).toMatchSnapshot(); element.setProps({ isOpen: true }); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentAction-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentAction-test.js index d54334a61f9..2114f366226 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentAction-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentAction-test.js @@ -25,8 +25,8 @@ import { click } from '../../../../helpers/testUtils'; it('should render correctly', () => { const element = shallow( { const toggle = jest.fn(); const element = shallow( ); - click(element.find('button')); + click(element.find('Button')); expect(toggle.mock.calls.length).toBe(1); element.setProps({ currentPopup: 'comment' }); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js index a321192729a..90cc0e1d8dc 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js @@ -53,9 +53,9 @@ it('should open the right popups when the buttons are clicked', () => { const element = shallow( ); - element.find('.js-issue-comment-edit').prop('onClick')(); + click(element.find('.js-issue-comment-edit')); expect(element.state()).toMatchSnapshot(); - element.find('.js-issue-comment-delete').prop('onClick')(); + click(element.find('.js-issue-comment-delete')); expect(element.state()).toMatchSnapshot(); element.update(); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueSeverity-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueSeverity-test.js index 98e4cf45c5b..08b00404347 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueSeverity-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueSeverity-test.js @@ -63,7 +63,7 @@ it('should open the popup when the button is clicked', () => { togglePopup={toggle} /> ); - click(element.find('button')); + click(element.find('Button')); expect(toggle.mock.calls).toMatchSnapshot(); element.setProps({ isOpen: true }); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTags-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTags-test.js index aa353241a8a..81d9a512a45 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTags-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTags-test.js @@ -71,7 +71,7 @@ it('should open the popup when the button is clicked', () => { togglePopup={toggle} /> ); - click(element.find('button')); + click(element.find('Button')); expect(toggle.mock.calls).toMatchSnapshot(); element.setProps({ isOpen: true }); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTransition-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTransition-test.js index 9bfc5d7cd85..98da66e0449 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTransition-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTransition-test.js @@ -84,7 +84,7 @@ it('should open the popup when the button is clicked', () => { togglePopup={toggle} /> ); - click(element.find('button')); + click(element.find('Button')); expect(toggle.mock.calls).toMatchSnapshot(); element.setProps({ isOpen: true }); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.js index de6dcde42bf..51132f338ca 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.js @@ -63,7 +63,7 @@ it('should open the popup when the button is clicked', () => { togglePopup={toggle} /> ); - click(element.find('button')); + click(element.find('Button')); expect(toggle.mock.calls).toMatchSnapshot(); element.setProps({ isOpen: true }); expect(element).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap index d4ff90579c6..d768c0c852d 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueAssign-test.js.snap @@ -4,112 +4,111 @@ exports[`should open the popup when the button is clicked 1`] = ` Array [ Array [ "assign", - Object { - "currentTarget": Object { - "blur": [Function], - }, - "preventDefault": [Function], - "stopPropagation": [Function], - "target": Object { - "blur": [Function], - }, - }, + undefined, ], ] `; exports[`should open the popup when the button is clicked 2`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + + +
    `; exports[`should render with the action 1`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + + +
    `; exports[`should render without the action when the correct rights are missing 1`] = ` diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelog-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelog-test.js.snap index 97f8c58d32a..0628de785bf 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelog-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueChangelog-test.js.snap @@ -10,91 +10,97 @@ Array [ `; exports[`should open the popup when the button is clicked 2`] = ` - - } - position="bottomright" - togglePopup={[Function]} +
    - } > - - - + + + +
    `; exports[`should render correctly 1`] = ` - - } - position="bottomright" - togglePopup={[Function]} +
    - } > - - - + + + +
    `; diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentAction-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentAction-test.js.snap index 7305e5d8472..3c62307690e 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentAction-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentAction-test.js.snap @@ -2,13 +2,13 @@ exports[`should open the popup when the button is clicked 1`] = `
  • - } - position="bottomleft" - togglePopup={ - [MockFunction] { - "calls": Array [ - Array [], - ], - } - } > - - + +
  • `; exports[`should render correctly 1`] = `
  • - } - position="bottomleft" - togglePopup={[MockFunction]} > - - + +
  • `; diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap index 71f4ef39f22..4db5ed5aa9c 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap @@ -35,9 +35,6 @@ exports[`should open the right popups when the buttons are clicked 3`] = ` "__html": "test", } } - onClick={[Function]} - role="Listitem" - tabIndex={0} />
    - test", - "key": "comment-key", - "updatable": true, +
    + test", + "key": "comment-key", + "updatable": true, + } } - } - customClass="issue-edit-comment-bubble-popup" - onComment={[Function]} - placeholder="" - toggleComment={[Function]} + onComment={[Function]} + placeholder="" + toggleComment={[Function]} + /> + } + > + - } - position="bottomright" - togglePopup={[Function]} + +
    +
    - - - } - } - popup={ - + - } - position="bottomright" - togglePopup={[Function]} - > - - + +
    `; @@ -133,9 +123,6 @@ exports[`should render correctly a comment that is not updatable 1`] = ` "__html": "test", } } - onClick={[Function]} - role="Listitem" - tabIndex={0} />
    test", } } - onClick={[Function]} - role="Listitem" - tabIndex={0} />
    - test", - "key": "comment-key", - "updatable": true, +
    + test", + "key": "comment-key", + "updatable": true, + } } - } - customClass="issue-edit-comment-bubble-popup" - onComment={[Function]} - placeholder="" - toggleComment={[Function]} + onComment={[Function]} + placeholder="" + toggleComment={[Function]} + /> + } + > + - } - position="bottomright" - togglePopup={[Function]} + +
    +
    - - - } - } - popup={ - + - } - position="bottomright" - togglePopup={[Function]} - > - - + +
    `; diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueSeverity-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueSeverity-test.js.snap index 98eb8644b75..898a75fd3d6 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueSeverity-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueSeverity-test.js.snap @@ -4,80 +4,77 @@ exports[`should open the popup when the button is clicked 1`] = ` Array [ Array [ "set-severity", - Object { - "currentTarget": Object { - "blur": [Function], - }, - "preventDefault": [Function], - "stopPropagation": [Function], - "target": Object { - "blur": [Function], - }, - }, + undefined, ], ] `; exports[`should open the popup when the button is clicked 2`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render with the action 1`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render without the action when the correct rights are missing 1`] = ` diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTags-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTags-test.js.snap index fa30aff7c20..ca33fb7f1ec 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTags-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTags-test.js.snap @@ -4,88 +4,85 @@ exports[`should open the popup when the button is clicked 1`] = ` Array [ Array [ "edit-tags", - Object { - "currentTarget": Object { - "blur": [Function], - }, - "preventDefault": [Function], - "stopPropagation": [Function], - "target": Object { - "blur": [Function], - }, - }, + undefined, ], ] `; exports[`should open the popup when the button is clicked 2`] = ` - - } - position="bottomright" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render with the action 1`] = ` - - } - position="bottomright" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render without the action when the correct rights are missing 1`] = ` diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap index 30fc9e84c33..8f3694dd8d0 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap @@ -68,7 +68,6 @@ exports[`should render the titlebar correctly 1`] = ` > - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render with a resolution 1`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render with the action 1`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render without the action when there is no transitions 1`] = ` diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.js.snap index 77988d1f003..1eb2844dbf6 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.js.snap @@ -4,82 +4,79 @@ exports[`should open the popup when the button is clicked 1`] = ` Array [ Array [ "set-type", - Object { - "currentTarget": Object { - "blur": [Function], - }, - "preventDefault": [Function], - "stopPropagation": [Function], - "target": Object { - "blur": [Function], - }, - }, + undefined, ], ] `; exports[`should open the popup when the button is clicked 2`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render with the action 1`] = ` - - } - position="bottomleft" - togglePopup={[Function]} +
    - - + + +
    `; exports[`should render without the action when the correct rights are missing 1`] = ` diff --git a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js index b3f230810fe..fcfd515b587 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.js @@ -22,9 +22,9 @@ import React from 'react'; import { getIssueChangelog } from '../../../api/issues'; import { translate } from '../../../helpers/l10n'; import Avatar from '../../../components/ui/Avatar'; -import BubblePopup from '../../../components/common/BubblePopup'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import IssueChangelogDiff from '../components/IssueChangelogDiff'; +import { DropdownOverlay } from '../../controls/Dropdown'; /*:: import type { ChangelogDiff } from '../components/IssueChangelogDiff'; */ /*:: import type { Issue } from '../types'; */ @@ -80,8 +80,8 @@ export default class ChangelogPopup extends React.PureComponent { const { issue } = this.props; const { author } = issue; return ( - -
    + +
    @@ -110,14 +110,14 @@ export default class ChangelogPopup extends React.PureComponent { {item.userName}

    )} - {item.diffs.map(diff => )} + {item.diffs.map(diff => )} ))}
    - +
    ); } } diff --git a/server/sonar-web/src/main/js/components/issue/popups/CommentDeletePopup.js b/server/sonar-web/src/main/js/components/issue/popups/CommentDeletePopup.js index 9776ab00253..c7fd5d89ae8 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/CommentDeletePopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/CommentDeletePopup.js @@ -19,8 +19,9 @@ */ // @flow import React from 'react'; +import { Button } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -import BubblePopup from '../../../components/common/BubblePopup'; +import { DropdownOverlay } from '../../controls/Dropdown'; /*:: type Props = { @@ -31,13 +32,13 @@ type Props = { export default function CommentDeletePopup(props /*: Props */) { return ( - -
    + +
    {translate('issue.comment.delete_confirm_message')}
    - +
    - +
    ); } diff --git a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js index 2a17f71383b..bee719a083e 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js +++ b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.js @@ -19,16 +19,15 @@ */ // @flow import React from 'react'; -import classNames from 'classnames'; -import BubblePopup from '../../../components/common/BubblePopup'; import MarkdownTips from '../../../components/common/MarkdownTips'; +import { Button, ResetButtonLink } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; +import { DropdownOverlay } from '../../controls/Dropdown'; /*:: import type { IssueComment } from '../types'; */ /*:: type Props = { comment?: IssueComment, - customClass?: string, onComment: string => void, toggleComment: boolean => void, placeholder: string, @@ -63,8 +62,7 @@ export default class CommentPopup extends React.PureComponent { } }; - handleCancelClick = (evt /*: MouseEvent */) => { - evt.preventDefault(); + handleCancelClick = () => { this.props.toggleComment(false); }; @@ -81,37 +79,37 @@ export default class CommentPopup extends React.PureComponent { render() { const { comment } = this.props; return ( - -
    -