diff options
author | Kirill Knize <kirill.knize@sonarsource.com> | 2020-08-25 15:30:16 +0200 |
---|---|---|
committer | Kirill Knize <kirill.knize@sonarsource.com> | 2020-08-26 15:52:01 +0200 |
commit | 0e14398a07c16b3b3172040db22f6bfd2890b739 (patch) | |
tree | e420f2c32f56d7b44ce33a5a9c2164099356e3d7 | |
parent | 5a0ddea73ca66ad5b9bc2ace4b46696c968afaab (diff) | |
download | sonarqube-poc/kirill+dam/open-issue-in-ide.tar.gz sonarqube-poc/kirill+dam/open-issue-in-ide.zip |
PoC Add Open in IDE link in issuepoc/kirill+dam/open-issue-in-ide
-rw-r--r-- | server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx | 29 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/components/issue/components/IssueOpenInIde.tsx | 40 |
2 files changed, 69 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx index 0d062921417..6ed338182f5 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx @@ -27,6 +27,7 @@ import IssueSeverity from './IssueSeverity'; import IssueTags from './IssueTags'; import IssueTransition from './IssueTransition'; import IssueType from './IssueType'; +import IssueOpenInIde from "./IssueOpenInIde"; interface Props { issue: T.Issue; @@ -84,6 +85,33 @@ export default class IssueActionsBar extends React.PureComponent<Props, State> { } }; + openInIde = (issue: T.Issue) => { + console.log(issue); + async function postData(url = '') { + // Default options are marked with * + const response = await fetch(url, { + method: 'GET', // *GET, POST, PUT, DELETE, etc. + mode: 'cors', // no-cors, *cors, same-origin + cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached + credentials: 'same-origin', // include, *same-origin, omit + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': 'http://localhost:9000 http://135.181.88.65:9000' + // 'Content-Type': 'application/x-www-form-urlencoded', + }, + redirect: 'follow', // manual, *follow, error + referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url + body: null// body data type must match "Content-Type" header + }); + return response.json(); // parses JSON response into native JavaScript objects + } + postData(`http://localhost:63333?projectName=${issue.projectName}&fileName=${issue.componentLongName}&lineNumber=${issue.line}`) + .then(data => { + console.log(data); // JSON data parsed by `data.json()` call + }); + } + + render() { const { issue } = this.props; const canAssign = issue.actions.includes('assign'); @@ -152,6 +180,7 @@ export default class IssueActionsBar extends React.PureComponent<Props, State> { toggleComment={this.toggleComment} /> )} + <IssueOpenInIde openIssueInIde={() => this.openInIde(issue)}/> </ul> <ul className="list-inline"> <li className="issue-meta js-issue-tags"> diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueOpenInIde.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueOpenInIde.tsx new file mode 100644 index 00000000000..4ea80506eaf --- /dev/null +++ b/server/sonar-web/src/main/js/components/issue/components/IssueOpenInIde.tsx @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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 { ButtonLink } from 'sonar-ui-common/components/controls/buttons'; + + +interface Props { + openIssueInIde:() => void +} + +export default class IssueOpenInIde extends React.PureComponent<Props> { + + render() { + return ( + <li className="issue-meta dropdown"> + <ButtonLink className="issue-action js-issue-comment" + onClick={this.props.openIssueInIde}> + <span className="issue-meta-label">Open in IDE</span> + </ButtonLink> + </li> + ); + } +} |