From c33c13715e4bd645dd7f8006171c8f5233a65f5f Mon Sep 17 00:00:00 2001 From: mjkkirschner Date: Wed, 8 May 2024 10:41:40 -0400 Subject: [PATCH 01/16] try adding new exported method for setting data on particular item. --- src/components/LibraryContainer.tsx | 37 +++++++++++++++++++++++++++++ src/components/LibraryItem.tsx | 17 ++----------- src/entry-point.tsx | 10 +++++++- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/components/LibraryContainer.tsx b/src/components/LibraryContainer.tsx index 7c7272e..49566a5 100644 --- a/src/components/LibraryContainer.tsx +++ b/src/components/LibraryContainer.tsx @@ -72,11 +72,13 @@ export class LibraryContainer extends React.Component 0){ + var res = this.searchForLeafLibItem(contextData,item.childItems) + if(res){ + return res + } + } + } + } + return null; + } + updateSections(sections: any): void { // Obtain the categories from each section to be added into the filtering options for search for (let section of sections) { @@ -293,6 +329,7 @@ export class LibraryContainer extends React.Component boolean) | null = null; // This is to make it possible to set an external search handler. // Given a search text, it will call the callback function with search result. @@ -166,4 +167,11 @@ export class LibraryController { this.refreshLibraryViewHandler(); } } + + modifyLibraryItemData(context:any ,data:ItemData):boolean{ + if(this.modifyItemHandler){ + return this.modifyItemHandler(context,data); + } + return false; + } } From afb6ff906ec45f906d949255e1e6b79d4c5d28d2 Mon Sep 17 00:00:00 2001 From: mjkkirschner Date: Wed, 8 May 2024 11:23:08 -0400 Subject: [PATCH 02/16] modify method also removes items from search --- src/components/LibraryContainer.tsx | 2 -- src/components/SearchResultItem.tsx | 13 +++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/LibraryContainer.tsx b/src/components/LibraryContainer.tsx index 49566a5..aec05b9 100644 --- a/src/components/LibraryContainer.tsx +++ b/src/components/LibraryContainer.tsx @@ -221,8 +221,6 @@ export class LibraryContainer extends React.Component containerRect.bottom) { + if (currentRect?.bottom > containerRect?.bottom) { currentItem.scrollIntoView(false); } } @@ -71,6 +71,11 @@ export class SearchResultItem extends React.Component Date: Wed, 8 May 2024 12:59:23 -0400 Subject: [PATCH 03/16] use full name to search update tests --- __tests__/Snapshottest/UIOutputComparisonTests.tsx | 2 +- .../__snapshots__/UIOutputComparisonTests.tsx.snap | 5 +++++ __tests__/UITests.tsx | 4 ++-- src/LibraryUtilities.ts | 2 ++ src/components/LibraryContainer.tsx | 14 ++++++++------ src/entry-point.tsx | 1 + 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/__tests__/Snapshottest/UIOutputComparisonTests.tsx b/__tests__/Snapshottest/UIOutputComparisonTests.tsx index 819928f..1f44f16 100644 --- a/__tests__/Snapshottest/UIOutputComparisonTests.tsx +++ b/__tests__/Snapshottest/UIOutputComparisonTests.tsx @@ -22,7 +22,7 @@ describe("LibraryContainer", function () { const libContainer = LibraryEntryPoint.CreateLibraryController(); // Creation of LibraryItem component - const libraryItemComponent = ; + const libraryItemComponent = ; it("Test UI rendering of single component of Library Item", function () { // "LibraryItem" with Shallow rendering to testing component as a unit. diff --git a/__tests__/Snapshottest/__snapshots__/UIOutputComparisonTests.tsx.snap b/__tests__/Snapshottest/__snapshots__/UIOutputComparisonTests.tsx.snap index d2b1ee9..d77c65c 100644 --- a/__tests__/Snapshottest/__snapshots__/UIOutputComparisonTests.tsx.snap +++ b/__tests__/Snapshottest/__snapshots__/UIOutputComparisonTests.tsx.snap @@ -12,6 +12,7 @@ exports[`LibraryContainer Test UI rendering of Library Item and child components "contextData": "", "description": "", "expanded": false, + "fullyQualifiedName": "", "iconUrl": "", "itemType": "category", "keywords": [ @@ -29,6 +30,7 @@ exports[`LibraryContainer Test UI rendering of Library Item and child components "contextData": "", "description": "", "expanded": false, + "fullyQualifiedName": "", "iconUrl": "", "itemType": "category", "keywords": [ @@ -45,6 +47,7 @@ exports[`LibraryContainer Test UI rendering of Library Item and child components "contextData": "", "description": "", "expanded": false, + "fullyQualifiedName": "", "iconUrl": "", "itemType": "none", "keywords": [ @@ -72,6 +75,8 @@ exports[`LibraryContainer Test UI rendering of Library Item and child components "SectionIconClickedEventName": "sectionIconClicked", "createLibraryByElementId": [Function], "createLibraryContainer": [Function], + "modifyItemHandler": null, + "modifyLibraryItemData": [Function], "on": [Function], "raiseEvent": [Function], "reactor": Reactor { diff --git a/__tests__/UITests.tsx b/__tests__/UITests.tsx index 758ed90..a66ed2c 100644 --- a/__tests__/UITests.tsx +++ b/__tests__/UITests.tsx @@ -117,7 +117,7 @@ describe("LibraryContainer UI", function () { // If you are testing full React components, // mount is used to do rendering and test actions are simulated on mounted html - let libraryItem = mount(); + let libraryItem = mount(); expect(libraryItem).to.have.lengthOf(1); expect(libraryItem.props().data.childItems).to.have.lengthOf(2); @@ -137,7 +137,7 @@ describe("LibraryContainer UI", function () { let data = createLibraryItem(ItemData); //pass a callback which if called will end the test - let libraryItem = mount( { done() }} />); + let libraryItem = mount( { done() }} />); let header = libraryItem.find(('div.LibraryItemHeader')).at(0);// the state of LibraryItem is changed when clicking on header expect(header).to.have.lengthOf(1); // verify that there is a header diff --git a/src/LibraryUtilities.ts b/src/LibraryUtilities.ts index 29fb3e3..dccbb64 100644 --- a/src/LibraryUtilities.ts +++ b/src/LibraryUtilities.ts @@ -91,6 +91,7 @@ export class ItemData { childItems: ItemData[] = []; pathToItem: ItemData[] = []; weight: number = 0; + fullyQualifiedName:string = "" constructor(public text: string) { this.keywords.push(text ? text.toLowerCase() : text); @@ -118,6 +119,7 @@ export class ItemData { this.keywords.push(keyword.toLowerCase().replace(/ /g, '')); }); this.keywords.push(typeListNode.fullyQualifiedName.toLowerCase().replace(/ /g, '')); + this.fullyQualifiedName = typeListNode.fullyQualifiedName; } appendChild(childItem: ItemData) { diff --git a/src/components/LibraryContainer.tsx b/src/components/LibraryContainer.tsx index aec05b9..c003d2c 100644 --- a/src/components/LibraryContainer.tsx +++ b/src/components/LibraryContainer.tsx @@ -219,17 +219,19 @@ export class LibraryContainer extends React.Component 0){ - var res = this.searchForLeafLibItem(contextData,item.childItems) - if(res){ - return res - } + var res = this.searchForLeafLibItem(fullyQualifiedNameToSearchFor,item.childItems) + if(res) + { + return res + } } } } diff --git a/src/entry-point.tsx b/src/entry-point.tsx index 3719864..0ea5de0 100644 --- a/src/entry-point.tsx +++ b/src/entry-point.tsx @@ -61,6 +61,7 @@ export class LibraryController { this.setLoadedTypesJson = this.setLoadedTypesJson.bind(this); this.setLayoutSpecsJson = this.setLayoutSpecsJson.bind(this); this.refreshLibraryView = this.refreshLibraryView.bind(this); + this.modifyLibraryItemData = this.modifyLibraryItemData.bind(this); this.reactor = new Reactor(); } From 46ec30968422f5761cdbed8acbede6d1b62be796 Mon Sep 17 00:00:00 2001 From: mjkkirschner Date: Wed, 8 May 2024 19:47:56 -0400 Subject: [PATCH 04/16] move to using context --- docs/RawTypeData.json | 6 ++++-- src/LibraryUtilities.ts | 5 +++++ src/components/LibraryContainer.tsx | 13 +++++++++++-- src/components/LibraryItem.tsx | 6 ++++++ src/components/SearchResultItem.tsx | 8 ++++++-- src/entry-point.tsx | 11 +++++++++++ src/sharedTypes.ts | 3 +++ 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 src/sharedTypes.ts diff --git a/docs/RawTypeData.json b/docs/RawTypeData.json index 892eb27..52d0f7f 100644 --- a/docs/RawTypeData.json +++ b/docs/RawTypeData.json @@ -18,7 +18,8 @@ "itemType": "action", "keywords": "Dynamo.Nodes.Symbol, Input, variable, argument, parameter", "weight": 0, - "description": "A function parameter, use with custom nodes.\n\nYou can specify the type and default value for parameter. E.g.,\n\ninput : var[]..[]\nvalue : bool = false" + "description": "A function parameter, use with custom nodes.\n\nYou can specify the type and default value for parameter. E.g.,\n\ninput : var[]..[]\nvalue : bool = false", + "hiddenInWorkspaceContext":true }, { "fullyQualifiedName": "Core.Input.Output", @@ -28,7 +29,8 @@ "itemType": "action", "keywords": "Dynamo.Nodes.Output, Output", "weight": 0, - "description": "A function output, use with custom nodes" + "description": "A function output, use with custom nodes", + "hiddenInWorkspaceContext":true }, { "fullyQualifiedName": "Core.Units.Convert Between Units", diff --git a/src/LibraryUtilities.ts b/src/LibraryUtilities.ts index dccbb64..c00a53d 100644 --- a/src/LibraryUtilities.ts +++ b/src/LibraryUtilities.ts @@ -17,6 +17,7 @@ export class TypeListNode { description: string = ""; processed: boolean = false; weight: number = 0; + hiddenInWorkspaceContext:boolean constructor(data: any) { this.fullyQualifiedName = data.fullyQualifiedName; @@ -27,6 +28,7 @@ export class TypeListNode { this.parameters = data.parameters; this.description = data.description; this.weight = data.weight; + this.hiddenInWorkspaceContext = data.hiddenInWorkspaceContext; } } @@ -34,6 +36,7 @@ export interface IncludeInfo { path: string; iconUrl?: string; inclusive?: boolean; + hiddenInWorkspaceContext?:boolean } export class IncludeItemPair { @@ -92,6 +95,7 @@ export class ItemData { pathToItem: ItemData[] = []; weight: number = 0; fullyQualifiedName:string = "" + hiddenInWorkspaceContext:boolean = false constructor(public text: string) { this.keywords.push(text ? text.toLowerCase() : text); @@ -120,6 +124,7 @@ export class ItemData { }); this.keywords.push(typeListNode.fullyQualifiedName.toLowerCase().replace(/ /g, '')); this.fullyQualifiedName = typeListNode.fullyQualifiedName; + this.hiddenInWorkspaceContext = typeListNode.hiddenInWorkspaceContext; } appendChild(childItem: ItemData) { diff --git a/src/components/LibraryContainer.tsx b/src/components/LibraryContainer.tsx index c003d2c..c86aa4b 100644 --- a/src/components/LibraryContainer.tsx +++ b/src/components/LibraryContainer.tsx @@ -10,6 +10,7 @@ import { Searcher } from "../Searcher"; import { SearchBar, CategoryData } from "./SearchBar"; import { SearchResultItem } from "./SearchResultItem"; import * as ReactDOM from "react-dom"; +import { HostingContextType } from "../sharedTypes"; declare global { interface Window { setTooltipText: any; } @@ -41,6 +42,7 @@ export interface LibraryContainerStates { action: string; query: string; } + hostingContext:HostingContextType } export class LibraryContainer extends React.Component { @@ -73,13 +75,14 @@ export class LibraryContainer extends React.Component void; @@ -72,8 +73,11 @@ export class SearchResultItem extends React.Component