/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the "Elastic License * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side * Public License v 1"; you may not use this file except in compliance with, at * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ import { EuiPage, EuiPageBody, EuiPageHeader, EuiPageSection, EuiPageTemplate, EuiSpacer, EuiTab, EuiTabs, } from '@elastic/eui'; import React, { useState } from 'react'; import ReactDOM from 'react-dom'; import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { AppMountParameters, CoreStart } from '@kbn/core/public'; import { ControlsExampleStartDeps } from '../plugin'; import { ControlGroupRendererExamples } from './control_group_renderer_examples'; import { ReactControlExample } from './react_control_example/react_control_example'; const CONTROLS_AS_A_BUILDING_BLOCK = 'controls_as_a_building_block'; const CONTROLS_REFACTOR_TEST = 'controls_refactor_test'; const App = ({ core, data, navigation, }: { core: CoreStart } & Pick) => { const [selectedTabId, setSelectedTabId] = useState(CONTROLS_REFACTOR_TEST); // TODO: Make this the first tab function onSelectedTabChanged(tabId: string) { setSelectedTabId(tabId); } function renderTabContent() { if (selectedTabId === CONTROLS_REFACTOR_TEST) { return ; } return ; } return ( onSelectedTabChanged(CONTROLS_REFACTOR_TEST)} isSelected={CONTROLS_REFACTOR_TEST === selectedTabId} > Register a new React control onSelectedTabChanged(CONTROLS_AS_A_BUILDING_BLOCK)} isSelected={CONTROLS_AS_A_BUILDING_BLOCK === selectedTabId} > Controls as a building block {renderTabContent()} ); }; export const renderApp = ( core: CoreStart, { data, navigation }: Pick, { element }: AppMountParameters ) => { ReactDOM.render(, element); return () => ReactDOM.unmountComponentAtNode(element); };