diff --git a/public/components/overview/home.tsx b/public/components/overview/home.tsx index 277e593201..7802dbf494 100644 --- a/public/components/overview/home.tsx +++ b/public/components/overview/home.tsx @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { HashRouter, RouteComponentProps, Switch, Route } from 'react-router-dom'; -import { EuiText } from '@elastic/eui'; +import { EuiSelect, EuiText } from '@elastic/eui'; import { i18n } from '@osd/i18n'; import { TraceAnalyticsCoreDeps } from '../trace_analytics/home'; import { ChromeBreadcrumb } from '../../../../../src/core/public'; @@ -112,12 +112,61 @@ configs.map((card) => { export const Home = ({ ..._props }: HomeProps) => { const homepage = coreRefs.contentManagement?.renderPage(HOME_PAGE_ID); + const [ids, setIds] = useState>([]); + const [value, setValue] = useState(''); + const [_, setIsRegistered] = useState(false); + + const onChange = (e: React.ChangeEvent) => { + setValue(e.target.value.toString()); + }; + + useEffect(() => { + coreRefs.savedObjectsClient + ?.find({ + type: 'dashboard', + }) + .then((response) => { + const dashboardIds = response.savedObjects.map((dashboard) => ({ + value: dashboard.id.toString(), + text: dashboard.id.toString(), + })); + setIds(dashboardIds); + setIsRegistered(true); + }) + .catch((response) => { + console.log(response); + }); + }, []); + useEffect(() => { + if (ids.length > 0) { + console.log(ids[0].value); + coreRefs.contentManagement?.registerContentProvider({ + id: '', + getContent: () => ({ + id: 'dashboard_content', + kind: 'dashboard', + order: 1000, + input: { + kind: 'dynamic', + get: () => Promise.resolve(ids[0].value), + }, + }), + getTargetArea: () => HOME_CONTENT_AREAS.DASHBOARD, + }); + } + }, [ids]); return (
+ onChange(e)} + /> {homepage}