From b3401c802c9b3f3cf09e927a0e5589bd028be3ce Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 12 Apr 2024 13:13:28 +0100 Subject: [PATCH] EmptyState: make "message" a required prop (#86029) * make "message" a required prop on EmptyState * run i18n:extract --- .../grafana-ui/src/components/EmptyState/EmptyState.mdx | 6 +++--- .../src/components/EmptyState/EmptyState.story.tsx | 1 + .../grafana-ui/src/components/EmptyState/EmptyState.tsx | 5 ++--- public/locales/en-US/grafana.json | 3 --- public/locales/pseudo-LOCALE/grafana.json | 3 --- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/grafana-ui/src/components/EmptyState/EmptyState.mdx b/packages/grafana-ui/src/components/EmptyState/EmptyState.mdx index e62d0038338..846652136a9 100644 --- a/packages/grafana-ui/src/components/EmptyState/EmptyState.mdx +++ b/packages/grafana-ui/src/components/EmptyState/EmptyState.mdx @@ -11,17 +11,17 @@ Use an empty state to communicate to the user that there is no data to display, Use in place of a results table or list when a search query or filter returns no results. -There are sensible defaults for the image and message, so in most cases you can use it without any additional props. +There are sensible defaults for the image, so in most cases all you need to provide is a message. ```jsx import { EmptyState } from '@grafana/ui'; -; +; ``` ### Providing custom overrides -You can optionally override the message or image, and add additional information or a button (e.g. to clear the search query) +You can optionally override or hide the image, add additional information or a button (e.g. to clear the search query) ```jsx import { Button, EmptyState } from '@grafana/ui'; diff --git a/packages/grafana-ui/src/components/EmptyState/EmptyState.story.tsx b/packages/grafana-ui/src/components/EmptyState/EmptyState.story.tsx index 307cb88332e..d4da9da7cff 100644 --- a/packages/grafana-ui/src/components/EmptyState/EmptyState.story.tsx +++ b/packages/grafana-ui/src/components/EmptyState/EmptyState.story.tsx @@ -28,6 +28,7 @@ export const Basic: StoryFn = (args) => { Basic.args = { children: 'Use this space to add any additional information', + message: 'No results found', variant: 'not-found', }; diff --git a/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx b/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx index 2e5871a5d64..4fa685e2d19 100644 --- a/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx +++ b/packages/grafana-ui/src/components/EmptyState/EmptyState.tsx @@ -1,6 +1,5 @@ import React, { ReactNode } from 'react'; -import { t } from '../../utils/i18n'; import { Box } from '../Layout/Box/Box'; import { Stack } from '../Layout/Stack/Stack'; import { Text } from '../Text/Text'; @@ -20,7 +19,7 @@ interface Props { /** * Message to display to the user */ - message?: string; + message: string; /** * Empty state variant. Possible values are 'search'. */ @@ -31,7 +30,7 @@ export const EmptyState = ({ button, children, image = , - message = t('grafana-ui.empty-state.not-found-message', 'No results found'), + message, hideImage = false, }: React.PropsWithChildren) => { return ( diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 0a041559e94..3374530e214 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -573,9 +573,6 @@ "drawer": { "close": "Close" }, - "empty-state": { - "not-found-message": "No results found" - }, "modal": { "close-tooltip": "Close" }, diff --git a/public/locales/pseudo-LOCALE/grafana.json b/public/locales/pseudo-LOCALE/grafana.json index 3a487595c91..118acb01e10 100644 --- a/public/locales/pseudo-LOCALE/grafana.json +++ b/public/locales/pseudo-LOCALE/grafana.json @@ -573,9 +573,6 @@ "drawer": { "close": "Cľőşę" }, - "empty-state": { - "not-found-message": "Ńő řęşūľŧş ƒőūʼnđ" - }, "modal": { "close-tooltip": "Cľőşę" },