From: Kirill Knize Date: Tue, 25 Aug 2020 13:30:16 +0000 (+0200) Subject: PoC Add Open in IDE link in issue X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fheads%2Fpoc%2Fkirill%2Bdam%2Fopen-issue-in-ide;p=sonarqube.git PoC Add Open in IDE link in issue --- 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 { } }; + 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 { toggleComment={this.toggleComment} /> )} + this.openInIde(issue)}/>
  • 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 { + + render() { + return ( +
  • + + Open in IDE + +
  • + ); + } +}