Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Refactor #180

Open
wants to merge 138 commits into
base: v2.x/staging
Choose a base branch
from
Open

Major Refactor #180

wants to merge 138 commits into from

Conversation

timgerstel
Copy link
Contributor

@timgerstel timgerstel commented Jun 12, 2024

  1. Make sure yaml and schema are ALWAYS set
  2. Change the description of smpe on the "Installation Type" stage as per @struga0258 's suggestion
  3. Wrap all global variables in components in useState() to reduce memory cost *Edit: this is still here but it was actually useless lol
  4. Fix scrolling on most stages
  5. Fix Initialization stage status not updating when all substeps are complete
  6. Add popup messages for upload yaml button on Launch Config/Networking stages
  7. Make editor use entire Zowe schema
  8. Use more Constants.tsx
  9. Add ability to retrieve example-zowe.yaml and JSON schemas when using SMPE mode
  10. Remove duplicate and unused vars
  11. Fix cursor jumping to end of port input on networking stage
  12. "Skip" on Unpax stage now fetches example-zowe.yaml and schemas
  13. Integrate @skurnevich's method of downloading example-zowe.yaml and schemas instead of parsing cat commands🐈
  14. Fix upload not working
  15. Fix improper merging of example-zowe.yaml and current config thanks to @skurnevich deep merge method
  16. Remove unused imports
  17. Reduce duplication
  18. Remove unused or unnecessary function args
  19. Fix schema errors
  20. Fix difference between smpe install dir and download/upload. Download/upload will no longer unpax to /runtime
  21. Fix makeDir infinite loop on planning stage with invalid dirs
  22. Fix yaml encoding so that zwe start can be run
  23. Make editor wider
  24. Fix certificates stage resetting zowe.setup.certificate values when changing zowe.verifyCertificates
  25. Increase editor width and height
  26. Probably more i forgot

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Change in a documentation
  • Refactor the code
  • Chore, repository cleanup, updates the dependencies.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

PR Checklist

Please delete options that are not relevant.

  • If the changes in this PR are meant for the next release / mainline, this PR targets a "staging" branch.
  • My code follows the style guidelines of this project (see: Contributing guideline)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes
  • video or image is included if visual changes are made
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works, or describe a test method below

Testing

Further comments

Signed-off-by: Timothy Gerstel <[email protected]>
…e editor was making things too tedious given the deadline

Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
…, and installation args are now set on the Home component. Wrap naked component global vars in useState calls. Fix auto scrolling when a stage has been complete

Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
…perly, remove unneeded ipcRenderer hooks

Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
@skurnevich
Copy link
Collaborator

skurnevich commented Jun 13, 2024

Does not work for me:

Local pax file uploading fails
Screenshot 2024-06-13 at 14 34 53

While downloading pax fails on schema parsing

14:43:42.429 › error setting schema from pax: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)

For the last one i have created the PR 179 to replace cat command output parsing with files downloading.
You can merge it first, or incorporate changes into this PR. The factual change is smaller than it looks, you just need to replace readExampleYamlAndSchema function and remove parseExampleYamlFromPax blocks as downloaded yaml and json files are ready to use

@skurnevich
Copy link
Collaborator

Hi @timgerstel is this PR ready for review/merge or would you like to add more changes?

@DivergentEuropeans
Copy link
Member

Created PR: #194

