|
@@ -1,5 +1,6 @@
|
|
|
import {Location} from 'history';
|
|
|
import pick from 'lodash/pick';
|
|
|
+import moment from 'moment';
|
|
|
|
|
|
import MarkLine from 'app/components/charts/components/markLine';
|
|
|
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
GlobalSelection,
|
|
|
LightWeightOrganization,
|
|
|
ReleaseComparisonChartType,
|
|
|
+ ReleaseWithHealth,
|
|
|
Repository,
|
|
|
} from 'app/types';
|
|
|
import {getUtcDateString} from 'app/utils/dates';
|
|
@@ -155,17 +157,31 @@ export const releaseComparisonChartHelp = {
|
|
|
[ReleaseComparisonChartType.USER_COUNT]: t('The number of users in a given period.'),
|
|
|
};
|
|
|
|
|
|
-export function generateReleaseMarkLine(title: string, position: number, theme: Theme) {
|
|
|
+type GenerateReleaseMarklineOptions = {
|
|
|
+ hideLabel?: boolean;
|
|
|
+ axisIndex?: number;
|
|
|
+};
|
|
|
+
|
|
|
+function generateReleaseMarkLine(
|
|
|
+ title: string,
|
|
|
+ position: number,
|
|
|
+ theme: Theme,
|
|
|
+ options?: GenerateReleaseMarklineOptions
|
|
|
+) {
|
|
|
+ const {hideLabel, axisIndex} = options || {};
|
|
|
+
|
|
|
return {
|
|
|
seriesName: title,
|
|
|
type: 'line',
|
|
|
data: [],
|
|
|
+ yAxisIndex: axisIndex ?? undefined,
|
|
|
+ xAxisIndex: axisIndex ?? undefined,
|
|
|
markLine: MarkLine({
|
|
|
silent: true,
|
|
|
lineStyle: {color: theme.gray300, type: 'solid'},
|
|
|
label: {
|
|
|
position: 'insideEndBottom',
|
|
|
- formatter: title,
|
|
|
+ formatter: hideLabel ? '' : title,
|
|
|
font: 'Rubik',
|
|
|
fontSize: 11,
|
|
|
} as any, // TODO(ts): weird echart types,
|
|
@@ -177,3 +193,45 @@ export function generateReleaseMarkLine(title: string, position: number, theme:
|
|
|
}),
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+export function generateReleaseMarkLines(
|
|
|
+ release: ReleaseWithHealth,
|
|
|
+ projectSlug: string,
|
|
|
+ theme: Theme,
|
|
|
+ options?: GenerateReleaseMarklineOptions
|
|
|
+) {
|
|
|
+ const adoptionStages = release.adoptionStages?.[projectSlug];
|
|
|
+
|
|
|
+ const markLines = [
|
|
|
+ generateReleaseMarkLine(
|
|
|
+ t('Release Created'),
|
|
|
+ moment(release.dateCreated).valueOf(),
|
|
|
+ theme,
|
|
|
+ options
|
|
|
+ ),
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (adoptionStages?.adopted) {
|
|
|
+ markLines.push(
|
|
|
+ generateReleaseMarkLine(
|
|
|
+ t('Adopted'),
|
|
|
+ moment(adoptionStages.adopted).valueOf(),
|
|
|
+ theme,
|
|
|
+ options
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if (adoptionStages?.unadopted) {
|
|
|
+ markLines.push(
|
|
|
+ generateReleaseMarkLine(
|
|
|
+ t('Unadopted'),
|
|
|
+ moment(adoptionStages.unadopted).valueOf(),
|
|
|
+ theme,
|
|
|
+ options
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return markLines;
|
|
|
+}
|