Skip to content

Commit

Permalink
Merge branch 'main' into feature/94603
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 authored Oct 5, 2022
2 parents 4a7e738 + a3e2af4 commit 4cf78d5
Show file tree
Hide file tree
Showing 249 changed files with 7,592 additions and 2,496 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@
"fast-deep-equal": "^3.1.1",
"fflate": "^0.6.9",
"file-saver": "^1.3.8",
"fnv-plus": "^1.3.1",
"font-awesome": "4.7.0",
"formik": "^2.2.9",
"fp-ts": "^2.3.1",
Expand Down Expand Up @@ -820,7 +819,6 @@
"@types/fetch-mock": "^7.3.1",
"@types/file-saver": "^2.0.0",
"@types/flot": "^0.0.31",
"@types/fnv-plus": "^1.3.0",
"@types/geojson": "7946.0.7",
"@types/getos": "^3.0.0",
"@types/gulp": "^4.0.6",
Expand Down
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
},
{
"groupName": "Profiling",
"matchPackageNames": ["fnv-plus", "peggy", "@types/dagre", "@types/fnv-plus"],
"matchPackageNames": ["peggy", "@types/dagre"],
"reviewers": ["team:profiling-ui"],
"matchBaseBranches": ["main"],
"labels": ["release_note:skip", "backport:skip"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('GaugeComponent', function () {
});

describe('ticks and color bands', () => {
it('sets proper color bands for values smaller than maximum', () => {
it('sets proper color bands and ticks on color bands for values smaller than maximum', () => {
const palette = {
type: 'palette' as const,
name: 'custom',
Expand All @@ -236,6 +236,7 @@ describe('GaugeComponent', function () {
},
} as GaugeRenderProps;
const goal = shallowWithIntl(<GaugeComponent {...customProps} />).find(Goal);
expect(goal.prop('ticks')).toEqual([0, 1, 2, 3, 4, 10]);
expect(goal.prop('bands')).toEqual([0, 1, 2, 3, 4, 10]);
});
it('sets proper color bands if palette steps are smaller than minimum', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
GaugeLabelMajorMode,
GaugeLabelMajorModes,
GaugeColorModes,
GaugeShapes,
GaugeTicksPositions,
} from '../../common';
import {
getAccessorsFromArgs,
Expand All @@ -30,7 +32,7 @@ import {
} from './utils';
import { getIcons } from './utils/icons';
import './index.scss';
import { GaugeCentralMajorMode } from '../../common/types';
import { GaugeCentralMajorMode, GaugeTicksPosition } from '../../common/types';
import { isBulletShape, isRoundShape } from '../../common/utils';

import './gauge.scss';
Expand Down Expand Up @@ -135,6 +137,35 @@ const getPreviousSectionValue = (value: number, bands: number[]) => {
return prevSectionValue;
};

function getTicksLabels(baseStops: number[]) {
const tenPercentRange = (Math.max(...baseStops) - Math.min(...baseStops)) * 0.1;
const lastIndex = baseStops.length - 1;
return baseStops.filter((stop, i) => {
if (i === 0 || i === lastIndex) {
return true;
}

return !(
stop - baseStops[i - 1] < tenPercentRange || baseStops[lastIndex] - stop < tenPercentRange
);
});
}

function getTicks(
ticksPosition: GaugeTicksPosition,
range: [number, number],
colorBands?: number[],
percentageMode?: boolean
) {
if (ticksPosition === GaugeTicksPositions.HIDDEN) {
return [];
}

if (ticksPosition === GaugeTicksPositions.BANDS && colorBands) {
return colorBands && getTicksLabels(colorBands);
}
}

export const GaugeComponent: FC<GaugeRenderProps> = memo(
({ data, args, uiState, formatFactory, paletteService, chartsThemeService, renderComplete }) => {
const {
Expand All @@ -146,6 +177,7 @@ export const GaugeComponent: FC<GaugeRenderProps> = memo(
labelMajorMode,
centralMajor,
centralMajorMode,
ticksPosition,
commonLabel,
} = args;

Expand Down Expand Up @@ -294,6 +326,12 @@ export const GaugeComponent: FC<GaugeRenderProps> = memo(
actualValue = actualValueToPercentsLegacy(palette?.params as CustomPaletteState, actualValue);
}

const totalTicks = getTicks(ticksPosition, [min, max], bands, args.percentageMode);
const ticks =
totalTicks && gaugeType === GaugeShapes.CIRCLE
? totalTicks.slice(0, totalTicks.length - 1)
: totalTicks;

const goalConfig = getGoalConfig(gaugeType);

const labelMajorTitle = getTitle(labelMajorMode, labelMajor, metricColumn?.name);
Expand Down Expand Up @@ -329,6 +367,7 @@ export const GaugeComponent: FC<GaugeRenderProps> = memo(
tickValueFormatter={({ value: tickValue }) => tickFormatter.convert(tickValue)}
tooltipValueFormatter={(tooltipValue) => tickFormatter.convert(tooltipValue)}
bands={bands}
ticks={ticks}
domain={{ min, max }}
bandFillColor={
colorMode === GaugeColorModes.PALETTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const securityConfig: GuideConfig = {
'Nullam ligula enim, malesuada a finibus vel, cursus sed risus.',
'Vivamus pretium, elit dictum lacinia aliquet, libero nibh dictum enim, a rhoncus leo magna in sapien.',
],
integration: 'endpoint',
location: {
appID: 'integrations',
path: '/browse/security',
},
},
{
id: 'rules',
Expand Down
31 changes: 31 additions & 0 deletions src/plugins/guided_onboarding/public/mocks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { BehaviorSubject } from 'rxjs';
import { GuidedOnboardingPluginStart } from '.';

const apiServiceMock: jest.Mocked<GuidedOnboardingPluginStart> = {
guidedOnboardingApi: {
setup: jest.fn(),
fetchActiveGuideState$: () => new BehaviorSubject(undefined),
fetchAllGuidesState: jest.fn(),
updateGuideState: jest.fn(),
activateGuide: jest.fn(),
completeGuide: jest.fn(),
isGuideStepActive$: () => new BehaviorSubject(false),
startGuideStep: jest.fn(),
completeGuideStep: jest.fn(),
isGuidedOnboardingActiveForIntegration$: () => new BehaviorSubject(false),
completeGuidedOnboardingForIntegration: jest.fn(),
},
};

export const guidedOnboardingMock = {
createSetup: () => {},
createStart: () => apiServiceMock,
};
97 changes: 97 additions & 0 deletions src/plugins/guided_onboarding/public/services/api.mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { GuideState } from '../../common/types';

export const searchAddDataActiveState: GuideState = {
guideId: 'search',
isActive: true,
status: 'in_progress',
steps: [
{
id: 'add_data',
status: 'active',
},
{
id: 'browse_docs',
status: 'inactive',
},
{
id: 'search_experience',
status: 'inactive',
},
],
};

export const searchAddDataInProgressState: GuideState = {
isActive: true,
status: 'in_progress',
steps: [
{
id: 'add_data',
status: 'in_progress',
},
{
id: 'browse_docs',
status: 'inactive',
},
{
id: 'search_experience',
status: 'inactive',
},
],
guideId: 'search',
};

export const securityAddDataInProgressState: GuideState = {
guideId: 'security',
status: 'in_progress',
isActive: true,
steps: [
{
id: 'add_data',
status: 'in_progress',
},
{
id: 'rules',
status: 'inactive',
},
],
};

export const securityRulesActivesState: GuideState = {
guideId: 'security',
isActive: true,
status: 'in_progress',
steps: [
{
id: 'add_data',
status: 'complete',
},
{
id: 'rules',
status: 'active',
},
],
};

export const noGuideActiveState: GuideState = {
guideId: 'security',
status: 'in_progress',
isActive: false,
steps: [
{
id: 'add_data',
status: 'in_progress',
},
{
id: 'rules',
status: 'inactive',
},
],
};
Loading

0 comments on commit 4cf78d5

Please sign in to comment.