How to use the @bentley/presentation-frontend.Presentation.presentation function in @bentley/presentation-frontend

To help you get started, we’ve selected a few @bentley/presentation-frontend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / presentation / components / src / common / ContentDataProvider.ts View on Github external
private getDefaultContentDescriptor = _.memoize(async (): Promise => {
    // istanbul ignore if
    if (this.keys.size > DEFAULT_KEYS_BATCH_SIZE) {
      const msg = `ContentDataProvider.getContentDescriptor requesting descriptor with ${this.keys.size} keys which
        exceeds the suggested size of ${DEFAULT_KEYS_BATCH_SIZE}. Possible "HTTP 413 Payload Too Large" error.`;
      Logger.logWarning("Presentation.Components", msg);
    }
    return Presentation.presentation.getContentDescriptor(this.createRequestOptions(),
      this._displayType, this.keys, this.selectionInfo);
  });
github imodeljs / imodeljs / ui / framework / src / ui-framework / pickers / ModelSelector / ModelSelector.tsx View on Github external
private _initCategoryState = async () => {
    return Presentation.presentation
      .rulesets()
      .add(require("../../../../rulesets/Categories.json")) // tslint:disable-line:no-floating-promises
      .then((ruleset: RegisteredRuleset) => {
        this._categoryRuleset = ruleset;

        this._setViewType(ruleset).then(() => {
          // tslint:disable-line:no-floating-promises
          this._updateCategoriesWithViewport(this.state.activeView); // tslint:disable-line:no-floating-promises
        });
      });
  }
github imodeljs / imodeljs / presentation / components / src / common / ContentDataProvider.ts View on Github external
private async registerRuleset(ruleset: Ruleset) {
    this._registeredRuleset = await Presentation.presentation.rulesets().add(ruleset);
    if (this._isDisposed) {
      // ensure we don't keep a hanging registered ruleset if the data provider
      // gets destroyed before the ruleset finishes registration
      this.disposeRegisteredRuleset();
    }
  }
github imodeljs / imodeljs / ui / framework / src / ui-framework / pickers / ModelSelector.tsx View on Github external
private _initModelState = () => {
    Presentation.presentation.rulesets().add(require("../../../rulesets/Models")) // tslint:disable-line:no-floating-promises
      .then((ruleset: RegisteredRuleset) => {
        if (!this._isMounted)
          return;
        this._modelRuleset = ruleset;
        this.setState({
          treeInfo: {
            ruleset,
            dataProvider: new ModelSelectorDataProvider(this.props.iModelConnection, ruleset.id),
            filter: "",
            filtering: false,
            prevProps: this.props,
            activeMatchIndex: 0,
            matchesCount: 0,
            selectedNodes: [],
          },
          expand: true,
github imodeljs / imodeljs / presentation / testing / src / HierarchyBuilder.ts View on Github external
public async createHierarchy(rulesetOrId: Ruleset | string): Promise {
    if (typeof rulesetOrId === "string")
      return this.doCreateHierarchy(rulesetOrId);

    return using(await Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset: RegisteredRuleset) => {
      return this.doCreateHierarchy(ruleset.id);
    });
  }
}
github imodeljs / imodeljs / presentation / testing / src / ContentBuilder.ts View on Github external
public async createContent(rulesetOrId: Ruleset | string, instanceKeys: InstanceKey[], displayType: string = DefaultContentDisplayTypes.PropertyPane) {
    if (typeof rulesetOrId === "string")
      return this.doCreateContent(rulesetOrId, instanceKeys, displayType);

    return using(await Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset: RegisteredRuleset) => {
      return this.doCreateContent(ruleset.id, instanceKeys, displayType);
    });
  }
github imodeljs / imodeljs / presentation / components / src / labels / LabelsProvider.ts View on Github external
private async getLabelsInternal(keys: InstanceKey[]) {
    return Presentation.presentation.getDisplayLabels({ imodel: this.imodel }, keys);
  }
github imodeljs / imodeljs / ui / framework / src / ui-framework / imodel-components / visibility-tree / VisibilityTree.tsx View on Github external
private async unregisterRuleset() {
    if (this._rulesetRegistration) {
      await Presentation.presentation.rulesets().remove(this._rulesetRegistration);
    }
  }
github imodeljs / imodeljs / presentation / components / src / tree / DataProvider.ts View on Github external
public getFilteredNodePaths = async (filter: string): Promise => {
    return Presentation.presentation.getFilteredNodePaths(this.createRequestOptions(), filter);
  }
github imodeljs / imodeljs / presentation / components / src / tree / DataProvider.ts View on Github external
private _getNodesAndCount = _.memoize(async (parentNode?: TreeNodeItem, pageOptions?: PageOptions) => {
    const requestCount = undefined !== pageOptions && 0 === pageOptions.start && undefined !== pageOptions.size;
    const parentKey = parentNode ? this.getNodeKey(parentNode) : undefined;

    if (!requestCount) {
      const allNodes = await Presentation.presentation.getNodes({ ...this.createRequestOptions(), paging: pageOptionsUiToPresentation(pageOptions) }, parentKey);
      return { nodes: parentNode ? createTreeNodeItems(allNodes, parentNode.id) : createTreeNodeItems(allNodes), count: allNodes.length };
    }

    const nodesResponse = await Presentation.presentation.getNodesAndCount({ ...this.createRequestOptions(), paging: pageOptionsUiToPresentation(pageOptions) }, parentKey);
    return { nodes: parentNode ? createTreeNodeItems(nodesResponse.nodes, parentNode.id) : createTreeNodeItems(nodesResponse.nodes), count: nodesResponse.count };
  }, MemoizationHelpers.getNodesKeyResolver);