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

port advanced watcher to react #34188

Conversation

alisonelizabeth
Copy link
Contributor

@alisonelizabeth alisonelizabeth commented Mar 29, 2019

This is an initial PR for the advanced watcher pages port to react. I’m a noob at typescript and react hooks, so appreciate any feedback on implementation - as well as design!

There are some TODOs left:

  • Previous code had a license validity check on save; need some help to determine best way to port this over
  • Redirect back to /watches is not implemented yet on save. I started trying to use the existing kbnUrl service, but was running into issues. I didn’t spend too much time on this, as I think the ultimate goal is to move to react router.

I left the angular code in there for now for testing/review purposes. I will remove once this is looking to be in good shape.

Screenshots

Create new watch
Screen Shot 2019-03-29 at 11 01 17 AM

Validation error modals
Screen Shot 2019-03-29 at 11 04 31 AM

Screen Shot 2019-03-29 at 11 04 47 AM

Edit existing watch
Screen Shot 2019-03-29 at 2 17 40 PM

Simulate watch
Screen Shot 2019-03-29 at 2 45 19 PM

Simulate results
Screen Shot 2019-03-29 at 2 17 53 PM

@elasticmachine
Copy link
Contributor

💔 Build Failed

@yaronp68 yaronp68 added the Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more label Apr 1, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui

@yaronp68
Copy link

yaronp68 commented Apr 1, 2019

@alisonelizabeth One more suggestion is to have an input template inside the editor when overriding input
Here's an example

{
  "took" : 63,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1000,
    "max_score" : null,
    "hits" : [ {
      
    }
    ]
  }
}

@alisonelizabeth
Copy link
Contributor Author

@yaronp68 thanks for the feedback! one concern i might have is the input override is optional so a user would have to delete the sample template if they didn't want it. i guess i'm still not familiar enough to know the most common use cases.

another possibility might be to include the sample template you provided on the left-hand side with the description (the user could then just copy it, if desired), but that might take up too much space. thoughts?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@alisonelizabeth
Copy link
Contributor Author

I pushed a commit with the updated trigger override fields, fyi @yaronp68

Screen Shot 2019-04-01 at 2 34 47 PM

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@yaronp68
Copy link

yaronp68 commented Apr 2, 2019

@alisonelizabeth Looks great. I would propose to add toggle button to override input and in case it is toggled off (default?) hide the editor?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@alisonelizabeth
Copy link
Contributor Author

@yaronp68 yeah, that's another possibility! i'd like to get some more feedback from others on it i think.

@alisonelizabeth
Copy link
Contributor Author

@bmcconaghy i pushed another commit with the changes we discussed this morning: added the license validity check and also attempted to use the kbnUrl service. It still isn't working correctly for me, maybe you could take a look when you get around to reviewing the code? I basically just passed down kbnUrl and licenseService as props from watch_edit_route. Not sure if this is the best approach - let me know if you know a better way! Thanks!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@yaronp68
Copy link

yaronp68 commented Apr 3, 2019

@bmcconaghy @alisonelizabeth One more suggestion, I believe will help the user to improve the conditions:
When returning results of the watch can we copy the input.payload.hits to a separate search field + editor named ctx.payload.hits

@bmcconaghy
Copy link
Contributor

We probably want to have something similar to this in the simulate results flyour to indicate status:
image

@bmcconaghy
Copy link
Contributor

I get a fatal error if I click over to simulate when the JSON in the edit box is invalid.

@alisonelizabeth
Copy link
Contributor Author

@bmcconaghy thanks for the feedback.

I'll look into the bug.

As far as the icon, good point. I noticed @pcsanwald created a common component for the watch statuses. I think I'll be able to reuse that - https://github.com/elastic/kibana/blob/a5f6de16a22590d839261c1a6e3645818a2620f1/x-pack/plugins/watcher/public/sections/watch_detail/components/watch_detail/watch_action_status.tsx.

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good, great job. Just had a few comments/questions.


function getTableData(watch: BaseWatch) {
const actions = watch.watch && watch.watch.actions;
return map(actions, (action, actionId) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of things here: map can be done in ES6 on arrays w/o the need for lodash, and actions could be false here right? in which case the mapping would fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. i think i may have carried this over from the previous logic :) i think the difference is lodash map supports objects, which actions is in this case (if i remember correctly). i'll look into it again though and confirm.

upstreamJson: any;
}

export interface BaseWatch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably just move all the models to TS, but we can do that in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can work on that next

x-pack/plugins/watcher/common/types/watch_types.ts Outdated Show resolved Hide resolved

// TODO: Remove once typescript definitions are in EUI
declare module '@elastic/eui' {
export const EuiCodeEditor: React.SFC<any>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why these are needed. I didn't need to add any eui types for my stuff (maybe I'm missing something)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's only for certain eui components.

see: https://github.com/elastic/kibana/blob/master/TYPESCRIPT.md#how-to-fix-common-typescript-errors

this may not be the correct place to put it. let me know what you think.

@alisonelizabeth
Copy link
Contributor Author

@bmcconaghy I pushed a commit that addresses most of your comments - thanks for the feedback! I also fixed an existing watcher bug, #18296.

TODOs:

  • Switch <EuiHealth> component to <EuiIcon> for displaying watch statuses (if it’s ok with you, I’ll hold off on fixing this until Paul’s PR is merged)
  • Look into use of lodash map in json_watch_edit_simulate.tsx
  • Just realized I think i need to move the simulate form state up a level, so if you tab from Simulate --> Edit --> back to Simulate, the state persists.

I’ll keep working through these, but didn’t want to block you from making progress on your end if you wanted to go ahead and merge. I also met with @gchaps this morning and have a few changes to make as far as text goes.

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we can handle the TODOs with another PR.

@alisonelizabeth alisonelizabeth merged commit 081bb7c into elastic:watcher-port-edit-watch Apr 4, 2019
@alisonelizabeth alisonelizabeth deleted the advanced-watch-port branch April 4, 2019 20:30
@elasticmachine
Copy link
Contributor

💔 Build Failed

bmcconaghy pushed a commit that referenced this pull request Apr 5, 2019
* replacing Angular watch list UI with React one

* fixing TS issues

* addressing PR feedback

* fixing TS issues

* more TS fixes

* TS fix

* addressing more PR feedback

* TS fixes

* removing unused/incompatible translations

* fixing functional test

* prettier fix

* fixing typp

* fixing missing comma

* fixing data-test-subject typo

* fixing functional test

* fixing functional tests

* fixing delete functional tests

* addressing PR feedback

* progress on watch edit

* port advanced watcher to react (#34188)

* port advanced watcher to react

* fix i18n

* update execute trigger override text fields to number input and select fields

* fix page title for edit mode

* remove todo comments

* add license validity check; pass kbnUrl service as prop

* address review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants