Skip to content

Commit

Permalink
Merge branch 'v2.x/staging' of https://github.com/zowe/zen into tests…
Browse files Browse the repository at this point in the history
…/stateManagement
  • Loading branch information
sagaryadavs committed May 28, 2024
2 parents 0062b70 + 4c6230b commit e71dceb
Show file tree
Hide file tree
Showing 16 changed files with 473 additions and 18 deletions.
5 changes: 5 additions & 0 deletions src/actions/InstallActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export class InstallActions {
return this.strategy.initSecurity(connectionArgs, installationArgs, zoweConfig);
}

initVsam(connectionArgs: IIpcConnectionArgs,
installationArgs: {installationDir: string, installationType: string}, zoweConfig: object): Promise<IResponse> {
return this.strategy.initVsam(connectionArgs, installationArgs, zoweConfig);
}

apfAuth(connectionArgs: IIpcConnectionArgs,
installationArgs: {installationDir: string, installationType: string}, zoweConfig: object): Promise<IResponse> {
return this.strategy.apfAuth(connectionArgs, installationArgs, zoweConfig);
Expand Down
43 changes: 43 additions & 0 deletions src/actions/InstallationHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,49 @@ class Installation {
return {status: result.rc === 0, details: result.jobOutput}
}

public async initVsam(connectionArgs: IIpcConnectionArgs,
installationArgs: {installationDir: string, installationType: string}, zoweConfig: object): Promise<IResponse>{

// Initialize Progress Store For Vsam
ProgressStore.set('initVsam.writeYaml', false);
ProgressStore.set('initVsam.uploadYaml', false);
ProgressStore.set('initVsam.success', false);

console.log('writing current yaml to disk');
const filePath = path.join(app.getPath('temp'), 'zowe.yaml')
await fs.writeFile(filePath, stringify(zoweConfig), (err) => {
if (err) {
console.warn("Can't save configuration to zowe.yaml");
ProgressStore.set('initVsam.writeYaml', false);
return {status: false, details: `Can't save configuration to zowe.yaml`};
}
});
ProgressStore.set('initVsam.writeYaml', true);
console.log("uploading yaml...");
const uploadYaml = await this.uploadYaml(connectionArgs, installationArgs.installationDir);
if(!uploadYaml.status){
return {status: false, details: `Error uploading yaml configuration: ${uploadYaml.details}`};
}
ProgressStore.set('initVsam.uploadYaml', uploadYaml.status);
const script = `cd ${installationArgs.installationType === "smpe" ? installationArgs.installationDir + '/bin' : installationArgs.installationDir + '/runtime/bin'};./zwe init vsam -c ${installationArgs.installationDir}/zowe.yaml --allow-overwritten --update-config`;
const result = await new Script().run(connectionArgs, script);

let errorFound = false;
let errorMessage = '';
const errorPattern = /Error ZWE.*/;
for (const key in result.jobOutput) {
const match = result.jobOutput[key].match(errorPattern);
if (match) {
errorFound = true;
errorMessage = match[0];
break;
}
}

ProgressStore.set('initVsam.success', result.rc === 0 && !errorFound);
return {status: result.rc === 0 && !errorFound, details: result.jobOutput, error: errorFound, errorMsg: errorMessage }
}

async generateYamlFile(zoweConfig: object): Promise<IResponse> {
const filePath = path.join(app.getPath('temp'), 'zowe.yaml')
await fs.writeFile(filePath, stringify(zoweConfig), (err) => {
Expand Down
9 changes: 8 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,20 @@ const createWindow = (): void => {
return res;
});

ipcMain.handle('init-vsam', async (event, connectionArgs, installationArgs, zoweConfig) => {
const res = await installActions.initVsam(connectionArgs, installationArgs, zoweConfig);
return res;
});

ipcMain.handle('get-init-security-progress', async () => {
const res = ProgressStore.getAll()['initSecurity'];
return res;
});


ipcMain.handle('get-init-vsam-progress', async () => {
const res = ProgressStore.getAll()['initVsam'];
return res;
});

const menuBuilder = new MenuBuilder(mainWindow);
menuBuilder.buildMenu();
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/components/configuration-wizard/Wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { selectLoading } from './wizardSlice';
import { useAppSelector } from '../../hooks';
import InitApfAuth from '../stages/InitApfAuth';
import Networking from '../stages/Networking';
import Vsam from '../stages/Vsam';
import LaunchConfig from '../stages/LaunchConfig';

export const stages = [
Expand All @@ -34,8 +35,9 @@ export const stages = [
{id: 1, label: 'Networking', component: <Networking/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to APF Auth Setup', statusKey: 'networkingStatus'},
{id: 2, label: 'APF Auth', component: <InitApfAuth/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to Security Setup', statusKey: 'apfAuthStatus'},
{id: 3, label: 'Security', component: <Security/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to Certificates Setup', statusKey: 'securityStatus'},
{id: 4, label: 'Certificates', component: <Certificates/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to Launch Setup', statusKey: 'certificateStatus'},
{id: 5, label: 'Launch Config', component: <LaunchConfig/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to Instance Setup', statusKey: 'launchConfigStatus'},
{id: 4, label: 'Certificates', component: <Certificates/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to Vsam Setup', statusKey: 'certificateStatus'},
{id: 5, label: 'Vsam', component: <Vsam/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to Launch Setup', statusKey: 'vsamStatus'},
{id: 6, label: 'Launch Config', component: <LaunchConfig/>, hasJCL: true, isSkippable: true, isSkipped: false, hasYaml: true, hasOutput: true, steps: 1, nextButton: 'Continue to Instance Setup', statusKey: 'launchConfigStatus'},
], nextButton: 'Review', statusKey: 'initializationStatus'},
{id: 4, label: 'Review Installation', component: <ReviewInstallation/>, hasJCL: false, isSkippable: false, hasOutput: false, steps: 1, nextButton: 'Finish Installation', statusKey: 'reviewStatus'},
{id: 5, label: 'Finish Installation', component: <FinishInstallation/>, hasJCL: false, isSkippable: false, isSkipped: false, hasOutput: false, steps: 1, statusKey: 'finishStatus'},
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/components/configuration-wizard/wizardSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { RootState } from '../../store';
import { IResponse } from '../../../types/interfaces';

interface WizardState {
loading: boolean;
Expand Down Expand Up @@ -39,6 +40,9 @@ export const wizardSlice = createSlice({
},
setYaml: (state, action: PayloadAction<any>) => {
state.yaml = action.payload;
window.electron.ipcRenderer.setConfig(action.payload).then((res: IResponse) => {
// Response
});
},
setSchema: (state, action: PayloadAction<any>) => {
state.schema = action.payload;
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/stages/Certificates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ const Certificates = () => {
}

if(showProgress) {
console.log('security: if progress');
const nextPosition = document.getElementById('start-certificate-progress');
nextPosition?.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
Expand Down Expand Up @@ -281,7 +280,7 @@ const Certificates = () => {
</React.Fragment>
}
</Box>
<Box sx={{ height: showProgress ? '30vh' : 'auto', minHeight: showProgress ? '30vh' : '10vh' }} id="certificate-progress"></Box>
<Box sx={{ height: showProgress ? '40vh' : 'auto', minHeight: showProgress ? '40vh' : '10vh' }} id="certificate-progress"></Box>
</ContainerCard>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/stages/InitApfAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const InitApfAuth = () => {
</React.Fragment>
}
</Box>
<Box sx={{ height: showProgress ? '55vh' : 'auto', minHeight: '30vh' }} id="apf-progress"></Box>
<Box sx={{ height: showProgress ? '60vh' : 'auto', minHeight: '60vh' }} id="apf-progress"></Box>
</ContainerCard>
</div>

Expand Down
11 changes: 4 additions & 7 deletions src/renderer/components/stages/Planning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ const Planning = () => {
setStep(0);
}

const formChangeHandler = (key?: string, value?: string, installationArg?: string) => {
const formChangeHandler = (key?: string, value?: any, installationArg?: string) => {
setIsLocationsUpdated(true);
setPlanningStatus(false);
setLocationsValidated(false);
Expand Down Expand Up @@ -428,11 +428,8 @@ Please customize the job statement below to match your system requirements.
</FormControl>
</Box>
{step > 0
? <Box sx={{height: step === 1 ? 'calc(100vh - 272px)' : 'auto', p: '36px 0'}} onBlur={async (e) => { dispatch(setYaml((await window.electron.ipcRenderer.getConfig()).details.config ?? localYaml)) }} onChange={(e) => {
dispatch(setYaml(localYaml));
formChangeHandler();
}}
>
?
<Box sx={{height: step === 1 ? 'calc(100vh - 272px)' : 'auto', p: '36px 0'}} >
<Typography id="position-1" sx={{ mb: 2, whiteSpace: 'pre-wrap' }} color="text.secondary">
{`Now let's define some properties like z/OS Unix locations, identifiers, and z/OSMF details (optional).`}
</Typography>
Expand Down Expand Up @@ -682,7 +679,7 @@ Please customize the job statement below to match your system requirements.
type="number"
value={localYaml?.zOSMF?.port || installationArgs.zosmfPort}
onChange={(e) => {
formChangeHandler("zOSMF.port", e.target.value, "zosmfPort");
formChangeHandler("zOSMF.port", Number(e.target.value), "zosmfPort");
window.electron.ipcRenderer.setConfigByKey('zOSMF.port', Number(e.target.value)).then((res: any) => {
// console.log('updated zowe.zOSMF.port')
})
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/stages/ReviewInstallation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const ReviewInstallation = () => {
completeProgress.apfAuthStatus,
completeProgress.securityStatus,
completeProgress.certificateStatus,
completeProgress.vsamStatus,
completeProgress.launchConfigStatus
];

Expand Down
4 changes: 1 addition & 3 deletions src/renderer/components/stages/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const Security = () => {
nextPosition?.scrollIntoView({behavior: 'smooth'});
}


updateProgress(getProgress('securityStatus'));
setInit(true);

Expand Down Expand Up @@ -118,7 +117,6 @@ const Security = () => {
}, 3000);

if(showProgress) {
console.log('security: if progress');
const nextPosition = document.getElementById('start-security-progress');
nextPosition?.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
Expand Down Expand Up @@ -248,7 +246,7 @@ const Security = () => {
}
</Box>
</Box>
<Box sx={{ height: showProgress ? '105vh' : 'auto', minHeight: showProgress ? '105vh' : '10vh' }} id="security-progress"></Box>
<Box sx={{ height: showProgress ? '125vh' : 'auto', minHeight: showProgress ? '125vh' : '10vh' }} id="security-progress"></Box>

</ContainerCard>
</div>
Expand Down
Loading

0 comments on commit e71dceb

Please sign in to comment.