DivergentEuropeans and others added 19 commits June 24, 2024 15:19
Revert create recursive dirs + add edgecase
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
…t longer attempt to create these

Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Leanid Astrakou <[email protected]>
Reset counter properly + don't forget the current char
Signed-off-by: Leanid Astrakou <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
ipcMain.handle('download-unpax', async (event, connectionArgs, installationArgs, version, zoweConfig) => {
const res = await installActions.downloadUnpax(connectionArgs, installationArgs, version, zoweConfig);
ipcMain.handle('get-yaml-schema', async (event, connectionArgs, installationArgs) => {
const res = await installActions.smpeGetExampleYamlAndSchemas(connectionArgs, installationArgs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be called "getExampleYamlAndSchemas"

I only see this used in 2 places, 1 in Stepper which is conditional to not SMPE and 2 in
Unpax step which is also not SMPE

<Card id={`card-${id}`} square={true} >
<Link key={`link-${id}`} to={link} >
<Box sx={{ width: '40vw', height: '40vh'}} onClick={(e) => {
const flattenedData = flatten(lastActiveState);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastActiveState is already a flat object with no nested properties, at a quick glance, don't see it set anywhere. Is this essential?

@@ -109,6 +116,42 @@ const Home = () => {
eventDispatcher.on('saveAndCloseEvent', () => setShowWizard(false));



//Home is the first screen the user will always see 100% of the time. Therefore, we will call the loading of the configs, schemas, and installation args here and set them to the redux memory states
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Home.tsx change is v satisfying

// To validate the javascript object against the schema
const isValid = validate(jsonData);
setIsSchemaValid(isValid);
setIsSchemaValid(!schemaValidate.errors);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N i c e

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that all that adjv stuff worked

const STAGE_ID = getStageDetails(stageLabel).id;
const SUB_STAGES = !!getStageDetails(stageLabel).subStages;
const SUB_STAGE_ID = SUB_STAGES ? getSubStageDetails(STAGE_ID, subStageLabel).id : 0;
const [STAGE_ID] = useState(getStageDetails(INIT_STAGE_LABEL).id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it, but I think @timgerstel might be right here. Not that you're wrong @skurnevich , I think both things are true: using const with useState introduces a small overhead. So it would be like:
For constants and simple values that do not involve expensive computation, use them directly without useState.
For values that involve expensive computation or need to persist across renders, use useState.

So something like this might be max/minning:

const Certificates = () => {
  const theme = useState(createTheme())[0]; // Expensive
  const stageLabel = 'Initialization';
  const STAGE_ID = useState(getStageDetails(INIT_STAGE_LABEL).id)[0]; // Potentially expensive?
};

"minimum": 0,
"maximum": 65535,
"description": "Port number of how you access Zowe APIML Gateway from your local computer."
const schema: any = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if BASE_SCHEMA is AJV "fixed", can't we remove the schemas in Networking + Launch Config and use BASE_SCHEMA? Or lmk I might be missing something

}
return null;
})}
</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole chunk is difficult to rea dfor me, but it looks mostly like a "code move" so it seems alright

} else {
console.warn('zwe init security failed', err?.toString()); // toString() throws run-time error on undefined or null
}
window.electron.ipcRenderer.setStandardOutput(`zwe init security failed: ${typeof err === "string" ? err : err.toString()}`).then((res: any) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this was tested, then you want to add:
alertEmitter.emit('showAlert', 'Please view Job Output for more details', 'error');

// Some parts of Zen pass the response as a string directly into the object
if (res.status == false && typeof res.details == "string") {
res.details = { 3: res.details };
}
if (res?.details && res.details[3] && res.details[3].indexOf(JCL_UNIX_SCRIPT_OK) == -1) { // This check means we got an error during zwe install
if (!res.status && res?.details && res.details[3] && res.details[3].indexOf(JCL_UNIX_SCRIPT_OK) == -1) { // This check means we got an error during zwe install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good addition. I remember cases where res.status = 0, yet the command failed. That was the whole point of using 'JCL_UNIX_SCRIPT_OK' as a better source of truth over status

setDownloadUnpaxProgress(downloadUnpaxStatus);
dispatch(setNextStepEnabled(false));
window.electron.ipcRenderer.fetchExampleYamlBtnOnClick(connectionArgs, installationArgs).then((res: IResponse) => {
if(!res.status){ //errors during runInstallation()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same point here about unreliability of res.status

Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Signed-off-by: Timothy Gerstel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Change Requested
Development

Successfully merging this pull request may close these issues.

None yet

3 participants