aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/issue
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-08-17 09:10:21 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-08-17 16:42:34 +0200
commit57fe683ca1f0cc1307a601e44ae367159257a66d (patch)
tree18e35e0b17a1f197c7c6c951f7573f3b486d6f0a /server/sonar-web/src/main/js/components/issue
parent0ce861b4c00a06e3a19ca42be3da809ad8f9d4db (diff)
downloadsonarqube-57fe683ca1f0cc1307a601e44ae367159257a66d.tar.gz
sonarqube-57fe683ca1f0cc1307a601e44ae367159257a66d.zip
SONAR-9435 Manage issues' popup at the list level
Diffstat (limited to 'server/sonar-web/src/main/js/components/issue')
-rw-r--r--server/sonar-web/src/main/js/components/issue/Issue.js32
-rw-r--r--server/sonar-web/src/main/js/components/issue/IssueView.js2
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js2
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.js2
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js2
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentAction-test.js4
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js4
7 files changed, 12 insertions, 36 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/Issue.js b/server/sonar-web/src/main/js/components/issue/Issue.js
index 674d9c35216..70a1fc90746 100644
--- a/server/sonar-web/src/main/js/components/issue/Issue.js
+++ b/server/sonar-web/src/main/js/components/issue/Issue.js
@@ -35,20 +35,14 @@ type Props = {|
onCheck?: string => void,
onClick: string => void,
onFilter?: (property: string, issue: Issue) => void,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?string,
selected: boolean
|};
*/
-/*::
-type State = {
- currentPopup: string
-};
-*/
-
export default class BaseIssue extends React.PureComponent {
- /*:: mounted: boolean; */
/*:: props: Props; */
- /*:: state: State; */
static contextTypes = {
store: PropTypes.object
@@ -58,15 +52,7 @@ export default class BaseIssue extends React.PureComponent {
selected: false
};
- constructor(props /*: Props */) {
- super(props);
- this.state = {
- currentPopup: ''
- };
- }
-
componentDidMount() {
- this.mounted = true;
if (this.props.selected) {
this.bindShortcuts();
}
@@ -85,7 +71,6 @@ export default class BaseIssue extends React.PureComponent {
}
componentWillUnmount() {
- this.mounted = false;
if (this.props.selected) {
this.unbindShortcuts();
}
@@ -135,16 +120,7 @@ export default class BaseIssue extends React.PureComponent {
}
togglePopup = (popupName /*: string */, open /*: ?boolean */) => {
- if (this.mounted) {
- this.setState((prevState /*: State */) => {
- if (prevState.currentPopup !== popupName && open !== false) {
- return { currentPopup: popupName };
- } else if (prevState.currentPopup === popupName && open !== true) {
- return { currentPopup: '' };
- }
- return prevState;
- });
- }
+ this.props.onPopupToggle(this.props.issue.key, popupName, open);
};
handleAssignement = (login /*: string */) => {
@@ -175,7 +151,7 @@ export default class BaseIssue extends React.PureComponent {
onFilter={this.props.onFilter}
onChange={this.props.onChange}
togglePopup={this.togglePopup}
- currentPopup={this.state.currentPopup}
+ currentPopup={this.props.openPopup}
selected={this.props.selected}
/>
);
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 be2f91af2ef..5800390c44c 100644
--- a/server/sonar-web/src/main/js/components/issue/IssueView.js
+++ b/server/sonar-web/src/main/js/components/issue/IssueView.js
@@ -30,7 +30,7 @@ import { deleteIssueComment, editIssueComment } from '../../api/issues';
/*::
type Props = {|
checked?: boolean,
- currentPopup: string,
+ currentPopup: ?string,
issue: Issue,
onAssign: string => void,
onChange: Issue => void,
diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js
index 2c119cbb393..03837602471 100644
--- a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js
+++ b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.js
@@ -32,7 +32,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
/*::
type Props = {
issue: Issue,
- currentPopup: string,
+ currentPopup: ?string,
onAssign: string => void,
onChange: Issue => void,
onFail: Error => void,
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 718d456df06..b756e185da9 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
@@ -29,7 +29,7 @@ import { translate } from '../../../helpers/l10n';
/*::
type Props = {|
commentPlaceholder: string,
- currentPopup: string,
+ currentPopup: ?string,
issueKey: string,
onChange: Issue => void,
onFail: Error => void,
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 c6958f6a768..82aa5852ef4 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
@@ -34,7 +34,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
/*::
type Props = {|
issue: Issue,
- currentPopup: string,
+ currentPopup: ?string,
onFail: Error => void,
onFilter?: (property: string, issue: Issue) => void,
togglePopup: (string, boolean | void) => void
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 c8ac8e05986..4485f3edea0 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
@@ -26,7 +26,7 @@ it('should render correctly', () => {
const element = shallow(
<IssueCommentAction
issueKey="issue-key"
- currentPopup=""
+ currentPopup={null}
onFail={jest.fn()}
onIssueChange={jest.fn()}
toggleComment={jest.fn()}
@@ -40,7 +40,7 @@ it('should open the popup when the button is clicked', () => {
const element = shallow(
<IssueCommentAction
issueKey="issue-key"
- currentPopup=""
+ currentPopup={null}
onFail={jest.fn()}
onIssueChange={jest.fn()}
toggleComment={toggle}
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js
index 407b05eb189..007163c6666 100644
--- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js
+++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js
@@ -41,7 +41,7 @@ const issue = {
it('should render the titlebar correctly', () => {
const element = shallow(
- <IssueTitleBar issue={issue} currentPopup="" onFail={jest.fn()} togglePopup={jest.fn()} />
+ <IssueTitleBar issue={issue} currentPopup={null} onFail={jest.fn()} togglePopup={jest.fn()} />
);
expect(element).toMatchSnapshot();
});
@@ -50,7 +50,7 @@ it('should render the titlebar with the filter', () => {
const element = shallow(
<IssueTitleBar
issue={issue}
- currentPopup=""
+ currentPopup={null}
onFail={jest.fn()}
onFilter={jest.fn()}
togglePopup={jest.fn()}