import Marionette from 'backbone.marionette';
import Template from '../templates/rule/coding-rules-rule-issues.hbs';
import { searchIssues } from '../../../api/issues';
-import { getComponentIssuesUrlAsString, getBaseUrl } from '../../../helpers/urls';
+import { getPathUrlAsString, getComponentIssuesUrl, getBaseUrl } from '../../../helpers/urls';
export default Marionette.ItemView.extend({
template: Template,
name: projectBase != null ? projectBase.longName : '',
issuesUrl:
projectBase != null &&
- getComponentIssuesUrlAsString(projectBase.key, {
- resolved: 'false',
- rules: this.model.id
- })
+ getPathUrlAsString(
+ getComponentIssuesUrl(projectBase.key, {
+ resolved: 'false',
+ rules: this.model.id
+ })
+ )
};
});
this.projects = projects;
import React from 'react';
import QualifierIcon from '../../../components/icons-components/QualifierIcon';
import { splitPath } from '../../../helpers/path';
-import { getComponentUrl } from '../../../helpers/urls';
+import { getPathUrlAsString, getProjectUrl } from '../../../helpers/urls';
/*:: import type { ComponentEnhanced } from '../types'; */
/*:: type Props = {
<a
id={'component-measures-component-link-' + component.key}
className="link-no-underline"
- href={getComponentUrl(component.key, branch)}
+ href={getPathUrlAsString(getProjectUrl(component.key, branch))}
onClick={this.handleClick}>
{this.renderInner()}
</a>
<a
id={'component-measures-component-link-' + component.key}
className="link-no-underline"
- href={getComponentUrl(component.refKey, branch)}>
+ href={getPathUrlAsString(getProjectUrl(component.refKey, branch))}>
<span className="big-spacer-right">
<i className="icon-detach" />
</span>
*/
// @flow
import React from 'react';
-import { Link } from 'react-router';
import QualifierIcon from '../shared/QualifierIcon';
import FavoriteContainer from '../controls/FavoriteContainer';
-import { getProjectUrl, getComponentIssuesUrl } from '../../helpers/urls';
+import { getPathUrlAsString, getProjectUrl, getComponentIssuesUrl } from '../../helpers/urls';
import { collapsedDirFromPath, fileFromPath } from '../../helpers/path';
import { translate } from '../../helpers/l10n';
import { formatMeasure } from '../../helpers/measures';
uuid
} = this.props.component;
const isUnitTest = q === 'UTS';
- // TODO check if source viewer is displayed inside workspace
const workspace = false;
let rawSourcesLink =
window.baseUrl + `/api/sources/raw?key=${encodeURIComponent(this.props.component.key)}`;
<div className="source-viewer-header-component">
<div className="component-name">
<div className="component-name-parent">
- <Link to={getProjectUrl(project, this.props.branch)} className="link-with-icon">
+ <a
+ href={getPathUrlAsString(getProjectUrl(project, this.props.branch))}
+ className="link-with-icon">
<QualifierIcon qualifier="TRK" /> <span>{projectName}</span>
- </Link>
+ </a>
</div>
{subProject != null && (
<div className="component-name-parent">
- <Link to={getProjectUrl(subProject, this.props.branch)} className="link-with-icon">
+ <a
+ href={getPathUrlAsString(getProjectUrl(subProject, this.props.branch))}
+ className="link-with-icon">
<QualifierIcon qualifier="BRC" /> <span>{subProjectName}</span>
- </Link>
+ </a>
</div>
)}
</a>
</li>
<li>
- <Link
+ <a
className="js-new-window"
target="_blank"
- to={{
+ href={getPathUrlAsString({
pathname: '/component',
query: { branch: this.props.branch, id: this.props.component.key }
- }}>
+ })}>
{translate('component_viewer.new_window')}
- </Link>
+ </a>
</li>
{!workspace && (
<li>
<div className="source-viewer-header-measure">
<span className="source-viewer-header-measure-value">
- <Link
- to={getComponentIssuesUrl(project, {
- resolved: 'false',
- fileUuids: uuid,
- branch: this.props.branch
- })}
+ <a
+ href={getPathUrlAsString(
+ getComponentIssuesUrl(project, {
+ resolved: 'false',
+ fileUuids: uuid,
+ branch: this.props.branch
+ })
+ )}
className="source-viewer-header-external-link"
target="_blank">
{measures.issues != null ? formatMeasure(measures.issues, 'SHORT_INT') : 0}{' '}
<i className="icon-detach" />
- </Link>
+ </a>
</span>
<span className="source-viewer-header-measure-label">
{translate('metric.violations.name')}
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import {
- getComponentUrl,
getComponentIssuesUrl,
getComponentDrilldownUrl,
+ getPathUrlAsString,
+ getProjectUrl,
getQualityGatesUrl,
getQualityGateUrl
} from '../urls';
(window as any).baseUrl = oldBaseUrl;
});
-describe('#getComponentUrl', () => {
+describe('#getPathUrlAsString', () => {
it('should return component url', () => {
- expect(getComponentUrl(SIMPLE_COMPONENT_KEY)).toBe('/dashboard?id=' + SIMPLE_COMPONENT_KEY);
+ expect(getPathUrlAsString(getProjectUrl(SIMPLE_COMPONENT_KEY, 'branch:7.0'))).toBe(
+ '/dashboard?id=' + SIMPLE_COMPONENT_KEY + '&branch=branch%3A7.0'
+ );
});
it('should encode component key', () => {
- expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe(
+ expect(getPathUrlAsString(getProjectUrl(COMPLEX_COMPONENT_KEY))).toBe(
'/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED
);
});
it('should take baseUrl into account', () => {
(window as any).baseUrl = '/context';
- expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe(
+ expect(getPathUrlAsString(getProjectUrl(COMPLEX_COMPONENT_KEY))).toBe(
'/context/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED
);
});
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { omitBy, isNil } from 'lodash';
import { stringify } from 'querystring';
import { isShortLivingBranch } from './branches';
import { getProfilePath } from '../apps/quality-profiles/utils';
return (window as any).baseUrl;
}
-/**
- * Generate URL for a component's home page
- * Deprecated : use getProjectUrl
- */
-export function getComponentUrl(componentKey: string, branch?: string): string {
- const branchQuery = branch ? `&branch=${encodeURIComponent(branch)}` : '';
- return getBaseUrl() + '/dashboard?id=' + encodeURIComponent(componentKey) + branchQuery;
+export function getPathUrlAsString(path: Location): string {
+ return `${getBaseUrl()}${path.pathname}?${stringify(omitBy(path.query, isNil))}`;
}
export function getProjectUrl(key: string, branch?: string): Location {
return { pathname: '/project/issues', query: { ...query || {}, id: componentKey } };
}
-export function getComponentIssuesUrlAsString(componentKey: string, query?: Query): string {
- const path = getComponentIssuesUrl(componentKey, query);
- return `${getBaseUrl()}${path.pathname}?${stringify(path.query)}`;
-}
-
/**
* Generate URL for a component's drilldown page
*/