/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import React from "react"; import * as H from "history"; import { EuiButton, EuiEmptyPrompt, EuiText } from "@elastic/eui"; import { ModalConsumer } from "../../../../components/Modal"; import CreatePolicyModal from "../../../../components/CreatePolicyModal"; import { ROUTES } from "../../../../utils/constants"; export const TEXT = { RESET_FILTERS: "There are no managed indices matching your applied filters. Reset your filters to view your managed indices.", NO_MANAGED_INDICES: "There are no existing managed indices. Create a policy to add to an index.", LOADING: "Loading managed indices...", }; const getMessagePrompt = ({ filterIsApplied, loading }: ManagedIndexEmptyPromptProps): string => { if (loading) return TEXT.LOADING; if (filterIsApplied) return TEXT.RESET_FILTERS; return TEXT.NO_MANAGED_INDICES; }; const getActions: React.SFC = ({ history, filterIsApplied, loading, resetFilters }) => { if (loading) return null; if (filterIsApplied) { return ( Reset Filters ); } const onClickCreate = (visual: boolean): void => { history.push(`${ROUTES.CREATE_POLICY}${visual ? "?type=visual" : ""}`); }; return ( {({ onShow }) => ( onShow(CreatePolicyModal, { history, onClickContinue: onClickCreate })}> Create policy )} ); }; interface ManagedIndexEmptyPromptProps { filterIsApplied: boolean; loading: boolean; resetFilters: () => void; history: H.History; } const ManagedIndexEmptyPrompt: React.SFC = (props) => (

{getMessagePrompt(props)}

} actions={getActions(props)} /> ); export default ManagedIndexEmptyPrompt;