in src/explorer.ts [463:516]
async switchProfile() {
const quickPick = vscode.window.createQuickPick();
quickPick.placeholder = "Select a profile";
const items = [];
const profileInstance = await getProfileInfoInstance();
const config = profileInstance?.getProfileInfo();
const profiles = config?.profiles;
for (const profile of profiles) {
let label = `$(account) ${profile.name}`;
if (profile.name === config.current) {
label = `$(account) ${profile.name} $(check)`;
}
items.push({
profile: profile.name,
label: label,
detail: `mode: ${profile.mode}, default region: ${profile.region_id}`,
});
}
items.push({
label: I18N.src.explorer.newSKProfile,
iconPath: new vscode.ThemeIcon("add"),
id: "ADD_NEW_PROFILE",
});
quickPick.items = items;
quickPick.onDidAccept(async () => {
if ((quickPick.selectedItems[0] as any)?.profile) {
vscode.window.showInformationMessage(
`Switching profile to ${(quickPick.selectedItems[0] as any).profile}, done`,
);
config.current = (quickPick.selectedItems[0] as any).profile;
await profileInstance.saveProfiles(config);
await getProfileInfoInstance();
vscode.commands.executeCommand("alicloud.api.restart");
quickPick.dispose();
} else if ((quickPick.selectedItems[0] as any)?.id === "ADD_NEW_PROFILE") {
vscode.commands.executeCommand("alicloud.api.openDocument", {
name: I18N.src.explorer.configAKProfile,
specName: "profile",
pageType: "profile",
column: vscode.ViewColumn.Beside,
});
}
});
quickPick.show();
}