*/
import * as React from 'react';
import { Link } from 'react-router';
-import { ComponentQualifier } from '../../../../js/types/component';
import Tooltip from '../../../components/controls/Tooltip';
import ClockIcon from '../../../components/icons/ClockIcon';
import FavoriteIcon from '../../../components/icons/FavoriteIcon';
};
renderProject = (component: ComponentResult) => {
- if (
- ComponentQualifier.SubProject !== (component.qualifier as ComponentQualifier) ||
- component.project == null
- ) {
+ if (component.project == null) {
return null;
}
it('selects results', () => {
const form = shallowRender();
form.setState({
- more: { TRK: 15, BRC: 0 },
+ more: { TRK: 15 },
open: true,
results: {
- TRK: [component('foo'), component('bar')],
- BRC: [component('qwe', ComponentQualifier.SubProject)]
+ TRK: [component('foo'), component('bar')]
},
selected: 'foo'
});
expect(form.state().selected).toBe('foo');
next(form, 'bar');
next(form, 'qualifier###TRK');
- next(form, 'qwe');
- next(form, 'qwe');
- prev(form, 'qualifier###TRK');
prev(form, 'bar');
select(form, 'foo');
prev(form, 'foo');
*/
import { shallow } from 'enzyme';
import * as React from 'react';
+import { ComponentQualifier } from '../../../../types/component';
import SearchResult from '../SearchResult';
beforeAll(() => {
isRecentlyBrowsed: true,
key: 'qwe',
name: 'qwe',
- qualifier: 'BRC',
+ qualifier: ComponentQualifier.Project,
project: 'foo'
};
const wrapper = shallowRender({ component });
renderResult={component => <span key={component.key}>{component.name}</span>}
results={{
TRK: [component('foo'), component('bar')],
- BRC: [component('qwe', 'BRC'), component('qux', 'BRC')],
FIL: [component('zux', 'FIL')]
}}
/>
shallow(
<SearchResults
allowMore={true}
- more={{ TRK: 175, BRC: 0 }}
+ more={{ TRK: 175 }}
onMoreClick={jest.fn()}
onSelect={jest.fn()}
renderNoResults={() => <div />}
renderResult={component => <span key={component.key}>{component.name}</span>}
results={{
- TRK: [component('foo'), component('bar')],
- BRC: [component('qwe', 'BRC'), component('qux', 'BRC')]
+ TRK: [component('foo'), component('bar')]
}}
/>
)
/>
<QualifierIcon
className="little-spacer-right"
- qualifier="BRC"
+ qualifier="TRK"
/>
</span>
<span
qualifier="TRK"
selected={false}
/>
- <li
- className="divider"
- key="divider-BRC"
- />
- <li
- className="menu-header"
- key="header-BRC"
- >
- qualifiers.BRC
- </li>
- <span
- key="qwe"
- >
- qwe
- </span>
- <span
- key="qux"
- >
- qux
- </span>
</ul>
`;
>
bar
</span>
- <li
- className="divider"
- key="divider-BRC"
- />
- <li
- className="menu-header"
- key="header-BRC"
- >
- qualifiers.BRC
- </li>
- <span
- key="qwe"
- >
- qwe
- </span>
- <span
- key="qux"
- >
- qux
- </span>
</ul>
`;
ComponentQualifier.Portfolio,
ComponentQualifier.SubPortfolio,
ComponentQualifier.Application,
- ComponentQualifier.Project,
- ComponentQualifier.SubProject
+ ComponentQualifier.Project
];
export function sortQualifiers(qualifiers: string[]) {
});
const isPortfolio = ['VW', 'SVW', 'APP'].includes(component.qualifier);
- const qualifiers = isPortfolio ? 'SVW,TRK' : 'BRC,UTS,FIL';
+ const qualifiers = isPortfolio ? 'SVW,TRK' : 'UTS,FIL';
getTree({
component: component.key,
expect(getTree).toHaveBeenCalledWith({
component: 'my-project',
q: 'bar',
- qualifiers: 'BRC,UTS,FIL',
+ qualifiers: 'UTS,FIL',
s: 'qualifier,name'
});
expect(onSearchResults).toHaveBeenCalledWith([
expect(getTree).toHaveBeenCalledWith({
component: 'my-project',
q: 'foo',
- qualifiers: 'BRC,UTS,FIL',
+ qualifiers: 'UTS,FIL',
s: 'qualifier,name'
});
}: Props) {
const displayProject =
!component ||
- ![
- ComponentQualifier.Project,
- ComponentQualifier.SubProject,
- ComponentQualifier.Directory
- ].includes(component.qualifier as ComponentQualifier);
- const displaySubProject =
- !component ||
- ![ComponentQualifier.SubProject, ComponentQualifier.Directory].includes(
+ ![ComponentQualifier.Project, ComponentQualifier.Directory].includes(
component.qualifier as ComponentQualifier
);
+
const displayBranchInformation = isView(component?.qualifier);
const selectedLocation = getSelectedLocation(issue, selectedFlowIndex, selectedLocationIndex);
</span>
)}
- {displaySubProject && issue.subProject !== undefined && issue.subProjectName !== undefined && (
- <span title={issue.subProjectName}>
- {limitComponentName(issue.subProjectName)}
- <span className="slash-separator" />
- </span>
- )}
-
<span title={componentName}>{collapsePath(componentName || '')}</span>
</div>
);
)
).toMatchSnapshot('with branch information');
});
-
-it('renders with sub-project', () => {
- const issue = { ...baseIssue, subProject: 'sub-proj', subProjectName: 'sub-proj-name' };
- expect(shallow(<ComponentBreadcrumbs component={undefined} issue={issue} />)).toMatchSnapshot();
-});
</span>
</div>
`;
-
-exports[`renders with sub-project 1`] = `
-<div
- aria-label="issues.on_file_x.proj-name, comp-name"
- className="component-name text-ellipsis"
->
- <QualifierIcon
- className="spacer-right"
- qualifier="FIL"
- />
- <span
- title="proj-name - test-branch"
- >
- proj-name
- <span
- className="slash-separator"
- />
- </span>
- <span
- title="sub-proj-name"
- >
- sub-proj-name
- <span
- className="slash-separator"
- />
- </span>
- <span
- title="comp-name"
- >
- comp-name
- </span>
-</div>
-`;
import * as React from 'react';
import { mockComponent } from '../../../../helpers/mocks/component';
import { mockAppState } from '../../../../helpers/testMocks';
-import { GlobalSettingKeys } from '../../../../types/settings';
import { ComponentQualifier } from '../../../../types/component';
+import { GlobalSettingKeys } from '../../../../types/settings';
import { Query } from '../../utils';
import { Sidebar } from '../Sidebar';
[ComponentQualifier.Application],
[ComponentQualifier.Portfolio],
[ComponentQualifier.SubPortfolio],
- [ComponentQualifier.SubProject],
[ComponentQualifier.Directory],
[ComponentQualifier.Developper]
])('should render facets for %p', qualifier => {
]
`;
-exports[`should render facets for "BRC" 1`] = `
-Array [
- "TypeFacet",
- "SeverityFacet",
- "ScopeFacet",
- "ResolutionFacet",
- "StatusFacet",
- "StandardFacet",
- "injectIntl(CreationDateFacet)",
- "withLanguagesContext(LanguageFacet)",
- "RuleFacet",
- "TagFacet",
- "DirectoryFacet",
- "FileFacet",
- "AssigneeFacet",
- "AuthorFacet",
-]
-`;
-
exports[`should render facets for "DEV" 1`] = `
Array [
"TypeFacet",
render() {
const { showMeasures } = this.props;
- const {
- key,
- measures,
- path,
- project,
- projectName,
- q,
- subProject,
- subProjectName
- } = this.props.sourceViewerFile;
+ const { key, measures, path, project, projectName, q } = this.props.sourceViewerFile;
const unitTestsOrLines = q === ComponentQualifier.TestFile ? 'tests' : 'lines';
const workspace = false;
const query = new URLSearchParams(
</a>
</div>
- {subProject !== undefined && (
- <div className="component-name-parent">
- <QualifierIcon qualifier="BRC" /> <span>{subProjectName}</span>
- </div>
- )}
-
<div className="component-name-path">
<QualifierIcon qualifier={q} /> <span>{collapsedDirFromPath(path)}</span>
<span className="component-name-file">{fileFromPath(path)}</span>
onExpand,
sourceViewerFile
} = props;
- const { measures, path, project, projectName, q, subProject, subProjectName } = sourceViewerFile;
+ const { measures, path, project, projectName, q } = sourceViewerFile;
const projectNameLabel = (
<>
</div>
)}
- {subProject !== undefined && (
- <>
- <QualifierIcon qualifier={ComponentQualifier.SubProject} />{' '}
- <span className="spacer-right">{subProjectName}</span>
- </>
- )}
-
{!isProjectRoot && (
<>
<div className="spacer-right">
).toMatchSnapshot('project root');
});
-it('should render correctly for subproject', () => {
- expect(
- shallowRender({
- sourceViewerFile: mockSourceViewerFile('foo/bar.ts', 'my-project', {
- subProject: 'foo',
- subProjectName: 'Foo'
- })
- })
- ).toMatchSnapshot();
-});
-
function shallowRender(props: Partial<Props> = {}) {
return shallow(
<SourceViewerHeaderSlim
</div>
`;
-exports[`should render correctly for subproject 1`] = `
-<div
- className="source-viewer-header-slim display-flex-row display-flex-space-between"
->
- <div
- className="display-flex-center flex-1"
- >
- <div
- className="spacer-right"
- >
- <a
- className="link-with-icon"
- href="/dashboard?id=my-project"
- >
- <QualifierIcon
- qualifier="TRK"
- />
-
- <span>
- MyProject
- </span>
- </a>
- </div>
- <QualifierIcon
- qualifier="BRC"
- />
-
- <span
- className="spacer-right"
- >
- Foo
- </span>
- <div
- className="spacer-right"
- >
- <QualifierIcon
- qualifier="FIL"
- />
-
- <span>
- foo/
- </span>
- <span
- className="component-name-file"
- >
- bar.ts
- </span>
- </div>
- <div
- className="spacer-right"
- >
- <ClipboardIconButton
- className="button-link link-no-underline"
- copyValue="foo/bar.ts"
- />
- </div>
- </div>
- <div
- className="flex-0 big-spacer-left"
- >
- <Link
- onlyActiveOnIndex={false}
- style={Object {}}
- to={
- Object {
- "pathname": "/project/issues",
- "query": Object {
- "files": "foo/bar.ts",
- "id": "my-project",
- "resolved": "false",
- },
- }
- }
- >
- source_viewer.view_all_issues
- </Link>
- </div>
- <DeferredSpinner
- className="little-spacer-right"
- >
- <div
- className="flex-0 big-spacer-left"
- >
- <ButtonIcon
- className="js-actions"
- onClick={[MockFunction]}
- >
- <ExpandSnippetIcon />
- </ButtonIcon>
- </div>
- </DeferredSpinner>
-</div>
-`;
-
exports[`should render correctly: no link to project 1`] = `
<div
className="source-viewer-header-slim display-flex-row display-flex-space-between"
return !isPullRequest(branchLike);
}
- isDifferentComponent = (
- a: { project: string; subProject?: string },
- b: { project: string; subProject?: string }
- ) => {
- return Boolean(a && b && (a.project !== b.project || a.subProject !== b.subProject));
+ isDifferentComponent = (a: { project: string }, b: { project: string }) => {
+ return Boolean(a && b && a.project !== b.project);
};
handleFileClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
duplications = sortBy(
duplications,
d => d.file.projectName !== sourceViewerFile.projectName,
- d => d.file.subProjectName !== sourceViewerFile.subProjectName,
d => d.file.key !== sourceViewerFile.key
);
<div className="spacer-top text-ellipsis" key={duplication.file.key}>
<div className="component-name">
{this.isDifferentComponent(duplication.file, this.props.sourceViewerFile) && (
- <>
- <div className="component-name-parent">
- <QualifierIcon className="little-spacer-right" qualifier="TRK" />
- <Link to={getProjectUrl(duplication.file.project)}>
- {duplication.file.projectName}
- </Link>
- </div>
- {duplication.file.subProject && duplication.file.subProjectName && (
- <div className="component-name-parent">
- <QualifierIcon className="little-spacer-right" qualifier="BRC" />
- {duplication.file.subProjectName}
- </div>
- )}
- </>
+ <div className="component-name-parent">
+ <QualifierIcon className="little-spacer-right" qualifier="TRK" />
+ <Link to={getProjectUrl(duplication.file.project)}>
+ {duplication.file.projectName}
+ </Link>
+ </div>
)}
{duplication.file.key !== this.props.sourceViewerFile.key && (
<Link to={getBranchLikeUrl(sourceViewerFile.project, branchLike)}>
{sourceViewerFile.projectName}
</Link>
-
- {sourceViewerFile.subProject && (
- <>
- <QualifierIcon className="big-spacer-left little-spacer-right" qualifier="BRC" />
- {sourceViewerFile.subProjectName}
- </>
- )}
</div>
<div className="display-flex-center little-spacer-top">
project: 'project-key',
projectName: 'Project Name',
q: ComponentQualifier.File,
- subProject: 'sub-project-key',
- subProjectName: 'Sub-Project Name',
uuid: 'abcd123'
};
>
Project Name
</Link>
- <QualifierIcon
- className="big-spacer-left little-spacer-right"
- qualifier="BRC"
- />
- Sub-Project Name
</div>
<div
className="display-flex-center little-spacer-top"
>
Project Name
</Link>
- <QualifierIcon
- className="big-spacer-left little-spacer-right"
- qualifier="BRC"
- />
- Sub-Project Name
</div>
<div
className="display-flex-center little-spacer-top"
>
Project Name
</Link>
- <QualifierIcon
- className="big-spacer-left little-spacer-right"
- qualifier="BRC"
- />
- Sub-Project Name
</div>
<div
className="display-flex-center little-spacer-top"
const qualifierIcons: Dict<(props: IconProps) => React.ReactElement> = {
app: ApplicationIcon,
- brc: SubProjectIcon,
dev: DeveloperIcon,
dir: DirectoryIcon,
fil: FileIcon,
svw: SubPortfolioIcon,
trk: ProjectIcon,
uts: UnitTestIcon,
- vw: PortfolioIcon,
-
- // deprecated:
- cla: UnitTestIcon,
- dev_prj: ProjectIcon,
- lib: LibraryIcon,
- pac: DirectoryIcon
+ vw: PortfolioIcon
};
interface QualifierIconProps {
);
}
-function LibraryIcon({ fill, ariaLabel, ...iconProps }: IconProps) {
- return (
- <Icon {...iconProps} ariaLabel={ariaLabel}>
- <path
- d="M1 13h4V3H1v10zm3-1H2v-2h2v2zM2 4h2v4H2V4zm4 9h4V3H6v10zm3-1H7v-2h2v2zM7 4h2v4H7V4zm4 9h4V3h-4v10zm3-1h-2v-2h2v2zm-2-8h2v4h-2V4z"
- style={{ fill: fill || colors.blue }}
- />
- </Icon>
- );
-}
-
function PortfolioIcon({ fill, ariaLabel, ...iconProps }: IconProps) {
return (
<Icon {...iconProps} ariaLabel={ariaLabel}>
);
}
-function SubProjectIcon({ fill, ariaLabel, ...iconProps }: IconProps) {
- return (
- <Icon {...iconProps} ariaLabel={ariaLabel}>
- <path
- d="M8 9V8h6v1h1v1h1v6H6v-6h1V9h1zm7 2H7v4h8v-4zm-1-7v3h-1V5H1v7h4v1H0V4h14zm-1-2v1.5h-1V3H2v.5H1V2h12zm-1-2v1.5h-1V1H3v.5H2V0h10z"
- style={{ fill: fill || colors.blue }}
- />
- </Icon>
- );
-}
-
function UnitTestIcon({ fill, ariaLabel, ...iconProps }: IconProps) {
return (
<Icon {...iconProps} ariaLabel={ariaLabel}>
'rule',
...(issue.tags || []).map(tag => `tag###${tag}`),
'project',
- issue.subProject ? 'module' : undefined,
'file'
].filter(item => item) as string[];
{issue.projectName}
</SelectListItem>
- {issue.subProject != null && (
- <SelectListItem item="module">
- <QualifierIcon className="little-spacer-right" qualifier="BRC" />
- {issue.subProjectName}
- </SelectListItem>
- )}
-
<SelectListItem item="file">
<QualifierIcon className="little-spacer-right" qualifier={issue.componentQualifier} />
{fileFromPath(issue.componentLongName)}
function shallowRender(props: Partial<SimilarIssuesPopup['props']> = {}) {
return shallow(
<SimilarIssuesPopup
- issue={mockIssue(false, { subProject: 'foo', subProjectName: 'Foo', tags: ['test-tag'] })}
+ issue={mockIssue(false, { tags: ['test-tag'] })}
onFilter={jest.fn()}
{...props}
/>
"rule",
"tag###test-tag",
"project",
- "module",
"file",
]
}
/>
Foo
</SelectListItem>
- <SelectListItem
- item="module"
- >
- <QualifierIcon
- className="little-spacer-right"
- qualifier="BRC"
- />
- Foo
- </SelectListItem>
<SelectListItem
item="file"
>
...issue,
...injectRelational(issue, components, 'component', 'key'),
...injectRelational(issue, components, 'project', 'key'),
- ...injectRelational(issue, components, 'subProject', 'key'),
...injectRelational(issue, rules, 'rule', 'key'),
...injectRelational(issue, users, 'assignee', 'login'),
...injectCommentsRelational(issue, users),
exports[`[Function isApplication] should work properly 1`] = `
Object {
"APP": true,
- "BRC": false,
"DEV": false,
"DIR": false,
"FIL": false,
exports[`[Function isFile] should work properly 1`] = `
Object {
"APP": false,
- "BRC": false,
"DEV": false,
"DIR": false,
"FIL": true,
exports[`[Function isPortfolioLike] should work properly 1`] = `
Object {
"APP": false,
- "BRC": false,
"DEV": false,
"DIR": false,
"FIL": false,
exports[`[Function isProject] should work properly 1`] = `
Object {
"APP": false,
- "BRC": false,
"DEV": false,
"DIR": false,
"FIL": false,
exports[`[Function isView] should work properly 1`] = `
Object {
"APP": true,
- "BRC": false,
"DEV": false,
"DIR": false,
"FIL": false,
Portfolio = 'VW',
Project = 'TRK',
SubPortfolio = 'SVW',
- SubProject = 'BRC',
TestFile = 'UTS'
}
message?: string;
severity: string;
status: string;
- subProject?: string;
textRange?: TextRange;
type: IssueType;
}
rule: string;
securityCategory: string;
status: HotspotStatus;
- subProject?: string;
updateDate: string;
vulnerabilityProbability: RiskExposure;
flows?: Array<{
name: string;
project: string;
projectName: string;
- subProject?: string;
- subProjectName?: string;
}
export type ExpandDirection = 'up' | 'down';
secondaryLocations: FlowLocation[];
severity: string;
status: string;
- subProject?: string;
- subProjectName?: string;
tags?: string[];
textRange?: TextRange;
transitions: string[];
project: string;
projectName: string;
q: ComponentQualifier;
- subProject?: string;
- subProjectName?: string;
uuid: string;
}
#------------------------------------------------------------------------------
qualifier.TRK=Project
-qualifier.BRC=Sub-project
qualifier.DIR=Directory
qualifier.PAC=Package
qualifier.VW=Portfolio
qualifier.configuration.APP=Application Configuration
qualifiers.TRK=Projects
-qualifiers.BRC=Sub-projects
qualifiers.DIR=Directories
qualifiers.PAC=Packages
qualifiers.VW=Portfolios