-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add useSavedState flag. * Impl useSavedState * NextVersion * rush change * Extract API * Add note to docs
- Loading branch information
Showing
9 changed files
with
158 additions
and
5 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
apps/test-app/src/frontend/appui/frontstages/TestWidgetFrontstage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from "react"; | ||
import { | ||
Frontstage, | ||
StagePanelState, | ||
Widget, | ||
WidgetState, | ||
} from "@itwin/appui-react"; | ||
import { createTestFrontstage } from "./createTestFrontstage"; | ||
|
||
/** Used in e2e tests to test different widget configurations. */ | ||
export const createTestWidgetFrontstage = () => { | ||
{ | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const frontstageParams = getFrontstageParams(urlParams); | ||
|
||
const defaultState = getDefaultState(urlParams); | ||
const useSavedState = urlParams.has("useSavedState"); | ||
|
||
const frontstage = createTestFrontstage({ | ||
id: "test-widget", | ||
version: frontstageParams.version, | ||
}); | ||
|
||
return { | ||
...frontstage, | ||
rightPanel: { | ||
defaultState: StagePanelState.Open, | ||
sections: { | ||
start: [ | ||
{ | ||
id: "widget-1", | ||
label: "Widget 1", | ||
content: <>Widget 1 content</>, | ||
defaultState, | ||
useSavedState, | ||
}, | ||
], | ||
}, | ||
}, | ||
} satisfies Frontstage; | ||
} | ||
}; | ||
|
||
function getFrontstageParams(params: URLSearchParams) { | ||
const versionParam = params.get("frontstageVersion"); | ||
const version = versionParam ? Number(versionParam) : undefined; | ||
return { version } satisfies Partial<Frontstage>; | ||
} | ||
|
||
function getDefaultState(params: URLSearchParams): Widget["defaultState"] { | ||
const param = params.get("defaultState"); | ||
if (param === "hidden") return WidgetState.Hidden; | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
common/changes/@itwin/appui-react/widget-useSavedState_2025-02-06-13-41.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@itwin/appui-react", | ||
"comment": "Add `useSavedState` to `Widget` interface.", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@itwin/appui-react" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# NextVersion <!-- omit from toc --> | ||
|
||
## @itwin/appui-react | ||
|
||
### Additions | ||
|
||
- Added `useSavedState` property to `Widget` interface. By default widgets with `defaultState=Hidden` are always hidden when the layout is restored (i.e. page is reloaded). When `useSavedState` is set to `true` it will override the default behavior and force the widget to use its saved layout state instead. This is useful for widgets that are hidden by default but should be shown when the layout is restored. [#1210](https://github.com/iTwin/appui/pull/1210) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters