From 848936b5dc2f082d0581e75147efbc6e5f5ace46 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Mon, 9 Sep 2019 14:35:14 -0700 Subject: [PATCH] fix(alerts): empty state --- ui/src/alerting/components/CheckCards.tsx | 43 ++++++++++++------ .../components/endpoints/EndpointCards.tsx | 45 ++++++++++++------- .../components/notifications/RuleCards.tsx | 33 +++++++++----- 3 files changed, 80 insertions(+), 41 deletions(-) diff --git a/ui/src/alerting/components/CheckCards.tsx b/ui/src/alerting/components/CheckCards.tsx index 6b30af11b3..663dbf4cc4 100644 --- a/ui/src/alerting/components/CheckCards.tsx +++ b/ui/src/alerting/components/CheckCards.tsx @@ -32,30 +32,32 @@ const CheckCards: FunctionComponent = ({ onCreateCheck, }) => { const cards = cs => cs.map(c => ) - const filteredCards = ( + const body = filtered => ( + + } + > + {cards(filtered)} + + ) + const filteredChecks = ( list={checks} searchKeys={['name']} searchTerm={searchTerm} > - {filtered => cards(filtered)} + {filtered => body(filtered)} ) return ( <> - - - } - > - {filteredCards} - - + {filteredChecks} ) } @@ -63,12 +65,25 @@ const CheckCards: FunctionComponent = ({ interface EmptyProps { showFirstTimeWidget: boolean onCreateCheck: () => void + searchTerm: string } const EmptyChecksList: FunctionComponent = ({ showFirstTimeWidget, onCreateCheck, + searchTerm, }) => { + if (searchTerm) { + return ( + + + + ) + } + if (showFirstTimeWidget) { return ( = ({endpoints, searchTerm}) => { )) - const filteredCards = ( + const body = ( list={endpoints} searchKeys={['name']} searchTerm={searchTerm} > - {filteredEndpoints => cards(filteredEndpoints)} + {filteredEndpoints => ( + } + > + {cards(filteredEndpoints)} + + )} ) + return {body} +} + +const EmptyEndpointList: FC<{searchTerm: string}> = ({searchTerm}) => { + if (searchTerm) { + return ( + + + + ) + } + return ( - - }> - {filteredCards} - - + + + ) } -const EmptyEndpointList: FC = () => ( - - - -) - export default EndpointCards diff --git a/ui/src/alerting/components/notifications/RuleCards.tsx b/ui/src/alerting/components/notifications/RuleCards.tsx index c2298ca250..e8476d8890 100644 --- a/ui/src/alerting/components/notifications/RuleCards.tsx +++ b/ui/src/alerting/components/notifications/RuleCards.tsx @@ -15,7 +15,7 @@ interface Props { searchTerm: string } -const NotificationRuleCards: FC = ({rules}) => { +const NotificationRuleCards: FC = ({rules, searchTerm}) => { const cards = rules => rules.map(nr => ) @@ -23,22 +23,33 @@ const NotificationRuleCards: FC = ({rules}) => { list={rules} searchKeys={['name']} - searchTerm="" + searchTerm={searchTerm} > - {filtered => cards(filtered)} + {filtered => ( + } + > + {cards(filtered)} + + )} ) - return ( - - }> - {filteredCards} - - - ) + return {filteredCards} } -const EmptyNotificationRulesList: FC = () => { +const EmptyNotificationRulesList: FC<{searchTerm: string}> = ({searchTerm}) => { + if (searchTerm) { + return ( + + + + ) + } + return (