diff --git a/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.scss b/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.scss deleted file mode 100644 index acd9576..0000000 --- a/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.scss +++ /dev/null @@ -1 +0,0 @@ -@import '~@redhat-cloud-services/frontend-components-utilities/styles/variables'; diff --git a/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.test.tsx b/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.test.tsx deleted file mode 100644 index 5bdbd59..0000000 --- a/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.test.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react'; -import { render, screen } from '@testing-library/react'; -import DomainOverview from './DomainOverview'; -import '@testing-library/jest-dom'; -import { Domain } from '../../../../Api'; - -test('expect sample-component to render children', () => { - const location = 'boston'; - const subscription_manager_id = '21ee4400-4bfc-11ee-ada9-482ae3863d30'; - const domain_demo: Domain = { - domain_name: 'mydomain.example', - domain_type: 'rhel-idm', - 'rhel-idm': { - ca_certs: [], - locations: [ - { - name: location, - description: 'cpd located at Boston', - }, - ], - realm_domains: ['mydomain.example'], - realm_name: 'MYDOMAIN.EXAMPLE', - servers: [ - { - location: location, - fqdn: 'server1.mydomain.example', - ca_server: true, - pkinit_server: true, - subscription_manager_id: subscription_manager_id, - hcc_enrollment_server: true, - hcc_update_server: true, - }, - ], - }, - }; - - render(); - expect(screen.getAllByRole('rowgroup')[1].children[0].children[0].textContent).toEqual(location); - expect(screen.getAllByRole('rowgroup')[1].children[0].children[1].textContent).toEqual(subscription_manager_id); -}); diff --git a/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.tsx b/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.tsx deleted file mode 100644 index cae5945..0000000 --- a/src/Routes/WizardPage/Components/DomainOverview/DomainOverview.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import './DomainOverview.scss'; -import { TableComposable, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table'; -import { Fragment, useState } from 'react'; -import React from 'react'; - -import { Domain } from '../../../../Api/api'; - -export interface IColumnType { - key: string; - title: string; - width?: number; - render?: (columnd: IColumnType, item: T) => void; -} - -/** - * This represent the table header displayed for the DomainList. - * @returns The table header for the DomainList component. - */ -const DomainRhelIdmHead: React.FC = () => { - return ( - - - Name - UUID - - - ); -}; - -const DomainRhelIdmBody: React.FC<{ domain: Domain }> = (props) => { - const [domain] = useState(props.domain); - - return ( - - {domain['rhel-idm']?.servers.map((server) => { - return ( - - {server.location} - {server.subscription_manager_id} - - ); - })} - - ); -}; - -export interface DomainProps { - domain: Domain; -} - -export const DomainOverview: React.FC = (props) => { - const [domain] = useState(props.domain); - - return ( - <> - - {domain.domain_type == 'rhel-idm' && ( - <> - - - - )} - - - ); -}; - -export default DomainOverview; diff --git a/src/Routes/WizardPage/Components/PageReview/PageReview.tsx b/src/Routes/WizardPage/Components/PageReview/PageReview.tsx index ca6a794..44eb541 100644 --- a/src/Routes/WizardPage/Components/PageReview/PageReview.tsx +++ b/src/Routes/WizardPage/Components/PageReview/PageReview.tsx @@ -1,21 +1,101 @@ -import React, { useState } from 'react'; +/** + * This library encapsulate the PageReview page for the wizard + * component. + * + * @example + * Basic usage + * ``` + * + * ``` + * + * @packageDocumentation + */ +import React from 'react'; -import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, Switch } from '@patternfly/react-core'; +import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, Title } from '@patternfly/react-core'; import './PageReview.scss'; -import { Domain } from '../../../../Api/api'; -import DomainOverview from '../../Components/DomainOverview/DomainOverview'; +import { Domain, DomainIpaServer } from '../../../../Api/api'; +import { TableComposable, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table'; -const PageReview: React.FC<{ data: Domain }> = (props) => { - const [isHostJoinEnabled, setIsHostJoinEnabled] = React.useState(true); - const [domain] = useState(props.data); +/** + * Encapsulate the table header for the list of + * rhel-idm ipa servers. + * @returns Return the table header render. + * @see {@link PageReviewIpaServers} about the parent component. + */ +const PageReviewIpaServersHead = () => { + return ( + + + Name + UUID + + + ); +}; + +/** + * Represents the propoerties for PageReviewIpaServersBody. + */ +interface PageReviewIpaServersProps { + /** The list of ipa servers associated to the rhel-idm. */ + servers?: DomainIpaServer[]; +} + +/** + * Represents the body which shows the IPA server list. + * @param props Contains the list of servers at `servers`. + * @returns the body for the list of servers to use in the + * `TableComposable` component. + * @see {@link PageReviewIpaServersProps} about the properties. + * @see {@link PageReviewIpa} about the parent component. + */ +const PageReviewIpaServersBody = (props: PageReviewIpaServersProps) => { + return ( + + {props.servers?.map((server) => { + return ( + + {server.fqdn} + {server.subscription_manager_id} + + ); + })} + + ); +}; - const onHostJoinEnabledChange = () => { - setIsHostJoinEnabled(!isHostJoinEnabled); - }; +/** + * Represent the table which list the IPA servers. + * @param props has the `servers` property which contains the + * list of servers that belongs to this rhel-idm domain. + * @returns the composable table with the header and body. + * @see {@link PageReviewIpaServersProps} about the properties. + * @see {@link PageReviewIpa} about the parent component. + */ +const PageReviewIpaServers = (props: PageReviewIpaServersProps) => { + return ( + <> + + + + + + ); +}; +/** + * This component represent the overview information to be + * presented for an rhel-idm domain service. + * @param props the `domain` property expect a 'rhel-idm' type. + * @returns the overview details for a rhel-idm domain service. + * @see {@link PageReviewProps} about the properties. + * @see {@link PageReview} about the parent component. + */ +const PageReviewIpa = (props: PageReviewProps) => { return ( - + <> = (props) => { }} > - Identity and access management solution - {domain.domain_type === 'rhel-idm' &&
RHEL IdM (IPA)
}
+ Service type + RHEL IdM (IPA)
- Name - {domain.title} + Kerberos realm + {props.domain['rhel-idm']?.realm_name} - Description - {domain.description} + Red Hat IdM/IPA servers + + + - DNS Domain/Servers - - {/* TODO Navigator panel */} - 1-3 of 3 v   <   > - + Service name + {props.domain.title} + + + Service description + {props.domain.description} - - Allow host domain join - - + Domain join on launch + + {props.domain.auto_enrollment_enabled ? 'Enable upon finishing registration' : 'Not enable upon finishing registration'}
-
+ + ); +}; + +/** + * Represent the properties for the PageReview component. + */ +interface PageReviewProps { + /** The ephemeral domain information, including the detailed + * information that the user have control about. */ + domain: Domain; +} + +/** + * It represents the Page review wizard, and it provide different view + * depending on the domain_type value. + * @param props provide the `domain` value to be rendered. + * @returns the render view for the domain overview. + * @see {@link PageReviewProps} to know about the properties. + * @see {@link WizardPage} about the parent component. + * @public + */ +const PageReview = (props: PageReviewProps) => { + return ( + <> + + Review + + {props.domain.domain_type === 'rhel-idm' && } + ); }; diff --git a/src/Routes/WizardPage/WizardPage.tsx b/src/Routes/WizardPage/WizardPage.tsx index 781f3f8..2eb48f7 100644 --- a/src/Routes/WizardPage/WizardPage.tsx +++ b/src/Routes/WizardPage/WizardPage.tsx @@ -23,22 +23,6 @@ const PageServiceRegistration = React.lazy(() => import('./Components/PageServic const PageServiceDetails = React.lazy(() => import('./Components/PageServiceDetails/PageServiceDetails')); const PageReview = React.lazy(() => import('./Components/PageReview/PageReview')); -const initialDomain: Domain = { - domain_id: '14f3a7a4-32c5-11ee-b40f-482ae3863d30', - domain_name: 'mydomain.example', - auto_enrollment_enabled: true, - title: 'My Domain', - description: 'My Domain Description', - domain_type: 'rhel-idm', - 'rhel-idm': { - realm_name: '', - realm_domains: [], - ca_certs: [], - servers: [], - locations: [], - }, -}; - /** * Wizard page to register a new domain into the service. * @see {@link PagePreparation} about the preparation page. @@ -110,6 +94,23 @@ const WizardPage = () => { // appContext.wizard.setUUID(''); // } } + if (id === 4) { + try { + if (domain.domain_id) { + const response = await resources_api.updateDomainUser(domain.domain_id, { + title: domain.title, + description: domain.description, + auto_enrollment_enabled: domain.auto_enrollment_enabled, + }); + if (response.status >= 400) { + // TODO show-up notification with error message + } + } + } catch (error) { + // TODO show-up notification with error message + console.log('error noNextPage: ' + error); + } + } }; const initCanJumpPage1 = true; @@ -194,8 +195,8 @@ const WizardPage = () => { { id: 4, name: 'Review', - // FIXME Pass here the 'registering.domain' field from the context - component: , + component: , + nextButtonText: 'Finish', canJumpTo: canJumpPage4, }, ];