removes unneeded select all checkbox

This commit is contained in:
Alex Corey 2020-07-06 14:27:33 -04:00
parent 79b95883a3
commit bc69406f31
2 changed files with 28 additions and 10 deletions

View File

@ -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 = <ContentLoading />;
} else if (!questions || questions?.length <= 0) {
content = (
<ContentEmpty
title={i18n._(t`No Survey Questions Found`)}
message={i18n._(t`Please add survey questions.`)}
/>
);
} else {
content = (
<DataList aria-label={i18n._(t`Survey List`)}>
@ -163,8 +168,21 @@ function SurveyList({
</AlertModal>
);
}
return (
<>
{(!questions || questions?.length <= 0) && (
<EmptyState variant="full">
<EmptyStateIcon icon={CubesIcon} />
<Title size="lg" headingLevel="h3">
{i18n._(t`No survey questions found.`)}
</Title>
<EmptyStateBody>
{i18n._(t`Please add survey questions.`)}
</EmptyStateBody>
<ToolbarAddButton isDisabled={!canEdit} linkTo={`${match.url}/add`} />
</EmptyState>
)}
<SurveyToolbar
isAllSelected={isAllSelected}
onSelectAll={handleSelectAll}

View File

@ -163,7 +163,7 @@ describe('Survey with no questions', () => {
<SurveyList template={mockJobTemplateData} />
);
});
expect(wrapper.find('ContentEmpty').length).toBe(1);
expect(wrapper.find('EmptyState').length).toBe(1);
expect(wrapper.find('SurveyListItem').length).toBe(0);
});
});