Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
});
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
});
});
}
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();
}
}
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,
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);
});
}
}
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);
});
}
private async getLabelsInternal(keys: InstanceKey[]) {
return Presentation.presentation.getDisplayLabels({ imodel: this.imodel }, keys);
}
private async unregisterRuleset() {
if (this._rulesetRegistration) {
await Presentation.presentation.rulesets().remove(this._rulesetRegistration);
}
}
public getFilteredNodePaths = async (filter: string): Promise => {
return Presentation.presentation.getFilteredNodePaths(this.createRequestOptions(), filter);
}
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);