Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EUIfy Watcher #35301

Merged
merged 81 commits into from
Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
a170f7a
replacing Angular watch list UI with React one (#32401)
bmcconaghy Mar 7, 2019
a7ecccc
Watcher port edit watch (#34633)
alisonelizabeth Apr 5, 2019
7de0bff
partial progress on threshold watch form including validation (#34819)
bmcconaghy Apr 10, 2019
d22e9c2
Merge remote-tracking branch 'upstream/master' into upstream-watcher-…
bmcconaghy Apr 10, 2019
0078417
Watcher history page: port to react (#33047)
Apr 12, 2019
ed4701e
adding validation and UI feedback for threshold watch expression (#34…
bmcconaghy Apr 12, 2019
b991618
Advanced watch cleanup (#34955)
alisonelizabeth Apr 15, 2019
cadca11
turning it all into one React app (#35185)
bmcconaghy Apr 19, 2019
14afdec
Add tooltips back to creation buttons on watch list page. (#35385)
cjcenizal Apr 21, 2019
fe371f4
Simplify doc links service and fix links. (#35382)
cjcenizal Apr 22, 2019
5faec7b
adding watch visualization (#35404)
bmcconaghy Apr 23, 2019
3e1767b
[Watcher] Handle 403 and 404 in Status and Edit routes and fix breadc…
cjcenizal Apr 23, 2019
96ee395
[Watcher] Refine copy and layout of Watch History detail panel. (#35462)
cjcenizal Apr 23, 2019
6b17a37
Merge branch 'master' of github.com:elastic/kibana into watcher-port
cjcenizal Apr 24, 2019
2f79b06
adding support for >=, <=, and between for threshold alerts (#35614)
bmcconaghy Apr 26, 2019
02a0a38
adding loading spinner for watch visualization (#35798)
bmcconaghy Apr 30, 2019
039e967
Merge branch 'master' of github.com:elastic/kibana into watcher-port
cjcenizal May 3, 2019
46d7f2f
Fix yarn.lock.
cjcenizal May 3, 2019
0835f38
[Watcher] Support for adding actions to threshold watch (#35175)
alisonelizabeth May 3, 2019
4162b6b
create common watch actions component (#36056)
alisonelizabeth May 6, 2019
83d2ae7
switching to LineAnnotation for threshold marking (#36024)
bmcconaghy May 6, 2019
52bbb7b
add support for acknowledging a watch (#36030)
alisonelizabeth May 6, 2019
4598964
add error callout on watch details page (#36139)
alisonelizabeth May 8, 2019
ec7eda8
add support for system watch (#36110)
alisonelizabeth May 8, 2019
de14177
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth May 9, 2019
742e282
upgrade @elastic/charts library (#36357)
alisonelizabeth May 9, 2019
0e04d0e
improve error and loading states (#36356)
alisonelizabeth May 10, 2019
59f11aa
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth May 20, 2019
5313150
fix TS error
alisonelizabeth May 20, 2019
76adef5
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth May 21, 2019
84a5905
Improvements to threshold watch (#36688)
alisonelizabeth May 22, 2019
24802ae
UI improvements to watch list page (#36816)
alisonelizabeth May 23, 2019
471e445
cleanup watcher code (#37029)
alisonelizabeth May 28, 2019
488c932
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth May 29, 2019
c34dd12
update watcher to use common license checker (#37331)
alisonelizabeth May 31, 2019
f88d61b
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 4, 2019
581bd62
address design review feedback (#37911)
alisonelizabeth Jun 4, 2019
0125ef1
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 7, 2019
35d5abe
move existing watch check to server (#38131)
alisonelizabeth Jun 7, 2019
b172132
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 11, 2019
7cf0cc2
address watcher bugs (#38442)
alisonelizabeth Jun 11, 2019
17b9d6a
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 14, 2019
c2c8ec6
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 18, 2019
09f78d8
remove @elastic/charts style.css import
alisonelizabeth Jun 18, 2019
667eb57
fix lint error
alisonelizabeth Jun 19, 2019
3fb0569
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 19, 2019
bc6874a
update watcher copy (#39200)
alisonelizabeth Jun 19, 2019
7dfb95b
[WATCHER] component integration tests (#37726)
alisonelizabeth Jun 19, 2019
cacf0c9
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 21, 2019
53eb81a
i18n fix
alisonelizabeth Jun 21, 2019
53b7633
fix jest tests
alisonelizabeth Jun 21, 2019
6367c2b
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 21, 2019
f8ef5d1
improvements to expression for threshold alert (#39362)
alisonelizabeth Jun 21, 2019
d9219ac
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 24, 2019
29f9c56
fix loading state on watch list page + better handling for reloads (#…
alisonelizabeth Jun 24, 2019
fef4779
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 24, 2019
edc6a23
address i18n feedback + bugfixes (#39624)
alisonelizabeth Jun 26, 2019
448b331
fix text size for watch status component (#39671)
alisonelizabeth Jun 26, 2019
d47f959
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 26, 2019
d57698c
fix lastMetCondition column + loading state for threshold actions
alisonelizabeth Jun 26, 2019
d0c5389
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 26, 2019
70f4946
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 27, 2019
3bb5eb6
component integration tests for watch status page (#39509)
alisonelizabeth Jun 27, 2019
b493b51
address review feedback
alisonelizabeth Jun 27, 2019
6c74295
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 27, 2019
ccecb29
remove deprecated xpack:defaultAdminEmail from email action
alisonelizabeth Jun 27, 2019
20972d2
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 27, 2019
d3a9de3
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 27, 2019
87ff8aa
Revert "remove deprecated xpack:defaultAdminEmail from email action"
alisonelizabeth Jun 28, 2019
a7aa653
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 28, 2019
0606bd8
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 28, 2019
ee9baa1
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 28, 2019
ba5868a
fix license checker
alisonelizabeth Jun 28, 2019
c75c90b
fix test
alisonelizabeth Jun 28, 2019
ffb1c1d
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 28, 2019
44450ac
fix action model test
alisonelizabeth Jun 28, 2019
6a7b762
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 28, 2019
c0e9ae2
fix tests
alisonelizabeth Jun 28, 2019
af75ef4
Revert "Revert "remove deprecated xpack:defaultAdminEmail from email …
alisonelizabeth Jun 28, 2019
d15b5ed
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 28, 2019
dfbf594
Merge branch 'master' of github.com:elastic/kibana into watcher-port
alisonelizabeth Jun 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions x-pack/dev-tools/jest/create_jest_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function createJestConfig({
'^ui/(.*)': `${kibanaDirectory}/src/legacy/ui/public/$1`,
'uiExports/(.*)': `${kibanaDirectory}/src/dev/jest/mocks/file_mocks.js`,
'^src/core/(.*)': `${kibanaDirectory}/src/core/$1`,
'^plugins/watcher/models/(.*)': `${xPackKibanaDirectory}/legacy/plugins/watcher/public/models/$1`,
'^plugins/([^\/.]*)(.*)': `${kibanaDirectory}/src/legacy/core_plugins/$1/public$2`,
'^legacy/plugins/xpack_main/(.*);': `${xPackKibanaDirectory}/legacy/plugins/xpack_main/public/$1`,
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
Expand Down
121 changes: 12 additions & 109 deletions x-pack/legacy/plugins/watcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,19 @@ This plugins adopts some conventions in addition to or in place of conventions i

## Folder structure
```
common/
constants/ // constants used across client and server
lib/ // helpers used across client and server
types/ // TS definitions
public/
directives/ (This is the same as *A, but is for directives that are used cross-view)
services/
watch/
index.js (no code here; only `export from watch.js`)
watch.js
notifications/
index.js (no code here; only `export from notifications.js`)
notifications.js
...
views/
edit/
...
list/
directives/ (*A)
my_directive_name/
directives/ (Subcomponents of my_directive_name are defined here, and this follows the same structure as *A)
index.js (no code here; only `export from my_directive_name.js`)
my_directive_name.js
my_directive_name.html
index.js (imports the directives in this folder, i.e.,my_directive_name)
routes/
index.js (no code here; only imports routes.js)
routes.js
index.js

components/ // common React components
constants/ // constants used on the client
lib/ // helpers used on the client
models/ // client models
sections/ // Sections of the app with corresponding React components
watch_edit
watch_list
watch_status
server/
lib/
screenshots/
Expand All @@ -44,90 +31,6 @@ server/
say_hello.js
```

## Data Services

api calls:
- GET /watch/{id}
- PUT /watch/{id}

using the service

```js
import watch from './services/watch'

watch.get(...)
watch.put(...)
```

## Services / Lib
- Shared code that requires state should be made into a service. For example, see `pageService`.
- Shared code that doesn't require state (e.g. a simple helper function) should be made a lib.
For example, see `clamp`.

## Controller classes
- All functions in controller classes should be defined as arrow function constants. This is to ensure the `this` context is consistent, regardless of where it is being called.

GOOD
```
controller: class WatchListController {
onQueryChanged = (query) => {...};
}
```

BAD
```
controller: class WatchListController {
onQueryChanged(query) {...};
}
```

```
controller: class WatchListController {
constructor() {
this.onQueryChanged = (query) => {...};
}
}
```

- Constructors should be used to initialize state and define $scope.$watch(es)

GOOD
```
controllerAs: 'watchList',
bindToController: true,
scope: { foo: '=' },
controller: class WatchListController {
constructor() {
this.foo = this.foo || 'default';

$scope.$watch('watchList.foo', () => {
console.log('foo changed, fool');
});
}
}
```
## Event handlers

Event handler functions should be named with the following pattern:

> `on<Verb>`, in present tense

In case there is ambiguity about _what_ the verb is acting upon a noun should be included like so:

> `on<Noun><Verb>`, in present tense

GOOD
```
onDelete
onWatchDelete
```

BAD
```
onDeleted
onWatchDeleted
```

## Data Flow

We have a layered architecture in the Watcher UI codebase, with each layer performing a specific function to the data as it flows through it.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { getWatch } from '../../../test/fixtures';

export const WATCH_ID = 'my-test-watch';

export const WATCH = { watch: getWatch({ id: WATCH_ID }) };
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import sinon, { SinonFakeServer } from 'sinon';
import { ROUTES } from '../../../common/constants';

const { API_ROOT } = ROUTES;

type HttpResponse = Record<string, any> | any[];

const mockResponse = (defaultResponse: HttpResponse, response: HttpResponse) => [
200,
{ 'Content-Type': 'application/json' },
JSON.stringify({ ...defaultResponse, ...response }),
];

// Register helpers to mock HTTP Requests
const registerHttpRequestMockHelpers = (server: SinonFakeServer) => {
const setLoadWatchesResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watches: [] };

server.respondWith('GET', `${API_ROOT}/watches`, mockResponse(defaultResponse, response));
};

const setLoadWatchResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watch: {} };
server.respondWith('GET', `${API_ROOT}/watch/:id`, mockResponse(defaultResponse, response));
};

const setLoadWatchHistoryResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watchHistoryItems: [] };
server.respondWith(
'GET',
`${API_ROOT}/watch/:id/history?startTime=*`,
mockResponse(defaultResponse, response)
);
};

const setLoadWatchHistoryItemResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watchHistoryItem: {} };
server.respondWith('GET', `${API_ROOT}/history/:id`, mockResponse(defaultResponse, response));
};

const setDeleteWatchResponse = (response?: HttpResponse, error?: any) => {
const status = error ? error.status || 400 : 200;
const body = error ? JSON.stringify(error.body) : JSON.stringify(response);

server.respondWith('POST', `${API_ROOT}/watches/delete`, [
status,
{ 'Content-Type': 'application/json' },
body,
]);
};

const setSaveWatchResponse = (id: string, response?: HttpResponse, error?: any) => {
const status = error ? error.status || 400 : 200;
const body = error ? JSON.stringify(error.body) : JSON.stringify(response);

server.respondWith('PUT', `${API_ROOT}/watch/${id}`, [
status,
{ 'Content-Type': 'application/json' },
body,
]);
};

const setLoadExecutionResultResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watchHistoryItem: {} };
server.respondWith('PUT', `${API_ROOT}/watch/execute`, mockResponse(defaultResponse, response));
};

const setLoadMatchingIndicesResponse = (response: HttpResponse = {}) => {
const defaultResponse = { indices: [] };
server.respondWith('POST', `${API_ROOT}/indices`, mockResponse(defaultResponse, response));
};

const setLoadEsFieldsResponse = (response: HttpResponse = {}) => {
const defaultResponse = { fields: [] };
server.respondWith('POST', `${API_ROOT}/fields`, mockResponse(defaultResponse, response));
};

const setLoadSettingsResponse = (response: HttpResponse = {}) => {
const defaultResponse = { action_types: {} };
server.respondWith('GET', `${API_ROOT}/settings`, mockResponse(defaultResponse, response));
};

const setLoadWatchVisualizeResponse = (response: HttpResponse = {}) => {
const defaultResponse = { visualizeData: {} };
server.respondWith(
'POST',
`${API_ROOT}/watch/visualize`,
mockResponse(defaultResponse, response)
);
};

const setDeactivateWatchResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watchStatus: {} };
server.respondWith(
'PUT',
`${API_ROOT}/watch/:id/deactivate`,
mockResponse(defaultResponse, response)
);
};

const setActivateWatchResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watchStatus: {} };
server.respondWith(
'PUT',
`${API_ROOT}/watch/:id/activate`,
mockResponse(defaultResponse, response)
);
};

const setAcknowledgeWatchResponse = (response: HttpResponse = {}) => {
const defaultResponse = { watchStatus: {} };
server.respondWith(
'PUT',
`${API_ROOT}/watch/:id/action/:actionId/acknowledge`,
mockResponse(defaultResponse, response)
);
};

return {
setLoadWatchesResponse,
setLoadWatchResponse,
setLoadWatchHistoryResponse,
setLoadWatchHistoryItemResponse,
setDeleteWatchResponse,
setSaveWatchResponse,
setLoadExecutionResultResponse,
setLoadMatchingIndicesResponse,
setLoadEsFieldsResponse,
setLoadSettingsResponse,
setLoadWatchVisualizeResponse,
setDeactivateWatchResponse,
setActivateWatchResponse,
setAcknowledgeWatchResponse,
};
};

export const init = () => {
const server = sinon.fakeServer.create();
server.respondImmediately = true;

// Define default response for unhandled requests.
// We make requests to APIs which don't impact the component under test, e.g. UI metric telemetry,
// and we can mock them all with a 200 instead of mocking each one individually.
server.respondWith([200, {}, 'DefaultResponse']);

const httpRequestsMockHelpers = registerHttpRequestMockHelpers(server);

return {
server,
httpRequestsMockHelpers,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { setup as watchListSetup } from './watch_list.helpers';
import { setup as watchStatusSetup } from './watch_status.helpers';
import { setup as watchCreateJsonSetup } from './watch_create_json.helpers';
import { setup as watchCreateThresholdSetup } from './watch_create_threshold.helpers';
import { setup as watchEditSetup } from './watch_edit.helpers';

export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../../test_utils';

export { setupEnvironment } from './setup_environment';

export const pageHelpers = {
watchList: { setup: watchListSetup },
watchStatus: { setup: watchStatusSetup },
watchCreateJson: { setup: watchCreateJsonSetup },
watchCreateThreshold: { setup: watchCreateThresholdSetup },
watchEdit: { setup: watchEditSetup },
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import axios from 'axios';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';
import { init as initHttpRequests } from './http_requests';
import { setHttpClient, setSavedObjectsClient } from '../../../public/lib/api';

const mockHttpClient = axios.create({ adapter: axiosXhrAdapter });

const mockSavedObjectsClient = () => {
return {
find: (_params?: any) => {},
};
};

export const setupEnvironment = () => {
const { server, httpRequestsMockHelpers } = initHttpRequests();

// @ts-ignore
setHttpClient(mockHttpClient);

setSavedObjectsClient(mockSavedObjectsClient());

return {
server,
httpRequestsMockHelpers,
};
};
Loading