Skip to content

Commit e2ad5ef

Browse files
authored
Fix UI provider bug and add new provider param to isSupportedStage callback (#3377)
* fix bug where the wrong number of parameters were being passed * fix missing parameter in provide widgets * rush change
1 parent 7d7423e commit e2ad5ef

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

common/api/appui-abstract.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ export abstract class BaseQuantityDescription implements PropertyDescription {
253253

254254
// @public
255255
export class BaseUiItemsProvider implements UiItemsProvider {
256-
constructor(_providerId: string, isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any) => boolean) | undefined);
256+
constructor(_providerId: string, isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any, provider?: UiItemsProvider | undefined) => boolean) | undefined);
257257
// (undocumented)
258258
get id(): string;
259259
// (undocumented)
260-
isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any) => boolean) | undefined;
260+
isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any, provider?: UiItemsProvider | undefined) => boolean) | undefined;
261261
// (undocumented)
262262
onUnregister(): void;
263263
provideBackstageItems(): BackstageItem[];
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/appui-abstract",
5+
"comment": "Fix missing parameter in UiManager.getWidgets call and pass provider to isSupportedStage function.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@itwin/appui-abstract"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/appui-react",
5+
"comment": "Fix missing parameter in UiManager.getWidgets call and pass provider to isSupportedStage function.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@itwin/appui-react"
10+
}

ui/appui-abstract/src/appui-abstract/UiItemsManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class BaseUiItemsProvider implements UiItemsProvider {
6262
* @param isSupportedStage - optional function that will be called to determine if tools should be added to current stage. If not set and
6363
* the current stage's `usage` is set to `StageUsage.General` then the provider will add items to frontstage.
6464
*/
65-
constructor(protected _providerId: string, public isSupportedStage?: (stageId: string, stageUsage: string, stageAppData?: any) => boolean) { }
65+
constructor(protected _providerId: string, public isSupportedStage?: (stageId: string, stageUsage: string, stageAppData?: any, provider?: UiItemsProvider) => boolean) { }
6666

6767
public get id(): string { return this._providerId; }
6868
public onUnregister(): void { }
@@ -83,7 +83,7 @@ export class BaseUiItemsProvider implements UiItemsProvider {
8383
let provideToStage = false;
8484

8585
if (this.isSupportedStage) {
86-
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData);
86+
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
8787
} else {
8888
provideToStage = (stageUsage === StageUsage.General);
8989
}
@@ -98,7 +98,7 @@ export class BaseUiItemsProvider implements UiItemsProvider {
9898
let provideToStage = false;
9999

100100
if (this.isSupportedStage) {
101-
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData);
101+
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
102102
} else {
103103
provideToStage = (stageUsage === StageUsage.General);
104104
}
@@ -115,7 +115,7 @@ export class BaseUiItemsProvider implements UiItemsProvider {
115115
let provideToStage = false;
116116

117117
if (this.isSupportedStage) {
118-
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData);
118+
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
119119
} else {
120120
provideToStage = (stageUsage === StageUsage.General);
121121
}

ui/appui-react/src/appui-react/widgets/WidgetManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class WidgetManager {
156156

157157
// Consult the UiItemsManager to get any Abstract widgets
158158
if (location in StagePanelLocation) {
159-
const widgets = UiItemsManager.getWidgets(stageId, stageUsage, location as StagePanelLocation, definedSection, frontstageApplicationData);
159+
const widgets = UiItemsManager.getWidgets(stageId, stageUsage, location as StagePanelLocation, definedSection, undefined, frontstageApplicationData);
160160
widgets.forEach((abstractProps: AbstractWidgetProps, index: number) => {
161161
const props = WidgetDef.createWidgetPropsFromAbstractProps(abstractProps);
162162
const stableId = getAddonStableWidgetId(stageUsage, location as StagePanelLocation, definedSection, index);

0 commit comments

Comments
 (0)