Skip to content

Commit

Permalink
Merge branch 'main' into issue-127123-add-recovery-context-to-log-thr…
Browse files Browse the repository at this point in the history
…eshold-rule
  • Loading branch information
kibanamachine authored May 2, 2022
2 parents edfbac2 + 0745196 commit e7d60be
Show file tree
Hide file tree
Showing 79 changed files with 992 additions and 698 deletions.
7 changes: 6 additions & 1 deletion src/plugins/controls/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ import {
CONTROL_GROUP_TYPE,
OPTIONS_LIST_CONTROL,
RANGE_SLIDER_CONTROL,
TIME_SLIDER_CONTROL,
// TIME_SLIDER_CONTROL,
} from '.';
/*
import {
TimesliderEmbeddableFactory,
TimeSliderControlEmbeddableInput,
} from './control_types/time_slider';
*/
import { controlsService } from './services/kibana/controls';

export class ControlsPlugin
Expand Down Expand Up @@ -104,6 +106,7 @@ export class ControlsPlugin
registerControlType(rangeSliderFactory);

// Time Slider Control Factory Setup
/* Temporary disabling Time Slider
const timeSliderFactoryDef = new TimesliderEmbeddableFactory();
const timeSliderFactory = embeddable.registerEmbeddableFactory(
TIME_SLIDER_CONTROL,
Expand All @@ -113,8 +116,10 @@ export class ControlsPlugin
timeSliderFactoryDef,
timeSliderFactory
);
registerControlType(timeSliderFactory);
*/
});

return {
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/controls/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PluginSetup as UnifiedSearchSetup } from '@kbn/unified-search-plugin/se
import { setupOptionsListSuggestionsRoute } from './control_types/options_list/options_list_suggestions_route';
import { controlGroupContainerPersistableStateServiceFactory } from './control_group/control_group_container_factory';
import { optionsListPersistableStateServiceFactory } from './control_types/options_list/options_list_embeddable_factory';
import { timeSliderPersistableStateServiceFactory } from './control_types/time_slider/time_slider_embeddable_factory';
// import { timeSliderPersistableStateServiceFactory } from './control_types/time_slider/time_slider_embeddable_factory';

