Skip to content

Commit

Permalink
Merge branch 'master' into search-legacy-hits-total
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 1, 2021
2 parents 60eabcc + bae179e commit 8e5b653
Show file tree
Hide file tree
Showing 81 changed files with 899 additions and 405 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/public/chrome/ui/header/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export function CollapsibleNav({
label: 'Home',
iconType: 'home',
href: homeHref,
'data-test-subj': 'homeLink',
onClick: (event) => {
if (isModifiedOrPrevented(event)) {
return;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const AddData: FC<Props> = ({ addBasePath, features }) => {
<EuiFlexItem className="homDataAdd__actions" grow={false}>
<div>
<EuiButtonEmpty
data-test-subj="addSampleData"
className="homDataAdd__actionButton"
flush="left"
href="#/tutorial_directory/sampleData"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class TutorialDirectoryUi extends React.Component {
// Add card for sample data that only gets show in "all" tab
tutorialCards.push({
id: 'sample_data',

name: this.props.intl.formatMessage({
id: 'home.tutorial.card.sampleDataTitle',
defaultMessage: 'Sample Data',
Expand Down Expand Up @@ -178,6 +179,7 @@ class TutorialDirectoryUi extends React.Component {
renderTabs = () => {
return this.tabs.map((tab, index) => (
<EuiTab
data-test-subj={`homeTab-${tab.id}`}
onClick={() => this.onSelectedTabChanged(tab.id)}
isSelected={tab.id === this.state.selectedTabId}
key={index}
Expand All @@ -203,7 +205,7 @@ class TutorialDirectoryUi extends React.Component {
})
.map((tutorial) => {
return (
<EuiFlexItem key={tutorial.name}>
<EuiFlexItem data-test-subj={`homeTab-${tutorial.name}`} key={tutorial.name}>
<Synopsis
id={tutorial.id}
iconType={tutorial.icon}
Expand Down
22 changes: 22 additions & 0 deletions src/plugins/index_pattern_management/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"public/**/*",
"server/**/*",
],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
{ "path": "../management/tsconfig.json" },
{ "path": "../url_forwarding/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const OverviewPageHeader: FC<Props> = ({
<EuiFlexItem className="kbnOverviewPageHeader__actionItem" grow={false}>
<RedirectAppLinks application={application}>
<EuiButtonEmpty
data-test-subj="homeAddData"
className="kbnOverviewPageHeader__actionButton"
flush="both"
href={addBasePath('/app/home#/tutorial_directory')}
Expand All @@ -96,6 +97,7 @@ export const OverviewPageHeader: FC<Props> = ({
<EuiFlexItem className="kbnOverviewPageHeader__actionItem" grow={false}>
<RedirectAppLinks application={application}>
<EuiButtonEmpty
data-test-subj="homeManage"
className="kbnOverviewPageHeader__actionButton"
flush="both"
iconType="gear"
Expand All @@ -116,6 +118,7 @@ export const OverviewPageHeader: FC<Props> = ({
<EuiFlexItem className="kbnOverviewPageHeader__actionItem" grow={false}>
<RedirectAppLinks application={application}>
<EuiButtonEmpty
data-test-subj="homeDevTools"
className="kbnOverviewPageHeader__actionButton"
flush="both"
iconType="wrench"
Expand Down
1 change: 1 addition & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
{ "path": "../src/plugins/ui_actions/tsconfig.json" },
{ "path": "../src/plugins/url_forwarding/tsconfig.json" },
{ "path": "../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../src/plugins/index_pattern_management/tsconfig.json" },
{ "path": "../src/plugins/legacy_export/tsconfig.json" }
]
}
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"src/plugins/vis_type_xy/**/*",
"src/plugins/visualizations/**/*",
"src/plugins/visualize/**/*",
"src/plugins/index_pattern_management/**/*",
// In the build we actually exclude **/public/**/* from this config so that
// we can run the TSC on both this and the .browser version of this config
// file, but if we did it during development IDEs would not be able to find
Expand Down Expand Up @@ -117,5 +118,6 @@
{ "path": "./src/plugins/vis_type_xy/tsconfig.json" },
{ "path": "./src/plugins/visualizations/tsconfig.json" },
{ "path": "./src/plugins/visualize/tsconfig.json" },
{ "path": "./src/plugins/index_pattern_management/tsconfig.json" },
]
}
3 changes: 2 additions & 1 deletion tsconfig.refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
{ "path": "./src/plugins/vis_type_vega/tsconfig.json" },
{ "path": "./src/plugins/vis_type_xy/tsconfig.json" },
{ "path": "./src/plugins/visualizations/tsconfig.json" },
{ "path": "./src/plugins/visualize/tsconfig.json" }
{ "path": "./src/plugins/visualize/tsconfig.json" },
{ "path": "./src/plugins/index_pattern_management/tsconfig.json" },
]
}
3 changes: 2 additions & 1 deletion x-pack/plugins/alerts/server/alerts_client/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export interface CreateOptions<Params extends AlertTypeParams> {
| 'executionStatus'
> & { actions: NormalizedAlertAction[] };
options?: {
id?: string;
migrationVersion?: Record<string, string>;
};
}
Expand Down Expand Up @@ -226,7 +227,7 @@ export class AlertsClient {
data,
options,
}: CreateOptions<Params>): Promise<Alert<Params>> {
const id = SavedObjectsUtils.generateId();
const id = options?.id || SavedObjectsUtils.generateId();

try {
await this.authorization.ensureAuthorized(
Expand Down
67 changes: 67 additions & 0 deletions x-pack/plugins/alerts/server/alerts_client/tests/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,73 @@ describe('create()', () => {
expect(actionsClient.isActionTypeEnabled).toHaveBeenCalledWith('test', { notifyUsage: true });
});

test('creates an alert with a custom id', async () => {
const data = getMockData();
const createdAttributes = {
...data,
alertTypeId: '123',
schedule: { interval: '10s' },
params: {
bar: true,
},
createdAt: '2019-02-12T21:01:22.479Z',
createdBy: 'elastic',
updatedBy: 'elastic',
updatedAt: '2019-02-12T21:01:22.479Z',
muteAll: false,
mutedInstanceIds: [],
actions: [
{
group: 'default',
actionRef: 'action_0',
actionTypeId: 'test',
params: {
foo: true,
},
},
],
};
unsecuredSavedObjectsClient.create.mockResolvedValueOnce({
id: '123',
type: 'alert',
attributes: createdAttributes,
references: [
{
name: 'action_0',
type: 'action',
id: '1',
},
],
});
taskManager.schedule.mockResolvedValueOnce({
id: 'task-123',
taskType: 'alerting:123',
scheduledAt: new Date(),
attempts: 1,
status: TaskStatus.Idle,
runAt: new Date(),
startedAt: null,
retryAt: null,
state: {},
params: {},
ownerId: null,
});
const result = await alertsClient.create({ data, options: { id: '123' } });
expect(result.id).toEqual('123');
expect(unsecuredSavedObjectsClient.create.mock.calls[0][2]).toMatchInlineSnapshot(`
Object {
"id": "123",
"references": Array [
Object {
"id": "1",
"name": "action_0",
"type": "action",
},
],
}
`);
});

test('creates an alert with multiple actions', async () => {
const data = getMockData({
actions: [
Expand Down
73 changes: 72 additions & 1 deletion x-pack/plugins/alerts/server/routes/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('createAlertRoute', () => {

const [config, handler] = router.post.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/alerts/alert"`);
expect(config.path).toMatchInlineSnapshot(`"/api/alerts/alert/{id?}"`);

alertsClient.create.mockResolvedValueOnce(createResult);

Expand Down Expand Up @@ -125,6 +125,9 @@ describe('createAlertRoute', () => {
],
"throttle": "30s",
},
"options": Object {
"id": undefined,
},
},
]
`);
Expand All @@ -134,6 +137,74 @@ describe('createAlertRoute', () => {
});
});

it('allows providing a custom id', async () => {
const expectedResult = {
...createResult,
id: 'custom-id',
};
const licenseState = licenseStateMock.create();
const router = httpServiceMock.createRouter();

createAlertRoute(router, licenseState);

const [config, handler] = router.post.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/alerts/alert/{id?}"`);

alertsClient.create.mockResolvedValueOnce(expectedResult);

const [context, req, res] = mockHandlerArguments(
{ alertsClient },
{
params: { id: 'custom-id' },
body: mockedAlert,
},
['ok']
);

expect(await handler(context, req, res)).toEqual({ body: expectedResult });

expect(alertsClient.create).toHaveBeenCalledTimes(1);
expect(alertsClient.create.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Object {
"data": Object {
"actions": Array [
Object {
"group": "default",
"id": "2",
"params": Object {
"foo": true,
},
},
],
"alertTypeId": "1",
"consumer": "bar",
"name": "abc",
"notifyWhen": "onActionGroupChange",
"params": Object {
"bar": true,
},
"schedule": Object {
"interval": "10s",
},
"tags": Array [
"foo",
],
"throttle": "30s",
},
"options": Object {
"id": "custom-id",
},
},
]
`);

expect(res.ok).toHaveBeenCalledWith({
body: expectedResult,
});
});

it('ensures the license allows creating alerts', async () => {
const licenseState = licenseStateMock.create();
const router = httpServiceMock.createRouter();
Expand Down
Loading

0 comments on commit 8e5b653

Please sign in to comment.