-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat: add support for deleting profiles #689
Conversation
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: jellypuno <jessielaine.punongbayan@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
…nsion-for-zowe into delete-profiles
Signed-off-by: jellypuno <jessielaine.punongbayan@broadcom.com>
Codecov Report
@@ Coverage Diff @@
## master #689 +/- ##
==========================================
- Coverage 92.17% 90.22% -1.95%
==========================================
Files 47 44 -3
Lines 4764 3847 -917
Branches 1003 658 -345
==========================================
- Hits 4391 3471 -920
- Misses 370 373 +3
Partials 3 3
Continue to review full report at Codecov.
|
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: jellypuno <jessielaine.punongbayan@broadcom.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat function and made a lot of sense changing the remove to hide. Can you just check that settings.json is being cleaned up completely please?.
I noticed some traces of a deleted profile in the sessions and recall section but the views were fine. Thank you.
Yes, works great for me :) Except for what Colin mentioned ofc |
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Heyoo, 3 things V:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Richelle this all seems to working neatly now. Thank you for cleaning up the recall section. The sessions that were left over was a throwback to not having cleaned up some old sessions that had been left behind.
It may be worth quickly running npm run vscode:prepublish and committing Package.json and the i18n file get changed slightly. I don't know if the linter on the pipeline would flag it otherwise
@crawr I am just testing this branch and I am not able to list files in a filter. After a long wait I get a 500 error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made some stylistic comments to make stuff easier to read. When the problem with fetching datasets is fixed, will be happy to approve. If you want some help with the debugging, plese, let me know!
src/Profiles.ts
Outdated
|
||
// Delete from Data Set Favorites | ||
datasetTree.mFavorites.forEach((ses) => { | ||
const findNode = ses.label.substring(1, ses.label.indexOf("]")).trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like trouble going forward 😁 But I do not know how to do it better at this point.
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Thanks for the reviews!
This looks like a regression in the handling of the Profile loader. I fixed it so that the extension will still load even if the default profile is not set. An informational message will appear instead.
Thanks for the tip, I ran the script and included the i18n file as a result.
I tested listing with my just my HLQ using regular DS filter search and |
@VitGottwald Are you sure? I just tried it now, I am not experiencing this error. |
Thanks @jellypuno . Looks like it was a problem on my end. After recompiling and deleting/adding profile from CLI I am not getting the error anymore. 👍 |
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
Signed-off-by: Richelle Anne Craw <richelleanne.craw@broadcom.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Demo'ed it today in Zowe Playback. Both commands works great!
@@ -153,6 +153,16 @@ export async function activate(context: vscode.ExtensionContext): Promise<ZoweEx | |||
} | |||
}); | |||
} | |||
if (datasetProvider || ussFileProvider || jobsProvider) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not worth adding this so close to v1.5 but the three trees have a superclass ZoweTreeProvider so you could have ZoweTreeProvider.
No action required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this functionality Richelle
src/Profiles.ts
Outdated
// Delete from USS Sessions list | ||
const ussSetting: any = {...vscode.workspace.getConfiguration().get(this.ussSchema)}; | ||
let sessUSS: string[] = ussSetting.sessions; | ||
let faveUSS: string[] = ussSetting.favorites; | ||
sessUSS = sessUSS.filter( (element) => { | ||
return element.trim() !== deleteLabel; | ||
}); | ||
faveUSS = faveUSS.filter( (element) => { | ||
return element.substring(1, element.indexOf("]")).trim() !== deleteLabel; | ||
}); | ||
ussSetting.sessions = sessUSS; | ||
ussSetting.favorites = faveUSS; | ||
await vscode.workspace.getConfiguration().update(this.ussSchema, ussSetting, vscode.ConfigurationTarget.Global); | ||
|
||
// Delete from Jobs Sessions list | ||
const jobsSetting: any = {...vscode.workspace.getConfiguration().get(this.jobsSchema)}; | ||
let sessJobs: string[] = jobsSetting.sessions; | ||
let faveJobs: string[] = jobsSetting.favorites; | ||
sessJobs = sessJobs.filter( (element) => { | ||
return element.trim() !== deleteLabel; | ||
}); | ||
faveJobs = faveJobs.filter( (element) => { | ||
return element.substring(1, element.indexOf("]")).trim() !== deleteLabel; | ||
}); | ||
jobsSetting.sessions = sessJobs; | ||
jobsSetting.favorites = faveJobs; | ||
await vscode.workspace.getConfiguration().update(this.jobsSchema, jobsSetting, vscode.ConfigurationTarget.Global); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a lot of knowledge duplication here. How about this:
// Delete from USS Sessions list | |
const ussSetting: any = {...vscode.workspace.getConfiguration().get(this.ussSchema)}; | |
let sessUSS: string[] = ussSetting.sessions; | |
let faveUSS: string[] = ussSetting.favorites; | |
sessUSS = sessUSS.filter( (element) => { | |
return element.trim() !== deleteLabel; | |
}); | |
faveUSS = faveUSS.filter( (element) => { | |
return element.substring(1, element.indexOf("]")).trim() !== deleteLabel; | |
}); | |
ussSetting.sessions = sessUSS; | |
ussSetting.favorites = faveUSS; | |
await vscode.workspace.getConfiguration().update(this.ussSchema, ussSetting, vscode.ConfigurationTarget.Global); | |
// Delete from Jobs Sessions list | |
const jobsSetting: any = {...vscode.workspace.getConfiguration().get(this.jobsSchema)}; | |
let sessJobs: string[] = jobsSetting.sessions; | |
let faveJobs: string[] = jobsSetting.favorites; | |
sessJobs = sessJobs.filter( (element) => { | |
return element.trim() !== deleteLabel; | |
}); | |
faveJobs = faveJobs.filter( (element) => { | |
return element.substring(1, element.indexOf("]")).trim() !== deleteLabel; | |
}); | |
jobsSetting.sessions = sessJobs; | |
jobsSetting.favorites = faveJobs; | |
await vscode.workspace.getConfiguration().update(this.jobsSchema, jobsSetting, vscode.ConfigurationTarget.Global); | |
// Delete from Session List | |
const isNotDeletedSession = (element) => element.trim() !== deleteLabel; | |
const isNotDeletedFavorite = (element) => | |
element.substring(1, element.indexOf("]")).trim() !== deleteLabel; | |
const deleteFromSessionList = async (schema) => { | |
const setting: { | |
settings: string[]; | |
favorites: string[]; | |
} = vscode.workspace.getConfiguration().get(schema); | |
await vscode.workspace.getConfiguration().update( | |
schema, | |
{ | |
...setting, | |
session: setting.favorites.filter(isNotDeletedSession), | |
favorites: setting.favorites.filter(isNotDeletedFavorite), | |
}, | |
vscode.ConfigurationTarget.Global | |
); | |
}; | |
deleteFromSessionList(this.dsSchema); | |
deleteFromSessionList(this.ussSchema); | |
deleteFromSessionList(this.jobsSchema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is room to extract pieces of knowledge like checking if an item is to be removed into functions and then reusing it. That would make the code more concise and "dry". But I think that is not a reason to block this PR.
Great job identifying all the places that need to be updated for a delete!
…-zowe into delete-profiles Signed-off-by: zFernand0 <fernando.rijocedeno@broadcom.com> # Conflicts: # __mocks__/@zowe/imperative.ts # __tests__/__unit__/Profiles.unit.test.ts # __tests__/__unit__/extension.unit.test.ts # src/Profiles.ts
a886ca2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Initially was getting a few timeouts on jest hooks. Maybe we should increment the default timeout on before/after hooks if we expect to perform some zowe action on them?
It had 2 or more approvals before resolving merge conflicts. |
Addresses:
Fix #332 - Support deleting a profile
Details:
deleteProfile()
under Profiles which can be executed via context menu and command paletteCliProfileManager
to perform the deleteRelease Notes:
Milestone: v1.5
Changelog: Provide ability to delete profiles via the explorer.