From d0d48a40049476174aef45975e3bb3b3b4ec821c Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Tue, 23 Jul 2024 14:50:17 +0000 Subject: [PATCH] Fixes #37677 - Extract RemWizard footer in a separate component --- .../OpenscapRemediationWizard/Footer.js | 54 +++++++++++++++++++ .../OpenscapRemediationWizard/constants.js | 9 ++++ .../OpenscapRemediationWizard/index.js | 16 ++++-- 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 webpack/components/OpenscapRemediationWizard/Footer.js diff --git a/webpack/components/OpenscapRemediationWizard/Footer.js b/webpack/components/OpenscapRemediationWizard/Footer.js new file mode 100644 index 00000000..870b3dcf --- /dev/null +++ b/webpack/components/OpenscapRemediationWizard/Footer.js @@ -0,0 +1,54 @@ +import React from 'react'; +import { + Button, + WizardFooter, + WizardContextConsumer, +} from '@patternfly/react-core'; +import { translate as __ } from 'foremanReact/common/I18n'; +import { WIZARD_TITLES } from './constants'; + +export const Footer = () => ( + + + {({ activeStep, onNext, onBack, onClose, goToStepByName }) => { + const isValid = + activeStep && activeStep.enableNext !== undefined + ? activeStep.enableNext + : true; + + return ( + <> + {!activeStep.isFinishedStep ? ( + + ) : null} + + + + ); + }} + + +); diff --git a/webpack/components/OpenscapRemediationWizard/constants.js b/webpack/components/OpenscapRemediationWizard/constants.js index 7f3e4ddb..b8f745bd 100644 --- a/webpack/components/OpenscapRemediationWizard/constants.js +++ b/webpack/components/OpenscapRemediationWizard/constants.js @@ -1,3 +1,5 @@ +import { translate as __ } from 'foremanReact/common/I18n'; + export const OPENSCAP_REMEDIATION_MODAL_ID = 'openscapRemediationModal'; export const HOSTS_PATH = '/hosts'; export const FAIL_RULE_SEARCH = 'fails_xccdf_rule'; @@ -12,3 +14,10 @@ export const JOB_INVOCATION_API_REQUEST_KEY = 'OPENSCAP_REX_JOB_INVOCATIONS'; export const SNIPPET_SH = 'urn:xccdf:fix:script:sh'; export const SNIPPET_ANSIBLE = 'urn:xccdf:fix:script:ansible'; + +export const WIZARD_TITLES = { + snippetSelect: __('Select snippet'), + reviewHosts: __('Review hosts'), + reviewRemediation: __('Review remediation'), + finish: __('Done'), +}; diff --git a/webpack/components/OpenscapRemediationWizard/index.js b/webpack/components/OpenscapRemediationWizard/index.js index d12d61aa..577c4530 100644 --- a/webpack/components/OpenscapRemediationWizard/index.js +++ b/webpack/components/OpenscapRemediationWizard/index.js @@ -7,12 +7,17 @@ import { sprintf, translate as __ } from 'foremanReact/common/I18n'; import { API_OPERATIONS, get } from 'foremanReact/redux/API'; import OpenscapRemediationWizardContext from './OpenscapRemediationWizardContext'; +import { Footer } from './Footer'; import { selectLogResponse, selectLogError, selectLogStatus, } from './OpenscapRemediationSelectors'; -import { REPORT_LOG_REQUEST_KEY, FAIL_RULE_SEARCH } from './constants'; +import { + REPORT_LOG_REQUEST_KEY, + FAIL_RULE_SEARCH, + WIZARD_TITLES, +} from './constants'; import { SnippetSelect, ReviewHosts, ReviewRemediation, Finish } from './steps'; const OpenscapRemediationWizard = ({ @@ -66,7 +71,7 @@ const OpenscapRemediationWizard = ({ const reviewHostsStep = { id: 2, - name: __('Review hosts'), + name: WIZARD_TITLES.reviewHosts, component: , canJumpTo: Boolean(snippet && method === 'job'), enableNext: Boolean(snippet && method), @@ -74,7 +79,7 @@ const OpenscapRemediationWizard = ({ const steps = [ { id: 1, - name: __('Select snippet'), + name: WIZARD_TITLES.snippetSelect, component: , canJumpTo: true, enableNext: Boolean(snippet && method), @@ -82,7 +87,7 @@ const OpenscapRemediationWizard = ({ ...(snippet && method === 'job' ? [reviewHostsStep] : []), { id: 3, - name: __('Review remediation'), + name: WIZARD_TITLES.reviewRemediation, component: , canJumpTo: Boolean(snippet && method), enableNext: method === 'job', @@ -90,7 +95,7 @@ const OpenscapRemediationWizard = ({ }, { id: 4, - name: __('Done'), + name: WIZARD_TITLES.finish, component: , isFinishedStep: true, }, @@ -128,6 +133,7 @@ const OpenscapRemediationWizard = ({ isOpen={isRemediationWizardOpen} steps={steps} onClose={onWizardClose} + footer={