Skip to content

Commit

Permalink
HMS-2584 fix: linter violation
Browse files Browse the repository at this point in the history
Fix linter violation and clean-up a bit the code.

Signed-off-by: Alejandro Visiedo <[email protected]>
  • Loading branch information
avisiedo committed Oct 9, 2023
1 parent 5f234d3 commit 7f5efee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 41 deletions.
2 changes: 0 additions & 2 deletions src/Components/SampleComponent/sample-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ const SampleComponent: React.FC = (props) => {
return <span className="sample-component"> {props.children} </span>;
};

SampleComponent.displayName = 'SampleComponent';

export default SampleComponent;
27 changes: 13 additions & 14 deletions src/Routes/DefaultPage/DefaultPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -117,6 +115,7 @@ const ListContent = () => {
const [perPage, setPerPage] = useState<number>(10);
const [offset, setOffset] = useState<number>(0);

// TODO Extract this code in a hook
useEffect(() => {
// eslint-disable-next-line prefer-const
let local_domains: Domain[] = [];
Expand Down Expand Up @@ -220,15 +219,14 @@ const DefaultPage = () => {
const resources_api = ResourcesApiFactory(undefined, base_url, undefined);

// States
// const [domains, setDomains] = useState<Domain[]>(appContext?.domains);

const [page, setPage] = useState<number>(0);
const [itemCount, setItemCount] = useState<number>(0);
const [perPage] = useState<number>(10);
const [offset, setOffset] = useState<number>(0);

console.log('INFO:DefaultPage render');

// TODO Extract in a hook
useEffect(() => {
// eslint-disable-next-line prefer-const
let local_domains: Domain[] = [];
Expand Down Expand Up @@ -264,21 +262,22 @@ const DefaultPage = () => {
};
}, [page, perPage, offset]);

if (/* appContext.domains.length == 0 */ itemCount == 0) {
return (
<>
<Header />
<EmptyContent />
</>
);
}

return (
const listContent = (
<>
<Header />
<ListContent />
</>
);

const emptyContent = (
<>
<Header />
<EmptyContent />
</>
);

const content = itemCount == 0 ? emptyContent : listContent;
return content;
};

export default DefaultPage;
Original file line number Diff line number Diff line change
@@ -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. */
Expand All @@ -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<IAppContext>(AppContext);

const base_url = '/api/idmsvc/v1';
Expand Down Expand Up @@ -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 (
<>
<Title headingLevel={'h2'}>Preparation for your directory and domain service</Title>
Expand Down
6 changes: 2 additions & 4 deletions src/Routes/WizardPage/WizardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -150,7 +148,7 @@ const WizardPage = () => {
};

/** Configure the wizard pages. */
const steps = [
const steps: WizardStep[] = [
{
// This page only display the pre-requisites
id: 1,
Expand Down

0 comments on commit 7f5efee

Please sign in to comment.