Skip to content

Commit

Permalink
Merge branch 'master' into node-options-from-cfg-file
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Apr 6, 2020
2 parents 305a7f6 + 450d5fc commit 891eda5
Show file tree
Hide file tree
Showing 151 changed files with 17,741 additions and 14,279 deletions.
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/discover/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class DiscoverPlugin implements Plugin<void, void> {
} = createKbnUrlTracker({
baseUrl: core.http.basePath.prepend('/app/kibana'),
defaultSubUrl: '#/discover',
storageKey: 'lastUrl:discover',
storageKey: `lastUrl:${core.http.basePath.get()}:discover`,
navLinkUpdater$: this.appStateUpdater,
toastNotifications: core.notifications.toasts,
stateParams: [
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class VisualizePlugin implements Plugin {
const { appMounted, appUnMounted, stop: stopUrlTracker, setActiveUrl } = createKbnUrlTracker({
baseUrl: core.http.basePath.prepend('/app/kibana'),
defaultSubUrl: '#/visualize',
storageKey: 'lastUrl:visualize',
storageKey: `lastUrl:${core.http.basePath.get()}:visualize`,
navLinkUpdater$: this.appStateUpdater,
toastNotifications: core.notifications.toasts,
stateParams: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export class AxisLabels {

selection.selectAll('.tick text').text(function(d) {
const parentNode = d3.select(this.parentNode).node();
const currentTickCenter =
scaleStartPad +
(config.isHorizontal() ? self.axisScale.scale(d) : upperBound - self.axisScale.scale(d));
const currentTickCenter = config.isHorizontal()
? scaleStartPad + self.axisScale.scale(d)
: upperBound - scaleStartPad - self.axisScale.scale(d);
const currentTickSize =
(config.isHorizontal() ? parentNode.getBBox().width : parentNode.getBBox().height) *
padding;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class DashboardPlugin
targetAppName === DashboardConstants.DASHBOARD_ID
);
},
storageKey: 'lastUrl:dashboard',
storageKey: `lastUrl:${core.http.basePath.get()}:dashboard`,
navLinkUpdater$: this.appStateUpdater,
toastNotifications: core.notifications.toasts,
stateParams: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { ErrorEmbeddable } from './error_embeddable';
import { EmbeddableRoot } from './embeddable_root';
import { mount } from 'enzyme';
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';

test('ErrorEmbeddable renders an embeddable', async () => {
const embeddable = new ErrorEmbeddable('some error occurred', { id: '123', title: 'Error' });
const component = mount(<EmbeddableRoot embeddable={embeddable} />);
expect(
component.getDOMNode().querySelectorAll('[data-test-subj="embeddableStackError"]').length
).toBe(1);
expect(
component.getDOMNode().querySelectorAll('[data-test-subj="errorMessageMarkdown"]').length
).toBe(1);
expect(
component
.getDOMNode()
.querySelectorAll('[data-test-subj="errorMessageMarkdown"]')[0]
.innerHTML.includes('some error occurred')
).toBe(true);
});

test('ErrorEmbeddable renders an embeddable with markdown message', async () => {
const error = '[some link](http://localhost:5601/takeMeThere)';
const embeddable = new ErrorEmbeddable(error, { id: '123', title: 'Error' });
const component = mount(<EmbeddableRoot embeddable={embeddable} />);
expect(
component.getDOMNode().querySelectorAll('[data-test-subj="embeddableStackError"]').length
).toBe(1);
expect(
component.getDOMNode().querySelectorAll('[data-test-subj="errorMessageMarkdown"]').length
).toBe(1);
expect(
component
.getDOMNode()
.querySelectorAll('[data-test-subj="errorMessageMarkdown"]')[0]
.innerHTML.includes(
'<a href="http://localhost:5601/takeMeThere" target="_blank" rel="noopener noreferrer">some link</a>'
)
).toBe(true);
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { EuiText, EuiIcon, EuiSpacer } from '@elastic/eui';
import React from 'react';
import ReactDOM from 'react-dom';
import { Markdown } from '../../../../kibana_react/public';
import { Embeddable } from './embeddable';
import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable';
import { IContainer } from '../containers';
Expand Down Expand Up @@ -53,7 +54,11 @@ export class ErrorEmbeddable extends Embeddable<EmbeddableInput, EmbeddableOutpu
<EuiText color="subdued" size="xs">
<EuiIcon type="alert" color="danger" />
<EuiSpacer size="s" />
{title}
<Markdown
markdown={title}
openLinksInNewTab={true}
data-test-subj="errorMessageMarkdown"
/>
</EuiText>
</div>,
dom
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/es_ui_shared/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

export { JsonEditor, OnJsonEditorUpdateHandler } from './components/json_editor';

export { SectionLoading } from './components/section_loading';

export { CronEditor, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR } from './components/cron_editor';

export {
SendRequestConfig,
SendRequestResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export const useField = (
errors,
form,
isPristine,
isValid: errors.length === 0,
isValidating,
isValidated,
isChangingValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ export function useForm<T extends FormData = FormData>(
}, [] as string[]);
};

const isFieldValid = (field: FieldHook) =>
field.getErrorsMessages() === null && !field.isValidating;
const isFieldValid = (field: FieldHook) => field.isValid && !field.isValidating;

const updateFormValidity = () => {
const fieldsArray = fieldsToArray();
Expand Down Expand Up @@ -167,14 +166,24 @@ export function useForm<T extends FormData = FormData>(
};

const validateAllFields = async (): Promise<boolean> => {
const fieldsToValidate = fieldsToArray().filter(field => !field.isValidated);
const fieldsArray = fieldsToArray();
const fieldsToValidate = fieldsArray.filter(field => !field.isValidated);

let isFormValid: boolean | undefined = isValid;

if (fieldsToValidate.length === 0) {
// Nothing left to validate, all fields are already validated.
return isValid!;
if (isFormValid === undefined) {
// We should never enter this condition as the form validity is updated each time
// a field is validated. But sometimes, during tests it does not happen and we need
// to wait the next tick (hooks lifecycle being tricky) to make sure the "isValid" state is updated.
// In order to avoid this unintentional behaviour, we add this if condition here.
isFormValid = fieldsArray.every(isFieldValid);
setIsValid(isFormValid);
}
return isFormValid;
}

const { isFormValid } = await validateFields(fieldsToValidate.map(field => field.path));
({ isFormValid } = await validateFields(fieldsToValidate.map(field => field.path)));

return isFormValid!;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface FieldHook {
readonly type: string;
readonly value: unknown;
readonly errors: ValidationError[];
readonly isValid: boolean;
readonly isPristine: boolean;
readonly isValidating: boolean;
readonly isValidated: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { CoreSetup } from 'kibana/public';
import { getUrlIdFromGotoRoute, getUrlPath, GOTO_PREFIX } from '../../common/short_url_routes';
import { hashUrl } from '../../../kibana_utils/public';

export const createShortUrlRedirectApp = (core: CoreSetup, location: Location) => ({
id: 'short_url_redirect',
Expand All @@ -35,6 +34,7 @@ export const createShortUrlRedirectApp = (core: CoreSetup, location: Location) =

const response = await core.http.get<{ url: string }>(getUrlPath(urlId));
const redirectUrl = response.url;
const { hashUrl } = await import('../../../kibana_utils/public');
const hashedUrl = hashUrl(redirectUrl);
const url = core.http.basePath.prepend(hashedUrl);

Expand Down
24 changes: 23 additions & 1 deletion test/functional/apps/visualize/_vertical_bar_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,32 @@ export default function({ getService, getPageObjects }) {
await PageObjects.visEditor.selectXAxisPosition('left');
await PageObjects.visEditor.clickGo();

const leftLabels = await PageObjects.visChart.getXAxisLabels();
// the getYAxisLabels helper always returns the labels on the left axis
const leftLabels = await PageObjects.visChart.getYAxisLabels();
log.debug(`${leftLabels.length} tick labels on left x axis`);
expect(leftLabels.length).to.be.greaterThan(bottomLabels.length * (2 / 3));
});

it('should not filter out first label after rotation of the chart', async function() {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVerticalBarChart();
await PageObjects.visualize.clickNewSearch();
await PageObjects.timePicker.setDefaultAbsoluteRange();
await PageObjects.visEditor.clickBucket('X-axis');
await PageObjects.visEditor.selectAggregation('Date Range');
await PageObjects.visEditor.selectField('@timestamp');
await PageObjects.visEditor.clickGo();
const bottomLabels = await PageObjects.visChart.getXAxisLabels();
expect(bottomLabels.length).to.be(1);

await PageObjects.visEditor.clickMetricsAndAxes();
await PageObjects.visEditor.selectXAxisPosition('left');
await PageObjects.visEditor.clickGo();

// the getYAxisLabels helper always returns the labels on the left axis
const leftLabels = await PageObjects.visChart.getYAxisLabels();
expect(leftLabels.length).to.be(1);
});
});

describe('bar charts range on x axis', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function ErrorRateAlertTrigger(props: Props) {
</PopoverExpression>,
<ForLastExpression
onChangeWindowSize={windowSize =>
setAlertParams('windowSize', windowSize)
setAlertParams('windowSize', windowSize || '')
}
onChangeWindowUnit={windowUnit =>
setAlertParams('windowUnit', windowUnit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function TransactionDurationAlertTrigger(props: Props) {
</PopoverExpression>,
<ForLastExpression
onChangeWindowSize={timeWindowSize =>
setAlertParams('windowSize', timeWindowSize)
setAlertParams('windowSize', timeWindowSize || '')
}
onChangeWindowUnit={timeWindowUnit =>
setAlertParams('windowUnit', timeWindowUnit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export interface IDynamicStyleProperty extends IStyleProperty {
getField(): IField | undefined;
getFieldName(): string;
getFieldOrigin(): FIELD_ORIGIN | undefined;
getComputedFieldName(): string | undefined;
getRangeFieldMeta(): RangeFieldMeta;
getCategoryFieldMeta(): CategoryFieldMeta;
isFieldMetaEnabled(): boolean;
Expand Down
3 changes: 1 addition & 2 deletions x-pack/legacy/plugins/maps/server/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getEcommerceSavedObjects } from './sample_data/ecommerce_saved_objects'
import { getFlightsSavedObjects } from './sample_data/flights_saved_objects.js';
import { getWebLogsSavedObjects } from './sample_data/web_logs_saved_objects.js';
import { registerMapsUsageCollector } from './maps_telemetry/collectors/register';
import { LICENSE_CHECK_STATE } from '../../../../plugins/licensing/server';
import { initRoutes } from './routes';
import { emsBoundariesSpecProvider } from './tutorials/ems';

Expand Down Expand Up @@ -52,7 +51,7 @@ export class MapPlugin {

licensing.license$.subscribe(license => {
const { state } = license.check('maps', 'basic');
if (state === LICENSE_CHECK_STATE.Valid && !routesInitialized) {
if (state === 'valid' && !routesInitialized) {
routesInitialized = true;
initRoutes(__LEGACY, license.uid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
WEEK,
MONTH,
YEAR,
} from '../../../../../../src/plugins/es_ui_shared/public/components/cron_editor';
} from '../../../../../../src/plugins/es_ui_shared/public';
import { indexPatterns } from '../../../../../../src/plugins/data/public';
import { setHttp } from '../../public/crud_app/services';
import { mockHttpRequest, pageHelpers } from './helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import {
EuiTitle,
} from '@elastic/eui';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { CronEditor } from '../../../../../../../../../src/plugins/es_ui_shared/public/components/cron_editor';
import { CronEditor } from '../../../../../../../../../src/plugins/es_ui_shared/public';
import { indexPatterns } from '../../../../../../../../../src/plugins/data/public';

import { indices } from '../../../../shared_imports';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import cloneDeep from 'lodash/lang/cloneDeep';
import get from 'lodash/object/get';
import pick from 'lodash/object/pick';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { WEEK } from '../../../../../../../../../src/plugins/es_ui_shared/public/components/cron_editor';
import { WEEK } from '../../../../../../../../../src/plugins/es_ui_shared/public';

import { validateId } from './validate_id';
import { validateIndexPattern } from './validate_index_pattern';
Expand Down
10 changes: 5 additions & 5 deletions x-pack/legacy/plugins/uptime/common/types/ping/histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/

export interface HistogramDataPoint {
upCount?: number | null;
upCount?: number;

downCount?: number | null;
downCount?: number;

x?: number | null;
x?: number;

x0?: number | null;
x0?: number;

y?: number | null;
y?: number;
}

export interface GetPingHistogramParams {
Expand Down
Loading

0 comments on commit 891eda5

Please sign in to comment.