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

Fix UI provider bug and add new provider param to isSupportedStage callback #3377

Merged
merged 3 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/api/appui-abstract.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ export abstract class BaseQuantityDescription implements PropertyDescription {

// @public
export class BaseUiItemsProvider implements UiItemsProvider {
constructor(_providerId: string, isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any) => boolean) | undefined);
constructor(_providerId: string, isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any, provider?: UiItemsProvider | undefined) => boolean) | undefined);
// (undocumented)
get id(): string;
// (undocumented)
isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any) => boolean) | undefined;
isSupportedStage?: ((stageId: string, stageUsage: string, stageAppData?: any, provider?: UiItemsProvider | undefined) => boolean) | undefined;
// (undocumented)
onUnregister(): void;
provideBackstageItems(): BackstageItem[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-abstract",
"comment": "Fix missing parameter in UiManager.getWidgets call and pass provider to isSupportedStage function.",
"type": "none"
}
],
"packageName": "@itwin/appui-abstract"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-react",
"comment": "Fix missing parameter in UiManager.getWidgets call and pass provider to isSupportedStage function.",
"type": "none"
}
],
"packageName": "@itwin/appui-react"
}
8 changes: 4 additions & 4 deletions ui/appui-abstract/src/appui-abstract/UiItemsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class BaseUiItemsProvider implements UiItemsProvider {
* @param isSupportedStage - optional function that will be called to determine if tools should be added to current stage. If not set and
* the current stage's `usage` is set to `StageUsage.General` then the provider will add items to frontstage.
*/
constructor(protected _providerId: string, public isSupportedStage?: (stageId: string, stageUsage: string, stageAppData?: any) => boolean) { }
constructor(protected _providerId: string, public isSupportedStage?: (stageId: string, stageUsage: string, stageAppData?: any, provider?: UiItemsProvider) => boolean) { }

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

if (this.isSupportedStage) {
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData);
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
} else {
provideToStage = (stageUsage === StageUsage.General);
}
Expand All @@ -98,7 +98,7 @@ export class BaseUiItemsProvider implements UiItemsProvider {
let provideToStage = false;

if (this.isSupportedStage) {
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData);
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
} else {
provideToStage = (stageUsage === StageUsage.General);
}
Expand All @@ -115,7 +115,7 @@ export class BaseUiItemsProvider implements UiItemsProvider {
let provideToStage = false;

if (this.isSupportedStage) {
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData);
provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
} else {
provideToStage = (stageUsage === StageUsage.General);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/appui-react/src/appui-react/widgets/WidgetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class WidgetManager {

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