Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into np/slim-bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Apr 19, 2020
2 parents b498623 + 796421f commit 90938b7
Show file tree
Hide file tree
Showing 154 changed files with 5,204 additions and 2,608 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
| [SavedQuery](./kibana-plugin-plugins-data-public.savedquery.md) | |
| [SavedQueryService](./kibana-plugin-plugins-data-public.savedqueryservice.md) | |
| [SearchSourceFields](./kibana-plugin-plugins-data-public.searchsourcefields.md) | |
| [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) | |
| [TabbedAggColumn](./kibana-plugin-plugins-data-public.tabbedaggcolumn.md) | \* |
| [TabbedTable](./kibana-plugin-plugins-data-public.tabbedtable.md) | \* |
| [TimeRange](./kibana-plugin-plugins-data-public.timerange.md) | |
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

15 changes: 12 additions & 3 deletions docs/user/alerting/action-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,23 @@ a| <<webhook-action-type, Webhook>>

[NOTE]
==============================================
Some action types are paid commercial features, while others are free.
For a comparison of the Elastic subscription levels,
see https://www.elastic.co/subscriptions[the subscription page].
Some action types are paid commercial features, while others are free.
For a comparison of the Elastic subscription levels,
see https://www.elastic.co/subscriptions[the subscription page].
==============================================

[float]
[[create-connectors]]
=== Connectors

You can create connectors for actions in <<managing-alerts-and-actions, Alerts and Actions>> or via the action API.
For out-of-the-box and standardized connectors, you can <<pre-configured-connectors, preconfigure connectors>>
before {kib} starts.

include::action-types/email.asciidoc[]
include::action-types/index.asciidoc[]
include::action-types/pagerduty.asciidoc[]
include::action-types/server-log.asciidoc[]
include::action-types/slack.asciidoc[]
include::action-types/webhook.asciidoc[]
include::pre-configured-connectors.asciidoc[]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions docs/user/alerting/pre-configured-connectors.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[role="xpack"]
[[pre-configured-connectors]]

== Preconfigured connectors

You can preconfigure an action connector to have all the information it needs prior to startup
by adding it to the `kibana.yml` file.
Sensitive configuration information, such as credentials, can use the {kib} keystore.

Preconfigured connectors offer the following capabilities:

- Require no setup. Configuration and credentials needed to execute an
action are predefined, including the connector name and ID.
- Appear in all spaces because they are not saved objects.
- Cannot be edited or deleted.

[float]
[[preconfigured-connector-example]]
=== Example of a preconfigured connector

The following example shows a valid configuration 2 out-of-the box connector.

[source,console]
------------------------
xpack.actions.preconfigured:
- id: 'my-slack1' <1>
actionTypeId: .slack <2>
name: 'Slack #xyz' <3>
config: <4>
webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz'
- id: 'webhook-service'
actionTypeId: .webhook
name: 'Email service'
config:
url: 'https://email-alert-service.elastic.co'
method: post
headers:
header1: value1
header2: value2
secrets: <5>
user: elastic
password: changeme
------------------------

<1> `id` is the action connector identifier.
<2> `actionTypeId` is the action type identifier.
<3> `name` is the name of the preconfigured connector.
<4> `config` is the action type specific to the configuration.
<5> `secrets` is sensitive configuration, such as username, password, and keys.

[NOTE]
==============================================
Sensitive properties, such as passwords, can also be stored in the {kib} keystore.
==============================================

[float]
[[pre-configured-connector-alert-form]]
=== Creating an alert with a preconfigured connector

When attaching an action to an alert,
select from a list of available action types, and
then select the Slack or Webhook type. Those action types were configured previously.
The preconfigured connector is installed and is automatically selected.

[role="screenshot"]
image::images/alert-pre-configured-slack-connector.png[Create alert with selected Slack action type]

The dropdown is populated with additional preconfigured Slack connectors.
The `preconfigured` label distinguishes them from space-aware connectors that use saved objects.

[role="screenshot"]
image::images/alert-pre-configured-connectors-dropdown.png[Dropdown list with pre-cofigured connectors]

[float]
[[managing-pre-configured-connectors]]
=== Managing preconfigured connectors

Preconfigured connectors appear in the connector list, regardless of which space the user is in.
They are tagged as “preconfigured” and cannot be deleted.

[role="screenshot"]
image::images/pre-configured-connectors-managing.png[Connectors managing tab with pre-cofigured]

Clicking on a preconfigured connector shows the description, but not any of the configuration.
A message indicates that this is a preconfigured connector.

[role="screenshot"]
image::images/pre-configured-connectors-view-screen.png[Pre-configured connector view details]
12 changes: 6 additions & 6 deletions src/core/public/plugins/plugin_loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('`loadPluginBundles` creates a script tag and loads initializer', async ()
const fakeScriptTag = createdScriptTags[0];
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith(
'src',
'/bundles/plugin/plugin-a/plugin-a.plugin.js'
'/bundles/plugin:plugin-a/plugin-a.plugin.js'
);
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith('id', 'kbn-plugin-plugin-a');
expect(fakeScriptTag.onload).toBeInstanceOf(Function);
Expand All @@ -85,7 +85,7 @@ test('`loadPluginBundles` includes the basePath', async () => {
const fakeScriptTag = createdScriptTags[0];
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith(
'src',
'/mybasepath/bundles/plugin/plugin-a/plugin-a.plugin.js'
'/mybasepath/bundles/plugin:plugin-a/plugin-a.plugin.js'
);
});

Expand All @@ -96,7 +96,7 @@ test('`loadPluginBundles` rejects if script.onerror is called', async () => {
fakeScriptTag1.onerror(new Error('Whoa there!'));

await expect(loadPromise).rejects.toThrowErrorMatchingInlineSnapshot(
`"Failed to load \\"plugin-a\\" bundle (/bundles/plugin/plugin-a/plugin-a.plugin.js)"`
`"Failed to load \\"plugin-a\\" bundle (/bundles/plugin:plugin-a/plugin-a.plugin.js)"`
);
});

Expand All @@ -105,7 +105,7 @@ test('`loadPluginBundles` rejects if timeout is reached', async () => {
// Override the timeout to 1 ms for testi.
loadPluginBundle(addBasePath, 'plugin-a', { timeoutMs: 1 })
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Timeout reached when loading \\"plugin-a\\" bundle (/bundles/plugin/plugin-a/plugin-a.plugin.js)"`
`"Timeout reached when loading \\"plugin-a\\" bundle (/bundles/plugin:plugin-a/plugin-a.plugin.js)"`
);
});

Expand All @@ -115,11 +115,11 @@ test('`loadPluginBundles` rejects if bundle does attach an initializer to window
const fakeScriptTag1 = createdScriptTags[0];

// Setup a fake initializer as if a plugin bundle had actually been loaded.
coreWindow.__kbnBundles__['plugin/plugin-a'] = undefined;
coreWindow.__kbnBundles__['plugin:plugin-a'] = undefined;
// Call the onload callback
fakeScriptTag1.onload();

await expect(loadPromise).rejects.toThrowErrorMatchingInlineSnapshot(
`"Definition of plugin \\"plugin-a\\" should be a function (/bundles/plugin/plugin-a/plugin-a.plugin.js)."`
`"Definition of plugin \\"plugin-a\\" should be a function (/bundles/plugin:plugin-a/plugin-a.plugin.js)."`
);
});
2 changes: 1 addition & 1 deletion src/core/public/plugins/plugin_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const loadPluginBundle: LoadPluginBundle = <

const script = document.createElement('script');
// Assumes that all plugin bundles get put into the bundles/plugins subdirectory
const bundlePath = addBasePath(`/bundles/plugin/${pluginName}/${pluginName}.plugin.js`);
const bundlePath = addBasePath(`/bundles/plugin:${pluginName}/${pluginName}.plugin.js`);
script.setAttribute('src', bundlePath);
script.setAttribute('id', `kbn-plugin-${pluginName}`);
script.setAttribute('async', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { getIndices } from './get_indices';
import { IndexPatternCreationConfig } from '../../../../../../../../../plugins/index_pattern_management/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search';
import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search/legacy';

export const successfulResponse = {
hits: {
Expand Down
9 changes: 6 additions & 3 deletions src/legacy/ui/ui_render/bootstrap/template.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) {
'{{this}}',
{{/each}}
'{{regularBundlePath}}/commons.bundle.js',
'{{regularBundlePath}}/plugin/kibanaUtils/kibanaUtils.plugin.js',
'{{regularBundlePath}}/plugin/esUiShared/esUiShared.plugin.js',
'{{regularBundlePath}}/plugin/kibanaReact/kibanaReact.plugin.js',
{{!-- '{{regularBundlePath}}/plugin:data/data.plugin.js', --}}
'{{regularBundlePath}}/plugin:kibanaUtils/kibanaUtils.plugin.js',
'{{regularBundlePath}}/plugin:esUiShared/esUiShared.plugin.js',
'{{regularBundlePath}}/plugin:kibanaReact/kibanaReact.plugin.js'
], function () {
load([
'{{regularBundlePath}}/{{appId}}.bundle.js',
{{#each styleSheetPaths}}
'{{this}}',
Expand Down
4 changes: 2 additions & 2 deletions src/optimize/bundles_route/bundles_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export function createBundlesRoute({
),
...npUiPluginPublicDirs.map(({ id, path }) =>
buildRouteForBundles(
`${basePublicPath}/bundles/plugin/${id}/`,
`/bundles/plugin/${id}/`,
`${basePublicPath}/bundles/plugin:${id}/`,
`/bundles/plugin:${id}/`,
path,
fileHashCache
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { FilterUtils } from './lib/filter_utils';
import {
DashboardAppState,
DashboardAppStateDefaults,
DashboardAppStateInUrl,
DashboardAppStateTransitions,
SavedDashboardPanel,
} from '../types';
Expand Down Expand Up @@ -165,11 +166,12 @@ export class DashboardStateManager {
});

// setup state syncing utils. state container will be synced with url into `this.STATE_STORAGE_KEY` query param
this.stateSyncRef = syncState<DashboardAppState>({
this.stateSyncRef = syncState<DashboardAppStateInUrl>({
storageKey: this.STATE_STORAGE_KEY,
stateContainer: {
...this.stateContainer,
set: (state: DashboardAppState | null) => {
get: () => this.toUrlState(this.stateContainer.get()),
set: (state: DashboardAppStateInUrl | null) => {
// sync state required state container to be able to handle null
// overriding set() so it could handle null coming from url
if (state) {
Expand Down Expand Up @@ -558,9 +560,9 @@ export class DashboardStateManager {
*/
private saveState({ replace }: { replace: boolean }): boolean {
// schedules setting current state to url
this.kbnUrlStateStorage.set<DashboardAppState>(
this.kbnUrlStateStorage.set<DashboardAppStateInUrl>(
this.STATE_STORAGE_KEY,
this.stateContainer.get()
this.toUrlState(this.stateContainer.get())
);
// immediately forces scheduled updates and changes location
return this.kbnUrlStateStorage.flush({ replace });
Expand Down Expand Up @@ -620,4 +622,13 @@ export class DashboardStateManager {
const current = _.omit(this.stateContainer.get(), propsToIgnore);
return !_.isEqual(initial, current);
}

private toUrlState(state: DashboardAppState): DashboardAppStateInUrl {
if (state.viewMode === ViewMode.VIEW) {
const { panels, ...stateWithoutPanels } = state;
return stateWithoutPanels;
}

return state;
}
}
8 changes: 8 additions & 0 deletions src/plugins/dashboard/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ export type DashboardAppStateDefaults = DashboardAppState & {
description?: string;
};

/**
* In URL panels are optional,
* Panels are not added to the URL when in "view" mode
*/
export type DashboardAppStateInUrl = Omit<DashboardAppState, 'panels'> & {
panels?: SavedDashboardPanel[];
};

export interface DashboardAppStateTransitions {
set: (
state: DashboardAppState
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ export {
SearchRequest,
SearchResponse,
SearchError,
SearchStrategyProvider,
ISearchSource,
SearchSource,
createSearchSource,
Expand Down
Loading

0 comments on commit 90938b7

Please sign in to comment.