interface SetupDeps {
embeddable: EmbeddableSetup;
Expand All @@ -25,7 +25,8 @@ interface SetupDeps {
export class ControlsPlugin implements Plugin<object, object, SetupDeps> {
public setup(core: CoreSetup, { embeddable, unifiedSearch }: SetupDeps) {
embeddable.registerEmbeddableFactory(optionsListPersistableStateServiceFactory());
embeddable.registerEmbeddableFactory(timeSliderPersistableStateServiceFactory());
// Temporary disabling Time Slider
// embeddable.registerEmbeddableFactory(timeSliderPersistableStateServiceFactory());

embeddable.registerEmbeddableFactory(
controlGroupContainerPersistableStateServiceFactory(embeddable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const DataViewEditor = ({
services,
defaultTypeIsRollup = false,
requireTimestampField = false,
showEmptyPrompt = true,
}: DataViewEditorPropsWithServices) => {
const { Provider: KibanaReactContextProvider } =
createKibanaReactContext<DataViewEditorContext>(services);
Expand All @@ -35,6 +36,7 @@ export const DataViewEditor = ({
onCancel={onCancel}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
showEmptyPrompt={showEmptyPrompt}
/>
</EuiFlyout>
</KibanaReactContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface Props {
onCancel: () => void;
defaultTypeIsRollup?: boolean;
requireTimestampField?: boolean;
showEmptyPrompt?: boolean;
}

const editorTitle = i18n.translate('indexPatternEditor.title', {
Expand All @@ -69,6 +70,7 @@ const IndexPatternEditorFlyoutContentComponent = ({
onCancel,
defaultTypeIsRollup,
requireTimestampField = false,
showEmptyPrompt = true,
}: Props) => {
const {
services: { http, dataViews, uiSettings, searchClient },
Expand Down Expand Up @@ -316,7 +318,12 @@ const IndexPatternEditorFlyoutContentComponent = ({
);

return (
<EmptyPrompts onCancel={onCancel} allSources={allSources} loadSources={loadSources}>
<EmptyPrompts
onCancel={onCancel}
allSources={allSources}
loadSources={loadSources}
showEmptyPrompt={showEmptyPrompt}
>
<FlyoutPanels.Group flyoutClassName={'indexPatternEditorFlyout'} maxWidth={1180}>
<FlyoutPanels.Item className="fieldEditor__mainFlyoutPanel" border="right">
<EuiTitle data-test-subj="flyoutTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const IndexPatternFlyoutContentContainer = ({
onCancel = () => {},
defaultTypeIsRollup,
requireTimestampField = false,
showEmptyPrompt = true,
}: DataViewEditorProps) => {
const {
services: { dataViews, notifications },
Expand Down Expand Up @@ -48,6 +49,7 @@ const IndexPatternFlyoutContentContainer = ({
onCancel={onCancel}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
showEmptyPrompt={showEmptyPrompt}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface Props {
onCancel: () => void;
allSources: MatchedItem[];
loadSources: () => void;
showEmptyPrompt?: boolean;
}

export function isUserDataIndex(source: MatchedItem) {
Expand All @@ -45,7 +46,13 @@ export function isUserDataIndex(source: MatchedItem) {
return true;
}

export const EmptyPrompts: FC<Props> = ({ allSources, onCancel, children, loadSources }) => {
export const EmptyPrompts: FC<Props> = ({
allSources,
onCancel,
children,
loadSources,
showEmptyPrompt,
}) => {
const {
services: { docLinks, application, http, searchClient, dataViews },
} = useKibana<DataViewEditorContext>();
Expand Down Expand Up @@ -93,7 +100,7 @@ export const EmptyPrompts: FC<Props> = ({ allSources, onCancel, children, loadSo
<PromptFooter onCancel={onCancel} />
</>
);
} else {
} else if (showEmptyPrompt) {
// first time
return (
<>
Expand All @@ -108,6 +115,8 @@ export const EmptyPrompts: FC<Props> = ({ allSources, onCancel, children, loadSo
<PromptFooter onCancel={onCancel} />
</>
);
} else {
setGoToForm(true);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data_view_editor/public/open_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const getEditorOpener =
onCancel = () => {},
defaultTypeIsRollup = false,
requireTimestampField = false,
showEmptyPrompt = true,
}: DataViewEditorProps): CloseEditor => {
const closeEditor = () => {
if (overlayRef) {
Expand Down Expand Up @@ -77,6 +78,7 @@ export const getEditorOpener =
}}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
showEmptyPrompt={showEmptyPrompt}
/>
</I18nProvider>
</KibanaReactContextProvider>,
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/data_view_editor/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export interface DataViewEditorProps {
* Sets whether a timestamp field is required to create an index pattern. Defaults to false.
*/
requireTimestampField?: boolean;
/**
* If set to false, the screen for prompting a user to create a data view will be skipped, and the user will be taken directly
* to data view creation.
*/
showEmptyPrompt?: boolean;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
8 changes: 8 additions & 0 deletions test/functional/apps/visualize/_tsvb_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await visualBuilder.selectAggType('derivative', 1);
await visualBuilder.setFieldForAggregation('Max of machine.ram', 1);

await visChart.waitForVisualizationRenderingStabilized();
const value = await visualBuilder.getMetricValue();

expect(value).to.eql('0');
Expand Down Expand Up @@ -197,6 +198,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await visualBuilder.selectAggType('derivative', 1);
await visualBuilder.setFieldForAggregation('Max of machine.ram', 1);

await visChart.waitForVisualizationRenderingStabilized();
const value = await visualBuilder.getGaugeCount();

expect(value).to.eql('0');
Expand Down Expand Up @@ -226,6 +228,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await visualBuilder.clickSeriesOption();
await visualBuilder.changeDataFormatter('number');

await visChart.waitForVisualizationRenderingStabilized();
const gaugeLabel = await visualBuilder.getGaugeLabel();
const gaugeCount = await visualBuilder.getGaugeCount();

Expand All @@ -239,6 +242,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await visualBuilder.clickPanelOptions('gauge');
await visualBuilder.setMetricsDataTimerangeMode('Last value');

await visChart.waitForVisualizationRenderingStabilized();
const gaugeLabel = await visualBuilder.getGaugeLabel();
const gaugeCount = await visualBuilder.getGaugeCount();

Expand Down Expand Up @@ -351,6 +355,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await visualBuilder.selectAggType('derivative', 1);
await visualBuilder.setFieldForAggregation('Max of machine.ram', 1);

await visChart.waitForVisualizationRenderingStabilized();
const value = await visualBuilder.getTopNCount();

expect(value).to.eql('0');
Expand Down Expand Up @@ -579,6 +584,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
];
await visualBuilder.clickSeriesOption();
await visualBuilder.changeDataFormatter('number');
await visChart.waitForVisualizationRenderingStabilized();
const legendItems = await visualBuilder.getLegendItemsContent();

expect(legendItems).to.eql(expectedLegendItems);
Expand Down Expand Up @@ -615,6 +621,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await visualBuilder.clickTopN();
await visualBuilder.checkTopNTabIsPresent();

await visChart.waitForVisualizationRenderingStabilized();
const topNLabel = await visualBuilder.getTopNLabel();
const topNCount = await visualBuilder.getTopNCount();

Expand All @@ -626,6 +633,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await visualBuilder.clickGauge();
await visualBuilder.checkGaugeTabIsPresent();

await visChart.waitForVisualizationRenderingStabilized();
const gaugeLabel = await visualBuilder.getGaugeLabel();
const gaugeCount = await visualBuilder.getGaugeCount();

Expand Down
9 changes: 1 addition & 8 deletions x-pack/plugins/apm/common/environment_filter_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,14 @@ export function getEnvironmentLabel(environment: string) {
return environment;
}

// #TODO Once we replace the select dropdown we can remove it
// EuiSelect > EuiSelectOption accepts text attribute
export const ENVIRONMENT_ALL_SELECT_OPTION = {
value: ENVIRONMENT_ALL_VALUE,
text: getEnvironmentLabel(ENVIRONMENT_ALL_VALUE),
};

export const ENVIRONMENT_ALL = {
value: ENVIRONMENT_ALL_VALUE,
label: getEnvironmentLabel(ENVIRONMENT_ALL_VALUE),
};

export const ENVIRONMENT_NOT_DEFINED = {
value: ENVIRONMENT_NOT_DEFINED_VALUE,
text: getEnvironmentLabel(ENVIRONMENT_NOT_DEFINED_VALUE),
label: getEnvironmentLabel(ENVIRONMENT_NOT_DEFINED_VALUE),
};

export function getEnvironmentEsField(environment: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const serviceInventoryHref = url.format({
query: timeRange,
});

const apiRequestsToIntercept = [
const mainApiRequestsToIntercept = [
{
endpoint: '/internal/apm/services?*',
aliasName: 'servicesRequest',
Expand All @@ -31,7 +31,14 @@ const apiRequestsToIntercept = [
},
];

const aliasNames = apiRequestsToIntercept.map(
const secondaryApiRequestsToIntercept = [
{
endpoint: 'internal/apm/suggestions?*',
aliasName: 'suggestionsRequest',
},
];

const mainAliasNames = mainApiRequestsToIntercept.map(
({ aliasName }) => `@${aliasName}`
);

Expand Down Expand Up @@ -77,43 +84,51 @@ describe('When navigating to the service inventory', () => {

describe.skip('Calls APIs', () => {
beforeEach(() => {
apiRequestsToIntercept.map(({ endpoint, aliasName }) => {
cy.intercept('GET', endpoint).as(aliasName);
});
[...mainApiRequestsToIntercept, ...secondaryApiRequestsToIntercept].map(
({ endpoint, aliasName }) => {
cy.intercept('GET', endpoint).as(aliasName);
}
);

cy.loginAsReadOnlyUser();
cy.visit(serviceInventoryHref);
});

it('with the correct environment when changing the environment', () => {
cy.wait(aliasNames);
cy.wait(mainAliasNames);
cy.get('[data-test-subj="environmentFilter"]').type('pro');

cy.expectAPIsToHaveBeenCalledWith({
apisIntercepted: ['@suggestionsRequest'],
value: 'fieldValue=pro',
});

cy.get('[data-test-subj="environmentFilter"]').select('production');
cy.contains('button', 'production').click();

cy.expectAPIsToHaveBeenCalledWith({
apisIntercepted: aliasNames,
apisIntercepted: mainAliasNames,
value: 'environment=production',
});
});

it('when clicking the refresh button', () => {
cy.wait(aliasNames);
cy.wait(mainAliasNames);
cy.contains('Refresh').click();
cy.wait(aliasNames);
cy.wait(mainAliasNames);
});

it('when selecting a different time range and clicking the update button', () => {
cy.wait(aliasNames);
cy.wait(mainAliasNames);

cy.selectAbsoluteTimeRange(
moment(timeRange.rangeFrom).subtract(5, 'm').toISOString(),
moment(timeRange.rangeTo).subtract(5, 'm').toISOString()
);
cy.contains('Update').click();
cy.wait(aliasNames);
cy.wait(mainAliasNames);

cy.contains('Refresh').click();
cy.wait(aliasNames);
cy.wait(mainAliasNames);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,18 @@ describe('Service Overview', () => {
it('with the correct environment when changing the environment', () => {
cy.wait(aliasNames, { requestTimeout: 10000 });

cy.get('[data-test-subj="environmentFilter"]').select('production');
cy.intercept('GET', 'internal/apm/suggestions?*').as(
'suggestionsRequest'
);

cy.get('[data-test-subj="environmentFilter"]').type('pro').click();

cy.expectAPIsToHaveBeenCalledWith({
apisIntercepted: ['@suggestionsRequest'],
value: 'fieldValue=pro',
});

cy.contains('button', 'production').click();

cy.expectAPIsToHaveBeenCalledWith({
apisIntercepted: aliasNames,
Expand Down
Loading

0 comments on commit e7d60be

Please sign in to comment.