Skip to content

Commit

Permalink
chore: add onOpenDialog api to support dialog jump (#4542)
Browse files Browse the repository at this point in the history
* impl onOpenDialog as DialogEditingContext

* add missing api in stub

Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Dong Lei <donglei@microsoft.com>
  • Loading branch information
3 people authored Nov 30, 2020
1 parent 6ad4945 commit e4c6c71
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const ShellApiStub: ShellApi = {
saveDialog: fn,
saveData: fnPromise,
navTo: fn,
onOpenDialog: fnPromise,
createQnATrigger: fn,
onFocusSteps: fn,
onFocusEvent: fn,
onSelect: fn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export const useEditorEventApi = (
const { selectedIds, setSelectedIds, selectableElements } = selectionContext;

const {
onOpenDialog,
onFocusSteps,
onFocusEvent,
onCopy: onClipboardChange,
navTo,
saveData: onChange,
undo,
redo,
Expand Down Expand Up @@ -158,7 +158,7 @@ export const useEditorEventApi = (
break;
case NodeEventTypes.OpenDialog:
handler = ({ callee }) => {
navTo(callee);
onOpenDialog(callee);
announce(ScreenReaderMessage.DialogOpened);
};
break;
Expand Down
5 changes: 5 additions & 0 deletions Composer/packages/client/src/shell/useShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ export function useShell(source: EventSource, projectId: string): Shell {
await navTo(projectId, path, rest);
}

async function openDialog(dialogId: string) {
await navTo(projectId, dialogId, '"beginDialog"');
}

async function focusEvent(subPath) {
if (rootBotProjectId == null) return;
await selectTo(projectId, dialogId, subPath);
Expand Down Expand Up @@ -209,6 +213,7 @@ export function useShell(source: EventSource, projectId: string): Shell {
renameRegExIntent: renameRegExIntentHandler,
updateIntentTrigger: updateIntentTriggerHandler,
navTo: navigationTo,
onOpenDialog: openDialog,
onFocusEvent: focusEvent,
onFocusSteps: focusSteps,
onSelect: setVisualEditorSelection,
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/types/src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export type ActionContextApi = {

export type DialogEditingContextApi = {
saveData: <T = any>(newData: T, updatePath?: string, callback?: () => void | Promise<void>) => Promise<void>;
onOpenDialog: (dialogId: string) => Promise<void>;
onFocusSteps: (stepIds: string[], focusedTab?: string) => Promise<void>;
onFocusEvent: (eventId: string) => Promise<void>;
onSelect: (ids: string[]) => void;
Expand Down

0 comments on commit e4c6c71

Please sign in to comment.