import TestStatusIcon from '../../icons-components/TestStatusIcon';
import { PopupPlacement } from '../../ui/popups';
import { WorkspaceContext } from '../../workspace/context';
-import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches';
+import {
+ isSameBranchLike,
+ getBranchLikeQuery,
+ isShortLivingBranch,
+ isPullRequest
+} from '../../../helpers/branches';
import { translate } from '../../../helpers/l10n';
import { collapsePath } from '../../../helpers/path';
this.mounted = false;
}
+ shouldLink() {
+ const { branchLike } = this.props;
+ return !isShortLivingBranch(branchLike) && !isPullRequest(branchLike);
+ }
+
fetchTests = () => {
this.setState({ loading: true });
getTests({
event.preventDefault();
event.currentTarget.blur();
const { key } = event.currentTarget.dataset;
- if (key) {
+ if (this.shouldLink() && key) {
this.context.workspace.openComponent({ branchLike: this.props.branchLike, key });
}
this.props.onClose();
};
+ renderFile(file: { key: string; longName: string }) {
+ return this.shouldLink() ? (
+ <a data-key={file.key} href="#" onClick={this.handleTestClick} title={file.longName}>
+ <span>{collapsePath(file.longName)}</span>
+ </a>
+ ) : (
+ <span>{collapsePath(file.longName)}</span>
+ );
+ }
+
render() {
const { line } = this.props;
const testCasesByFile = groupBy(this.state.testCases || [], 'fileKey');
return (
<DropdownOverlay placement={PopupPlacement.RightTop}>
- <div className="abs-width-400">
+ <div className="source-viewer-bubble-popup abs-width-400">
<h6 className="spacer-bottom">
{translate('source_viewer.covered')}
{!!line.conditions && (
translate('source_viewer.tooltip.no_information_about_tests')}
{testFiles.map(testFile => (
<div className="spacer-top text-ellipsis" key={testFile.file.key}>
- <a
- data-key={testFile.file.key}
- href="#"
- onClick={this.handleTestClick}
- title={testFile.file.longName}>
- <span>{collapsePath(testFile.file.longName)}</span>
- </a>
+ {this.renderFile(testFile.file)}
<ul>
{testFile.tests.map(testCase => (
<li
import QualifierIcon from '../../icons-components/QualifierIcon';
import { PopupPlacement } from '../../ui/popups';
import { WorkspaceContext } from '../../workspace/context';
+import { isShortLivingBranch, isPullRequest } from '../../../helpers/branches';
import { translate } from '../../../helpers/l10n';
import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path';
import { getProjectUrl } from '../../../helpers/urls';
workspace: PropTypes.object.isRequired
};
+ shouldLink() {
+ const { branchLike } = this.props;
+ return !isShortLivingBranch(branchLike) && !isPullRequest(branchLike);
+ }
+
isDifferentComponent = (
a: { project: string; subProject?: string },
b: { project: string; subProject?: string }
event.preventDefault();
event.currentTarget.blur();
const { key, line } = event.currentTarget.dataset;
- if (key) {
+ if (this.shouldLink() && key) {
this.context.workspace.openComponent({
branchLike: this.props.branchLike,
key,
this.props.onClose();
};
+ renderDuplication(file: DuplicatedFile, children: React.ReactNode, line?: number) {
+ return this.shouldLink() ? (
+ <a
+ data-key={file.key}
+ data-line={line}
+ href="#"
+ onClick={this.handleFileClick}
+ title={file.name}>
+ {children}
+ </a>
+ ) : (
+ children
+ );
+ }
+
render() {
const { duplicatedFiles = {}, sourceViewerFile } = this.props;
{duplication.file.key !== this.props.sourceViewerFile.key && (
<div className="component-name-path">
- <a
- className="link-action"
- data-key={duplication.file.key}
- href="#"
- onClick={this.handleFileClick}
- title={duplication.file.name}>
- <span>{collapsedDirFromPath(duplication.file.name)}</span>
- <span className="component-name-file">
- {fileFromPath(duplication.file.name)}
- </span>
- </a>
+ {this.renderDuplication(
+ duplication.file,
+ <>
+ <span>{collapsedDirFromPath(duplication.file.name)}</span>
+ <span className="component-name-file">
+ {fileFromPath(duplication.file.name)}
+ </span>
+ </>
+ )}
</div>
)}
{'Lines: '}
{duplication.blocks.map((block, index) => (
<React.Fragment key={index}>
- <a
- data-key={duplication.file.key}
- data-line={block.from}
- href="#"
- onClick={this.handleFileClick}>
- {block.from}
- {' – '}
- {block.from + block.size - 1}
- </a>
+ {this.renderDuplication(
+ duplication.file,
+ <>
+ {block.from}
+ {' – '}
+ {block.from + block.size - 1}
+ </>,
+ block.from
+ )}
{index < duplication.blocks.length - 1 && ', '}
</React.Fragment>
))}
const hasPopup =
line.coverageStatus === 'covered' || line.coverageStatus === 'partially-covered';
+ const bar = hasPopup ? (
+ <div className="source-line-bar" onClick={this.handleClick} role="button" tabIndex={0} />
+ ) : (
+ <div className="source-line-bar" />
+ );
+
const cell = line.coverageStatus ? (
<Tooltip
overlay={popupOpen ? undefined : translate('source_viewer.tooltip', line.coverageStatus)}
placement="right">
- <div className="source-line-bar" />
+ {bar}
</Tooltip>
) : (
- <div className="source-line-bar" />
+ bar
);
if (hasPopup) {
return (
- <td
- className={className}
- data-line-number={line.line}
- onClick={this.handleClick}
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
- role="button"
- tabIndex={0}>
+ <td className={className} data-line-number={line.line}>
<Toggler
onRequestClose={this.closePopup}
open={popupOpen}
'source-line-duplicated': duplicated
});
- const cell = <div className="source-line-bar" />;
-
return duplicated ? (
- <td
- className={className}
- data-index={index}
- data-line-number={line.line}
- onClick={this.handleClick}
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
- role="button"
- tabIndex={0}>
+ <td className={className} data-index={index} data-line-number={line.line}>
<Toggler
onRequestClose={this.closePopup}
open={popupOpen}
overlay={this.props.renderDuplicationPopup(index, line.line)}>
- <Tooltip overlay={translate('source_viewer.tooltip.duplicated_block')} placement="right">
- {cell}
+ <Tooltip
+ overlay={popupOpen ? undefined : translate('source_viewer.tooltip.duplicated_block')}
+ placement="right">
+ <div
+ className="source-line-bar"
+ onClick={this.handleClick}
+ role="button"
+ tabIndex={0}
+ />
</Tooltip>
</Toggler>
</td>
) : (
<td className={className} data-index={index} data-line-number={line.line}>
- {cell}
+ <div className="source-line-bar" />
</td>
);
}
<td
className="source-meta source-line-coverage source-line-covered"
data-line-number={3}
- onClick={[Function]}
- role="button"
- tabIndex={0}
>
<Toggler
onRequestClose={[Function]}
>
<div
className="source-line-bar"
+ onClick={[Function]}
+ role="button"
+ tabIndex={0}
/>
</Tooltip>
</Toggler>
className="source-meta source-line-duplications-extra source-line-duplicated"
data-index={1}
data-line-number={3}
- onClick={[Function]}
- role="button"
- tabIndex={0}
>
<Toggler
onRequestClose={[Function]}
>
<div
className="source-line-bar"
+ onClick={[Function]}
+ role="button"
+ tabIndex={0}
/>
</Tooltip>
</Toggler>
height: 18px;
}
+.source-line-bar[role='button'] {
+ cursor: pointer;
+}
+
+.source-line-bar:focus {
+ outline: none;
+}
+
.source-line-covered {
background-color: var(--green) !important;
}
font-family: var(--baseFontFamily);
font-size: var(--baseFontSize);
text-align: left;
+ user-select: text;
}
.issue-location {