import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { BranchLike } from '../../../types/branch-like';
import { TreeComponentWithPath } from '../../../types/component';
-import { Facet, Query, ReferencedComponent } from '../utils';
+import { Facet, Query } from '../utils';
interface Props {
branchLike?: BranchLike;
componentKey: string;
fetching: boolean;
- fileUuids: string[];
+ files: string[];
loadSearchResultCount: (property: string, changes: Partial<Query>) => Promise<Facet>;
onChange: (changes: Partial<Query>) => void;
onToggle: (property: string) => void;
open: boolean;
query: Query;
- referencedComponents: T.Dict<ReferencedComponent>;
stats: Facet | undefined;
}
export default class FileFacet extends React.PureComponent<Props> {
- getFilePath = (fileUuid: string) => {
- const { referencedComponents } = this.props;
- return referencedComponents[fileUuid]
- ? collapsePath(referencedComponents[fileUuid].path || '', 15)
- : fileUuid;
- };
-
- getReferencedComponent = (key: string) => {
- const { referencedComponents } = this.props;
- const fileUuid = Object.keys(referencedComponents).find(uuid => {
- return referencedComponents[uuid].key === key;
- });
- return fileUuid ? referencedComponents[fileUuid] : undefined;
- };
-
- getFacetItemText = (fileUuid: string) => {
- const { referencedComponents } = this.props;
- return referencedComponents[fileUuid] ? referencedComponents[fileUuid].path || '' : fileUuid;
+ getFacetItemText = (path: string) => {
+ return path;
};
getSearchResultKey = (file: TreeComponentWithPath) => {
- const component = this.getReferencedComponent(file.key);
- return component ? component.uuid : file.key;
+ return file.path;
};
getSearchResultText = (file: TreeComponentWithPath) => {
return this.props.loadSearchResultCount('files', {
files: files
.map(file => {
- const component = this.getReferencedComponent(file.key);
- return component && component.uuid;
+ return file.path;
})
.filter(isDefined)
});
</>
);
- renderFacetItem = (fileUuid: string) => {
- const name = this.getFilePath(fileUuid);
- return this.renderFile(name);
+ renderFacetItem = (path: string) => {
+ return this.renderFile(path);
};
renderSearchResult = (file: TreeComponentWithPath, term: string) => {
renderSearchResult={this.renderSearchResult}
searchPlaceholder={translate('search.search_for_files')}
stats={this.props.stats}
- values={this.props.fileUuids}
+ values={this.props.files}
/>
);
}
<FileFacet
branchLike={branchLike}
fetching={loadingFacets.files === true}
- fileUuids={query.files}
+ files={query.files}
open={!!openFacets.files}
- referencedComponents={this.props.referencedComponentsById}
stats={facets.files}
{...commonProps}
/>
import { mockBranch } from '../../../../helpers/mocks/branch-like';
import { mockComponent } from '../../../../helpers/testMocks';
import { TreeComponentWithPath } from '../../../../types/component';
-import { Query, ReferencedComponent } from '../../utils';
+import { Query } from '../../utils';
import FileFacet from '../FileFacet';
jest.mock('../../../../api/components', () => ({
});
it('#getSearchResultKey()', () => {
- expect(instance.getSearchResultKey({ key: 'foo' } as TreeComponentWithPath)).toBe('fooUuid');
- expect(instance.getSearchResultKey({ key: 'bar' } as TreeComponentWithPath)).toBe('bar');
+ expect(instance.getSearchResultKey({ key: 'bar', path: 'bar' } as TreeComponentWithPath)).toBe(
+ 'bar'
+ );
});
it('#getFacetItemText()', () => {
- expect(instance.getFacetItemText('fooUuid')).toBe('foo/bar.js');
expect(instance.getFacetItemText('bar')).toBe('bar');
});
});
branchLike={branch}
componentKey={component.key}
fetching={false}
- fileUuids={['foo', 'bar']}
+ files={['foo', 'bar']}
loadSearchResultCount={jest.fn()}
onChange={jest.fn()}
onToggle={jest.fn()}
open={false}
query={{} as Query}
- referencedComponents={{
- fooUuid: { key: 'foo', uuid: 'fooUuid', path: 'foo/bar.js' } as ReferencedComponent
- }}
stats={undefined}
{...props}
/>
className="little-spacer-right"
qualifier="FIL"
/>
- foo/bar.js
+ fooUuid
</React.Fragment>
`;
createdInLast: parseAsString(query.createdInLast),
cwe: parseAsArray(query.cwe, parseAsString),
directories: parseAsArray(query.directories, parseAsString),
- files: parseAsArray(query.fileUuids, parseAsString),
+ files: parseAsArray(query.files, parseAsString),
issues: parseAsArray(query.issues, parseAsString),
languages: parseAsArray(query.languages, parseAsString),
modules: parseAsArray(query.moduleUuids, parseAsString),
createdInLast: serializeString(query.createdInLast),
cwe: serializeStringArray(query.cwe),
directories: serializeStringArray(query.directories),
- fileUuids: serializeStringArray(query.files),
+ files: serializeStringArray(query.files),
issues: serializeStringArray(query.issues),
languages: serializeStringArray(query.languages),
moduleUuids: serializeStringArray(query.modules),
export function mapFacet(facet: string) {
const propertyMapping: T.Dict<string> = {
- files: 'fileUuids',
modules: 'moduleUuids'
};
return propertyMapping[facet] || facet;
// for readability purpose
const propertyMapping: T.Dict<string> = {
- fileUuids: 'files',
moduleUuids: 'modules'
};
{ISSUE_TYPES.map((type: T.IssueType) => {
const params = {
...getBranchLikeQuery(branchLike),
- fileUuids: sourceViewerFile.uuid,
+ files: sourceViewerFile.path,
resolved: 'false',
types: type
};
onExpand,
sourceViewerFile
} = props;
- const {
- measures,
- path,
- project,
- projectName,
- q,
- subProject,
- subProjectName,
- uuid
- } = sourceViewerFile;
+ const { measures, path, project, projectName, q, subProject, subProjectName } = sourceViewerFile;
const projectNameLabel = (
<>
<Link
to={getComponentIssuesUrl(project, {
...getBranchLikeQuery(branchLike),
- fileUuids: uuid,
+ files: path,
resolved: 'false'
})}>
{translate('source_viewer.view_all_issues')}
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
"types": "BUG",
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
"types": "VULNERABILITY",
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
"types": "CODE_SMELL",
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
"types": "SECURITY_HOTSPOT",
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
},
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
},
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
},
Object {
"pathname": "/project/issues",
"query": Object {
- "fileUuids": "foo-bar",
+ "files": "foo/bar.ts",
"id": "my-project",
"resolved": "false",
},