Skip to content
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

As a Dynamo integrator I want to control where my nodes are located in the library #12848

Merged
merged 11 commits into from
May 6, 2022

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented May 2, 2022

Purpose

https://jira.autodesk.com/browse/DYN-3407

For built-in packages Dynamo host product integrators should have a way of modifying the library layout spec so that their packages show up in the main sections of the library, and not the "add-on" section.

This PR does the following:

  • introduces a recursive MergeLayoutSpecs method. This method can merge sections and categories of two layout specs objects. It does not merge data, only child elements. For example, it won't combine IncludeInfo or IconUrl of elements, it will only merge their child element collections.
  • builtin packages that are present on startup and contain a pkg/extra/layoutspecs.json file, will trigger a layout spec application request.
  • If the libraryViewExtension is loaded , it will handle the request and attempt to merge the two layout specs.
  • NodeSearchElements's loaded from builtin packages directory will now be marked with the BuiltIn flag, in addition to the Packaged flag.
  • BuiltIn package items in the library will have the prefix bltinpkg:// as opposed to pkg:// for normal packages. This is the prefix that should be applied to the paths that integrators put in their layoutspec file.
  • tests are added.
  • LibraryViewExtensionTests.csproj is reenabled for build in debug and release, and I've added a few tests to it, I've also removed LibraryViewExtension(CEF) as a dep and instead pointed to LibraryViewExtensionMSWebbrowser. Most of the tests for the old library have been commented out as these simply don't make sense or don't compile. It's a bigger task to get these working again, and we'll be tossing the MSWebBrowser implementation soon anyway for WebView2 hopefully.
  • PR to buildscripts so these tests run as part of master-15 build: https://git.autodesk.com/Dynamo/DynamoBuildscripts/pull/29

Here is an example of moving the zero touch dynamo samples package into a category named Revit

Screen Shot 2022-04-28 at 4 41 24 PM

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Release Notes

Internal API for Dynamo integrators to modify the library layout for their builtin packages.

Reviewers

...

@mjkkirschner mjkkirschner requested review from pinzart90 and sm6srw May 2, 2022 21:22
@mjkkirschner mjkkirschner added the PTAL Please Take A Look 👀 label May 2, 2022
@mjkkirschner mjkkirschner changed the title Layout As a Dynamo integrator I want to control where my nodes are located in the library May 2, 2022
@@ -84,8 +84,12 @@ protected virtual object CreateObjectForSerialization(IEnumerable<NodeSearchElem
/// </summary>
public static string GetFullyQualifiedName(NodeSearchElement element)
{
if (element.ElementType.HasFlag(ElementTypes.Packaged) && element.ElementType.HasFlag(ElementTypes.BuiltIn))
Copy link
Contributor

@pinzart90 pinzart90 May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not add this condition inside the if at line 88 ?

if (element.ElementType.HasFlag(ElementTypes.Packaged))
{
   if (element.ElementType.HasFlag(ElementTypes.BuiltIn) {
       return string.Format("{0}{1}.{2}", "bltinpkg://", element.FullCategoryName, element.Name);
    }
    //Use FullCategory and name as read from _customization.xml file
    return string.Format("{0}{1}.{2}", "pkg://", element.FullCategoryName, element.Name);
}

Copy link
Member Author

@mjkkirschner mjkkirschner May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like using nested if statements if avoidable, if you much prefer your sample code I will make the switch.

@mjkkirschner
Copy link
Member Author

mjkkirschner commented May 3, 2022

latest tests finally ran and did not introduce any new regressions!
https://master-5.jenkins.autodesk.com/job/Dynamo/job/DynamoSelfServe/job/pullRequestValidation/5918/

Copy link
Contributor

@sm6srw sm6srw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

{
//try to combine the layout specs.
var customizationService = extensionManager.Service<ILibraryViewCustomization>();
//TODO if the layoutspec is empty, we're calling this too early, we can retry after x seconds?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen this happening?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but only before when I was calling this code from the ExtensionsManager (before view extensions like libraryjs were loaded)

Copy link
Contributor

@pinzart90 pinzart90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mjkkirschner mjkkirschner merged commit 1100695 into DynamoDS:master May 6, 2022
@mjkkirschner mjkkirschner deleted the layout branch May 6, 2022 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PTAL Please Take A Look 👀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants