Skip to content

Commit

Permalink
Set type for submitting from views
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Sep 30, 2023
1 parent 2dc0f8a commit ee1dc56
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 0 additions & 1 deletion apps/meteor/client/views/banners/UiKitBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const UiKitBanner = ({ initialView }: UiKitBannerProps) => {
view: {
...view,
id: view.viewId,
state: {},
},
isCleared: true,
})
Expand Down
21 changes: 17 additions & 4 deletions packages/ui-contexts/src/ActionManagerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,23 @@ type ViewClosedTriggerOptions = {
type: 'viewClosed';
appId: string;
viewId: UiKit.View['viewId'];
view: UiKit.View & { id: UiKit.View['viewId']; state: Record<string, unknown> };
view: UiKit.View & { id: UiKit.View['viewId']; state?: Record<string, unknown> };
isCleared: boolean;
};

type ViewSubmitTriggerOptions = {
type: 'viewSubmit';
appId: string;
viewId: UiKit.View['viewId'];
actionId?: string;
triggerId?: string;
payload: {
view: UiKit.View & { id: UiKit.View['viewId']; state?: Record<string, unknown> };
};
};

type TriggerOptions = BlockActionTriggerOptions | ViewClosedTriggerOptions | ViewSubmitTriggerOptions;

/**
* Utility type to remove the `type` property from an **union** of objects.
*/
Expand All @@ -58,7 +71,7 @@ type ActionManagerContextValue = {
triggerId: any;
},
) => any;
triggerAction(action: BlockActionTriggerOptions | ViewClosedTriggerOptions): Promise<void>;
triggerAction(action: TriggerOptions): Promise<void>;
triggerAction({
type,
actionId,
Expand All @@ -81,9 +94,9 @@ type ActionManagerContextValue = {
tmid: any;
}): Promise<any>;
triggerBlockAction(options: WithoutType<BlockActionTriggerOptions>): Promise<void>;
triggerActionButtonAction: (options: any) => Promise<any>;
triggerSubmitView: ({ viewId, ...options }: { [x: string]: any; viewId: any }) => Promise<void>;
triggerCancel(options: WithoutType<ViewClosedTriggerOptions>): Promise<void>;
triggerSubmitView(options: WithoutType<ViewSubmitTriggerOptions>): Promise<void>;
triggerActionButtonAction: (options: any) => Promise<any>;
getUserInteractionPayloadByViewId: (viewId: any) => any;
};

Expand Down

0 comments on commit ee1dc56

Please sign in to comment.