diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-08-17 10:10:44 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-08-21 20:21:03 +0200 |
commit | 01e36514435cede2ecbb6acd28266fa608168fb9 (patch) | |
tree | d76839bee4fe4723a638fd037b79b4c5e4f3e641 /server/sonar-web/src/main/js/apps/issues | |
parent | 3263ad9ed40308ba701dfc71149a87843aca173b (diff) | |
download | sonarqube-01e36514435cede2ecbb6acd28266fa608168fb9.tar.gz sonarqube-01e36514435cede2ecbb6acd28266fa608168fb9.zip |
SONAR-11093 use "projects" instead of "projectUuids"
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues')
11 files changed, 45 insertions, 32 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.tsx b/server/sonar-web/src/main/js/apps/issues/components/App.tsx index 8e32c0e0691..355614151ee 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/App.tsx @@ -126,7 +126,8 @@ export interface State { openPopup?: { issue: string; name: string }; paging?: Paging; query: Query; - referencedComponents: { [componentKey: string]: ReferencedComponent }; + referencedComponentsById: { [id: string]: ReferencedComponent }; + referencedComponentsByKey: { [key: string]: ReferencedComponent }; referencedLanguages: { [languageKey: string]: ReferencedLanguage }; referencedRules: { [ruleKey: string]: ReferencedRule }; referencedUsers: { [login: string]: ReferencedUser }; @@ -157,7 +158,8 @@ export default class App extends React.PureComponent<Props, State> { myIssues: props.myIssues || areMyIssuesSelected(props.location.query), openFacets: { severities: true, types: true }, query: parseQuery(props.location.query), - referencedComponents: {}, + referencedComponentsById: {}, + referencedComponentsByKey: {}, referencedLanguages: {}, referencedRules: {}, referencedUsers: {}, @@ -477,7 +479,8 @@ export default class App extends React.PureComponent<Props, State> { issues, openIssue, paging, - referencedComponents: keyBy(other.components, 'uuid'), + referencedComponentsById: keyBy(other.components, 'uuid'), + referencedComponentsByKey: keyBy(other.components, 'key'), referencedLanguages: keyBy(other.languages, 'key'), referencedRules: keyBy(other.rules, 'key'), referencedUsers: keyBy(other.users, 'login'), @@ -602,10 +605,14 @@ export default class App extends React.PureComponent<Props, State> { this.setState(state => ({ facets: { ...state.facets, ...parseFacets(facets) }, loadingFacets: omit(state.loadingFacets, facet), - referencedComponents: { - ...state.referencedComponents, + referencedComponentsById: { + ...state.referencedComponentsById, ...keyBy(other.components, 'uuid') }, + referencedComponentsByKey: { + ...state.referencedComponentsByKey, + ...keyBy(other.components, 'key') + }, referencedLanguages: { ...state.referencedLanguages, ...keyBy(other.languages, 'key') @@ -945,7 +952,8 @@ export default class App extends React.PureComponent<Props, State> { openFacets={this.state.openFacets} organization={this.props.organization} query={query} - referencedComponents={this.state.referencedComponents} + referencedComponentsById={this.state.referencedComponentsById} + referencedComponentsByKey={this.state.referencedComponentsByKey} referencedLanguages={this.state.referencedLanguages} referencedRules={this.state.referencedRules} referencedUsers={this.state.referencedUsers} diff --git a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx index 588bcc38efe..a93601a5176 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx @@ -83,7 +83,7 @@ export default class ListItem extends React.PureComponent<Props, State> { onFilterChange({ ...issuesReset, rules: [issue.rule] }); break; case 'project': - onFilterChange({ ...issuesReset, projects: [issue.projectUuid] }); + onFilterChange({ ...issuesReset, projects: [issue.projectKey] }); break; case 'module': if (issue.subProjectUuid) { diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx index 2108d640fda..75a749bffd3 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { ShallowWrapper } from 'enzyme'; import App from '../App'; import { shallowWithIntl, waitAndUpdate } from '../../../../helpers/testUtils'; import { Issue } from '../../../../app/types'; @@ -35,6 +36,7 @@ const paging = { pageIndex: 1, pageSize: 100, total: 4 }; const eventNoShiftKey = { shiftKey: false } as MouseEvent; const eventWithShiftKey = { shiftKey: true } as MouseEvent; +const referencedComponent = { key: 'foo-key', name: 'bar', organization: 'John', uuid: 'foo-uuid' }; const PROPS = { branch: { isMain: true, name: 'master' }, currentUser: { @@ -48,7 +50,7 @@ const PROPS = { location: { pathname: '/issues', query: {} }, fetchIssues: () => Promise.resolve({ - components: [], + components: [referencedComponent], effortTotal: 1, facets, issues, @@ -64,12 +66,14 @@ const PROPS = { }; it('should render a list of issue', async () => { - const wrapper = shallowWithIntl(<App {...PROPS} />, { + const wrapper: ShallowWrapper<App['props'], App['state']> = shallowWithIntl(<App {...PROPS} />, { context: { router: { replace } } }); await waitAndUpdate(wrapper); expect(wrapper.state().issues.length).toBe(4); + expect(wrapper.state().referencedComponentsById).toEqual({ 'foo-uuid': referencedComponent }); + expect(wrapper.state().referencedComponentsByKey).toEqual({ 'foo-key': referencedComponent }); }); it('should be able to check/uncheck a group of issues with the Shift key', async () => { diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx index 3895cc0053a..f0bcd9eaa55 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx @@ -49,7 +49,7 @@ it('should display form when issues are present', async () => { project: 'foo', projectName: 'foo', projectOrganization: 'foo', - projectUuid: 'foo', + projectKey: 'foo', rule: 'foo', ruleName: 'foo', secondaryLocations: [], diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx index 549928cb0ea..2658e5ee0e0 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx @@ -33,7 +33,7 @@ const issue = { project: '', projectName: '', projectOrganization: '', - projectUuid: '', + projectKey: '', rule: '', ruleName: '', severity: '', diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap index 744a5418ee6..5a50fbad489 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap @@ -19,9 +19,9 @@ exports[`should render 1`] = ` "message": "", "organization": "", "project": "", + "projectKey": "", "projectName": "", "projectOrganization": "", - "projectUuid": "", "rule": "", "ruleName": "", "secondaryLocations": Array [], diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx index b04c72cf2af..32d22268dce 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx @@ -43,12 +43,14 @@ interface Props { export default class FileFacet extends React.PureComponent<Props> { getFile = (file: string) => { const { referencedComponents } = this.props; - return referencedComponents[file] ? collapsePath(referencedComponents[file].path, 15) : file; + return referencedComponents[file] + ? collapsePath(referencedComponents[file].path || '', 15) + : file; }; getFacetItemText = (file: string) => { const { referencedComponents } = this.props; - return referencedComponents[file] ? referencedComponents[file].path : file; + return referencedComponents[file] ? referencedComponents[file].path || '' : file; }; getSearchResultKey = (file: TreeComponent) => { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx index 399977dcd90..a88080345c5 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx @@ -43,7 +43,7 @@ interface Props { } interface SearchedProject { - id: string; + key: string; name: string; organization: string; } @@ -64,8 +64,7 @@ export default class ProjectFacet extends React.PureComponent<Props> { }).then(({ components, paging }) => ({ paging, results: components.map(component => ({ - id: component.refId || component.id, - key: component.key, + key: component.refKey || component.key, name: component.name, organization: component.organization })) @@ -80,7 +79,6 @@ export default class ProjectFacet extends React.PureComponent<Props> { }).then(({ components, paging }) => ({ paging, results: components.map(component => ({ - id: component.id, key: component.key, name: component.name, organization: component.organization @@ -95,7 +93,7 @@ export default class ProjectFacet extends React.PureComponent<Props> { loadSearchResultCount = (projects: SearchedProject[]) => { return this.props.loadSearchResultCount('projects', { - projects: projects.map(project => project.id) + projects: projects.map(project => project.key) }); }; @@ -137,7 +135,7 @@ export default class ProjectFacet extends React.PureComponent<Props> { facetHeader={translate('issues.facet.projects')} fetching={this.props.fetching} getFacetItemText={this.getProjectName} - getSearchResultKey={project => project.id} + getSearchResultKey={project => project.key} getSearchResultText={project => project.name} loadSearchResultCount={this.loadSearchResultCount} onChange={this.props.onChange} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index ca83e63f750..1e37378bab5 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -56,7 +56,8 @@ export interface Props { openFacets: { [facet: string]: boolean }; organization: { key: string } | undefined; query: Query; - referencedComponents: { [componentKey: string]: ReferencedComponent }; + referencedComponentsById: { [id: string]: ReferencedComponent }; + referencedComponentsByKey: { [key: string]: ReferencedComponent }; referencedLanguages: { [languageKey: string]: ReferencedLanguage }; referencedRules: { [ruleKey: string]: ReferencedRule }; referencedUsers: { [login: string]: ReferencedUser }; @@ -82,7 +83,7 @@ export default class Sidebar extends React.PureComponent<Props> { fetching={loadingFacets.modules === true} modules={query.modules} open={!!openFacets.modules} - referencedComponents={this.props.referencedComponents} + referencedComponents={this.props.referencedComponentsById} stats={facets.modules} {...commonProps} /> @@ -100,7 +101,7 @@ export default class Sidebar extends React.PureComponent<Props> { fetching={loadingFacets.files === true} files={query.files} open={!!openFacets.files} - referencedComponents={this.props.referencedComponents} + referencedComponents={this.props.referencedComponentsById} stats={facets.files} {...commonProps} /> @@ -233,7 +234,7 @@ export default class Sidebar extends React.PureComponent<Props> { organization={this.props.organization} projects={query.projects} query={query} - referencedComponents={this.props.referencedComponents} + referencedComponents={this.props.referencedComponentsByKey} stats={facets.projects} /> )} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx index 85bdcd358f4..82c486fa438 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx @@ -40,7 +40,8 @@ const renderSidebar = (props?: Partial<Props>) => { openFacets={{}} organization={undefined} query={{} as Query} - referencedComponents={{}} + referencedComponentsById={{}} + referencedComponentsByKey={{}} referencedLanguages={{}} referencedRules={{}} referencedUsers={{}} diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index bf7898e8747..ee1412f78f8 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -85,7 +85,7 @@ export function parseQuery(query: RawQuery): Query { languages: parseAsArray(query.languages, parseAsString), modules: parseAsArray(query.moduleUuids, parseAsString), owaspTop10: parseAsArray(query.owaspTop10, parseAsString), - projects: parseAsArray(query.projectUuids, parseAsString), + projects: parseAsArray(query.projects, parseAsString), resolutions: parseAsArray(query.resolutions, parseAsString), resolved: parseAsBoolean(query.resolved), rules: parseAsArray(query.rules, parseAsString), @@ -121,7 +121,7 @@ export function serializeQuery(query: Query): RawQuery { languages: serializeStringArray(query.languages), moduleUuids: serializeStringArray(query.modules), owaspTop10: serializeStringArray(query.owaspTop10), - projectUuids: serializeStringArray(query.projects), + projects: serializeStringArray(query.projects), resolutions: serializeStringArray(query.resolutions), resolved: query.resolved ? undefined : 'false', rules: serializeStringArray(query.rules), @@ -151,8 +151,7 @@ export interface Facet { export function mapFacet(facet: string) { const propertyMapping: { [x: string]: string } = { files: 'fileUuids', - modules: 'moduleUuids', - projects: 'projectUuids' + modules: 'moduleUuids' }; return propertyMapping[facet] || facet; } @@ -165,8 +164,7 @@ export function parseFacets(facets: RawFacet[]): { [x: string]: Facet } { // for readability purpose const propertyMapping: { [x: string]: string } = { fileUuids: 'files', - moduleUuids: 'modules', - projectUuids: 'projects' + moduleUuids: 'modules' }; const result: { [x: string]: Facet } = {}; @@ -189,7 +187,8 @@ export interface ReferencedComponent { key: string; name: string; organization: string; - path: string; + path?: string; + uuid: string; } export interface ReferencedUser { |