You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by kg...@apache.org on 2022/05/31 12:30:22 UTC

[superset] branch master updated: feat(explore): Add empty state to annotations (#20160)

This is an automated email from the ASF dual-hosted git repository.

kgabryje pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ee1f492a7 feat(explore): Add empty state to annotations (#20160)
0ee1f492a7 is described below

commit 0ee1f492a799f339e1adf3b260a95ff541c331de
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Tue May 31 14:30:06 2022 +0200

    feat(explore): Add empty state to annotations (#20160)
    
    * feat(explore): Add empty state to annotations
    
    * Set line height for small empty state description
    
    * Simplify code
---
 .../src/components/EmptyState/index.tsx            |  1 +
 .../AnnotationLayerControl/AnnotationLayer.jsx     | 35 +++++++++++++++++++++-
 .../explore/components/controls/SelectControl.jsx  |  3 ++
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/components/EmptyState/index.tsx b/superset-frontend/src/components/EmptyState/index.tsx
index 7ba54567e4..7ee69d7eea 100644
--- a/superset-frontend/src/components/EmptyState/index.tsx
+++ b/superset-frontend/src/components/EmptyState/index.tsx
@@ -106,6 +106,7 @@ const BigDescription = styled(Description)`
 const SmallDescription = styled(Description)`
   ${({ theme }) => css`
     margin-top: ${theme.gridUnit}px;
+    line-height: 1.2;
   `}
 `;
 
diff --git a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx
index 973fabaccf..8df36c1291 100644
--- a/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx
+++ b/superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx
@@ -27,6 +27,7 @@ import {
   getChartMetadataRegistry,
   validateNonEmpty,
   isValidExpression,
+  styled,
   withTheme,
 } from '@superset-ui/core';
 
@@ -43,6 +44,7 @@ import {
 } from 'src/modules/AnnotationTypes';
 import PopoverSection from 'src/components/PopoverSection';
 import ControlHeader from 'src/explore/components/ControlHeader';
+import { EmptyStateSmall } from 'src/components/EmptyState';
 
 const AUTOMATIC_COLOR = '';
 
@@ -98,6 +100,35 @@ const defaultProps = {
   close: () => {},
 };
 
+const NotFoundContentWrapper = styled.div`
+  && > div:first-child {
+    padding-left: 0;
+    padding-right: 0;
+  }
+`;
+
+const NotFoundContent = () => (
+  <NotFoundContentWrapper>
+    <EmptyStateSmall
+      title={t('No annotation layers')}
+      description={
+        <span>
+          {t('Add an annotation layer')}{' '}
+          <a
+            href="/annotationlayermodelview/list"
+            target="_blank"
+            rel="noopener noreferrer"
+          >
+            {t('here')}
+          </a>
+          .
+        </span>
+      }
+      image="empty.svg"
+    />
+  </NotFoundContentWrapper>
+);
+
 class AnnotationLayer extends React.PureComponent {
   constructor(props) {
     super(props);
@@ -416,6 +447,7 @@ class AnnotationLayer extends React.PureComponent {
           onChange={this.handleValue}
           validationErrors={!value ? ['Mandatory'] : []}
           optionRenderer={this.renderOption}
+          notFoundContent={<NotFoundContent />}
         />
       );
     }
@@ -760,9 +792,10 @@ class AnnotationLayer extends React.PureComponent {
                   ariaLabel={t('Annotation source type')}
                   hovered
                   description={t('Choose the source of your annotations')}
-                  label={t('Annotation Source')}
+                  label={t('Annotation source')}
                   name="annotation-source-type"
                   options={supportedSourceTypes}
+                  notFoundContent={<NotFoundContent />}
                   value={sourceType}
                   onChange={this.handleAnnotationSourceType}
                   validationErrors={!sourceType ? [t('Mandatory')] : []}
diff --git a/superset-frontend/src/explore/components/controls/SelectControl.jsx b/superset-frontend/src/explore/components/controls/SelectControl.jsx
index 53b7440cb4..59141458a4 100644
--- a/superset-frontend/src/explore/components/controls/SelectControl.jsx
+++ b/superset-frontend/src/explore/components/controls/SelectControl.jsx
@@ -53,6 +53,7 @@ const propTypes = {
   placeholder: PropTypes.string,
   filterOption: PropTypes.func,
   tokenSeparators: PropTypes.arrayOf(PropTypes.string),
+  notFoundContent: PropTypes.object,
 
   // ControlHeader props
   label: PropTypes.string,
@@ -179,6 +180,7 @@ export default class SelectControl extends React.PureComponent {
       showHeader,
       value,
       tokenSeparators,
+      notFoundContent,
       // ControlHeader props
       description,
       renderTrigger,
@@ -245,6 +247,7 @@ export default class SelectControl extends React.PureComponent {
       sortComparator: this.props.sortComparator,
       value: getValue(),
       tokenSeparators,
+      notFoundContent,
     };
 
     return (