From 7f5efee0dc8afd3509b81174322cb7fbc8bfcf9f Mon Sep 17 00:00:00 2001 From: Alejandro Visiedo Date: Mon, 9 Oct 2023 07:36:31 +0200 Subject: [PATCH] HMS-2584 fix: linter violation Fix linter violation and clean-up a bit the code. Signed-off-by: Alejandro Visiedo --- .../SampleComponent/sample-component.tsx | 2 -- src/Routes/DefaultPage/DefaultPage.tsx | 27 +++++++++---------- .../PagePreparation/PagePreparation.tsx | 24 +++-------------- src/Routes/WizardPage/WizardPage.tsx | 6 ++--- 4 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/Components/SampleComponent/sample-component.tsx b/src/Components/SampleComponent/sample-component.tsx index 2089845..50484a2 100644 --- a/src/Components/SampleComponent/sample-component.tsx +++ b/src/Components/SampleComponent/sample-component.tsx @@ -11,6 +11,4 @@ const SampleComponent: React.FC = (props) => { return {props.children} ; }; -SampleComponent.displayName = 'SampleComponent'; - export default SampleComponent; diff --git a/src/Routes/DefaultPage/DefaultPage.tsx b/src/Routes/DefaultPage/DefaultPage.tsx index a124899..3293fe4 100644 --- a/src/Routes/DefaultPage/DefaultPage.tsx +++ b/src/Routes/DefaultPage/DefaultPage.tsx @@ -29,8 +29,6 @@ import { Domain, ResourcesApiFactory } from '../../Api/api'; import { DomainList } from '../../Components/DomainList/DomainList'; import { AppContext, IAppContext } from '../../AppContext'; -// const SampleComponent = lazy(() => import('../../Components/SampleComponent/sample-component')); - const Header = () => { const linkLearnMoreAbout = 'https://access.redhat.com/articles/1586893'; const title = 'Directory and Domain Services'; @@ -117,6 +115,7 @@ const ListContent = () => { const [perPage, setPerPage] = useState(10); const [offset, setOffset] = useState(0); + // TODO Extract this code in a hook useEffect(() => { // eslint-disable-next-line prefer-const let local_domains: Domain[] = []; @@ -220,8 +219,6 @@ const DefaultPage = () => { const resources_api = ResourcesApiFactory(undefined, base_url, undefined); // States - // const [domains, setDomains] = useState(appContext?.domains); - const [page, setPage] = useState(0); const [itemCount, setItemCount] = useState(0); const [perPage] = useState(10); @@ -229,6 +226,7 @@ const DefaultPage = () => { console.log('INFO:DefaultPage render'); + // TODO Extract in a hook useEffect(() => { // eslint-disable-next-line prefer-const let local_domains: Domain[] = []; @@ -264,21 +262,22 @@ const DefaultPage = () => { }; }, [page, perPage, offset]); - if (/* appContext.domains.length == 0 */ itemCount == 0) { - return ( - <> -
- - - ); - } - - return ( + const listContent = ( <>
); + + const emptyContent = ( + <> +
+ + + ); + + const content = itemCount == 0 ? emptyContent : listContent; + return content; }; export default DefaultPage; diff --git a/src/Routes/WizardPage/Components/PagePreparation/PagePreparation.tsx b/src/Routes/WizardPage/Components/PagePreparation/PagePreparation.tsx index 23461bf..4feeb21 100644 --- a/src/Routes/WizardPage/Components/PagePreparation/PagePreparation.tsx +++ b/src/Routes/WizardPage/Components/PagePreparation/PagePreparation.tsx @@ -1,10 +1,10 @@ -import React, { useContext, useEffect, useState } from 'react'; +import React, { useContext, useEffect } from 'react'; import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon'; import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; -import { Button, ClipboardCopy, Form, FormGroup, Icon, Select, SelectOption, TextContent, Title } from '@patternfly/react-core'; +import { Button, ClipboardCopy, Form, FormGroup, Icon, TextContent, Title } from '@patternfly/react-core'; import './PagePreparation.scss'; -import { DomainType, ResourcesApiFactory } from '../../../../Api'; +import { ResourcesApiFactory } from '../../../../Api'; import { AppContext, IAppContext } from '../../../../AppContext'; /** Represent the properties for PagePreparation component. */ @@ -31,7 +31,6 @@ const PagePreparation = (props: PagePreparationProps) => { const prerequisitesLink = 'https://www.google.com?q=rhel-idm+pre-requisites'; // States - const [isOpen, setIsOpen] = useState(false); const appContext = useContext(AppContext); const base_url = '/api/idmsvc/v1'; @@ -73,23 +72,6 @@ const PagePreparation = (props: PagePreparationProps) => { }); }, [token, domain_id]); - const onRegisterDomainTypeSelect = () => { - // TODO Not implemented, currently only support rhel-idm - console.debug('PagePreparation.onRegisterDomainTypeSelect in WizardPage'); - return; - }; - - const onToggleClick = () => { - setIsOpen(!isOpen); - }; - - const domainOptions = [ - { - value: 'rhel-idm' as DomainType, - title: 'RHEL IdM (IPA)', - }, - ]; - return ( <> Preparation for your directory and domain service diff --git a/src/Routes/WizardPage/WizardPage.tsx b/src/Routes/WizardPage/WizardPage.tsx index 54d9093..e912189 100644 --- a/src/Routes/WizardPage/WizardPage.tsx +++ b/src/Routes/WizardPage/WizardPage.tsx @@ -123,9 +123,7 @@ const WizardPage = () => { const onVerify = (value: VerifyState, data?: Domain) => { appContext.wizard.setRegisteredStatus(value); if (value === 'completed') { - if (data) { - appContext.wizard.setDomain(data); - } + data && appContext.wizard.setDomain(data); setCanJumpPage3(true); } else { setCanJumpPage3(false); @@ -150,7 +148,7 @@ const WizardPage = () => { }; /** Configure the wizard pages. */ - const steps = [ + const steps: WizardStep[] = [ { // This page only display the pre-requisites id: 1,