Skip to content

fix: Update cloud product categories #136

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

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion media/src/components/APIPage/API.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const API: React.FC<APIProps> = (props) => {
}, []);

return (
<div className="bg-[var(--vscode-textBlockQuote-background)] pb-4" ref={pageEl}>
<div className="h-full bg-[var(--vscode-textBlockQuote-background)] pb-4" ref={pageEl}>
{/* */}
<APIPageContext.Provider
initialState={{
Expand Down
2 changes: 1 addition & 1 deletion media/src/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const App: React.FC<AppProps> = (props) => {
) : null;

return (
<div className="w-full">
<div className="h-[100vh] w-full">
<APIPage
selectedApi={selectedApi}
product={popcode}
Expand Down
44 changes: 36 additions & 8 deletions src/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,27 @@ export class PontAPITreeItem extends vscode.TreeItem {
}

export class PontAPIExplorer {
static getProductItems(products: Array<Product>, element: PontAPITreeItem = null) {
return products?.map((product) => {
static getProductItems(element = null) {
if (element.contextValue === "productGroup2") {
const productGroups = _.groupBy(element.children, (item) => {
if (item?.categoryName?.length) {
return item.categoryName;
} else {
return "其他";
}
});
return Object.keys(productGroups || {})?.map((group) => {
return {
specName: group,
contextValue: "productGroup",
label: `${group}`,
modName: group,
children: productGroups[group],
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
};
});
}
return element.children?.map((product) => {
return {
specName: product.code,
modName: "",
Expand Down Expand Up @@ -243,13 +262,20 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
getAPIManagerChildren(element?: PontAPITreeItem): vscode.ProviderResult<PontAPITreeItem[]> {
if (element.contextValue === "alicloudProducts") {
const productExplorer = getProductRequestInstance();
const productGroups = _.groupBy(productExplorer?.products, (product) => product.group);
const productGroups = _.groupBy(productExplorer?.products, (product) => {
if (product?.category2Name?.length) {
return product.category2Name;
} else {
return "其他";
}
});
return Object.keys(productGroups || {})?.map((group) => {
return {
specName: group,
contextValue: "productGroup",
contextValue: "productGroup2",
label: `${group}`,
modName: group,
children: productGroups[group],
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
};
});
Expand Down Expand Up @@ -311,10 +337,10 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
});
} else if (element.contextValue === "Dir" && spec) {
return PontAPIExplorer.getDirItems(spec, element);
} else if (element.contextValue === "productGroup") {
} else if (element.contextValue === "productGroup" || element.contextValue === "productGroup2") {
const productExplorer = getProductRequestInstance();
const productGroups = _.groupBy(productExplorer?.products, (product) => product.group);
return PontAPIExplorer.getProductItems(productGroups[element?.modName?.toString()], element);
// const productGroups = _.groupBy(productExplorer?.products, (product) => product.category2Name);
return PontAPIExplorer.getProductItems(element);
} else {
return PontAPIExplorer.getDirItems(spec);
}
Expand Down Expand Up @@ -349,7 +375,9 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
getSpecInfoFromName(item.name || "").version === version,
)?.length
) {
vscode.window.showInformationMessage("该产品及其版本号已订阅,您可以使用 cmd + ctrl + l 来搜索该产品下的API。");
vscode.window.showInformationMessage(
"该产品及其版本号已订阅,您可以使用「mac: ctrl+cmd+l」,「win: ctrl+alt+l」来搜索该产品下的API。",
);
} else {
pontxConfig.origins = [
...(pontxConfig.origins || []),
Expand Down
20 changes: 11 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export declare class Product {
code: string;
name: string;
description: string;
shortName: string;
group: string;
style: string;
versions: Array<string>;
defaultVersion: string;
}
code: string;
name: string;
description: string;
shortName: string;
group: string;
style: string;
versions: Array<string>;
defaultVersion: string;
categoryName: string;
category2Name: string;
}
Loading