Skip to content

[Question] How to use Context Containers? #49096

@streamich

Description

@streamich

I would like to understand how to correctly use the Context Container API from the New Platform Core. Please help me to fill in the FILL_ME_IN blanks.

Consider an example with 3 plugins:

  1. management app plugin that allows to register management app sections;
  2. canvas plugin that wants to render a “Canvas” section in management app and in that section render a preview of a Canvas element, which is rendered using Expressions service;
  3. expressions plugin provides an expression executor/renderer, but that executor/renderer is available only in start lifecycle; whereas Canvas would register its section in management app already in setup life-cycle.

Below are the three plugins; there are also two FILL_ME_IN places that need to be filled in.

class ManagementPlugin extends Plugin {
  setup () {
    return {
      sections: {
        register: (section) => { FILL_ME_IN }
      },
    };
  }
}

class CanvasPlugin extends Plugin {
  setup (core, plugins) {
    const mySection = plugins.management.sections.register({
      title: 'Canvas',
      order: 1,
      euiIconType: 'canvas',
    });
    mySection.registerApp({
      title: 'Expressions',
      async mount(context, params) {
        ReactDOM.render(
          <CanvasExpressionsSettings renderExpression={ FILL_ME_IN } />,
          context.domElement
        );
      }
    });
  }
}

class ExpressionsPlugin extends Plugin {
  start () {
    return {
      renderExpression: (expression, el) => {},
    };
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//discussstaleUsed to mark issues that were closed for being stale

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions