Skip to content

Commit

Permalink
Merge branch 'master' into indicator_followup
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 1, 2021
2 parents f2de1ad + 4ea10d9 commit 16b6f6c
Show file tree
Hide file tree
Showing 457 changed files with 8,521 additions and 4,148,470 deletions.
4 changes: 2 additions & 2 deletions docs/user/dashboard/drilldowns.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ that shows a single data center or server.
[[url-drilldowns]]
==== URL drilldowns

beta[] URL drilldowns enable you to navigate from a dashboard to internal or external URLs.
URL drilldowns enable you to navigate from a dashboard to internal or external URLs.
Destination URLs can be dynamic, depending on the dashboard context or user interaction with a panel.
For example, if you have a dashboard that shows data from a Github repository, you can create a URL drilldown
that opens Github from the dashboard.
Expand Down Expand Up @@ -226,7 +226,7 @@ and date range are carried over.
[[create-a-url-drilldown]]
=== Try it: Create a URL drilldown

beta[] To create URL drilldowns, you add <<variables,variables>> to a URL template, which configures the bahavior of the drilldown.
To create URL drilldowns, you add <<variables,variables>> to a URL template, which configures the behavior of the drilldown.

image:images/url_drilldown_go_to_github.gif[Drilldown on pie chart that navigates to Github]

Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Adapters as Adapters_2 } from 'src/plugins/inspector/common';
import { ApiResponse } from '@elastic/elasticsearch';
import { ApiResponse as ApiResponse_2 } from '@elastic/elasticsearch/lib/Transport';
import { ApplicationStart } from 'kibana/public';
import { ApplicationUsageTracker } from '@kbn/analytics';
import { Assign } from '@kbn/utility-types';
import { BehaviorSubject } from 'rxjs';
import { BfetchPublicSetup } from 'src/plugins/bfetch/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ Application Usage will automatically track the active minutes on screen and clic

The prop `viewId` is used as a unique identifier for your plugin. The Application Id is automatically attached to the tracked usage, based on the ID used when registering your app via `core.application.register`.

#### Advanced Usage

If you have a custom use case not provided by the Application Usage helpers you can use the `usageCollection.applicationUsageTracker` public api directly.

To start tracking a view: `applicationUsageTracker.trackApplicationViewUsage(viewId)`
Calling this method will marks the specified `viewId` as active. applicationUsageTracker will start tracking clicks and screen minutes for the view.

To stop tracking a view: `applicationUsageTracker.flushTrackedView(viewId)`
Calling this method will stop tracking the clicks and screen minutes for that view. Usually once the view is no longer active.


## Application Usage Telemetry Data

This collector reports the number of general clicks and minutes on screen for each registered application in Kibana.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ import { Query } from '@elastic/eui';
import { parse } from 'query-string';
import { i18n } from '@kbn/i18n';
import { CoreStart, ChromeBreadcrumb } from 'src/core/public';
import type {
SpacesAvailableStartContract,
SpacesContextProps,
} from 'src/plugins/spaces_oss/public';
import { DataPublicPluginStart } from '../../../data/public';
import { SavedObjectsTaggingApi } from '../../../saved_objects_tagging_oss/public';
import type { SpacesAvailableStartContract } from '../../../spaces_oss/public';
import {
ISavedObjectsManagementServiceRegistry,
SavedObjectsManagementActionServiceStart,
SavedObjectsManagementColumnServiceStart,
} from '../services';
import { SavedObjectsTable } from './objects_table';

const EmptyFunctionComponent: React.FC = ({ children }) => <>{children}</>;
const getEmptyFunctionComponent: React.FC<SpacesContextProps> = ({ children }) => <>{children}</>;

const SavedObjectsTablePage = ({
coreStart,
Expand Down Expand Up @@ -71,7 +74,8 @@ const SavedObjectsTablePage = ({
}, [setBreadcrumbs]);

const ContextWrapper = useMemo(
() => spacesApi?.ui.components.SpacesContext || EmptyFunctionComponent,
() =>
spacesApi ? spacesApi.ui.components.getSpacesContextProvider : getEmptyFunctionComponent,
[spacesApi]
);

Expand Down
9 changes: 5 additions & 4 deletions src/plugins/spaces_oss/public/api.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ type SpacesApiUiComponentMock = jest.Mocked<SpacesApiUiComponent>;

const createApiUiComponentsMock = () => {
const mock: SpacesApiUiComponentMock = {
SpacesContext: jest.fn(),
ShareToSpaceFlyout: jest.fn(),
SpaceList: jest.fn(),
LegacyUrlConflict: jest.fn(),
getSpacesContextProvider: jest.fn(),
getShareToSpaceFlyout: jest.fn(),
getSpaceList: jest.fn(),
getLegacyUrlConflict: jest.fn(),
getSpaceAvatar: jest.fn(),
};

return mock;
Expand Down
38 changes: 32 additions & 6 deletions src/plugins/spaces_oss/public/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Observable } from 'rxjs';
import type { FunctionComponent } from 'react';
import type { ReactElement } from 'react';
import { Space } from '../common';

/**
Expand All @@ -22,12 +22,19 @@ export interface SpacesApi {
ui: SpacesApiUi;
}

/**
* Function that returns a promise for a lazy-loadable component.
*
* @public
*/
export type LazyComponentFn<T> = (props: T) => ReactElement;

/**
* @public
*/
export interface SpacesApiUi {
/**
* {@link SpacesApiUiComponent | React components} to support the spaces feature.
* Lazy-loadable {@link SpacesApiUiComponent | React components} to support the spaces feature.
*/
components: SpacesApiUiComponent;
/**
Expand Down Expand Up @@ -62,13 +69,13 @@ export interface SpacesApiUiComponent {
/**
* Provides a context that is required to render some Spaces components.
*/
SpacesContext: FunctionComponent<SpacesContextProps>;
getSpacesContextProvider: LazyComponentFn<SpacesContextProps>;
/**
* Displays a flyout to edit the spaces that an object is shared to.
*
* Note: must be rendered inside of a SpacesContext.
*/
ShareToSpaceFlyout: FunctionComponent<ShareToSpaceFlyoutProps>;
getShareToSpaceFlyout: LazyComponentFn<ShareToSpaceFlyoutProps>;
/**
* Displays a corresponding list of spaces for a given list of saved object namespaces. It shows up to five spaces (and an indicator for
* any number of spaces that the user is not authorized to see) by default. If more than five named spaces would be displayed, the extras
Expand All @@ -77,7 +84,7 @@ export interface SpacesApiUiComponent {
*
* Note: must be rendered inside of a SpacesContext.
*/
SpaceList: FunctionComponent<SpaceListProps>;
getSpaceList: LazyComponentFn<SpaceListProps>;
/**
* Displays a callout that needs to be used if a call to `SavedObjectsClient.resolve()` results in an `"conflict"` outcome, which
* indicates that the user has loaded the page which is associated directly with one object (A), *and* with a legacy URL that points to a
Expand All @@ -95,7 +102,11 @@ export interface SpacesApiUiComponent {
*
* New URL path: `#/workpad/workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1`
*/
LegacyUrlConflict: FunctionComponent<LegacyUrlConflictProps>;
getLegacyUrlConflict: LazyComponentFn<LegacyUrlConflictProps>;
/**
* Displays an avatar for the given space.
*/
getSpaceAvatar: LazyComponentFn<SpaceAvatarProps>;
}

/**
Expand Down Expand Up @@ -251,3 +262,18 @@ export interface LegacyUrlConflictProps {
*/
otherObjectPath: string;
}

/**
* @public
*/
export interface SpaceAvatarProps {
space: Partial<Space>;
size?: 's' | 'm' | 'l' | 'xl';
className?: string;
/**
* When enabled, allows EUI to provide an aria-label for this component, which is announced on screen readers.
*
* Default value is true.
*/
announceSpaceName?: boolean;
}
2 changes: 2 additions & 0 deletions src/plugins/spaces_oss/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
} from './types';

