aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/api/time-machine.ts2
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/Extension.tsx6
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx1
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/components/charts/DonutChart.tsx2
-rw-r--r--server/sonar-web/src/main/js/helpers/testUtils.ts6
-rw-r--r--server/sonar-web/src/main/js/types/extension.ts5
7 files changed, 19 insertions, 5 deletions
diff --git a/server/sonar-web/src/main/js/api/time-machine.ts b/server/sonar-web/src/main/js/api/time-machine.ts
index f6e7ee3da68..0f9f592cd71 100644
--- a/server/sonar-web/src/main/js/api/time-machine.ts
+++ b/server/sonar-web/src/main/js/api/time-machine.ts
@@ -22,7 +22,7 @@ import { getJSON } from '../helpers/request';
import { BranchParameters } from '../types/branch-like';
import { Paging } from '../types/types';
-interface TimeMachineResponse {
+export interface TimeMachineResponse {
measures: {
metric: string;
history: Array<{ date: string; value?: string }>;
diff --git a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx
index e13e596fd83..e7fc3f0a962 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx
+++ b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx
@@ -29,7 +29,7 @@ import { getBaseUrl } from '../../../helpers/system';
import { AppState } from '../../../types/appstate';
import { ExtensionStartMethod } from '../../../types/extension';
import { Dict, Extension as TypeExtension } from '../../../types/types';
-import { CurrentUser } from '../../../types/users';
+import { CurrentUser, HomePage } from '../../../types/users';
import * as theme from '../../theme';
import withAppStateContext from '../app-state/withAppStateContext';
import withCurrentUserContext from '../current-user/withCurrentUserContext';
@@ -41,6 +41,7 @@ interface Props extends WrappedComponentProps {
location: Location;
options?: Dict<any>;
router: Router;
+ updateCurrentUserHomepage: (homepage: HomePage) => void;
}
interface State {
@@ -80,6 +81,9 @@ export class Extension extends React.PureComponent<Props, State> {
theme,
baseUrl: getBaseUrl(),
l10nBundle: getCurrentL10nBundle(),
+ // See SONAR-16207 and core-extension-governance/src/main/js/portfolios/components/Header.tsx
+ // for more information on why we're passing this as a prop to an extension.
+ updateCurrentUserHomepage: this.props.updateCurrentUserHomepage,
...this.props.options
});
diff --git a/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx b/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx
index 3001705b905..7f2166da2be 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx
@@ -97,6 +97,7 @@ function shallowRender(props: Partial<Extension['props']> = {}) {
intl={{} as IntlShape}
location={mockLocation()}
router={mockRouter()}
+ updateCurrentUserHomepage={jest.fn()}
{...props}
/>
);
diff --git a/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap b/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap
index 4821cb22c56..183e24e1dfc 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap
@@ -49,6 +49,7 @@ exports[`should render React extensions correctly 1`] = `
"setRouteLeaveHook": [MockFunction],
}
}
+ updateCurrentUserHomepage={[MockFunction]}
>
<div>
<Helmet
@@ -108,6 +109,7 @@ exports[`should render React extensions correctly 2`] = `
"setRouteLeaveHook": [MockFunction],
}
}
+ updateCurrentUserHomepage={[MockFunction]}
>
<div>
<Helmet
diff --git a/server/sonar-web/src/main/js/components/charts/DonutChart.tsx b/server/sonar-web/src/main/js/components/charts/DonutChart.tsx
index 546f24479bb..df0345b515f 100644
--- a/server/sonar-web/src/main/js/components/charts/DonutChart.tsx
+++ b/server/sonar-web/src/main/js/components/charts/DonutChart.tsx
@@ -20,7 +20,7 @@
import { arc as d3Arc, pie as d3Pie, PieArcDatum } from 'd3-shape';
import * as React from 'react';
-interface DataPoint {
+export interface DataPoint {
fill: string;
value: number;
}
diff --git a/server/sonar-web/src/main/js/helpers/testUtils.ts b/server/sonar-web/src/main/js/helpers/testUtils.ts
index fb85521b28e..e43030383a4 100644
--- a/server/sonar-web/src/main/js/helpers/testUtils.ts
+++ b/server/sonar-web/src/main/js/helpers/testUtils.ts
@@ -54,7 +54,11 @@ export function submit(element: ShallowWrapper | ReactWrapper): void {
});
}
-export function change(element: ShallowWrapper | ReactWrapper, value: string, event = {}): void {
+export function change(
+ element: ShallowWrapper | ReactWrapper,
+ value: string | object,
+ event = {}
+): void {
// `type()` returns a component constructor for a composite element and string for DOM nodes
if (typeof element.type() === 'function') {
element.prop<Function>('onChange')(value);
diff --git a/server/sonar-web/src/main/js/types/extension.ts b/server/sonar-web/src/main/js/types/extension.ts
index 3defc91892d..ccc7c6656c3 100644
--- a/server/sonar-web/src/main/js/types/extension.ts
+++ b/server/sonar-web/src/main/js/types/extension.ts
@@ -22,7 +22,7 @@ import { Location, Router } from '../components/hoc/withRouter';
import { AppState } from './appstate';
import { L10nBundle } from './l10nBundle';
import { Component, Dict } from './types';
-import { CurrentUser } from './users';
+import { CurrentUser, HomePage } from './users';
export enum AdminPageExtension {
GovernanceConsole = 'governance/views_console'
@@ -55,6 +55,9 @@ export interface ExtensionStartMethodParameter {
};
baseUrl: string;
l10nBundle: L10nBundle;
+ // See SONAR-16207 and core-extension-governance/src/main/js/portfolios/components/Header.tsx
+ // for more information on why we're passing this as a prop to an extension.
+ updateCurrentUserHomepage: (homepage: HomePage) => void;
}
export type ExtensionStartMethodReturnType = React.ReactNode | Function | void | undefined | null;