diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-11-16 11:25:17 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-11-20 20:21:01 +0100 |
commit | 691b83c7377679e7ec4e6bd2fc10ae44a06c4379 (patch) | |
tree | b093166532a7b53e452198b90d5241a4c7d217a0 /server/sonar-web/src/main/js | |
parent | a67c0b97c2c476745eeb06ff2bfd24f1ee77540a (diff) | |
download | sonarqube-691b83c7377679e7ec4e6bd2fc10ae44a06c4379.tar.gz sonarqube-691b83c7377679e7ec4e6bd2fc10ae44a06c4379.zip |
SONAR-10770 update data shape
Diffstat (limited to 'server/sonar-web/src/main/js')
3 files changed, 32 insertions, 25 deletions
diff --git a/server/sonar-web/src/main/js/app/types.ts b/server/sonar-web/src/main/js/app/types.ts index a9fc074cc19..542324c1cd6 100644 --- a/server/sonar-web/src/main/js/app/types.ts +++ b/server/sonar-web/src/main/js/app/types.ts @@ -62,14 +62,16 @@ export interface AnalysisEvent { status: string; stillFailing: boolean; }; - projects?: Array<{ - branch?: string; - changeType: string; - key: string; - name: string; - newBranch?: string; - oldBranch?: string; - }>; + definitionChange?: { + projects: Array<{ + branch?: string; + changeType: string; + key: string; + name: string; + newBranch?: string; + oldBranch?: string; + }>; + }; } export interface AppState { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx index 5a7f71acfc9..0dac0529dfb 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx @@ -30,10 +30,11 @@ import { getProjectUrl } from '../../../helpers/urls'; import LongLivingBranchIcon from '../../../components/icons-components/LongLivingBranchIcon'; import { isMainBranch } from '../../../helpers/branches'; -export type DefinitionChangeEvent = AnalysisEvent & Required<Pick<AnalysisEvent, 'projects'>>; +export type DefinitionChangeEvent = AnalysisEvent & + Required<Pick<AnalysisEvent, 'definitionChange'>>; export function isDefinitionChangeEvent(event: AnalysisEvent): event is DefinitionChangeEvent { - return event.category === 'DEFINITION_CHANGE' && event.projects !== undefined; + return event.category === 'DEFINITION_CHANGE' && event.definitionChange !== undefined; } interface Props { @@ -155,7 +156,7 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State {expanded && ( <ul> - {event.projects.map(project => ( + {event.definitionChange.projects.map(project => ( <li className="display-flex-center little-spacer-top" key={project.key}> {this.renderProjectChange(project)} </li> diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx index 5e5a626df17..adff6e7da08 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx @@ -28,10 +28,12 @@ it('should render', () => { category: 'DEFINITION_CHANGE', key: 'foo1234', name: '', - projects: [ - { changeType: 'ADDED', key: 'foo', name: 'Foo', branch: 'master' }, - { changeType: 'REMOVED', key: 'bar', name: 'Bar', branch: 'master' } - ] + definitionChange: { + projects: [ + { changeType: 'ADDED', key: 'foo', name: 'Foo', branch: 'master' }, + { changeType: 'REMOVED', key: 'bar', name: 'Bar', branch: 'master' } + ] + } }; const wrapper = shallow(<DefinitionChangeEventInner branchLike={undefined} event={event} />); expect(wrapper).toMatchSnapshot(); @@ -47,16 +49,18 @@ it('should render for a branch', () => { category: 'DEFINITION_CHANGE', key: 'foo1234', name: '', - projects: [ - { changeType: 'ADDED', key: 'foo', name: 'Foo', branch: 'feature-x' }, - { - changeType: 'BRANCH_CHANGED', - key: 'bar', - name: 'Bar', - oldBranch: 'master', - newBranch: 'feature-y' - } - ] + definitionChange: { + projects: [ + { changeType: 'ADDED', key: 'foo', name: 'Foo', branch: 'feature-x' }, + { + changeType: 'BRANCH_CHANGED', + key: 'bar', + name: 'Bar', + oldBranch: 'master', + newBranch: 'feature-y' + } + ] + } }; const wrapper = shallow(<DefinitionChangeEventInner branchLike={branch} event={event} />); click(wrapper.find('.project-activity-event-inner-more-link')); |