Skip to content

Commit

Permalink
Merge branch 'main' into profile-management
Browse files Browse the repository at this point in the history
  • Loading branch information
JillieBeanSim authored Oct 2, 2023
2 parents f4b0e0c + 4b30095 commit ccc9223
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
### New features and enhancements

- Added optional `getTag` function to `ZoweExplorerAPI.IUss` for getting the tag of a file on USS.
- Added new API {ZE Extender MetaData} to allow extenders to have the metadata of registered extenders to aid in team configuration file creation from a view that isn't Zowe Explorer's. [#2394](https://github.com/zowe/vscode-extension-for-zowe/issues/2394)

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ const baseProfileWithToken = {
tokenValue: "baseToken",
},
};
const profilemetadata: zowe.imperative.ICommandProfileTypeConfiguration[] = [
{
type: "acme",
schema: {
type: "object",
title: "acme profile1",
description: "A profile to execute commands",
properties: {},
},
},
];

function createProfInfoMock(profiles: Partial<zowe.imperative.IProfileLoaded>[]): zowe.imperative.ProfileInfo {
return {
Expand Down Expand Up @@ -153,6 +164,20 @@ describe("ProfilesCache", () => {
expect(Object.keys(keyring).length).toBe(5);
});

it("addToConfigArray should set the profileTypeConfigurations array", () => {
const profCache = new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger);
profilemetadata.push(profilemetadata[0]);
profCache.addToConfigArray(profilemetadata);
expect(profCache.profileTypeConfigurations).toEqual(profilemetadata.filter((a, index) => index == 0));
});

it("getConfigArray should return the data of profileTypeConfigurations Array", () => {
const profCache = new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger);
profCache.profileTypeConfigurations = profilemetadata;
const res = profCache.getConfigArray();
expect(res).toEqual(profilemetadata);
});

it("loadNamedProfile should find profiles by name and type", () => {
const profCache = new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger);
profCache.allProfiles = [lpar1Profile as zowe.imperative.IProfileLoaded, zftpProfile as zowe.imperative.IProfileLoaded];
Expand Down
16 changes: 16 additions & 0 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class ProfilesCache {
public profilesForValidation: IProfileValidation[] = [];
public profilesValidationSetting: IValidationSetting[] = [];
public allProfiles: zowe.imperative.IProfileLoaded[] = [];
public profileTypeConfigurations: zowe.imperative.ICommandProfileTypeConfiguration[] = [];
protected allTypes: string[];
protected allExternalTypes = new Set<string>();
protected profilesByType = new Map<string, zowe.imperative.IProfileLoaded[]>();
Expand All @@ -83,6 +84,21 @@ export class ProfilesCache {
return require("@zowe/secrets-for-zowe-sdk").keyring;
}

public addToConfigArray(extendermetadata: zowe.imperative.ICommandProfileTypeConfiguration[]): void {
extendermetadata?.forEach((item) => {
const index = this.profileTypeConfigurations.findIndex((ele) => ele.type == item.type);
if (index !== -1) {
this.profileTypeConfigurations[index] = item;
} else {
this.profileTypeConfigurations.push(item);
}
});
}

public getConfigArray(): zowe.imperative.ICommandProfileTypeConfiguration[] {
return this.profileTypeConfigurations;
}

public async getProfileInfo(_envTheia = false): Promise<zowe.imperative.ProfileInfo> {
const mProfileInfo = new zowe.imperative.ProfileInfo("zowe", {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Added "Sort Jobs" feature for job nodes in Jobs tree view. [#2257](https://github.com/zowe/vscode-extension-for-zowe/issues/2251)
- Introduce a new user interface for managing profiles via right-click action "Manage Profile".
- Added new edit feature on `Edit Attributes` view for changing file tags on USS [#2113](https://github.com/zowe/vscode-extension-for-zowe/issues/2113)
- Added new API {ZE Extender MetaData} to allow extenders to have the metadata of registered extenders to aid in team configuration file creation from a view that isn't Zowe Explorer's. [#2394](https://github.com/zowe/vscode-extension-for-zowe/issues/2394)

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ describe("ZoweExplorerExtender unit tests", () => {
value: jest.fn(),
configurable: true,
});

Object.defineProperty(Profiles.getInstance(), "addToConfigArray", {
value: jest.fn(),
configurable: true,
});
return newMocks;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/zowe-explorer/src/Profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,12 @@ export class Profiles extends ProfilesCache {

const impConfig: zowe.imperative.IImperativeConfig = zowe.getImperativeConfig();
const knownCliConfig: zowe.imperative.ICommandProfileTypeConfiguration[] = impConfig.profiles;
// add extenders config info from global variable
globals.EXTENDER_CONFIG.forEach((item) => {

const extenderinfo = this.getConfigArray();
extenderinfo.forEach((item) => {
knownCliConfig.push(item);
});

knownCliConfig.push(impConfig.baseProfile);
config.setSchema(zowe.imperative.ConfigSchema.buildSchema(knownCliConfig));

Expand Down
6 changes: 2 additions & 4 deletions packages/zowe-explorer/src/ZoweExplorerExtender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ export class ZoweExplorerExtender implements ZoweExplorerApi.IApiExplorerExtende
});
}
}
// add extender config info to global variable
profileTypeConfigurations?.forEach((item) => {
globals.EXTENDER_CONFIG.push(item);
});
if (profileTypeConfigurations !== undefined) Profiles.getInstance().addToConfigArray(profileTypeConfigurations);

// sequentially reload the internal profiles cache to satisfy all the newly added profile types
await ZoweExplorerExtender.refreshProfilesQueue.add(async (): Promise<void> => {
await Profiles.getInstance().refresh(ZoweExplorerApiRegister.getInstance());
Expand Down

0 comments on commit ccc9223

Please sign in to comment.