From 3a776ccbff37bd33d0166abba7f17b20bfcb5db0 Mon Sep 17 00:00:00 2001 From: nixocio Date: Thu, 23 Sep 2021 08:46:18 -0400 Subject: [PATCH] Update empty survey list Update empty survey list to be as the remaining lists. See: https://github.com/ansible/awx/issues/10942 --- .../src/screens/Template/Survey/SurveyList.js | 43 +++++++------------ .../screens/Template/Survey/SurveyToolbar.js | 25 ++++++----- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/awx/ui/src/screens/Template/Survey/SurveyList.js b/awx/ui/src/screens/Template/Survey/SurveyList.js index 924ea2e8ec..7be6ae6277 100644 --- a/awx/ui/src/screens/Template/Survey/SurveyList.js +++ b/awx/ui/src/screens/Template/Survey/SurveyList.js @@ -1,19 +1,11 @@ import React, { useState } from 'react'; import { t } from '@lingui/macro'; -import { useRouteMatch } from 'react-router-dom'; -import { - Button, - Title, - EmptyState, - EmptyStateIcon, - EmptyStateBody, -} from '@patternfly/react-core'; +import { Button } from '@patternfly/react-core'; import { TableComposable, Thead, Tr, Th, Tbody } from '@patternfly/react-table'; -import { CubesIcon } from '@patternfly/react-icons'; -import ContentLoading from 'components/ContentLoading'; import AlertModal from 'components/AlertModal'; -import { ToolbarAddButton } from 'components/PaginatedTable'; +import ContentEmpty from 'components/ContentEmpty'; +import ContentLoading from 'components/ContentLoading'; import useSelected from 'hooks/useSelected'; import SurveyListItem from './SurveyListItem'; @@ -29,8 +21,6 @@ function SurveyList({ deleteSurvey, canEdit, }) { - const match = useRouteMatch(); - const questions = survey?.spec || []; const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [isOrderModalOpen, setIsOrderModalOpen] = useState(false); @@ -109,10 +99,10 @@ function SurveyList({ - {t`Name`} - {t`Type`} - {t`Default`} - {t`Actions`} + {t`Name`} + {t`Type`} + {t`Default`} + {t`Actions`} @@ -148,16 +138,14 @@ function SurveyList({ ); } - if ((!questions || questions?.length <= 0) && !isLoading) { - return ( - - - - {t`No survey questions found.`} - - {t`Please add survey questions.`} - - + const emptyList = !questions || questions?.length <= 0; + + if (emptyList && !isLoading) { + content = ( + ); } return ( @@ -175,6 +163,7 @@ function SurveyList({ onToggleSurvey={toggleSurvey} isDeleteDisabled={selected?.length === 0} canEdit={canEdit} + emptyList={emptyList} onToggleDeleteModal={() => setIsDeleteModalOpen(true)} /> {content} diff --git a/awx/ui/src/screens/Template/Survey/SurveyToolbar.js b/awx/ui/src/screens/Template/Survey/SurveyToolbar.js index 5d4860e768..d2ba2a91d1 100644 --- a/awx/ui/src/screens/Template/Survey/SurveyToolbar.js +++ b/awx/ui/src/screens/Template/Survey/SurveyToolbar.js @@ -32,6 +32,7 @@ function SurveyToolbar({ isDeleteDisabled, onToggleDeleteModal, onOpenOrderModal, + emptyList, }) { isDeleteDisabled = !canEdit || isDeleteDisabled; const match = useRouteMatch(); @@ -94,17 +95,19 @@ function SurveyToolbar({ - - onToggleSurvey(!surveyEnabled)} - /> - + {!emptyList && ( + + onToggleSurvey(!surveyEnabled)} + /> + + )} );