Skip to content

Commit

Permalink
feat: resourceTree获取resourceList支持自定义过滤 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
Noodles006 authored Jan 15, 2024
1 parent 0c8961f commit 492ce98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ import { AddFile } from '../addFile';
const { Popup } = Overlay;
const { Item } = Menu;

function filterResourceList(resourceList: IPublicModelResource[] | undefined, handler?: Function) {
if (typeof handler === 'function') {
return handler(resourceList);
}

return resourceList;
}

export function ResourcePaneContent(props: IPluginOptions) {
const { workspace } = props.pluginContext || {};
const [resourceList, setResourceList] = useState<IPublicModelResource[] | undefined>(
workspace?.resourceList
filterResourceList(workspace?.resourceList, props?.options?.filterResourceList)
);
workspace?.onResourceListChange(() => {
setResourceList(workspace.resourceList);
setResourceList(filterResourceList(workspace?.resourceList, props?.options?.filterResourceList));
});
return (
<ResourceListTree
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-view-manager-pane/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export interface IOptions {

handleClose?: (force?: boolean) => void;

filterResourceList?: () => {};

showIconText?: boolean;

skeletonConfig?: IPublicTypeSkeletonConfig;
Expand Down Expand Up @@ -135,6 +137,11 @@ ViewManagerPane.meta = {
type: 'function',
description: '',
},
{
key: 'filterResourceList',
type: 'function',
description: '',
},
{
key: 'showIconText',
type: 'boolean',
Expand Down

0 comments on commit 492ce98

Please sign in to comment.