Skip to content

Commit

Permalink
feat: add wiki guide for API Catalog (#272)
Browse files Browse the repository at this point in the history
* feat: add wiki doc for learn api catalog

* feat: update

* feat: update

* feat: update

* feat: add wiki to tree item
  • Loading branch information
wenytang-ms authored Oct 22, 2024
1 parent 1721269 commit a328802
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@
"title": "%azure-api-center.commands.apiCenterWorkspace.removeApis.title%",
"icon": "$(close)",
"category": "Azure API Center"
},
{
"command": "azure-api-center.apiCenterWorkspace.learnApiCatalog",
"title": "%azure-api-center.commands.apiCenterWorkspace.learnApiCatalog.title%",
"icon": "$(info)",
"category": "Azure API Center"
}
],
"views": {
Expand Down Expand Up @@ -221,6 +227,11 @@
"when": "view == apiCenterTreeView",
"group": "navigation"
},
{
"command": "azure-api-center.apiCenterWorkspace.learnApiCatalog",
"when": "view == apiCenterWorkspace",
"group": "navigation"
},
{
"command": "azure-api-center.apiCenterWorkspace.addApis",
"when": "view == apiCenterWorkspace",
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
"azure-api-center.views.api-center-treeview.controlplane.title": "Azure API Center",
"azure-api-center.views.api-center-treeview.dataplane.title": "Platform API Catalog",
"azure-api-center.commands.apiCenterWorkspace.addApis.title": "Connect to an API Center",
"azure-api-center.commands.apiCenterWorkspace.removeApis.title": "Disconnect from API Center"
"azure-api-center.commands.apiCenterWorkspace.removeApis.title": "Disconnect from API Center",
"azure-api-center.commands.apiCenterWorkspace.learnApiCatalog.title": "Learn about API Catalog"
}
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const makrdownDocuments = "markdown-documents";
export const defaultRulesetFile = "https://raw.githubusercontent.com/Azure/APICenter-Analyzer/preview/resources/rulesets/oas.yaml";
export const azureApiGuidelineRulesetFile = "https://raw.githubusercontent.com/azure/azure-api-style-guide/main/spectral.yaml";
export const spectralOwaspRulesetFile = "https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.mjs";
export const LearnMoreAboutAPICatalog = "https://aka.ms/LearnAboutAPICatalog";
export const MODEL_SELECTOR: vscode.LanguageModelChatSelector = { vendor: 'copilot', family: 'gpt-4o' };
export const ExceedTokenLimit = "Message exceeds token limit";
export const SpectralExtensionId = "stoplight.spectral";
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { setApiRuleset } from './commands/setApiRuleset';
import { SignInToDataPlane } from "./commands/signInToDataPlane";
import { testInPostman } from './commands/testInPostman';
import { ErrorProperties, TelemetryProperties } from './common/telemetryEvent';
import { doubleClickDebounceDelay, selectedNodeKey } from './constants';
import { LearnMoreAboutAPICatalog, doubleClickDebounceDelay, selectedNodeKey } from './constants';
import { ext } from './extensionVariables';
import { ApiVersionDefinitionTreeItem } from './tree/ApiVersionDefinitionTreeItem';
import { createAzureAccountTreeItem } from "./tree/AzureAccountTreeItem";
Expand Down Expand Up @@ -133,6 +133,8 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.executeCommand('workbench.actions.treeView.apiCenterWorkspace.collapseAll');
});

registerCommandWithTelemetry('azure-api-center.apiCenterWorkspace.learnApiCatalog', () => vscode.env.openExternal(vscode.Uri.parse(LearnMoreAboutAPICatalog)));

registerCommandWithTelemetry('azure-api-center.apiCenterWorkspace.removeApi', removeDataplaneAPI);

context.subscriptions.push(
Expand Down
9 changes: 9 additions & 0 deletions src/test/unit/tree/dataPlaneAccountTreeItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ describe("ApiServerItem treeItem test case", () => {
afterEach(() => {
sandbox.restore();
});
it("DataPlanAccountManagerTreeItem return catalog wiki", async () => {
ext.dataPlaneAccounts = [];
sandbox.stub(AzureDataSessionProviderHelper, "getSessionProvider").returns(sessionProvider);
const node: DataPlanAccountManagerTreeItem = new DataPlanAccountManagerTreeItem(sessionProvider);
const res = await node.loadMoreChildrenImpl(true, {} as IActionContext);
assert.equal(res.length, 1);
assert.equal(res[0].commandId, "azure-api-center.apiCenterWorkspace.learnApiCatalog");
assert.equal(res[0].id, "azureapicentercatalogwiki");
});
it("ApiServerItem loadmorechild return login", async () => {
sandbox.stub(AzureDataSessionProviderHelper, "getSessionProvider").returns(sessionProvider);
const node: ApiServerItem = new ApiServerItem(new DataPlanAccountManagerTreeItem(sessionProvider), subContext);
Expand Down
10 changes: 10 additions & 0 deletions src/tree/DataPlaneAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ export class DataPlanAccountManagerTreeItem extends AzExtParentTreeItem {
public dispose(): void { }
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[] | GenericTreeItem[]> {
const accounts = ext.dataPlaneAccounts;
if (!accounts.length) {
return [new GenericTreeItem(this, {
label: UiStrings.APIDataPlaneWiki,
commandId: "azure-api-center.apiCenterWorkspace.learnApiCatalog",
contextValue: "azureCommand",
id: "azureapicentercatalogwiki",
iconPath: new vscode.ThemeIcon("book"),
includeInTreeItemPicker: true,
})];
}
return await this.createTreeItemsWithErrorHandling(
accounts,
'inValidResource',
Expand Down
1 change: 1 addition & 0 deletions src/uiStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ export class UiStrings {
static readonly GetTreeView = vscode.l10n.t("Please connect to Azure API Center Service first.");
static readonly APIControlPlaneView = vscode.l10n.t("API Center Management Plane");
static readonly APIDataPlaneView = vscode.l10n.t("API Center Data Plane");
static readonly APIDataPlaneWiki = vscode.l10n.t("API Catalog Guide")

Check warning on line 135 in src/uiStrings.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon

Check warning on line 135 in src/uiStrings.ts

View workflow job for this annotation

GitHub Actions / unit-test

Missing semicolon
}

0 comments on commit a328802

Please sign in to comment.