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

Vltava - Dynamic Component Discovery via Registry #1126

Merged
merged 15 commits into from
Feb 5, 2020
Merged

Vltava - Dynamic Component Discovery via Registry #1126

merged 15 commits into from
Feb 5, 2020

Conversation

skylerjokiel
Copy link
Contributor

This PR explores the Container Registry as a discovery mechanism for the Tabs Component.

Before this change the Tabs Component hard coded all it's components and it was required that the Tabs Component brought these components along or they were defined in the container.

Now, when constructing the Container we pass in a Registry that we treat as an IComponent. Components can request the registry and query for the available components and capabilities of that components. This is currently schematized and pretty specific to Vltava but This can definitely be extensible. Now when new components are added to the Container Registry these components will be available for other components to consume.

This isn't an end goal but a good stopping place in the progression.

Example:

https://www.wu2.prague.office-int.com/waterpark/damaged-sister1?chaincode=@fluid-example/vltava@0.13.0-skjokiel-1

Also in this pr

  • Added FacePile to the top nav bar with piped users.

Copy link
Contributor Author

@skylerjokiel skylerjokiel left a comment

Choose a reason for hiding this comment

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

added some notes

}

const generateFactory = () => {
const containerComponentsDefinition: IContainerComponentDetails[] = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Schema to define what components exist in the container


public getNewTabTypes(): ITabsTypes[] {
const response: ITabsTypes[] = [];
this.internalRegistry.getFromCapabilities("IComponentHTMLVisual").forEach((e) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the interesting part. The DataModel gets the registry and searches for capabilities that support IComponentHTMLVisual only to display.

@@ -37,8 +37,15 @@ export class TabsComponent extends PrimedComponent implements IComponentHTMLVisu
}

protected async componentHasInitialized() {
const registry = await this.context.hostRuntime.IComponentRegistry.get("");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

getting the registry from the runtime and passing it into the model.

factory: Promise.resolve(ClickerInstantiationFactory),
capabilities: ["IComponentHTMLVisual"],
friendlyName: "Clicker",
fabricIconName: "NumberField",
Copy link
Contributor

Choose a reason for hiding this comment

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

i think these properties should be on the object returned by the factory. as it seems to me that ideally these are exposed by the component's factory so it is self describing, rather than defined by the app.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the same thought process. There are pros for each direction. It's similar to the "type" defined in the mapping. If we put it in the factory we have to resolve the factory. If we don't then there is no common place.

I have it living outside for now because I'm don't want to be committed to updating all the factories that I'm using. That is a pattern I'm exploring though.

* Licensed under the MIT License.
*/

import * as React from "react";
Copy link
Contributor

Choose a reason for hiding this comment

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

it'd be nice to split reviews next time, as there is a lot of code modified here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry about that :(

@@ -37,8 +37,15 @@ export class TabsComponent extends PrimedComponent implements IComponentHTMLVisu
}

protected async componentHasInitialized() {
const registry = await this.context.hostRuntime.IComponentRegistry.get("");
Copy link
Contributor

Choose a reason for hiding this comment

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

"" [](start = 79, length = 2)

i don't like the use of empty string here, why not just exposes IComponentRegistryDetails off the IComponentRegistry, and inspect this.context.hostRuntime.IComponentRegistry rather than having to get a fake registry and inspect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100% agree but currently you can't set the default registry. I logged a bug to fix this:
#1138

Copy link
Contributor

Choose a reason for hiding this comment

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

uggh. yeah. forgot about that. it has to do with the _scheduler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep yep :(

@skylerjokiel skylerjokiel merged commit abdb2aa into microsoft:master Feb 5, 2020
@skylerjokiel skylerjokiel deleted the registry-container-service-vltava branch April 21, 2020 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants