/* * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * * Any modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import React, { useState } from 'react'; import ReactDOM from 'react-dom'; import { EuiText, EuiPageContent, EuiCard, EuiPageContentHeader, EuiFieldSearch, EuiListGroup, EuiHighlight, EuiLink, EuiButtonIcon, EuiPage, } from '@elastic/eui'; import { AppMountParameters } from '../../../src/core/public'; import { ExampleDefinition } from './types'; interface Props { examples: ExampleDefinition[]; navigateToApp: (appId: string) => void; getUrlForApp: (appId: string) => string; } function DeveloperExamples({ examples, navigateToApp, getUrlForApp }: Props) { const [search, setSearch] = useState(''); const lcSearch = search.toLowerCase(); const filteredExamples = !lcSearch ? examples : examples.filter((def) => { if (def.description.toLowerCase().indexOf(lcSearch) >= 0) return true; if (def.title.toLowerCase().indexOf(lcSearch) >= 0) return true; return false; }); return (

Developer examples

The following examples showcase services and APIs that are available to developers.

setSearch(e.target.value)} isClearable={true} aria-label="Search developer examples" />
{filteredExamples.map((def) => ( {def.description} } title={ { navigateToApp(def.appId); }} > {def.title} window.open(getUrlForApp(def.appId), '_blank', 'noopener, noreferrer') } > Open in new tab } image={def.image} footer={def.links ? : undefined} titleSize="xs" textAlign="left" /> ))}
); } export const renderApp = (props: Props, element: AppMountParameters['element']) => { ReactDOM.render(, element); return () => ReactDOM.unmountComponentAtNode(element); };