From bc69406f31b61078b82a1826f2a2bc60f238ceca Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Mon, 6 Jul 2020 14:27:33 -0400 Subject: [PATCH 1/3] removes unneeded select all checkbox --- .../screens/Template/Survey/SurveyList.jsx | 36 ++++++++++++++----- .../Template/Survey/SurveyList.test.jsx | 2 +- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx b/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx index 5d6b738a41..8c296f0c44 100644 --- a/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx +++ b/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx @@ -1,11 +1,21 @@ import React, { useState } from 'react'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; -import { DataList, Button as _Button } from '@patternfly/react-core'; +import { useRouteMatch } from 'react-router-dom'; +import { + DataList, + Button as _Button, + Title, + EmptyState, + EmptyStateIcon, + EmptyStateBody, +} from '@patternfly/react-core'; +import { CubesIcon } from '@patternfly/react-icons'; import styled from 'styled-components'; import ContentLoading from '../../../components/ContentLoading'; -import ContentEmpty from '../../../components/ContentEmpty'; +// import ContentEmpty from '../../../components/ContentEmpty'; import AlertModal from '../../../components/AlertModal'; +import { ToolbarAddButton } from '../../../components/PaginatedDataList'; import SurveyListItem from './SurveyListItem'; import SurveyToolbar from './SurveyToolbar'; @@ -25,6 +35,8 @@ function SurveyList({ canEdit, i18n, }) { + const match = useRouteMatch(); + const questions = survey?.spec || []; const [selected, setSelected] = useState([]); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); @@ -78,13 +90,6 @@ function SurveyList({ let content; if (isLoading) { content = ; - } else if (!questions || questions?.length <= 0) { - content = ( - - ); } else { content = ( @@ -163,8 +168,21 @@ function SurveyList({ ); } + return ( <> + {(!questions || questions?.length <= 0) && ( + + + + {i18n._(t`No survey questions found.`)} + + + {i18n._(t`Please add survey questions.`)} + + + + )} { ); }); - expect(wrapper.find('ContentEmpty').length).toBe(1); + expect(wrapper.find('EmptyState').length).toBe(1); expect(wrapper.find('SurveyListItem').length).toBe(0); }); }); From ad536ec3d94ac2bbfe181774f714c554ad3c2598 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Wed, 8 Jul 2020 09:14:58 -0400 Subject: [PATCH 2/3] Removes commented out line --- awx/ui_next/src/screens/Template/Survey/SurveyList.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx b/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx index 8c296f0c44..a28e6c813c 100644 --- a/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx +++ b/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx @@ -13,7 +13,6 @@ import { import { CubesIcon } from '@patternfly/react-icons'; import styled from 'styled-components'; import ContentLoading from '../../../components/ContentLoading'; -// import ContentEmpty from '../../../components/ContentEmpty'; import AlertModal from '../../../components/AlertModal'; import { ToolbarAddButton } from '../../../components/PaginatedDataList'; From 496862592a98e4b1346fb4036e02276a5cee09e9 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Thu, 16 Jul 2020 12:59:27 -0400 Subject: [PATCH 3/3] fixes erroneous render --- .../screens/Template/Survey/SurveyList.jsx | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx b/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx index a28e6c813c..dd06e0bca9 100644 --- a/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx +++ b/awx/ui_next/src/screens/Template/Survey/SurveyList.jsx @@ -167,21 +167,22 @@ function SurveyList({ ); } - + if (!questions || questions?.length <= 0) { + return ( + + + + {i18n._(t`No survey questions found.`)} + + + {i18n._(t`Please add survey questions.`)} + + + + ); + } return ( <> - {(!questions || questions?.length <= 0) && ( - - - - {i18n._(t`No survey questions found.`)} - - - {i18n._(t`Please add survey questions.`)} - - - - )}