Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Anywhere] More bug fixes #4251

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/plugins/vis_augmenter/public/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,22 @@ describe('utils', () => {
} as unknown) as Vis;
expect(isEligibleForVisLayers(invalidVis)).toEqual(false);
});
it('vis is ineligible with no seriesParams', async () => {
const invalidVis = ({
params: {
type: 'pie',
categoryAxes: [
{
position: 'bottom',
},
],
},
data: {
aggs: VALID_AGGS,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(invalidVis)).toEqual(false);
});
it('vis is ineligible with valid type and disabled setting', async () => {
uiSettingsMock.get.mockImplementation((key: string) => {
return key !== PLUGIN_AUGMENTATION_ENABLE_SETTING;
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/vis_augmenter/public/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
buildExpression,
ExpressionAstFunctionBuilder,
} from '../../../../plugins/expressions/public';
import { SavedObjectLoader } from '../../../../plugins/saved_objects/public';
import {
ISavedAugmentVis,
SavedAugmentVisLoader,
Expand All @@ -28,7 +27,7 @@ export const isEligibleForVisLayers = (vis: Vis): boolean => {
// Only support date histogram and ensure there is only 1 x-axis and it has to be on the bottom.
// Additionally to have a valid x-axis, there needs to be a segment aggregation
const hasValidXaxis =
vis.data.aggs !== undefined &&
vis.data?.aggs !== undefined &&
vis.data.aggs?.byTypeName('date_histogram').length === 1 &&
vis.params.categoryAxes.length === 1 &&
vis.params.categoryAxes[0].position === 'bottom' &&
Expand All @@ -37,12 +36,13 @@ export const isEligibleForVisLayers = (vis: Vis): boolean => {
// multiple supported yaxis only. If there are other aggregation types, this is not
// valid for augmentation
const hasCorrectAggregationCount =
vis.data.aggs !== undefined &&
vis.data?.aggs !== undefined &&
vis.data.aggs?.bySchemaName('metric').length > 0 &&
vis.data.aggs?.bySchemaName('metric').length === vis.data.aggs?.aggs.length - 1;
const hasOnlyLineSeries =
vis.params.seriesParams.every((seriesParam: { type: string }) => seriesParam.type === 'line') &&
vis.params.type === 'line';
vis.params?.seriesParams?.every(
(seriesParam: { type: string }) => seriesParam.type === 'line'
) && vis.params?.type === 'line';
// Checks if the augmentation setting is enabled
const config = getUISettings();
const isAugmentationEnabled = config.get(PLUGIN_AUGMENTATION_ENABLE_SETTING);
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/vis_type_vega/public/vega_view/vega_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ export class VegaView extends VegaBaseView {
// to align the data / events. We do this by checking if padding is needed on the left
// and/or right, and adding padding based on the y axis config.
left:
leftValueAxisPadding && flyoutContext === VisFlyoutContext.EVENT_VIS ? yAxisPadding : 0,
leftValueAxisPadding &&
(flyoutContext === VisFlyoutContext.EVENT_VIS ||
flyoutContext === VisFlyoutContext.TIMELINE_VIS)
? yAxisPadding
: 0,
right:
rightValueAxisPadding && flyoutContext === VisFlyoutContext.EVENT_VIS
? yAxisPadding
Expand Down