export {
LazyComponentFn,
SpacesApi,
SpacesApiUi,
SpacesApiUiComponent,
Expand All @@ -24,6 +25,7 @@ export {
ShareToSpaceSavedObjectTarget,
SpaceListProps,
LegacyUrlConflictProps,
SpaceAvatarProps,
} from './api';

export const plugin = () => new SpacesOssPlugin();
18 changes: 13 additions & 5 deletions src/plugins/usage_collection/public/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ import { ApplicationUsageContext } from './components/track_application_view';

export type Setup = jest.Mocked<UsageCollectionSetup>;

export const createApplicationUsageTrackerMock = (): ApplicationUsageTracker => {
const applicationUsageTrackerMock: jest.Mocked<ApplicationUsageTracker> = {
setCurrentAppId: jest.fn(),
// This is to avoid having to mock every private property of the class
type ApplicationUsageTrackerPublic = Pick<ApplicationUsageTracker, keyof ApplicationUsageTracker>;

export const createApplicationUsageTrackerMock = (): ApplicationUsageTrackerPublic => {
const applicationUsageTrackerMock: jest.Mocked<ApplicationUsageTrackerPublic> = {
trackApplicationViewUsage: jest.fn(),
} as any;
flushTrackedView: jest.fn(),
updateViewClickCounter: jest.fn(),
setCurrentAppId: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
pauseTrackingAll: jest.fn(),
resumeTrackingAll: jest.fn(),
};

return applicationUsageTrackerMock;
};
Expand All @@ -32,7 +41,6 @@ const createSetupContract = (): Setup => {
</ApplicationUsageContext.Provider>
),
},
applicationUsageTracker: applicationUsageTrackerMock,
reportUiCounter: jest.fn(),
};

Expand Down
7 changes: 0 additions & 7 deletions src/plugins/usage_collection/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ export interface UsageCollectionSetup {
components: {
ApplicationUsageTrackingProvider: React.FC;
};
applicationUsageTracker: IApplicationUsageTracker;
reportUiCounter: Reporter['reportUiCounter'];
}

export interface UsageCollectionStart {
reportUiCounter: Reporter['reportUiCounter'];
applicationUsageTracker: Pick<
ApplicationUsageTracker,
'trackApplicationViewUsage' | 'flushTrackedView' | 'updateViewClickCounter'
>;
}

export function isUnauthenticated(http: HttpSetup) {
Expand Down Expand Up @@ -83,7 +78,6 @@ export class UsageCollectionPlugin implements Plugin<UsageCollectionSetup, Usage
</ApplicationUsageContext.Provider>
),
},
applicationUsageTracker,
reportUiCounter: this.reporter.reportUiCounter,
};
}
Expand All @@ -105,7 +99,6 @@ export class UsageCollectionPlugin implements Plugin<UsageCollectionSetup, Usage
this.reporter.reportUserAgent('kibana');

return {
applicationUsageTracker: this.getPublicApplicationUsageTracker(),
reportUiCounter: this.reporter.reportUiCounter,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const DO_NOT_REPORT = ['kibana'];

export function trackApplicationUsageChange(
currentAppId$: Observable<string | undefined>,
applicationUsageTracker: ApplicationUsageTracker
applicationUsageTracker: Pick<
ApplicationUsageTracker,
'updateViewClickCounter' | 'setCurrentAppId' | 'trackApplicationViewUsage'
>
) {
const windowClickSubscrition = fromEvent(window, 'click').subscribe(() => {
applicationUsageTracker.updateViewClickCounter(MAIN_APP_DEFAULT_VIEW_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export { NumberInputOption } from './number_input';
export { RangeOption } from './range';
export { RequiredNumberInputOption } from './required_number_input';
export { TextInputOption } from './text_input';
export { PercentageModeOption } from './percentage_mode';
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 React from 'react';
import { mountWithIntl } from '@kbn/test/jest';
import { PercentageModeOption, PercentageModeOptionProps } from './percentage_mode';
import { EuiFieldText } from '@elastic/eui';

describe('PercentageModeOption', () => {
let props: PercentageModeOptionProps;
let component;
beforeAll(() => {
props = {
percentageMode: true,
setValue: jest.fn(),
};
});

it('renders the EuiFieldText', () => {
component = mountWithIntl(<PercentageModeOption {...props} />);
expect(component.find(EuiFieldText).length).toBe(1);
});

it('should call setValue when value was putted in fieldText', () => {
component = mountWithIntl(<PercentageModeOption {...props} />);
const fieldText = component.find(EuiFieldText);
fieldText.props().onChange!({
target: {
value: '0.0%',
},
} as React.ChangeEvent<HTMLInputElement>);

expect(props.setValue).toHaveBeenCalledWith('percentageFormatPattern', '0.0%');
});

it('fieldText should be disabled when percentageMode is false', () => {
props.percentageMode = false;
component = mountWithIntl(<PercentageModeOption {...props} />);
const fieldText = component.find(EuiFieldText);

expect(fieldText.props().disabled).toBeTruthy();
});
});
Loading

0 comments on commit 16b6f6c

Please sign in to comment.