elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.79k stars 8.19k forks source link

[Discover] Deangularize context_app.html #70211

Closed kertal closed 3 years ago

kertal commented 4 years ago

So the context_app template is entirely occupied by directives using React. Well not entirely ... a small directive of indomitable Angular holds out against React and won't go away until #67259 takes over.

So for further deangularisation the doc-table directive needs to be wrapped in a React component. When this is done, the whole template can be migrated to a single React component clearing the way to migrate the controller and to get rid out the Angular router.

How to proceed

Here's how the React Angular Doc table could look like (in approximately)

export function DocTable({ render, renderProps }: Props) { 
   const render = convertDirectiveToRenderFn({ template: `<doc-table></doc_table>` }, () => getAngularInjector());
   const ref = useRef<HTMLDivElement>(null); 
   useEffect(() => { 
     if (ref && ref.current) { 
       return render(ref.current, renderProps); 
     } 
   }, [render, renderProps]); 
   return <div ref={ref} />; 
 } 

Alternative: Of course you could migrate doc_table directive to React, but this a potential 🐇 hole. Note: Once this is done, we could migrate the next template 🦖, discover.html could be next

majagrubic commented 3 years ago

Closed with 3 PRs above