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

Move layout initialization to reducer #636

Merged
merged 35 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
518a359
Missing upath dep to fix test debugging.
GerardasB Dec 11, 2023
2339d7b
Initial initialize action.
GerardasB Dec 11, 2023
f1a6bba
Batch multiple dispatch calls instead of moving everything into initi…
GerardasB Dec 11, 2023
bb3428d
Add actions needed to initialize panels.
GerardasB Dec 12, 2023
63f4776
Set-up logging.
GerardasB Dec 12, 2023
1432454
Add WidgetDefAddAction.
GerardasB Dec 13, 2023
106b7a8
Remove tab action.
GerardasB Dec 14, 2023
a9e9496
Log reducer actions.
GerardasB Dec 14, 2023
575389c
Refactor restoreNineZoneState.
GerardasB Dec 14, 2023
af39333
Remove unused helpers.
GerardasB Dec 14, 2023
01b2d2c
Remove SavedNineZoneState.
GerardasB Dec 14, 2023
a076e50
Fix test failures.
GerardasB Dec 14, 2023
9f89566
Revive tests.
GerardasB Dec 14, 2023
5447021
Add test for action batching.
GerardasB Dec 15, 2023
12774f1
Move state helpers out of barrel file.
GerardasB Dec 15, 2023
65f1ab5
Reuse helper to update panel size when changing min/max size.
GerardasB Dec 15, 2023
3e2efb4
Coverage.
GerardasB Dec 18, 2023
0fc388b
Disable trace logging.
GerardasB Dec 18, 2023
0892e8c
Extract API.
GerardasB Dec 18, 2023
365a2c5
Rush change.
GerardasB Dec 18, 2023
5890094
Fix linter errors.
GerardasB Dec 18, 2023
dad6f90
Fix test flakiness when dragging a widget.
GerardasB Dec 18, 2023
462570e
Merge branch 'master' into reducer-actions
GerardasB Dec 19, 2023
148398e
Respect empty snapshotPath URL param.
GerardasB Dec 19, 2023
2c2dce4
Set explicit height to make tests consistent.
GerardasB Dec 20, 2023
230e548
Merge branch 'master' into reducer-actions
GerardasB Dec 20, 2023
1769465
Move tests to corresponding files.
GerardasB Jan 2, 2024
b88b760
Cleanup test.
GerardasB Jan 2, 2024
4df1ede
Add a test for dispatch w/o batching.
GerardasB Jan 2, 2024
10977e4
Simplify addFrontstageWidgetDefs.
GerardasB Jan 2, 2024
8be4e7d
Reuse hideWidgetDef.
GerardasB Jan 2, 2024
12f6438
Use template literal in PanelSectionId type.
GerardasB Jan 2, 2024
c852ec0
Simplify getPanelSectionId.
GerardasB Jan 2, 2024
6c01405
Merge remote-tracking branch 'origin/master' into reducer-actions
GerardasB Jan 2, 2024
67d7cc9
Merge branch 'master' into reducer-actions
GerardasB Jan 3, 2024
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
126 changes: 84 additions & 42 deletions common/api/appui-layout-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,18 @@

import { BeEvent } from '@itwin/core-bentley';
import type { CommonProps } from '@itwin/core-react';
import { IconSpec } from '@itwin/core-react';
import type { IconSpec } from '@itwin/core-react';
import type { NoChildrenProps } from '@itwin/core-react';
import type { OmitChildrenProp } from '@itwin/core-react';
import { Point } from '@itwin/core-react';
import type { PopupProps } from '@itwin/core-react';
import * as React_2 from 'react';
import { Rectangle } from '@itwin/core-react';
import type { RectangleProps } from '@itwin/core-react';
import { SizeProps } from '@itwin/core-react';
import type { SizeProps } from '@itwin/core-react';
import { StoreApi } from 'zustand';
import { UseBoundStore } from 'zustand';

// @internal
export function addDockedToolSettings(state: NineZoneState, tabId: TabState["id"], hidden?: boolean): NineZoneState;

// @internal (undocumented)
export function addFloatingWidget(state: NineZoneState, id: FloatingWidgetState["id"], tabs: WidgetState["tabs"], floatingWidgetArgs?: Partial<FloatingWidgetState>, widgetArgs?: Partial<WidgetState>): NineZoneState;

// @internal (undocumented)
export function addPanelWidget(state: NineZoneState, side: PanelSide, id: WidgetState["id"], tabs: WidgetState["tabs"], widgetArgs?: Partial<WidgetState>): NineZoneState;

// @internal (undocumented)
export function addPopoutWidget(state: NineZoneState, id: PopoutWidgetState["id"], tabs: WidgetState["tabs"], popoutWidgetArgs?: Partial<PopoutWidgetState>, widgetArgs?: Partial<WidgetState>): NineZoneState;

// @internal
export function addRemovedTab(state: NineZoneState, tabId: TabState["id"]): NineZoneState;

// @internal
export function addTab(state: NineZoneState, id: TabState["id"], tabArgs?: Partial<TabState>): NineZoneState;

// @internal
export function addTabToWidget(state: NineZoneState, tabId: TabState["id"], widgetId: WidgetState["id"]): NineZoneState;

// @internal
export function addWidgetToolSettings(state: NineZoneState, tabId: TabState["id"]): NineZoneState;

// @internal (undocumented)
export const AnimateDockedToolSettingsContext: React_2.Context<boolean>;

Expand Down Expand Up @@ -313,9 +289,6 @@ export interface FloatingTabLocation {
// @internal (undocumented)
export function FloatingWidget(props: FloatingWidgetProps): JSX.Element;

// @internal (undocumented)
export function floatingWidgetBringToFront(state: NineZoneState, floatingWidgetId: FloatingWidgetState["id"]): NineZoneState;

// @internal (undocumented)
export interface FloatingWidgetBringToFrontAction {
// (undocumented)
Expand Down Expand Up @@ -520,12 +493,6 @@ export interface HorizontalPanelState extends PanelState {
// @internal (undocumented)
export const IconOnlyOnWidgetTabContext: React_2.Context<boolean>;

// @internal (undocumented)
export function insertPanelWidget(state: NineZoneState, side: PanelSide, id: WidgetState["id"], tabs: WidgetState["tabs"], sectionIndex: number, widgetArgs?: Partial<WidgetState>): NineZoneState;

// @internal
export function insertTabToWidget(state: NineZoneState, tabId: TabState["id"], widgetId: WidgetState["id"], tabIndex: number): NineZoneState;

// @internal (undocumented)
export function isFloatingTabLocation(location: TabLocation): location is FloatingTabLocation;

Expand Down Expand Up @@ -664,7 +631,7 @@ export interface NavigationAreaProps extends CommonProps, NoChildrenProps {
export function NineZone(props: NineZoneProps): JSX.Element;

// @internal (undocumented)
export type NineZoneAction = ResizeAction | PanelToggleCollapsedAction | PanelSetCollapsedAction | PanelSetPinnedAction | PanelSetSizeAction | PanelSetSplitterPercentAction | PanelToggleSpanAction | PanelTogglePinnedAction | PanelInitializeAction | FloatingWidgetResizeAction | FloatingWidgetSetBoundsAction | FloatingWidgetBringToFrontAction | FloatingWidgetSendBackAction | FloatingWidgetClearUserSizedAction | FloatingWidgetSetUserSizedAction | PopoutWidgetSendBackAction | PanelWidgetDragStartAction | WidgetDragAction | WidgetDragEndAction | WidgetTabClickAction | WidgetTabCloseAction | WidgetTabDoubleClickAction | WidgetTabDragStartAction | WidgetTabDragAction | WidgetTabDragEndAction | WidgetTabExpandAction | WidgetTabFloatAction | WidgetTabHideAction | WidgetTabOpenAction | WidgetTabPopoutAction | WidgetTabSetLabelAction | WidgetTabSetPopoutBoundsAction | WidgetTabShowAction | WidgetTabUnloadAction | ToolSettingsDragStartAction | ToolSettingsDockAction;
export type NineZoneAction = ResizeAction | PanelToggleCollapsedAction | PanelSetCollapsedAction | PanelSetPinnedAction | PanelSetSizeAction | PanelSetMinSizeAction | PanelSetMaxSizeAction | PanelSetResizableAction | PanelSetSplitterPercentAction | PanelToggleSpanAction | PanelTogglePinnedAction | PanelInitializeAction | FloatingWidgetResizeAction | FloatingWidgetSetBoundsAction | FloatingWidgetBringToFrontAction | FloatingWidgetSendBackAction | FloatingWidgetClearUserSizedAction | FloatingWidgetSetUserSizedAction | PopoutWidgetSendBackAction | PanelWidgetDragStartAction | WidgetDragAction | WidgetDragEndAction | WidgetTabClickAction | WidgetTabCloseAction | WidgetTabDoubleClickAction | WidgetTabDragStartAction | WidgetTabDragAction | WidgetTabDragEndAction | WidgetTabExpandAction | WidgetTabFloatAction | WidgetTabHideAction | WidgetTabRemoveAction | WidgetTabOpenAction | WidgetTabPopoutAction | WidgetTabSetLabelAction | WidgetTabSetPopoutBoundsAction | WidgetTabShowAction | WidgetTabUnloadAction | WidgetTabUpdateAction | ToolSettingsDragStartAction | ToolSettingsDockAction | WidgetDefAddAction | WidgetDefAddToolSettingsAction;

// @internal (undocumented)
export type NineZoneDispatch = (action: NineZoneAction) => void;
Expand Down Expand Up @@ -800,6 +767,26 @@ export interface PanelSetCollapsedAction {
readonly type: "PANEL_SET_COLLAPSED";
}

// @internal (undocumented)
export interface PanelSetMaxSizeAction {
// (undocumented)
readonly maxSize: PanelState["maxSize"];
// (undocumented)
readonly side: PanelSide;
// (undocumented)
readonly type: "PANEL_SET_MAX_SIZE";
}

// @internal (undocumented)
export interface PanelSetMinSizeAction {
// (undocumented)
readonly minSize: PanelState["minSize"];
// (undocumented)
readonly side: PanelSide;
// (undocumented)
readonly type: "PANEL_SET_MIN_SIZE";
}

// @internal (undocumented)
export interface PanelSetPinnedAction {
// (undocumented)
Expand All @@ -810,6 +797,16 @@ export interface PanelSetPinnedAction {
readonly type: "PANEL_SET_PINNED";
}

// @internal (undocumented)
export interface PanelSetResizableAction {
// (undocumented)
readonly resizable: PanelState["resizable"];
// (undocumented)
readonly side: PanelSide;
// (undocumented)
readonly type: "PANEL_SET_RESIZABLE";
}

// @internal (undocumented)
export interface PanelSetSizeAction {
// (undocumented)
Expand Down Expand Up @@ -1023,12 +1020,6 @@ export interface PreviewMaximizedWidgetFeatureProviderProps {
// @internal (undocumented)
export function PreviewMaximizeToggle(): JSX.Element;

// @internal
export function removeTab(state: NineZoneState, tabId: TabState["id"]): NineZoneState;

// @internal
export function removeTabFromWidget(state: NineZoneState, tabId: TabState["id"]): NineZoneState;

// @internal (undocumented)
export interface ResizeAction {
// (undocumented)
Expand Down Expand Up @@ -1714,6 +1705,39 @@ export interface WidgetContextArgs {
measure: () => Rectangle;
}

// @internal (undocumented)
export interface WidgetDefAddAction {
// (undocumented)
readonly floatingWidget: {
readonly id: FloatingWidgetState["id"];
readonly preferredPosition?: XAndY;
};
// (undocumented)
readonly id: TabState["id"];
// (undocumented)
readonly location: "panel" | "floating";
// (undocumented)
readonly overrides?: Partial<TabState>;
// (undocumented)
readonly panelSection: {
readonly id: WidgetState["id"];
readonly index: number;
readonly side: PanelSide;
};
// (undocumented)
readonly type: "WIDGET_DEF_ADD";
}

// @internal (undocumented)
export interface WidgetDefAddToolSettingsAction {
// (undocumented)
readonly id: TabState["id"];
// (undocumented)
readonly overrides?: Partial<TabState>;
// (undocumented)
readonly type: "WIDGET_DEF_ADD_TOOL_SETTINGS";
}

// @internal (undocumented)
export interface WidgetDragAction {
// (undocumented)
Expand Down Expand Up @@ -2034,6 +2058,14 @@ export interface WidgetTabProviderProps extends TabPositionContextArgs {
showOnlyTabIcon?: boolean;
}

// @internal (undocumented)
export interface WidgetTabRemoveAction {
// (undocumented)
readonly id: TabState["id"];
// (undocumented)
readonly type: "WIDGET_TAB_REMOVE";
}

// @internal (undocumented)
export function WidgetTabs(): JSX.Element;

Expand Down Expand Up @@ -2091,6 +2123,16 @@ export interface WidgetTabUnloadAction {
readonly type: "WIDGET_TAB_UNLOAD";
}

// @internal (undocumented)
export interface WidgetTabUpdateAction {
// (undocumented)
readonly id: TabState["id"];
// (undocumented)
readonly overrides: Partial<TabState>;
// (undocumented)
readonly type: "WIDGET_TAB_UPDATE";
}

// @internal (undocumented)
export interface WidgetToolSettingsState {
// (undocumented)
Expand Down
45 changes: 16 additions & 29 deletions common/api/appui-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import { MessageBoxType } from '@itwin/core-frontend';
import { MessageBoxValue } from '@itwin/core-frontend';
import { MessageSeverity } from '@itwin/appui-abstract';
import type { MessageType } from '@itwin/core-react';
import { NineZoneDispatch } from '@itwin/appui-layout-react';
import type { NineZoneDispatch } from '@itwin/appui-layout-react';
import type { NineZoneLabels } from '@itwin/appui-layout-react';
import type { NineZoneState } from '@itwin/appui-layout-react';
import type { NoChildrenProps } from '@itwin/core-react';
Expand Down Expand Up @@ -100,7 +100,6 @@ import type { SolarDataProvider } from '@itwin/imodel-components-react';
import { StandardViewId } from '@itwin/core-frontend';
import type { Store } from 'redux';
import type { StringGetter } from '@itwin/appui-abstract';
import type { TabState } from '@itwin/appui-layout-react';
import type { ToasterSettings } from '@itwin/itwinui-react/cjs/core/Toast/Toaster';
import type { ToastOptions } from '@itwin/itwinui-react';
import { Tool } from '@itwin/core-frontend';
Expand Down Expand Up @@ -354,7 +353,7 @@ export interface ActiveContentChangedEventArgs {
}

// @internal (undocumented)
export function ActiveFrontstageDefProvider({ frontstageDef, layout, }: ActiveFrontstageDefProviderProps): JSX.Element;
export function ActiveFrontstageDefProvider({ frontstageDef, }: ActiveFrontstageDefProviderProps): JSX.Element;

// @public
export function ActivityCenterField(props: CommonProps): JSX.Element | null;
Expand All @@ -376,13 +375,10 @@ export class ActivityMessageUpdatedEvent extends UiEvent<ActivityMessageEventArg
}

// @internal
export function addMissingWidgets(frontstageDef: FrontstageDef, initialState: NineZoneState): NineZoneState;
export function addFrontstageWidgetDefs(frontstageDef: FrontstageDef): void;

// @internal (undocumented)
export function addPanelWidgets(state: NineZoneState, frontstageDef: FrontstageDef, location: StagePanelLocation): NineZoneState;

// @internal (undocumented)
export function addWidgets(state: NineZoneState, widgets: ReadonlyArray<WidgetDef>, side: PanelSide, widgetId: WidgetId): NineZoneState;
// @internal
export function addPanelSectionWidgetDefs(frontstageDef: FrontstageDef, location: StagePanelLocation, section: StagePanelSection): void;

// @public
export interface AllowedUiItemsProviderOverrides {
Expand All @@ -408,9 +404,6 @@ export type AnyItemDef = GroupItemDef | CommandItemDef | ToolItemDef | ActionBut
// @public
export type AnyToolbarItemDef = AnyItemDef | CustomItemDef;

// @internal (undocumented)
export function appendWidgets(state: NineZoneState, widgetDefs: ReadonlyArray<WidgetDef>, location: StagePanelLocation, section: StagePanelSection): NineZoneState;

// @public
export class AppNotificationManager extends NotificationManager {
clearToolTip(): void;
Expand Down Expand Up @@ -1748,9 +1741,6 @@ export interface ExpandableSectionProps extends CommonProps {
title?: string;
}

// @internal (undocumented)
export function expandWidget(state: NineZoneState, id: TabState["id"]): NineZoneState;

// @public
export interface ExtensibleToolbarProps {
// (undocumented)
Expand Down Expand Up @@ -2192,6 +2182,8 @@ export interface FrontstageDeactivatedEventArgs {
export class FrontstageDef {
// (undocumented)
addFloatingContentControl(contentControl?: ContentControl): void;
// @internal
batch(fn: () => void): void;
// (undocumented)
get bottomPanel(): StagePanelDef | undefined;
get contentControls(): ContentControl[];
Expand All @@ -2206,6 +2198,7 @@ export class FrontstageDef {
static create(provider: FrontstageProvider): Promise<FrontstageDef>;
// @internal (undocumented)
get dispatch(): NineZoneDispatch;
set dispatch(dispatch: NineZoneDispatch);
// @beta
dockWidgetContainer(widgetId: string): void;
// @internal (undocumented)
Expand Down Expand Up @@ -2347,6 +2340,9 @@ export function getIsHiddenIfSelectionNotActive(): ConditionalBooleanValue;
// @beta (undocumented)
export function getListPanel(props: ListPickerProps): React_2.ReactNode;

// @internal (undocumented)
export function getPanelSectionId(location: StagePanelLocation, section: StagePanelSection): PanelSectionId;

// @internal (undocumented)
export function getPanelSectionWidgets(frontstageDef: FrontstageDef, location: StagePanelLocation, section: StagePanelSection): ReadonlyArray<WidgetDef>;

Expand All @@ -2362,9 +2358,6 @@ export function getSelectionContextSyncEventIds(): string[];
// @beta
export function getUiSettingsManagerEntry(itemPriority: number): SettingsTabEntry;

// @internal (undocumented)
export function getWidgetId(location: StagePanelLocation, section: StagePanelSection): WidgetId;

// @internal (undocumented)
export type GroupedItems = ReadonlyArray<ReadonlyArray<BackstageItem>>;

Expand Down Expand Up @@ -2581,10 +2574,10 @@ export interface InitialAppUiSettings {
}

// @internal (undocumented)
export function initializeNineZoneState(frontstageDef: FrontstageDef): NineZoneState;
export function initializeNineZoneState(frontstageDef: FrontstageDef): void;

// @internal (undocumented)
export function initializePanel(state: NineZoneState, frontstageDef: FrontstageDef, location: StagePanelLocation): NineZoneState;
export function initializePanel(frontstageDef: FrontstageDef, location: StagePanelLocation): void;

// @beta (undocumented)
export class InputEditorCommitHandler {
Expand Down Expand Up @@ -2666,9 +2659,6 @@ export function isFrontstageStateSettingResult(settingsResult: UiStateStorageRes
// @beta
export function isNoSelectionActive(): boolean;

// @internal (undocumented)
export function isPanelCollapsed(panelState: StagePanelState | undefined): boolean;

// @internal
export const isReactContent: (content: PopupContentType) => content is ReactContent;

Expand Down Expand Up @@ -3296,7 +3286,7 @@ export interface OverflowToolbarOptions {
}

// @internal
export function packNineZoneState(state: NineZoneState): SavedNineZoneState;
export function packNineZoneState(state: NineZoneState): NineZoneState;

// @public
export interface PanelPinnedChangedEventArgs {
Expand Down Expand Up @@ -3623,7 +3613,7 @@ export class RestoreFrontstageLayoutTool extends Tool {
}

// @internal
export function restoreNineZoneState(frontstageDef: FrontstageDef, saved: SavedNineZoneState): NineZoneState;
export function restoreNineZoneState(frontstageDef: FrontstageDef, packed: NineZoneState): void;

// @internal (undocumented)
export interface RotationData {
Expand Down Expand Up @@ -3910,9 +3900,6 @@ export class SheetsModalFrontstage implements ModalFrontstageInfo {
title: string;
}

// @internal (undocumented)
export function showWidget(state: NineZoneState, id: TabState["id"]): NineZoneState;

// @public
export const SnapModeField: ConnectedComponent<typeof SnapModeFieldComponent, Omit_3<SnapModeFieldProps, "snapMode">>;

Expand Down Expand Up @@ -5505,7 +5492,7 @@ export interface WidgetPanelsFrontstageState {
// (undocumented)
id: FrontstageDef["id"];
// (undocumented)
nineZone: SavedNineZoneState;
nineZone: NineZoneState;
stateVersion: number;
version: number;
}
Expand Down
Loading
Loading