From 9a644e075203bbdd020f3947a5f6189910f590ca Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Fri, 19 Jul 2024 14:10:03 +0530 Subject: [PATCH 01/23] First commit Signed-off-by: Sakshi Bobade --- src/renderer/components/Home.tsx | 11 +++++--- src/renderer/components/common/Stepper.tsx | 23 +++++++++------ .../stages/connection/Connection.tsx | 11 ++++++-- .../stages/installation/installationSlice.ts | 8 +++++- .../stages/progress/StageProgressStatus.ts | 27 ++++++++++++++++++ .../stages/progress/progressConst.ts | 28 +++++++++++++++++++ 6 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 src/renderer/components/stages/progress/progressConst.ts diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 1499e9ca..35172cb1 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -28,7 +28,7 @@ import Wizard from './configuration-wizard/Wizard' import { ActiveState } from '../../types/stateInterfaces'; import { getInstallationArguments, getPreviousInstallation } from './stages/progress/StageProgressStatus'; import { DEF_NO_OUTPUT, FALLBACK_SCHEMA, FALLBACK_YAML } from './common/Utils'; -import { selectInstallationArgs, setInstallationArgs, installationSlice } from './stages/installation/installationSlice'; +import { selectInstallationArgs, setInstallationArgs, installationSlice, setIsNewerInstallation } from './stages/installation/installationSlice'; import PasswordDialog from './common/passwordDialog'; // REVIEW: Get rid of routing @@ -88,10 +88,12 @@ const Home = () => { const makeCard = (card: ICard) => { const {id, name, description, link, media} = card; - + const handleClick = () => { let newInstallationArgs = installationSlice.getInitialState().installationArgs; if (id === "install") { + dispatch(setIsNewerInstallation(true)); + setIsNewInstallation(true); newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; } else if (id === "dry run") { newInstallationArgs = {...newInstallationArgs, dryRunMode: true}; @@ -216,6 +218,7 @@ const Home = () => { const resumeProgress = () => { setShowWizard(true); dispatch(setResumeProgress(true)); + dispatch(setIsNewerInstallation(false)); if(connectionStatus) { setShowPasswordDialog(true); @@ -268,8 +271,8 @@ const Home = () => { {showWizard && <> {showPasswordDialog && } - {(showPasswordDialog && updatedConnection) && } - {!showPasswordDialog && } + {(showPasswordDialog && updatedConnection) && } + {!showPasswordDialog && } } diff --git a/src/renderer/components/common/Stepper.tsx b/src/renderer/components/common/Stepper.tsx index 0b345870..57e1349d 100644 --- a/src/renderer/components/common/Stepper.tsx +++ b/src/renderer/components/common/Stepper.tsx @@ -17,7 +17,7 @@ import StepLabel from '@mui/material/StepLabel'; import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; import { Link } from 'react-router-dom'; -import { selectConnectionStatus } from '../stages/progress/progressSlice'; +import { selectConnectionStatus, setConnectionStatus } from '../stages/progress/progressSlice'; import { useAppDispatch, useAppSelector } from '../../hooks'; import { selectNextStepEnabled, setLoading, setYaml } from '../configuration-wizard/wizardSlice'; import { selectActiveStepIndex, selectActiveSubStepIndex } from '../stages/progress/activeStepSlice'; @@ -29,13 +29,13 @@ import Warning from '@mui/icons-material/Warning'; import CheckCircle from '@mui/icons-material/CheckCircle'; import { TYPE_YAML, TYPE_OUTPUT, TYPE_JCL, INIT_STAGE_LABEL, REVIEW_INSTALL_STAGE_LABEL, UNPAX_STAGE_LABEL } from '../common/Utils'; import { getProgress, getCompleteProgress, mapAndSetSkipStatus, mapAndGetSkipStatus } from '../stages/progress/StageProgressStatus'; - +import {initProgressStatus} from '../stages/progress/progressConst'; import '../../styles/Stepper.css'; import { StepIcon } from '@mui/material'; import { getStageDetails } from '../../../services/StageDetails'; import { IResponse } from '../../../types/interfaces'; import { selectConnectionArgs, setPassword } from '../stages/connection/connectionSlice'; -import { selectInstallationArgs } from '../stages/installation/installationSlice'; +import { selectInstallationArgs, selectIsNewInstallation } from '../stages/installation/installationSlice'; // TODO: define props, stages, stage interfaces // TODO: One rule in the store to enable/disable button @@ -46,8 +46,14 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages const INIT_STAGE_ID = getStageDetails(INIT_STAGE_LABEL).id; const REVIEW_STAGE_ID = getStageDetails(REVIEW_INSTALL_STAGE_LABEL).id; - const completeProgress = getCompleteProgress(); + const isNewInstallation = useAppSelector(selectIsNewInstallation); + + let completeProgress = {...initProgressStatus}; + if(!isNewInstallation) { + completeProgress = getCompleteProgress(); + } + const stageProgressStatus = [ useSelector(selectConnectionStatus), completeProgress.planningStatus, @@ -66,11 +72,9 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages completeProgress.certificateStatus, completeProgress.launchConfigStatus ]) - - - const [activeStep, setActiveStep] = initialization ? useState(0) : useState(useAppSelector(selectActiveStepIndex)); - const [activeSubStep, setActiveSubStep] = initialization ? useState(0) : useState(useAppSelector(selectActiveSubStepIndex)); + const [activeStep, setActiveStep] = isNewInstallation ? useState(0) : useState(useAppSelector(selectActiveStepIndex)); + const [activeSubStep, setActiveSubStep] = isNewInstallation ? useState(0) : useState(useAppSelector(selectActiveSubStepIndex)); const [nextText, setNextText] = useState("Continue"); const [contentType, setContentType] = useState('output'); const [editorVisible, setEditorVisible] = useState(false); @@ -239,9 +243,10 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages alertEmitter.emit('hideAlert'); eventDispatcher.emit('saveAndCloseEvent'); dispatch(setPassword('')); + dispatch(setConnectionStatus(false)); // TODO: This is a workaround for same session + Save & Close + new install not resetting the Wizard properly. // Fixed by reloading page. This is not ideal and should be investigated - window.location.reload(); + // window.location.reload(); } const isNextStepEnabled = useAppSelector(selectNextStepEnabled); diff --git a/src/renderer/components/stages/connection/Connection.tsx b/src/renderer/components/stages/connection/Connection.tsx index f1d7dbd6..b4d875e5 100644 --- a/src/renderer/components/stages/connection/Connection.tsx +++ b/src/renderer/components/stages/connection/Connection.tsx @@ -33,10 +33,10 @@ import { setConnectionStatus, selectConnectionStatus} from '../progress/progres import { Container } from "@mui/material"; import { alertEmitter } from "../../Header"; import { getStageDetails, initStageSkipStatus } from "../../../../services/StageDetails"; -import { initializeProgress, getActiveStage, } from "../progress/StageProgressStatus"; +import { initializeProgress, getActiveStage, resetProgress } from "../progress/StageProgressStatus"; import eventDispatcher from "../../../../services/eventDispatcher"; import { setLocationValidationDetails } from "../PlanningSlice"; -import { selectInstallationArgs } from "../installation/installationSlice"; +import { selectInstallationArgs, selectIsNewInstallation } from "../installation/installationSlice"; const Connection = () => { @@ -125,6 +125,7 @@ const FTPConnectionForm = () => { const [isFtpConnection, setIsFtpConnection] = useState(useAppSelector(selectConnectionSecure)); const [isAllCertificatesAccepted, setIsAllCertificatesAccepted] = useState(useAppSelector(selectAcceptAllCertificates)); + const [isNewInstallation, setIsNewInstallation] = useState(useAppSelector(selectIsNewInstallation)); const [formProcessed, toggleFormProcessed] = React.useState(false); const [validationDetails, setValidationDetails] = React.useState(''); @@ -132,6 +133,12 @@ const FTPConnectionForm = () => { const installationArgs = useAppSelector(selectInstallationArgs); + useEffect(() => { + if(isNewInstallation) { + resetProgress(connectionArgs.host, connectionArgs.user); + } + }, []); + const handleFormChange = (ftpConnection?:boolean, acceptCerts?:boolean) => { dispatch(setConnectionStatus(false)); dispatch(setNextStepEnabled(false)); diff --git a/src/renderer/components/stages/installation/installationSlice.ts b/src/renderer/components/stages/installation/installationSlice.ts index 872c74b7..3d05f99c 100644 --- a/src/renderer/components/stages/installation/installationSlice.ts +++ b/src/renderer/components/stages/installation/installationSlice.ts @@ -17,6 +17,7 @@ interface InstallationState { installationArgs: InstallationArgs; zoweVersion: string; licenseAgreement: boolean; + isNewInstallation?: boolean; } const initialState: InstallationState = { @@ -42,6 +43,7 @@ const initialState: InstallationState = { }, zoweVersion: '', licenseAgreement: getInstallationTypeStatus()?.licenseAgreement || false, + isNewInstallation: false, }; export const installationSlice = createSlice({ @@ -67,14 +69,18 @@ export const installationSlice = createSlice({ state.licenseAgreement = action.payload; setInstallationTypeStatus('licenseAgreement', action.payload) }, + setIsNewerInstallation: (state, action: PayloadAction) => { + state.isNewInstallation = action.payload; + } } }); -export const { setInstallationArgs, setZoweVersion, setInstallationType, setLicenseAgreement, setUserUploadedPaxPath} = installationSlice.actions; +export const { setInstallationArgs, setZoweVersion, setInstallationType, setLicenseAgreement, setUserUploadedPaxPath, setIsNewerInstallation} = installationSlice.actions; export const selectInstallationArgs = (state: RootState) => state.installation.installationArgs; export const selectZoweVersion = (state: RootState) => state.installation.zoweVersion; export const selectInstallationType = (state: RootState) => state.installation.installationArgs.installationType; export const selectLicenseAgreement = (state: RootState) => state.installation.licenseAgreement; +export const selectIsNewInstallation = (state: RootState) => state.installation.isNewInstallation; export default installationSlice.reducer; diff --git a/src/renderer/components/stages/progress/StageProgressStatus.ts b/src/renderer/components/stages/progress/StageProgressStatus.ts index 592460c4..c976245e 100644 --- a/src/renderer/components/stages/progress/StageProgressStatus.ts +++ b/src/renderer/components/stages/progress/StageProgressStatus.ts @@ -147,9 +147,20 @@ let prevInstallationKey = `prev_installation`; let skipStateKey = `skip_state`; let installationArgsKey = `intallation_args`; +let isNewInstallation = false; + let skipKeysArray: (keyof SkipState)[] = Object.keys(stepSkipStatus) as (keyof SkipState)[]; +const setNewInstallation = (isNewerInstallation: boolean) => { + +} + const setKeys = (id: string) => { + + if (progressStateKey.endsWith(`_${id}`)) { + return; + } + progressStateKey = `${progressStateKey}_${id}`; activeStateKey = `${activeStateKey}_${id}`; planningStateKey = `${planningStateKey}_${id}`; @@ -166,6 +177,22 @@ const setKeys = (id: string) => { installationArgsKey = `${installationArgsKey}_${id}`; } +export const resetProgress = (host: string, user: string,) => { + if(host && user) { + const id = `${host}_${user}`; + setKeys(id); + } + + const keysArray = [progressStateKey, activeStateKey, planningStateKey, installationTypeKey, downloadUnpaxKey, datasetInstallationKey, apfAuthKey, securityKey, stcsKey, certificateKey, vsamKey, planningValidationDetailsKey, prevInstallationKey, skipStateKey, installationArgsKey]; + console.log('keysArray: ', keysArray); + keysArray.forEach(key => { + if(localStorage.getItem(key) !== null) { + console.log('removing key: ', key); + localStorage.removeItem(key); + } + }) +} + export const initializeProgress = (host: string, user: string, isResume: boolean) => { const id = `${host}_${user}`; setKeys(id); diff --git a/src/renderer/components/stages/progress/progressConst.ts b/src/renderer/components/stages/progress/progressConst.ts new file mode 100644 index 00000000..e31357db --- /dev/null +++ b/src/renderer/components/stages/progress/progressConst.ts @@ -0,0 +1,28 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + */ + +import { ProgressState } from "../../../../types/stateInterfaces"; + +export const initProgressStatus: ProgressState = { + connectionStatus: false, + planningStatus: false, + installationTypeStatus: false, + downloadUnpaxStatus: false, + initializationStatus: false, + datasetInstallationStatus: false, + networkingStatus: false, + apfAuthStatus: false, + securityStatus: false, + stcsStatus: false, + certificateStatus: false, + vsamStatus: false, + launchConfigStatus: false, + reviewStatus: false, + } \ No newline at end of file From 0bb238d9637039e4d0a9d9f88d1cd36482c2e2f0 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Fri, 19 Jul 2024 14:57:26 +0530 Subject: [PATCH 02/23] Some code cleanup Signed-off-by: Sakshi Bobade --- .../stages/progress/StageProgressStatus.ts | 139 ++---------------- .../stages/progress/progressConst.ts | 135 +++++++++++++++-- 2 files changed, 134 insertions(+), 140 deletions(-) diff --git a/src/renderer/components/stages/progress/StageProgressStatus.ts b/src/renderer/components/stages/progress/StageProgressStatus.ts index c976245e..5042f06c 100644 --- a/src/renderer/components/stages/progress/StageProgressStatus.ts +++ b/src/renderer/components/stages/progress/StageProgressStatus.ts @@ -10,126 +10,23 @@ import { flatten, unflatten } from 'flat'; import { ProgressState, PlanningState, InstallationType, ActiveState, DatasetInstallationState, InitSubStepsState, CertInitSubStepsState, PlanningValidationDetails, SkipState, InstallationArgs, DownloadUnpaxState} from '../../../../types/stateInterfaces'; +import { initProgressStatus, initInstallationTypeStatus, initDownloadUnpaxStatus, initActiveStatus, initPlanningStageStatus, initDatasetInstallationStatus, initApfAuthStatus, initSecurityInitStatus, initStcsInitStatus, initCertificateInitStatus, initVsamInitStatus, initPlanningValidationDetailsStatus, initStepSkipStatus, initInstallationArgsStatus } from './progressConst'; import { stages } from '../../configuration-wizard/Wizard'; -const installationTypeStatus: InstallationType = { - installationType: 'download', - licenseAgreement: false, - userUploadedPaxPath: '', -} - -export const downloadUnpaxStatus: DownloadUnpaxState = { - uploadYaml: false, - download: false, - upload: false, - unpax: false, - getExampleYaml: false, - getSchemas: false, -} - -const progressStatus: ProgressState = { - connectionStatus: false, - planningStatus: false, - installationTypeStatus: false, - downloadUnpaxStatus: false, - initializationStatus: false, - datasetInstallationStatus: false, - networkingStatus: false, - apfAuthStatus: false, - securityStatus: false, - stcsStatus: false, - certificateStatus: false, - vsamStatus: false, - launchConfigStatus: false, - reviewStatus: false, -} - -const activeStatus: ActiveState = { - activeStepIndex: 0, - isSubStep: false, - activeSubStepIndex: 0, -}; - -const planningStageStatus: PlanningState = { - jobStatement: '', - isJobStatementValid: false, - isLocationValid: false, -} - -export const datasetInstallationStatus: DatasetInstallationState = { - uploadYaml: false, - install: false, - initMVS: false -} - -const apfAuthStatus: InitSubStepsState = { - writeYaml: false, - uploadYaml: false, - success: false -} - -const securityInitStatus: InitSubStepsState = { - writeYaml: false, - uploadYaml: false, - success: false -} - -const stcsInitStatus: InitSubStepsState = { - writeYaml: false, - uploadYaml: false, - success: false -} - -const certificateInitStatus: CertInitSubStepsState = { - writeYaml: false, - uploadYaml: false, - zweInitCertificate: false -} - -const vsamInitStatus: InitSubStepsState = { - writeYaml: false, - uploadYaml: false, - success: false -} - -const planningValidationDetailsStatus: PlanningValidationDetails = { - javaVersion: '', - nodeVersion: '', - spaceAvailableMb: '', - error: '' -} - -const stepSkipStatus: SkipState = { - downloadUnpax: false, - datasetInstallation: false, - networking: false, - apfAuth: false, - security: false, - certificate: false, - vsam: false, - launchConfig: false -} - -const installationArgsStatus: InstallationArgs = { - installationDir: '', - workspaceDir: '', - logDir:'', - extensionDir:'', - installationType: 'download', - userUploadedPaxPath: '', - downloadDir: '', - javaHome: '', - nodeHome: '', - setupConfig: {}, - jobName: 'ZWE1SV', - jobPrefix: 'ZWE1', - rbacProfile: '1', - cookieId: '1', - zosmfHost: '', - zosmfPort: '443', - zosmfApplId: 'IZUDFLT', - dryRunMode:false -} +const installationTypeStatus: InstallationType = { ...initInstallationTypeStatus }; +export const downloadUnpaxStatus: DownloadUnpaxState = { ...initDownloadUnpaxStatus } +const progressStatus: ProgressState = { ...initProgressStatus } +const activeStatus: ActiveState = { ...initActiveStatus }; +const planningStageStatus: PlanningState = { ...initPlanningStageStatus } +export const datasetInstallationStatus: DatasetInstallationState = { ...initDatasetInstallationStatus } +const apfAuthStatus: InitSubStepsState = { ...initApfAuthStatus } +const securityInitStatus: InitSubStepsState = { ...initSecurityInitStatus } +const stcsInitStatus: InitSubStepsState = { ...initStcsInitStatus } +const certificateInitStatus: CertInitSubStepsState = { ...initCertificateInitStatus } +const vsamInitStatus: InitSubStepsState = { ...initVsamInitStatus } +const planningValidationDetailsStatus: PlanningValidationDetails = { ...initPlanningValidationDetailsStatus } +const stepSkipStatus: SkipState = { ...initStepSkipStatus } +const installationArgsStatus: InstallationArgs = { ...initInstallationArgsStatus } let progressStateKey = 'stage_progress'; let activeStateKey = 'active_state'; @@ -147,14 +44,8 @@ let prevInstallationKey = `prev_installation`; let skipStateKey = `skip_state`; let installationArgsKey = `intallation_args`; -let isNewInstallation = false; - let skipKeysArray: (keyof SkipState)[] = Object.keys(stepSkipStatus) as (keyof SkipState)[]; -const setNewInstallation = (isNewerInstallation: boolean) => { - -} - const setKeys = (id: string) => { if (progressStateKey.endsWith(`_${id}`)) { diff --git a/src/renderer/components/stages/progress/progressConst.ts b/src/renderer/components/stages/progress/progressConst.ts index e31357db..5c3de832 100644 --- a/src/renderer/components/stages/progress/progressConst.ts +++ b/src/renderer/components/stages/progress/progressConst.ts @@ -8,21 +8,124 @@ * Copyright Contributors to the Zowe Project. */ -import { ProgressState } from "../../../../types/stateInterfaces"; +import { ProgressState, PlanningState, InstallationType, ActiveState, DatasetInstallationState, InitSubStepsState, CertInitSubStepsState, PlanningValidationDetails, SkipState, InstallationArgs, DownloadUnpaxState } from "../../../../types/stateInterfaces"; export const initProgressStatus: ProgressState = { - connectionStatus: false, - planningStatus: false, - installationTypeStatus: false, - downloadUnpaxStatus: false, - initializationStatus: false, - datasetInstallationStatus: false, - networkingStatus: false, - apfAuthStatus: false, - securityStatus: false, - stcsStatus: false, - certificateStatus: false, - vsamStatus: false, - launchConfigStatus: false, - reviewStatus: false, - } \ No newline at end of file + connectionStatus: false, + planningStatus: false, + installationTypeStatus: false, + downloadUnpaxStatus: false, + initializationStatus: false, + datasetInstallationStatus: false, + networkingStatus: false, + apfAuthStatus: false, + securityStatus: false, + stcsStatus: false, + certificateStatus: false, + vsamStatus: false, + launchConfigStatus: false, + reviewStatus: false, +} + +export const initInstallationTypeStatus: InstallationType = { + installationType: 'download', + licenseAgreement: false, + userUploadedPaxPath: '', +} + +export const initDownloadUnpaxStatus: DownloadUnpaxState = { + uploadYaml: false, + download: false, + upload: false, + unpax: false, + getExampleYaml: false, + getSchemas: false, +} + +export const initActiveStatus: ActiveState = { + activeStepIndex: 0, + isSubStep: false, + activeSubStepIndex: 0, +} + +export const initPlanningStageStatus: PlanningState = { + jobStatement: '', + isJobStatementValid: false, + isLocationValid: false, +} + +export const initDatasetInstallationStatus: DatasetInstallationState = { + uploadYaml: false, + install: false, + initMVS: false +} + +export const initApfAuthStatus: InitSubStepsState = { + writeYaml: false, + uploadYaml: false, + success: false +} + +export const initSecurityInitStatus: InitSubStepsState = { + writeYaml: false, + uploadYaml: false, + success: false +} + +export const initStcsInitStatus: InitSubStepsState = { + writeYaml: false, + uploadYaml: false, + success: false +} + +export const initCertificateInitStatus: CertInitSubStepsState = { + writeYaml: false, + uploadYaml: false, + zweInitCertificate: false +} + +export const initVsamInitStatus: InitSubStepsState = { + writeYaml: false, + uploadYaml: false, + success: false +} + +export const initPlanningValidationDetailsStatus: PlanningValidationDetails = { + javaVersion: '', + nodeVersion: '', + spaceAvailableMb: '', + error: '' +} + +export const initStepSkipStatus: SkipState = { + downloadUnpax: false, + datasetInstallation: false, + networking: false, + apfAuth: false, + security: false, + certificate: false, + vsam: false, + launchConfig: false +} + +export const initInstallationArgsStatus: InstallationArgs = { + installationDir: '', + workspaceDir: '', + logDir:'', + extensionDir:'', + installationType: 'download', + userUploadedPaxPath: '', + downloadDir: '', + javaHome: '', + nodeHome: '', + setupConfig: {}, + jobName: 'ZWE1SV', + jobPrefix: 'ZWE1', + rbacProfile: '1', + cookieId: '1', + zosmfHost: '', + zosmfPort: '443', + zosmfApplId: 'IZUDFLT', + dryRunMode:false +} + \ No newline at end of file From ccf7108a0e724e7ff7990bbcf2ac05b0fee9fbb1 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Fri, 19 Jul 2024 15:30:10 +0530 Subject: [PATCH 03/23] Addressing the changes for the new installation Signed-off-by: Sakshi Bobade --- src/renderer/components/common/Stepper.tsx | 4 +- .../stages/progress/StageProgressStatus.ts | 67 ++++++++++++++----- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/src/renderer/components/common/Stepper.tsx b/src/renderer/components/common/Stepper.tsx index 57e1349d..71217d9c 100644 --- a/src/renderer/components/common/Stepper.tsx +++ b/src/renderer/components/common/Stepper.tsx @@ -41,7 +41,7 @@ import { selectInstallationArgs, selectIsNewInstallation } from '../stages/insta export default function HorizontalLinearStepper({stages, initialization}:{stages: any, initialization?:boolean}) { - const connectionStatus = useSelector(selectConnectionStatus); + const connectionStatus = useState(useAppSelector(selectConnectionStatus)); const INIT_STAGE_ID = getStageDetails(INIT_STAGE_LABEL).id; const REVIEW_STAGE_ID = getStageDetails(REVIEW_INSTALL_STAGE_LABEL).id; @@ -243,7 +243,7 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages alertEmitter.emit('hideAlert'); eventDispatcher.emit('saveAndCloseEvent'); dispatch(setPassword('')); - dispatch(setConnectionStatus(false)); + // dispatch(setConnectionStatus(false)); // TODO: This is a workaround for same session + Save & Close + new install not resetting the Wizard properly. // Fixed by reloading page. This is not ideal and should be investigated // window.location.reload(); diff --git a/src/renderer/components/stages/progress/StageProgressStatus.ts b/src/renderer/components/stages/progress/StageProgressStatus.ts index 5042f06c..2e10950b 100644 --- a/src/renderer/components/stages/progress/StageProgressStatus.ts +++ b/src/renderer/components/stages/progress/StageProgressStatus.ts @@ -13,20 +13,20 @@ import { ProgressState, PlanningState, InstallationType, ActiveState, DatasetIns import { initProgressStatus, initInstallationTypeStatus, initDownloadUnpaxStatus, initActiveStatus, initPlanningStageStatus, initDatasetInstallationStatus, initApfAuthStatus, initSecurityInitStatus, initStcsInitStatus, initCertificateInitStatus, initVsamInitStatus, initPlanningValidationDetailsStatus, initStepSkipStatus, initInstallationArgsStatus } from './progressConst'; import { stages } from '../../configuration-wizard/Wizard'; -const installationTypeStatus: InstallationType = { ...initInstallationTypeStatus }; -export const downloadUnpaxStatus: DownloadUnpaxState = { ...initDownloadUnpaxStatus } -const progressStatus: ProgressState = { ...initProgressStatus } -const activeStatus: ActiveState = { ...initActiveStatus }; -const planningStageStatus: PlanningState = { ...initPlanningStageStatus } -export const datasetInstallationStatus: DatasetInstallationState = { ...initDatasetInstallationStatus } -const apfAuthStatus: InitSubStepsState = { ...initApfAuthStatus } -const securityInitStatus: InitSubStepsState = { ...initSecurityInitStatus } -const stcsInitStatus: InitSubStepsState = { ...initStcsInitStatus } -const certificateInitStatus: CertInitSubStepsState = { ...initCertificateInitStatus } -const vsamInitStatus: InitSubStepsState = { ...initVsamInitStatus } -const planningValidationDetailsStatus: PlanningValidationDetails = { ...initPlanningValidationDetailsStatus } -const stepSkipStatus: SkipState = { ...initStepSkipStatus } -const installationArgsStatus: InstallationArgs = { ...initInstallationArgsStatus } +let installationTypeStatus: InstallationType; +export let downloadUnpaxStatus: DownloadUnpaxState; +let progressStatus: ProgressState; +let activeStatus: ActiveState; +let planningStageStatus: PlanningState; +export let datasetInstallationStatus: DatasetInstallationState; +let apfAuthStatus: InitSubStepsState; +let securityInitStatus: InitSubStepsState; +let stcsInitStatus: InitSubStepsState; +let certificateInitStatus: CertInitSubStepsState; +let vsamInitStatus: InitSubStepsState; +let planningValidationDetailsStatus: PlanningValidationDetails; +let stepSkipStatus: SkipState; +let installationArgsStatus: InstallationArgs; let progressStateKey = 'stage_progress'; let activeStateKey = 'active_state'; @@ -44,7 +44,8 @@ let prevInstallationKey = `prev_installation`; let skipStateKey = `skip_state`; let installationArgsKey = `intallation_args`; -let skipKeysArray: (keyof SkipState)[] = Object.keys(stepSkipStatus) as (keyof SkipState)[]; +// let skipKeysArray: (keyof SkipState)[] = Object.keys(stepSkipStatus) as (keyof SkipState)[]; +let skipKeysArray: (keyof SkipState)[]; const setKeys = (id: string) => { @@ -68,6 +69,26 @@ const setKeys = (id: string) => { installationArgsKey = `${installationArgsKey}_${id}`; } +const resetProgressObjects = () => { + installationTypeStatus = { ...initInstallationTypeStatus }; + downloadUnpaxStatus = { ...initDownloadUnpaxStatus }; + progressStatus = { ...initProgressStatus }; + activeStatus = { ...initActiveStatus }; + planningStageStatus = { ...initPlanningStageStatus }; + datasetInstallationStatus = { ...initDatasetInstallationStatus }; + apfAuthStatus = { ...initApfAuthStatus }; + securityInitStatus = { ...initSecurityInitStatus }; + stcsInitStatus = { ...initStcsInitStatus }; + certificateInitStatus = { ...initCertificateInitStatus }; + vsamInitStatus = { ...initVsamInitStatus }; + planningValidationDetailsStatus = { ...initPlanningValidationDetailsStatus }; + stepSkipStatus = { ...initStepSkipStatus }; + installationArgsStatus = { ...initInstallationArgsStatus }; + + skipKeysArray = Object.keys(stepSkipStatus) as (keyof SkipState)[]; + +} + export const resetProgress = (host: string, user: string,) => { if(host && user) { const id = `${host}_${user}`; @@ -82,12 +103,16 @@ export const resetProgress = (host: string, user: string,) => { localStorage.removeItem(key); } }) + + resetProgressObjects(); } export const initializeProgress = (host: string, user: string, isResume: boolean) => { const id = `${host}_${user}`; setKeys(id); + resetProgressObjects(); + const progress = localStorage.getItem(progressStateKey); if(!progress || !isResume) { const flattenedData = flatten(progressStatus); @@ -358,6 +383,9 @@ export const getDownloadUnpaxState = (): DownloadUnpaxState => { }; export const setPlanningStageStatus = (key: K, newValue: PlanningState[K]): void => { + if(!planningStageStatus) { + return; + } const planningData = localStorage.getItem(planningStateKey); if (planningData) { const flattenedData = JSON.parse(planningData); @@ -380,6 +408,9 @@ export const getPlanningStageStatus = (): PlanningState => { } export const setInstallationArguments = (newInstallationArgs: InstallationArgs): void => { + if(!installationArgsStatus) { + return; + } Object.assign(installationArgsStatus, newInstallationArgs); const flattenedData = flatten(installationArgsStatus); localStorage.setItem(installationArgsKey, JSON.stringify(flattenedData)); @@ -414,6 +445,9 @@ export const getProgress = (key: keyof ProgressState): boolean => { const unFlattenedData = unflatten(flattenedData) as ProgressState; return unFlattenedData[key]; } else { + if(!progressStatus) { + return false; + } return progressStatus[key]; } } @@ -424,6 +458,9 @@ export const getCompleteProgress = () : ProgressState => { const flattenedData = JSON.parse(progress); return unflatten(flattenedData); } else { + if(!progressStatus) { + return initProgressStatus; + } return progressStatus; } } From d97b60f3e695466f6e4ab30712f8516080ba8a4f Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Fri, 19 Jul 2024 18:07:07 +0530 Subject: [PATCH 04/23] Adding the job statement on new installation Signed-off-by: Sakshi Bobade --- src/renderer/components/stages/Planning.tsx | 5 ++--- src/renderer/components/stages/PlanningSlice.tsx | 3 ++- .../components/stages/progress/StageProgressStatus.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/stages/Planning.tsx b/src/renderer/components/stages/Planning.tsx index 6280545f..e9fceadf 100644 --- a/src/renderer/components/stages/Planning.tsx +++ b/src/renderer/components/stages/Planning.tsx @@ -21,7 +21,7 @@ import { setYaml, setNextStepEnabled, setLoading, selectYaml } from '../configur import { selectConnectionArgs, setConnectionArgs, setJobStatementVal } from './connection/connectionSlice'; import { setPlanningStatus, selectPlanningStatus } from './progress/progressSlice'; import { setZoweVersion, setInstallationArgs, selectInstallationArgs, selectZoweVersion } from './installation/installationSlice'; -import { setJobStatement, setJobStatementValid, setJobStatementValidMsg, setLocationValidationDetails, setIsLocationValid, selectJobStatementValidMsg, selectLocValidationDetails } from "./PlanningSlice"; +import { setJobStatement, setJobStatementValid, setJobStatementValidMsg, setLocationValidationDetails, setIsLocationValid, selectJobStatementValidMsg, selectLocValidationDetails, selectJobStatement } from "./PlanningSlice"; import { useAppDispatch, useAppSelector } from '../../hooks'; import { IResponse } from '../../../types/interfaces'; import { alertEmitter } from "../Header"; @@ -63,8 +63,7 @@ const Planning = () => { const [jobHeaderSaved, setJobHeaderSaved] = useState(false); const [isJobStatementUpdated, setIsJobStatementUpdated] = useState(false); - // const [jobStatementValue, setJobStatementValue] = useState(useAppSelector(selectJobStatement)); - const [jobStatementValue, setJobStatementValue] = useState(getPlanningStageStatus()?.jobStatement); + const [jobStatementValue, setJobStatementValue] = useState(useAppSelector(selectJobStatement)); const [locationsValidated, setLocationsValidated] = useState(getPlanningStageStatus()?.isLocationValid || false); const [isLocationsUpdated, setIsLocationsUpdated] = useState(false); diff --git a/src/renderer/components/stages/PlanningSlice.tsx b/src/renderer/components/stages/PlanningSlice.tsx index 82357bd5..765b5ebb 100644 --- a/src/renderer/components/stages/PlanningSlice.tsx +++ b/src/renderer/components/stages/PlanningSlice.tsx @@ -11,6 +11,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { RootState } from '../../store'; import { setPlanningStageStatus, getPlanningStageStatus } from './progress/StageProgressStatus'; +import { DEF_JOB_STATEMENT } from '../common/Utils'; export interface jobValidation { jobStatement: string; @@ -24,7 +25,7 @@ export interface locationValidation { } const initialState: jobValidation = { - jobStatement: getPlanningStageStatus()?.jobStatement || '', + jobStatement: getPlanningStageStatus()?.jobStatement || DEF_JOB_STATEMENT, isJobStatementValid: getPlanningStageStatus()?.isJobStatementValid || false, jobStatementValidMsg: '' } diff --git a/src/renderer/components/stages/progress/StageProgressStatus.ts b/src/renderer/components/stages/progress/StageProgressStatus.ts index 2e10950b..b7051ece 100644 --- a/src/renderer/components/stages/progress/StageProgressStatus.ts +++ b/src/renderer/components/stages/progress/StageProgressStatus.ts @@ -507,7 +507,7 @@ export const getPreviousInstallation = () : ActiveState => { const flattenedData = JSON.parse(activeStage); return unflatten(flattenedData); } else { - return activeStatus; + return initActiveStatus; } } From 3d1f1e48640e4518053181bf359dc119b96eab22 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Fri, 19 Jul 2024 18:16:18 +0530 Subject: [PATCH 05/23] reset connection status on new installation --- src/renderer/components/Home.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 35172cb1..42eba4d1 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -22,7 +22,7 @@ import { Tooltip } from '@mui/material'; import installationImg from '../assets/installation.png' import installationDryImg from '../assets/installation-dry-run.png' import eventDispatcher from "../../services/eventDispatcher"; -import { selectConnectionStatus} from './stages/progress/progressSlice'; +import { selectConnectionStatus, setConnectionStatus} from './stages/progress/progressSlice'; import HorizontalLinearStepper from './common/Stepper'; import Wizard from './configuration-wizard/Wizard' import { ActiveState } from '../../types/stateInterfaces'; @@ -94,6 +94,7 @@ const Home = () => { if (id === "install") { dispatch(setIsNewerInstallation(true)); setIsNewInstallation(true); + dispatch(setConnectionStatus(false)); newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; } else if (id === "dry run") { newInstallationArgs = {...newInstallationArgs, dryRunMode: true}; From 21692a6f9ffd7c8ebba63c6bd160c012217bd7e9 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Fri, 19 Jul 2024 18:59:24 +0530 Subject: [PATCH 06/23] Removing console logs Signed-off-by: Sakshi Bobade --- src/renderer/components/common/Stepper.tsx | 4 ---- .../components/stages/progress/StageProgressStatus.ts | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/renderer/components/common/Stepper.tsx b/src/renderer/components/common/Stepper.tsx index 71217d9c..70cba2d2 100644 --- a/src/renderer/components/common/Stepper.tsx +++ b/src/renderer/components/common/Stepper.tsx @@ -243,10 +243,6 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages alertEmitter.emit('hideAlert'); eventDispatcher.emit('saveAndCloseEvent'); dispatch(setPassword('')); - // dispatch(setConnectionStatus(false)); - // TODO: This is a workaround for same session + Save & Close + new install not resetting the Wizard properly. - // Fixed by reloading page. This is not ideal and should be investigated - // window.location.reload(); } const isNextStepEnabled = useAppSelector(selectNextStepEnabled); diff --git a/src/renderer/components/stages/progress/StageProgressStatus.ts b/src/renderer/components/stages/progress/StageProgressStatus.ts index b7051ece..139ab04b 100644 --- a/src/renderer/components/stages/progress/StageProgressStatus.ts +++ b/src/renderer/components/stages/progress/StageProgressStatus.ts @@ -44,7 +44,6 @@ let prevInstallationKey = `prev_installation`; let skipStateKey = `skip_state`; let installationArgsKey = `intallation_args`; -// let skipKeysArray: (keyof SkipState)[] = Object.keys(stepSkipStatus) as (keyof SkipState)[]; let skipKeysArray: (keyof SkipState)[]; const setKeys = (id: string) => { @@ -96,10 +95,8 @@ export const resetProgress = (host: string, user: string,) => { } const keysArray = [progressStateKey, activeStateKey, planningStateKey, installationTypeKey, downloadUnpaxKey, datasetInstallationKey, apfAuthKey, securityKey, stcsKey, certificateKey, vsamKey, planningValidationDetailsKey, prevInstallationKey, skipStateKey, installationArgsKey]; - console.log('keysArray: ', keysArray); keysArray.forEach(key => { if(localStorage.getItem(key) !== null) { - console.log('removing key: ', key); localStorage.removeItem(key); } }) From c1d74f463388b99fc8293574115780d4ad124927 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 13:51:05 +0530 Subject: [PATCH 07/23] Updating the resume code Signed-off-by: Sakshi Bobade --- src/renderer/components/Home.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 42eba4d1..50dc8a09 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -83,7 +83,6 @@ const Home = () => { const defaultTooltip: string = "Resume"; const resumeTooltip = connectionStatus ? defaultTooltip : `Validate Credentials & ${defaultTooltip}`; const [showPasswordDialog, setShowPasswordDialog] = useState(false); - const [updatedConnection, setUpdatedConnection] = useState(false); const [isResume, setIsResume] = useState(useAppSelector(selectResumeProgress)); const makeCard = (card: ICard) => { @@ -223,12 +222,11 @@ const Home = () => { if(connectionStatus) { setShowPasswordDialog(true); - setUpdatedConnection(false); } } const confirmConnection = (status: boolean) => { - setUpdatedConnection(status); + setShowPasswordDialog(!status); setShowWizard(status); } @@ -272,7 +270,6 @@ const Home = () => { {showWizard && <> {showPasswordDialog && } - {(showPasswordDialog && updatedConnection) && } {!showPasswordDialog && } } From 22c41f7b8e31491548c32bc307c9b2da509933de Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 13:54:18 +0530 Subject: [PATCH 08/23] Updating the resume code Signed-off-by: Sakshi Bobade --- src/renderer/components/Home.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 50dc8a09..13af2b0c 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -70,7 +70,6 @@ const Home = () => { const dispatch = useAppDispatch(); const connectionStatus = useAppSelector(selectConnectionStatus); const [showWizard, setShowWizard] = useState(false); - const [showLoginDialog, setShowLogin] = useState(false); const [localYaml, setLocalYaml] = useState(useAppSelector(selectYaml)); const [schema, setLocalSchema] = useState(useAppSelector(selectSchema)); const installationArgs = useAppSelector(selectInstallationArgs); From a9897f7abe583485d3ad44dba9ccb87efaad4bab Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 15:02:12 +0530 Subject: [PATCH 09/23] Removing duplicate states for the newInstallation Signed-off-by: Sakshi Bobade --- src/renderer/components/Home.tsx | 17 ++++++++--------- .../stages/installation/installationSlice.ts | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 13af2b0c..7ba952fe 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -28,7 +28,7 @@ import Wizard from './configuration-wizard/Wizard' import { ActiveState } from '../../types/stateInterfaces'; import { getInstallationArguments, getPreviousInstallation } from './stages/progress/StageProgressStatus'; import { DEF_NO_OUTPUT, FALLBACK_SCHEMA, FALLBACK_YAML } from './common/Utils'; -import { selectInstallationArgs, setInstallationArgs, installationSlice, setIsNewerInstallation } from './stages/installation/installationSlice'; +import { selectInstallationArgs, setInstallationArgs, installationSlice, setIsNewInstallation, selectIsNewInstallation } from './stages/installation/installationSlice'; import PasswordDialog from './common/passwordDialog'; // REVIEW: Get rid of routing @@ -76,22 +76,21 @@ const Home = () => { const { activeStepIndex, isSubStep, activeSubStepIndex, lastActiveDate } = getPreviousInstallation(); - const [isNewInstallation, setIsNewInstallation] = useState(false); - const stages: any = []; const defaultTooltip: string = "Resume"; const resumeTooltip = connectionStatus ? defaultTooltip : `Validate Credentials & ${defaultTooltip}`; const [showPasswordDialog, setShowPasswordDialog] = useState(false); const [isResume, setIsResume] = useState(useAppSelector(selectResumeProgress)); + const isNewInstallation = useAppSelector(selectIsNewInstallation); + const makeCard = (card: ICard) => { const {id, name, description, link, media} = card; const handleClick = () => { let newInstallationArgs = installationSlice.getInitialState().installationArgs; if (id === "install") { - dispatch(setIsNewerInstallation(true)); - setIsNewInstallation(true); + dispatch(setIsNewInstallation(true)); dispatch(setConnectionStatus(false)); newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; } else if (id === "dry run") { @@ -201,10 +200,10 @@ const Home = () => { if (!lastInstallation) { const flattenedData = flatten(lastActiveState); localStorage.setItem(prevInstallationKey, JSON.stringify(flattenedData)); - setIsNewInstallation(true); + dispatch(setIsNewInstallation(true)); } else { const data: ActiveState = unflatten(JSON.parse(lastInstallation)); - setIsNewInstallation(!(data && data.lastActiveDate)); + dispatch(setIsNewInstallation(!(data && data.lastActiveDate))); } @@ -217,7 +216,7 @@ const Home = () => { const resumeProgress = () => { setShowWizard(true); dispatch(setResumeProgress(true)); - dispatch(setIsNewerInstallation(false)); + dispatch(setIsNewInstallation(false)); if(connectionStatus) { setShowPasswordDialog(true); @@ -234,7 +233,7 @@ const Home = () => { {!showWizard &&
- + {stages.length > 0 && }
{!connectionStatus &&
} diff --git a/src/renderer/components/stages/installation/installationSlice.ts b/src/renderer/components/stages/installation/installationSlice.ts index 3d05f99c..4bcd01e8 100644 --- a/src/renderer/components/stages/installation/installationSlice.ts +++ b/src/renderer/components/stages/installation/installationSlice.ts @@ -69,13 +69,13 @@ export const installationSlice = createSlice({ state.licenseAgreement = action.payload; setInstallationTypeStatus('licenseAgreement', action.payload) }, - setIsNewerInstallation: (state, action: PayloadAction) => { + setIsNewInstallation: (state, action: PayloadAction) => { state.isNewInstallation = action.payload; } } }); -export const { setInstallationArgs, setZoweVersion, setInstallationType, setLicenseAgreement, setUserUploadedPaxPath, setIsNewerInstallation} = installationSlice.actions; +export const { setInstallationArgs, setZoweVersion, setInstallationType, setLicenseAgreement, setUserUploadedPaxPath, setIsNewInstallation} = installationSlice.actions; export const selectInstallationArgs = (state: RootState) => state.installation.installationArgs; export const selectZoweVersion = (state: RootState) => state.installation.zoweVersion; From 15e7661cf07e9cd39fc62c7bfa06c837fc8be98f Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 15:10:30 +0530 Subject: [PATCH 10/23] Resetting resume status --- src/renderer/components/Home.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 7ba952fe..f5b97945 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -92,6 +92,7 @@ const Home = () => { if (id === "install") { dispatch(setIsNewInstallation(true)); dispatch(setConnectionStatus(false)); + dispatch(setResumeProgress(false)); newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; } else if (id === "dry run") { newInstallationArgs = {...newInstallationArgs, dryRunMode: true}; From d57f6855bba507d946391461f288df6e010faafb Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 16:11:32 +0530 Subject: [PATCH 11/23] Not initializing the state anymore in stepper --- src/renderer/components/common/Stepper.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/renderer/components/common/Stepper.tsx b/src/renderer/components/common/Stepper.tsx index 70cba2d2..5f7e684d 100644 --- a/src/renderer/components/common/Stepper.tsx +++ b/src/renderer/components/common/Stepper.tsx @@ -17,7 +17,7 @@ import StepLabel from '@mui/material/StepLabel'; import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; import { Link } from 'react-router-dom'; -import { selectConnectionStatus, setConnectionStatus } from '../stages/progress/progressSlice'; +import { selectConnectionStatus } from '../stages/progress/progressSlice'; import { useAppDispatch, useAppSelector } from '../../hooks'; import { selectNextStepEnabled, setLoading, setYaml } from '../configuration-wizard/wizardSlice'; import { selectActiveStepIndex, selectActiveSubStepIndex } from '../stages/progress/activeStepSlice'; @@ -29,7 +29,6 @@ import Warning from '@mui/icons-material/Warning'; import CheckCircle from '@mui/icons-material/CheckCircle'; import { TYPE_YAML, TYPE_OUTPUT, TYPE_JCL, INIT_STAGE_LABEL, REVIEW_INSTALL_STAGE_LABEL, UNPAX_STAGE_LABEL } from '../common/Utils'; import { getProgress, getCompleteProgress, mapAndSetSkipStatus, mapAndGetSkipStatus } from '../stages/progress/StageProgressStatus'; -import {initProgressStatus} from '../stages/progress/progressConst'; import '../../styles/Stepper.css'; import { StepIcon } from '@mui/material'; import { getStageDetails } from '../../../services/StageDetails'; @@ -48,11 +47,7 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages const isNewInstallation = useAppSelector(selectIsNewInstallation); - let completeProgress = {...initProgressStatus}; - - if(!isNewInstallation) { - completeProgress = getCompleteProgress(); - } + const completeProgress = getCompleteProgress(); const stageProgressStatus = [ useSelector(selectConnectionStatus), From 3b2eb91a4612b9d2125bc42c7eddee4eade2f874 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 16:19:50 +0530 Subject: [PATCH 12/23] Removing the useselector hook --- src/renderer/components/common/Stepper.tsx | 5 ++--- src/renderer/components/stages/ReviewInstallation.tsx | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/common/Stepper.tsx b/src/renderer/components/common/Stepper.tsx index 5f7e684d..1acc074f 100644 --- a/src/renderer/components/common/Stepper.tsx +++ b/src/renderer/components/common/Stepper.tsx @@ -9,7 +9,6 @@ */ import React, { useState, useEffect } from 'react'; -import { useSelector } from 'react-redux'; import Box from '@mui/material/Box'; import Stepper from '@mui/material/Stepper'; import Step from '@mui/material/Step'; @@ -40,7 +39,7 @@ import { selectInstallationArgs, selectIsNewInstallation } from '../stages/insta export default function HorizontalLinearStepper({stages, initialization}:{stages: any, initialization?:boolean}) { - const connectionStatus = useState(useAppSelector(selectConnectionStatus)); + const connectionStatus = useAppSelector(selectConnectionStatus); const INIT_STAGE_ID = getStageDetails(INIT_STAGE_LABEL).id; const REVIEW_STAGE_ID = getStageDetails(REVIEW_INSTALL_STAGE_LABEL).id; @@ -50,7 +49,7 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages const completeProgress = getCompleteProgress(); const stageProgressStatus = [ - useSelector(selectConnectionStatus), + useAppSelector(selectConnectionStatus), completeProgress.planningStatus, completeProgress.installationTypeStatus, completeProgress.downloadUnpaxStatus, diff --git a/src/renderer/components/stages/ReviewInstallation.tsx b/src/renderer/components/stages/ReviewInstallation.tsx index 340ec70a..e2611626 100644 --- a/src/renderer/components/stages/ReviewInstallation.tsx +++ b/src/renderer/components/stages/ReviewInstallation.tsx @@ -9,7 +9,6 @@ */ import React, {useEffect, useState} from "react"; -import { useSelector } from 'react-redux'; import {Box, Button, Typography, Tooltip} from '@mui/material'; import CheckCircleIcon from '@mui/icons-material/CheckCircle'; import WarningIcon from '@mui/icons-material/Warning'; @@ -48,7 +47,7 @@ const ReviewInstallation = () => { const completeProgress = getCompleteProgress(); const stageProgressStatus = [ - useSelector(selectConnectionStatus), + useAppSelector(selectConnectionStatus), completeProgress.planningStatus, completeProgress.installationTypeStatus, completeProgress.initializationStatus, From b9da937c82c205c692c8dc757018faba056f6e68 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 16:22:55 +0530 Subject: [PATCH 13/23] Removing the unused states --- src/renderer/components/Home.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index f5b97945..d68112ee 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -71,10 +71,9 @@ const Home = () => { const connectionStatus = useAppSelector(selectConnectionStatus); const [showWizard, setShowWizard] = useState(false); const [localYaml, setLocalYaml] = useState(useAppSelector(selectYaml)); - const [schema, setLocalSchema] = useState(useAppSelector(selectSchema)); - const installationArgs = useAppSelector(selectInstallationArgs); + const schema = useAppSelector(selectSchema); - const { activeStepIndex, isSubStep, activeSubStepIndex, lastActiveDate } = getPreviousInstallation(); + const { lastActiveDate } = getPreviousInstallation(); const stages: any = []; const defaultTooltip: string = "Resume"; From 03223891d54bdbff7293dcd6c3e9d1bf6fdc43f7 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 16:31:17 +0530 Subject: [PATCH 14/23] Removing unused states, functions --- src/renderer/components/common/Stepper.tsx | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/renderer/components/common/Stepper.tsx b/src/renderer/components/common/Stepper.tsx index 1acc074f..e938f03b 100644 --- a/src/renderer/components/common/Stepper.tsx +++ b/src/renderer/components/common/Stepper.tsx @@ -41,9 +41,6 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages const connectionStatus = useAppSelector(selectConnectionStatus); - const INIT_STAGE_ID = getStageDetails(INIT_STAGE_LABEL).id; - const REVIEW_STAGE_ID = getStageDetails(REVIEW_INSTALL_STAGE_LABEL).id; - const isNewInstallation = useAppSelector(selectIsNewInstallation); const completeProgress = getCompleteProgress(); @@ -69,10 +66,8 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages const [activeStep, setActiveStep] = isNewInstallation ? useState(0) : useState(useAppSelector(selectActiveStepIndex)); const [activeSubStep, setActiveSubStep] = isNewInstallation ? useState(0) : useState(useAppSelector(selectActiveSubStepIndex)); - const [nextText, setNextText] = useState("Continue"); const [contentType, setContentType] = useState('output'); const [editorVisible, setEditorVisible] = useState(false); - const [editorContent, setEditorContent] = useState(''); const installationArgs = useAppSelector(selectInstallationArgs); const connectionArgs = useAppSelector(selectConnectionArgs); const dispatch = useAppDispatch(); @@ -106,14 +101,6 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages setEditorVisible(!editorVisible); }; - const getContinueText = () => { - return 'Continue to next step';//'+stages[activeStep+1].label; - }; - - const getSkipText = () => { - return 'Skip step';//+stages[activeStep+1].label; - }; - const handleYAML = () => { toggleEditorVisibility(TYPE_YAML); } @@ -166,14 +153,12 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages return; } setActiveStep((prevActiveStep) => prevActiveStep + 1); - setNextText(getContinueText()); } }; const handleBack = () => { alertEmitter.emit('hideAlert'); stages[activeStep].subStages && activeSubStep > 0 ? setActiveSubStep((prevActiveSubStep) => prevActiveSubStep - 1) : setActiveStep((prevActiveStep) => prevActiveStep - 1); - setNextText(getContinueText()); }; const handleReset = () => { @@ -181,11 +166,6 @@ export default function HorizontalLinearStepper({stages, initialization}:{stages setActiveStep(0); }; - const handlePreview = (test_jcl: any) => { - toggleEditorVisibility(TYPE_JCL); - setEditorContent(test_jcl); - }; - const handleStepperClick = (newActiveStep: number, isSubStep: boolean, subStepIndex?: number) => { if(!connectionStatus) { return; From 14421c059d8dc2ade01236be65b71b64fd43dbcb Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 7 Aug 2024 17:27:28 +0530 Subject: [PATCH 15/23] Updating te fuction names --- .../components/stages/progress/StageProgressStatus.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/stages/progress/StageProgressStatus.ts b/src/renderer/components/stages/progress/StageProgressStatus.ts index 139ab04b..bd8c4716 100644 --- a/src/renderer/components/stages/progress/StageProgressStatus.ts +++ b/src/renderer/components/stages/progress/StageProgressStatus.ts @@ -68,7 +68,7 @@ const setKeys = (id: string) => { installationArgsKey = `${installationArgsKey}_${id}`; } -const resetProgressObjects = () => { +const setProgressObjects = () => { installationTypeStatus = { ...initInstallationTypeStatus }; downloadUnpaxStatus = { ...initDownloadUnpaxStatus }; progressStatus = { ...initProgressStatus }; @@ -100,15 +100,13 @@ export const resetProgress = (host: string, user: string,) => { localStorage.removeItem(key); } }) - - resetProgressObjects(); } export const initializeProgress = (host: string, user: string, isResume: boolean) => { const id = `${host}_${user}`; setKeys(id); - resetProgressObjects(); + setProgressObjects(); const progress = localStorage.getItem(progressStateKey); if(!progress || !isResume) { From 4727edb993722625fa02606980d3b6066562664d Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 13:30:51 +0530 Subject: [PATCH 16/23] Adding the new Warning Dialog --- .../components/Dialogs/WarningDialog.tsx | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/renderer/components/Dialogs/WarningDialog.tsx diff --git a/src/renderer/components/Dialogs/WarningDialog.tsx b/src/renderer/components/Dialogs/WarningDialog.tsx new file mode 100644 index 00000000..99acc6fa --- /dev/null +++ b/src/renderer/components/Dialogs/WarningDialog.tsx @@ -0,0 +1,43 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + */ +import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, TextField } from '@mui/material'; +import { useState } from 'react'; + +const WarningDialog = ({onWarningDialogSubmit}: {onWarningDialogSubmit: any}) => { + + const [isDialogVisible, setIsDialogVisible] = useState(true); + + const handleClose = () => { + setIsDialogVisible(false); + onWarningDialogSubmit(false); + } + + const handleSubmit = () => { + setIsDialogVisible(false); + onWarningDialogSubmit(true); + } + + return ( +
+ + Warning! + Hey There + +
+ + +
+
+
+
+ ) +} + +export default WarningDialog; \ No newline at end of file From 92ef950bdf231acf3c3f9b0534a55afe67e834c5 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 14:35:33 +0530 Subject: [PATCH 17/23] Updating the Home comp --- src/renderer/components/Home.tsx | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index d68112ee..4a28c02f 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -30,6 +30,7 @@ import { getInstallationArguments, getPreviousInstallation } from './stages/prog import { DEF_NO_OUTPUT, FALLBACK_SCHEMA, FALLBACK_YAML } from './common/Utils'; import { selectInstallationArgs, setInstallationArgs, installationSlice, setIsNewInstallation, selectIsNewInstallation } from './stages/installation/installationSlice'; import PasswordDialog from './common/passwordDialog'; +import WarningDialog from './Dialogs/WarningDialog'; // REVIEW: Get rid of routing @@ -81,7 +82,9 @@ const Home = () => { const [showPasswordDialog, setShowPasswordDialog] = useState(false); const [isResume, setIsResume] = useState(useAppSelector(selectResumeProgress)); - const isNewInstallation = useAppSelector(selectIsNewInstallation); + // const isNewInstallation = useAppSelector(selectIsNewInstallation); + const [isNewInstallation, setNewInstallation] = useState(useAppSelector(selectIsNewInstallation)); + const [newInstallationClicked, setNewInstallationClick] = useState(false); const makeCard = (card: ICard) => { const {id, name, description, link, media} = card; @@ -89,6 +92,10 @@ const Home = () => { const handleClick = () => { let newInstallationArgs = installationSlice.getInitialState().installationArgs; if (id === "install") { + setNewInstallationClick(true); + if(!isNewInstallation) { + return; + } dispatch(setIsNewInstallation(true)); dispatch(setConnectionStatus(false)); dispatch(setResumeProgress(false)); @@ -96,6 +103,7 @@ const Home = () => { } else if (id === "dry run") { newInstallationArgs = {...newInstallationArgs, dryRunMode: true}; } + console.log("isNewInstallation: ", isNewInstallation); dispatch(setYaml(FALLBACK_YAML)); dispatch(setInstallationArgs(newInstallationArgs)); window.electron.ipcRenderer.setConfigByKeyNoValidate("installationArgs", newInstallationArgs); @@ -132,6 +140,11 @@ const Home = () => { ) } + useEffect(() => { + console.log("isNewInstallation changed:", isNewInstallation); + console.log("newInstallationClicked:", newInstallationClicked); + }); + useEffect(() => { eventDispatcher.on('saveAndCloseEvent', () => setShowWizard(false)); @@ -217,7 +230,7 @@ const Home = () => { setShowWizard(true); dispatch(setResumeProgress(true)); dispatch(setIsNewInstallation(false)); - + if(connectionStatus) { setShowPasswordDialog(true); } @@ -228,8 +241,17 @@ const Home = () => { setShowWizard(status); } + const confirmNewInstallation = (status: boolean) => { + setNewInstallation(status); + setNewInstallationClick(false); + } + return ( <> + { !isNewInstallation && newInstallationClicked && + + } + {!showWizard &&
From 5a4195511f803295e71c714b4b46dc517887b97e Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 16:26:14 +0530 Subject: [PATCH 18/23] Adding the card component and updating the warning component --- .../components/Dialogs/WarningDialog.tsx | 4 +-- src/renderer/components/HomeCard.tsx | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/renderer/components/HomeCard.tsx diff --git a/src/renderer/components/Dialogs/WarningDialog.tsx b/src/renderer/components/Dialogs/WarningDialog.tsx index 99acc6fa..95578343 100644 --- a/src/renderer/components/Dialogs/WarningDialog.tsx +++ b/src/renderer/components/Dialogs/WarningDialog.tsx @@ -31,8 +31,8 @@ const WarningDialog = ({onWarningDialogSubmit}: {onWarningDialogSubmit: any}) => Hey There
- - + +
diff --git a/src/renderer/components/HomeCard.tsx b/src/renderer/components/HomeCard.tsx new file mode 100644 index 00000000..a63ce7d7 --- /dev/null +++ b/src/renderer/components/HomeCard.tsx @@ -0,0 +1,26 @@ +import { Box, Card, CardContent, CardMedia, Typography, Tooltip, Button } from '@mui/material'; +import { Link } from 'react-router-dom'; + +const CardComponent = ({ id, name, description, link, media, previousInstallation, handleClick }:{id: string, name: string, description: string, link: string, media: any, previousInstallation: boolean, handleClick: any}) => { + return ( + + handleClick(id)}> + + + + + + {name} + + + {description} + + + + + + + ); +}; + +export default CardComponent; From 761551bb2a59be307f3e5772f308d67773f01454 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 16:46:01 +0530 Subject: [PATCH 19/23] Separating the code base --- src/renderer/components/Home.tsx | 134 ++++++++---------- .../{HomeCard.tsx => HomeCardComponent.tsx} | 7 +- src/types/interfaces.ts | 8 ++ 3 files changed, 72 insertions(+), 77 deletions(-) rename src/renderer/components/{HomeCard.tsx => HomeCardComponent.tsx} (74%) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 4a28c02f..19edfe92 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -10,7 +10,7 @@ import '../global.css'; import { useEffect, useState } from "react"; -import { Link } from 'react-router-dom'; +import { Link, useNavigate } from 'react-router-dom'; import { Box, Card, CardContent, CardMedia, Typography, Button } from '@mui/material'; import flatten, { unflatten } from 'flat'; import { IResponse, IIpcConnectionArgs } from '../../types/interfaces'; @@ -25,23 +25,17 @@ import eventDispatcher from "../../services/eventDispatcher"; import { selectConnectionStatus, setConnectionStatus} from './stages/progress/progressSlice'; import HorizontalLinearStepper from './common/Stepper'; import Wizard from './configuration-wizard/Wizard' -import { ActiveState } from '../../types/stateInterfaces'; +import { ActiveState, InstallationArgs } from '../../types/stateInterfaces'; import { getInstallationArguments, getPreviousInstallation } from './stages/progress/StageProgressStatus'; import { DEF_NO_OUTPUT, FALLBACK_SCHEMA, FALLBACK_YAML } from './common/Utils'; import { selectInstallationArgs, setInstallationArgs, installationSlice, setIsNewInstallation, selectIsNewInstallation } from './stages/installation/installationSlice'; import PasswordDialog from './common/passwordDialog'; import WarningDialog from './Dialogs/WarningDialog'; +import HomeCardComponent from './HomeCardComponent'; +import { ICard } from '../../types/interfaces'; // REVIEW: Get rid of routing -interface ICard { - id: string, - name: string, - description: string, - link: string, - media: any, -} - const cards: Array = [ { id: "install", @@ -69,6 +63,7 @@ const lastActiveState: ActiveState = { const Home = () => { const dispatch = useAppDispatch(); + const navigate = useNavigate(); const connectionStatus = useAppSelector(selectConnectionStatus); const [showWizard, setShowWizard] = useState(false); const [localYaml, setLocalYaml] = useState(useAppSelector(selectYaml)); @@ -80,70 +75,40 @@ const Home = () => { const defaultTooltip: string = "Resume"; const resumeTooltip = connectionStatus ? defaultTooltip : `Validate Credentials & ${defaultTooltip}`; const [showPasswordDialog, setShowPasswordDialog] = useState(false); - const [isResume, setIsResume] = useState(useAppSelector(selectResumeProgress)); - // const isNewInstallation = useAppSelector(selectIsNewInstallation); - const [isNewInstallation, setNewInstallation] = useState(useAppSelector(selectIsNewInstallation)); + const isNewInstallation = useAppSelector(selectIsNewInstallation); const [newInstallationClicked, setNewInstallationClick] = useState(false); + const [previousInstallation, setPreviousInstallation] = useState(false); + let newInstallationArgs = installationSlice.getInitialState().installationArgs; + + const handleCardClick = (newInstallationArgs: InstallationArgs) => { + dispatch(setYaml(FALLBACK_YAML)); + dispatch(setInstallationArgs(newInstallationArgs)); + window.electron.ipcRenderer.setConfigByKeyNoValidate("installationArgs", newInstallationArgs); + setLocalYaml(FALLBACK_YAML); + window.electron.ipcRenderer.setConfig(FALLBACK_YAML); + // TODO: Ideally, reset connectionArgs too + // but this introduces bug with "self certificate chain" it's the checkbox, it looks checked but + // it acts like it's not unless you touch it + // dispatch(setConnectionArgs(connectionSlice.getInitialState().connectionArgs)); + } - const makeCard = (card: ICard) => { - const {id, name, description, link, media} = card; + const handleClick = (id: string) => { - const handleClick = () => { - let newInstallationArgs = installationSlice.getInitialState().installationArgs; - if (id === "install") { - setNewInstallationClick(true); - if(!isNewInstallation) { - return; - } - dispatch(setIsNewInstallation(true)); - dispatch(setConnectionStatus(false)); - dispatch(setResumeProgress(false)); - newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; - } else if (id === "dry run") { - newInstallationArgs = {...newInstallationArgs, dryRunMode: true}; + if (id === "install") { + setNewInstallationClick(true); + if(previousInstallation) { + return; } - console.log("isNewInstallation: ", isNewInstallation); - dispatch(setYaml(FALLBACK_YAML)); - dispatch(setInstallationArgs(newInstallationArgs)); - window.electron.ipcRenderer.setConfigByKeyNoValidate("installationArgs", newInstallationArgs); - setLocalYaml(FALLBACK_YAML); - window.electron.ipcRenderer.setConfig(FALLBACK_YAML); - // TODO: Ideally, reset connectionArgs too - // but this introduces bug with "self certificate chain" it's the checkbox, it looks checked but - // it acts like it's not unless you touch it - // dispatch(setConnectionArgs(connectionSlice.getInitialState().connectionArgs)); - setIsResume(false); - }; - - return ( - - - - - - - - {name} - - - {description} - - - - - - - ) - } - - useEffect(() => { - console.log("isNewInstallation changed:", isNewInstallation); - console.log("newInstallationClicked:", newInstallationClicked); - }); + dispatch(setIsNewInstallation(true)); + dispatch(setConnectionStatus(false)); + dispatch(setResumeProgress(false)); + newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; + } else if (id === "dry run") { + newInstallationArgs = {...newInstallationArgs, dryRunMode: true}; + } + handleCardClick(newInstallationArgs); + }; useEffect(() => { eventDispatcher.on('saveAndCloseEvent', () => setShowWizard(false)); @@ -196,7 +161,6 @@ const Home = () => { const connectionStore = res.details; if (connectionStore["connection-type"] === 'ftp') { const jobStatement = connectionStore['ftp-details'].jobStatement.trim() || useAppSelector(selectInitJobStatement); - // console.log(JSON.stringify(connectionStore['ftp-details'],null,2)); const connectionArgs: IIpcConnectionArgs = { ...connectionStore["ftp-details"], password: "", @@ -214,9 +178,11 @@ const Home = () => { const flattenedData = flatten(lastActiveState); localStorage.setItem(prevInstallationKey, JSON.stringify(flattenedData)); dispatch(setIsNewInstallation(true)); + setPreviousInstallation(false); } else { const data: ActiveState = unflatten(JSON.parse(lastInstallation)); dispatch(setIsNewInstallation(!(data && data.lastActiveDate))); + setPreviousInstallation(!!(data && data.lastActiveDate)); } @@ -242,13 +208,22 @@ const Home = () => { } const confirmNewInstallation = (status: boolean) => { - setNewInstallation(status); + dispatch(setIsNewInstallation(status)) setNewInstallationClick(false); + setPreviousInstallation(!status); + + if(status) { + dispatch(setConnectionStatus(false)); + dispatch(setResumeProgress(false)); + newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; + handleCardClick(newInstallationArgs); + navigate('/wizard'); + } } return ( <> - { !isNewInstallation && newInstallationClicked && + { previousInstallation && newInstallationClicked && } @@ -261,10 +236,21 @@ const Home = () => { {!connectionStatus &&
}
- {cards.map(card => makeCard(card))} + {cards.map(card => ( + + ))}
- {!isNewInstallation &&
+ {previousInstallation &&
diff --git a/src/renderer/components/HomeCard.tsx b/src/renderer/components/HomeCardComponent.tsx similarity index 74% rename from src/renderer/components/HomeCard.tsx rename to src/renderer/components/HomeCardComponent.tsx index a63ce7d7..40a461f3 100644 --- a/src/renderer/components/HomeCard.tsx +++ b/src/renderer/components/HomeCardComponent.tsx @@ -1,8 +1,9 @@ import { Box, Card, CardContent, CardMedia, Typography, Tooltip, Button } from '@mui/material'; import { Link } from 'react-router-dom'; -const CardComponent = ({ id, name, description, link, media, previousInstallation, handleClick }:{id: string, name: string, description: string, link: string, media: any, previousInstallation: boolean, handleClick: any}) => { - return ( +const HomeCardComponent = ({ id, name, description, link, media, previousInstallation, handleClick }:{id: string, name: string, description: string, link: string, media: any, previousInstallation: boolean, handleClick: any}) => { + + return ( handleClick(id)}> @@ -23,4 +24,4 @@ const CardComponent = ({ id, name, description, link, media, previousInstallatio ); }; -export default CardComponent; +export default HomeCardComponent; diff --git a/src/types/interfaces.ts b/src/types/interfaces.ts index e7eecbae..0c84163a 100644 --- a/src/types/interfaces.ts +++ b/src/types/interfaces.ts @@ -45,3 +45,11 @@ export interface IResponse { errorMsg?: string; } +export interface ICard { + id: string, + name: string, + description: string, + link: string, + media: any, +} + From 028520b0b240e8c0364a353be1b4fc1ffd133eb8 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 17:21:47 +0530 Subject: [PATCH 20/23] Home comp refactoring --- src/renderer/components/Home.tsx | 42 ++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 19edfe92..760c9359 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -36,6 +36,7 @@ import { ICard } from '../../types/interfaces'; // REVIEW: Get rid of routing +// Cards Data const cards: Array = [ { id: "install", @@ -53,40 +54,49 @@ const cards: Array = [ } ] +// Constants const prevInstallationKey = "prev_installation"; const lastActiveState: ActiveState = { activeStepIndex: 0, isSubStep: false, activeSubStepIndex: 0, }; +const defaultTooltip: string = "Resume"; + +// Helper Functions +const getNewInstallationArgs = (id: string, currentArgs: InstallationArgs) => { + return id === "install" + ? { ...currentArgs, dryRunMode: false } + : { ...currentArgs, dryRunMode: true }; +}; const Home = () => { const dispatch = useAppDispatch(); const navigate = useNavigate(); const connectionStatus = useAppSelector(selectConnectionStatus); - const [showWizard, setShowWizard] = useState(false); - const [localYaml, setLocalYaml] = useState(useAppSelector(selectYaml)); const schema = useAppSelector(selectSchema); - - const { lastActiveDate } = getPreviousInstallation(); - const stages: any = []; - const defaultTooltip: string = "Resume"; const resumeTooltip = connectionStatus ? defaultTooltip : `Validate Credentials & ${defaultTooltip}`; - const [showPasswordDialog, setShowPasswordDialog] = useState(false); - const isNewInstallation = useAppSelector(selectIsNewInstallation); + let newInstallationArgs = installationSlice.getInitialState().installationArgs; + const { lastActiveDate } = getPreviousInstallation(); + + const [showWizard, setShowWizard] = useState(false); + const [localYaml, setLocalYaml] = useState(useAppSelector(selectYaml)); + const [showPasswordDialog, setShowPasswordDialog] = useState(false); const [newInstallationClicked, setNewInstallationClick] = useState(false); const [previousInstallation, setPreviousInstallation] = useState(false); - let newInstallationArgs = installationSlice.getInitialState().installationArgs; const handleCardClick = (newInstallationArgs: InstallationArgs) => { dispatch(setYaml(FALLBACK_YAML)); dispatch(setInstallationArgs(newInstallationArgs)); + window.electron.ipcRenderer.setConfigByKeyNoValidate("installationArgs", newInstallationArgs); - setLocalYaml(FALLBACK_YAML); window.electron.ipcRenderer.setConfig(FALLBACK_YAML); + + setLocalYaml(FALLBACK_YAML); + // TODO: Ideally, reset connectionArgs too // but this introduces bug with "self certificate chain" it's the checkbox, it looks checked but // it acts like it's not unless you touch it @@ -95,6 +105,9 @@ const Home = () => { const handleClick = (id: string) => { + const initialInstallationArgs = installationSlice.getInitialState().installationArgs; + const newInstallationArgs = getNewInstallationArgs(id, initialInstallationArgs); + if (id === "install") { setNewInstallationClick(true); if(previousInstallation) { @@ -103,9 +116,6 @@ const Home = () => { dispatch(setIsNewInstallation(true)); dispatch(setConnectionStatus(false)); dispatch(setResumeProgress(false)); - newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; - } else if (id === "dry run") { - newInstallationArgs = {...newInstallationArgs, dryRunMode: true}; } handleCardClick(newInstallationArgs); }; @@ -154,9 +164,6 @@ const Home = () => { } }); - window.electron.ipcRenderer.setStandardOutput(DEF_NO_OUTPUT).then((res: any) => { - }) - window.electron.ipcRenderer.findPreviousInstallations().then((res: IResponse) => { const connectionStore = res.details; if (connectionStore["connection-type"] === 'ftp') { @@ -215,8 +222,7 @@ const Home = () => { if(status) { dispatch(setConnectionStatus(false)); dispatch(setResumeProgress(false)); - newInstallationArgs = {...newInstallationArgs, dryRunMode: false}; - handleCardClick(newInstallationArgs); + handleCardClick({ ...installationSlice.getInitialState().installationArgs, dryRunMode: false }); navigate('/wizard'); } } From 1334659f353ae08294404f966f5c5edc59a61de3 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 17:37:34 +0530 Subject: [PATCH 21/23] Code organizing --- src/renderer/components/Home.tsx | 68 +++++++++---------- src/renderer/components/HomeCardComponent.tsx | 4 +- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 760c9359..77d4db84 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -88,38 +88,6 @@ const Home = () => { const [newInstallationClicked, setNewInstallationClick] = useState(false); const [previousInstallation, setPreviousInstallation] = useState(false); - const handleCardClick = (newInstallationArgs: InstallationArgs) => { - dispatch(setYaml(FALLBACK_YAML)); - dispatch(setInstallationArgs(newInstallationArgs)); - - window.electron.ipcRenderer.setConfigByKeyNoValidate("installationArgs", newInstallationArgs); - window.electron.ipcRenderer.setConfig(FALLBACK_YAML); - - setLocalYaml(FALLBACK_YAML); - - // TODO: Ideally, reset connectionArgs too - // but this introduces bug with "self certificate chain" it's the checkbox, it looks checked but - // it acts like it's not unless you touch it - // dispatch(setConnectionArgs(connectionSlice.getInitialState().connectionArgs)); - } - - const handleClick = (id: string) => { - - const initialInstallationArgs = installationSlice.getInitialState().installationArgs; - const newInstallationArgs = getNewInstallationArgs(id, initialInstallationArgs); - - if (id === "install") { - setNewInstallationClick(true); - if(previousInstallation) { - return; - } - dispatch(setIsNewInstallation(true)); - dispatch(setConnectionStatus(false)); - dispatch(setResumeProgress(false)); - } - handleCardClick(newInstallationArgs); - }; - useEffect(() => { eventDispatcher.on('saveAndCloseEvent', () => setShowWizard(false)); @@ -214,6 +182,38 @@ const Home = () => { setShowWizard(status); } + const handleNewInstallation = (newInstallationArgs: InstallationArgs) => { + dispatch(setYaml(FALLBACK_YAML)); + dispatch(setInstallationArgs(newInstallationArgs)); + + window.electron.ipcRenderer.setConfigByKeyNoValidate("installationArgs", newInstallationArgs); + window.electron.ipcRenderer.setConfig(FALLBACK_YAML); + + setLocalYaml(FALLBACK_YAML); + + // TODO: Ideally, reset connectionArgs too + // but this introduces bug with "self certificate chain" it's the checkbox, it looks checked but + // it acts like it's not unless you touch it + // dispatch(setConnectionArgs(connectionSlice.getInitialState().connectionArgs)); + } + + const handleCardClick = (id: string) => { + + const initialInstallationArgs = installationSlice.getInitialState().installationArgs; + const newInstallationArgs = getNewInstallationArgs(id, initialInstallationArgs); + + if (id === "install") { + setNewInstallationClick(true); + if(previousInstallation) { + return; + } + dispatch(setIsNewInstallation(true)); + dispatch(setConnectionStatus(false)); + dispatch(setResumeProgress(false)); + } + handleNewInstallation(newInstallationArgs); + }; + const confirmNewInstallation = (status: boolean) => { dispatch(setIsNewInstallation(status)) setNewInstallationClick(false); @@ -222,7 +222,7 @@ const Home = () => { if(status) { dispatch(setConnectionStatus(false)); dispatch(setResumeProgress(false)); - handleCardClick({ ...installationSlice.getInitialState().installationArgs, dryRunMode: false }); + handleNewInstallation({ ...installationSlice.getInitialState().installationArgs, dryRunMode: false }); navigate('/wizard'); } } @@ -250,7 +250,7 @@ const Home = () => { description={card.description} link={card.link} media={card.media} - handleClick={handleClick} + handleCardClick={handleCardClick} previousInstallation={previousInstallation} /> ))} diff --git a/src/renderer/components/HomeCardComponent.tsx b/src/renderer/components/HomeCardComponent.tsx index 40a461f3..22355aff 100644 --- a/src/renderer/components/HomeCardComponent.tsx +++ b/src/renderer/components/HomeCardComponent.tsx @@ -1,11 +1,11 @@ import { Box, Card, CardContent, CardMedia, Typography, Tooltip, Button } from '@mui/material'; import { Link } from 'react-router-dom'; -const HomeCardComponent = ({ id, name, description, link, media, previousInstallation, handleClick }:{id: string, name: string, description: string, link: string, media: any, previousInstallation: boolean, handleClick: any}) => { +const HomeCardComponent = ({ id, name, description, link, media, previousInstallation, handleCardClick }:{id: string, name: string, description: string, link: string, media: any, previousInstallation: boolean, handleCardClick: any}) => { return ( - handleClick(id)}> + handleCardClick(id)}> From 43299da13d189c82677f912dd56ff1b8193aa882 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 18:37:01 +0530 Subject: [PATCH 22/23] Defining Routes --- src/Routes/RouteConstant.tsx | 5 +++++ src/renderer/components/Home.tsx | 15 ++++++++------- src/renderer/index.tsx | 5 +++-- 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 src/Routes/RouteConstant.tsx diff --git a/src/Routes/RouteConstant.tsx b/src/Routes/RouteConstant.tsx new file mode 100644 index 00000000..cd65fb01 --- /dev/null +++ b/src/Routes/RouteConstant.tsx @@ -0,0 +1,5 @@ +export const ROUTES = { + HOME: '/', + WIZARD: '/wizard', +}; + \ No newline at end of file diff --git a/src/renderer/components/Home.tsx b/src/renderer/components/Home.tsx index 77d4db84..0fe4644f 100644 --- a/src/renderer/components/Home.tsx +++ b/src/renderer/components/Home.tsx @@ -33,6 +33,7 @@ import PasswordDialog from './common/passwordDialog'; import WarningDialog from './Dialogs/WarningDialog'; import HomeCardComponent from './HomeCardComponent'; import { ICard } from '../../types/interfaces'; +import { ROUTES } from '../../Routes/RouteConstant'; // REVIEW: Get rid of routing @@ -79,7 +80,6 @@ const Home = () => { const stages: any = []; const resumeTooltip = connectionStatus ? defaultTooltip : `Validate Credentials & ${defaultTooltip}`; const isNewInstallation = useAppSelector(selectIsNewInstallation); - let newInstallationArgs = installationSlice.getInitialState().installationArgs; const { lastActiveDate } = getPreviousInstallation(); const [showWizard, setShowWizard] = useState(false); @@ -87,6 +87,7 @@ const Home = () => { const [showPasswordDialog, setShowPasswordDialog] = useState(false); const [newInstallationClicked, setNewInstallationClick] = useState(false); const [previousInstallation, setPreviousInstallation] = useState(false); + const [defaultYaml, setDefaultYaml] = useState(FALLBACK_YAML); useEffect(() => { eventDispatcher.on('saveAndCloseEvent', () => setShowWizard(false)); @@ -98,8 +99,9 @@ const Home = () => { window.electron.ipcRenderer.getConfig().then((res: IResponse) => { if (res.status) { dispatch(setYaml(res.details)); + setDefaultYaml(res.details); } else { - dispatch(setYaml(FALLBACK_YAML)); + dispatch(setYaml(defaultYaml)); } }) } @@ -160,7 +162,6 @@ const Home = () => { setPreviousInstallation(!!(data && data.lastActiveDate)); } - }); return () => { eventDispatcher.off('saveAndCloseEvent', () => setShowWizard(true)); @@ -183,13 +184,13 @@ const Home = () => { } const handleNewInstallation = (newInstallationArgs: InstallationArgs) => { - dispatch(setYaml(FALLBACK_YAML)); + dispatch(setYaml(defaultYaml)); dispatch(setInstallationArgs(newInstallationArgs)); window.electron.ipcRenderer.setConfigByKeyNoValidate("installationArgs", newInstallationArgs); - window.electron.ipcRenderer.setConfig(FALLBACK_YAML); + window.electron.ipcRenderer.setConfig(defaultYaml); - setLocalYaml(FALLBACK_YAML); + setLocalYaml(defaultYaml); // TODO: Ideally, reset connectionArgs too // but this introduces bug with "self certificate chain" it's the checkbox, it looks checked but @@ -223,7 +224,7 @@ const Home = () => { dispatch(setConnectionStatus(false)); dispatch(setResumeProgress(false)); handleNewInstallation({ ...installationSlice.getInitialState().installationArgs, dryRunMode: false }); - navigate('/wizard'); + navigate(ROUTES.WIZARD); } } diff --git a/src/renderer/index.tsx b/src/renderer/index.tsx index b8584af3..8f680680 100644 --- a/src/renderer/index.tsx +++ b/src/renderer/index.tsx @@ -19,6 +19,7 @@ import Wizard from './components/configuration-wizard/Wizard'; import Header from './components/Header'; import theme from './theme'; import { ThemeProvider } from '@mui/material/styles'; +import { ROUTES } from '../Routes/RouteConstant'; // TODO: Support of Zowe Configuration and Saved Installation actions. // - Add and use state saving @@ -34,9 +35,9 @@ function App() { - }> + }> } /> - }/> + }/> } /> From f4176a26fb6b91120ce4a8bb496ea9059bc52684 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Thu, 8 Aug 2024 19:00:49 +0530 Subject: [PATCH 23/23] Updating the warning dialog --- src/renderer/components/Dialogs/WarningDialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/Dialogs/WarningDialog.tsx b/src/renderer/components/Dialogs/WarningDialog.tsx index 95578343..49a6d7ea 100644 --- a/src/renderer/components/Dialogs/WarningDialog.tsx +++ b/src/renderer/components/Dialogs/WarningDialog.tsx @@ -28,10 +28,10 @@ const WarningDialog = ({onWarningDialogSubmit}: {onWarningDialogSubmit: any}) =>
Warning! - Hey There + Starting a new installation will erase the previously stored installation data from the wizard. Do you wish to proceed?
- +