webpack/scenes/ContentViews/Publish/PublishContentViewWizard.js in katello-4.4.2.2 vs webpack/scenes/ContentViews/Publish/PublishContentViewWizard.js in katello-4.5.0.rc1
- old
+ new
@@ -10,23 +10,23 @@
import CVPublishReview from './CVPublishReview';
import {
selectEnvironmentPaths,
selectEnvironmentPathsStatus,
} from '../components/EnvironmentPaths/EnvironmentPathSelectors';
-import getContentViews from '../ContentViewsActions';
-import getContentViewDetails from '../Details/ContentViewDetailActions';
import { stopPollingTask } from '../../Tasks/TaskActions';
-import { cvVersionPublishKey } from '../ContentViewsConstants';
+import { cvVersionTaskPollingKey } from '../ContentViewsConstants';
const PublishContentViewWizard = ({
- details, show, setIsOpen, currentStep, setCurrentStep,
+ details, show, onClose,
}) => {
const { name, id: cvId, version_count: versionCount } = details;
+ const POLLING_TASK_KEY = cvVersionTaskPollingKey(cvId);
const [description, setDescription] = useState('');
const [userCheckedItems, setUserCheckedItems] = useState([]);
const [promote, setPromote] = useState(false);
const [forcePromote, setForcePromote] = useState([]);
+ const [currentStep, setCurrentStep] = useState(1);
const dispatch = useDispatch();
const environmentPathResponse = useSelector(selectEnvironmentPaths);
const environmentPathStatus = useSelector(selectEnvironmentPathsStatus);
const environmentPathLoading = environmentPathStatus === STATUS.PENDING;
@@ -59,13 +59,12 @@
setUserCheckedItems={setUserCheckedItems}
forcePromote={forcePromote}
cvId={cvId}
versionCount={versionCount}
show={show}
- setIsOpen={setIsOpen}
+ onClose={onClose}
currentStep={currentStep}
- setCurrentStep={setCurrentStep}
/>,
isFinishedStep: true,
},
];
@@ -107,32 +106,27 @@
<Wizard
title={__('Publish')}
description={currentStep === 3 ? __(`Publishing ${name}`) : __(`Determining settings for ${name}`)}
steps={steps}
startAtStep={currentStep}
+ // Let the wizard handle step change
+ onGoToStep={({ id }) => setCurrentStep(id)}
+ onNext={({ id }) => setCurrentStep(id)}
+ onBack={({ id }) => setCurrentStep(id)}
onClose={() => {
- setDescription('');
- setUserCheckedItems([]);
- setPromote(false);
- setForcePromote([]);
if (currentStep === 3) {
- setCurrentStep(1);
- dispatch(getContentViewDetails(cvId));
- dispatch(getContentViews);
- dispatch(stopPollingTask(cvVersionPublishKey(cvId, versionCount)));
- }
- setIsOpen(false);
+ dispatch(stopPollingTask(POLLING_TASK_KEY));
+ onClose(true);
+ } else onClose();
}}
isOpen={show}
/>
);
};
PublishContentViewWizard.propTypes = {
show: PropTypes.bool.isRequired,
- setIsOpen: PropTypes.func.isRequired,
- currentStep: PropTypes.number.isRequired,
- setCurrentStep: PropTypes.func.isRequired,
+ onClose: PropTypes.func.isRequired,
details: PropTypes.shape({
id: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),