diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-03-14 12:47:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-14 12:47:17 +0100 |
commit | 6f189a7c95ee207e02c7c9321ed37d0c6ca4afe6 (patch) | |
tree | 494c72690c0ac9607716574a5bfa49f9c4ca315a /server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx | |
parent | 47d50b8a9c17d595a07b6a7e157849ccf1ffc302 (diff) | |
download | sonarqube-6f189a7c95ee207e02c7c9321ed37d0c6ca4afe6.tar.gz sonarqube-6f189a7c95ee207e02c7c9321ed37d0c6ca4afe6.zip |
rewrite workspace in react (#3140)
Diffstat (limited to 'server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 0ba3cd6ec40..72ac6fa5bcd 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -20,10 +20,12 @@ import { stringify } from 'querystring'; import * as React from 'react'; import { Link } from 'react-router'; +import * as PropTypes from 'prop-types'; import MeasuresOverlay from './components/MeasuresOverlay'; import { SourceViewerFile, BranchLike } from '../../app/types'; import QualifierIcon from '../shared/QualifierIcon'; import FavoriteContainer from '../controls/FavoriteContainer'; +import { WorkspaceContext } from '../workspace/context'; import { getPathUrlAsString, getBranchLikeUrl, @@ -46,6 +48,13 @@ interface State { } export default class SourceViewerHeader extends React.PureComponent<Props, State> { + // prettier-ignore + context!: { workspace: WorkspaceContext }; + + static contextTypes = { + workspace: PropTypes.object.isRequired + }; + state: State = { measuresOverlay: false }; handleShowMeasuresClick = (event: React.SyntheticEvent<HTMLAnchorElement>) => { @@ -60,8 +69,7 @@ export default class SourceViewerHeader extends React.PureComponent<Props, State openInWorkspace = (event: React.SyntheticEvent<HTMLAnchorElement>) => { event.preventDefault(); const { key } = this.props.sourceViewerFile; - const Workspace = require('../workspace/main').default; - Workspace.openComponent({ key, branchLike: this.props.branchLike }); + this.context.workspace.openComponent({ branchLike: this.props.branchLike, key }); }; render() { |