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

feat: control Flow Editor via the Electron app menu #3660

Merged
merged 20 commits into from
Jul 31, 2020
Merged

Conversation

yeze322
Copy link
Contributor

@yeze322 yeze322 commented Jul 20, 2020

Description

closes #3227

Problem

In Electron app, there are a group of menu items under the system menu -> 'Edit' label which are designed to share the same functionality with Composer Toolbar (Undo/Redo/Cut/Copy/Del).
Screen Shot 2020-06-01 at 10 29 37 AM

However, they never work due to not connected to editor events.

Target

This PR connected Composer editor APIs with the Electron app menu bar to fix this issue.
Supported actions:

  • 'undo' (api not provided by Shell, WIP by @lei9444 )
  • 'redo' (api not provided by Shell, WIP by @lei9444 )
  • 'copy'
  • 'cut'
  • 'delete'
  • 'paste' (paste is available in the flyout action menu)

How it works

Electron app menu runs in main process; Composer web app runs in renderer process.
To connect them together, we can leverage Electron IPC mechanism to let 'main' process post messages to 'renderer' process.

// main process (app menu) -> post messages
rendererWindow.webContents.send('event-name', eventData);

// renderer process (Composer webapp) -> subscribe events
ipcRenderer.on('event-name', (e, eventData) => handle(eventData));

Task Item

Screenshots

electron-app-menu

@yeze322
Copy link
Contributor Author

yeze322 commented Jul 20, 2020

@cwhitten Chris do you think it's a good solution to share those Composer APIs via the global window variable?

@coveralls
Copy link

coveralls commented Jul 20, 2020

Coverage Status

Coverage decreased (-0.2%) to 57.313% when pulling b5288b5 on visual/appmenu into ba18903 on main.

@cwhitten
Copy link
Member

@yeze322 this seems reasonable. We wouldn't want to enable those actions if there was no current node selection, so we need to add a enabled/disabled heuristic. cc @tonyanziano

@cwhitten cwhitten requested a review from tonyanziano July 23, 2020 15:41
@yeze322 yeze322 changed the title draft: control Flow Editor via the Electron app menu feat: control Flow Editor via the Electron app menu Jul 28, 2020
@yeze322 yeze322 marked this pull request as ready for review July 28, 2020 13:16
@yeze322
Copy link
Contributor Author

yeze322 commented Jul 28, 2020

Feature completed, ready for review and test.
I've tested on Windows platform.

Copy link
Member

@cwhitten cwhitten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my earlier comment on needing to wire up a disabled/enabled heuristic. It needs to match what options are available in the authoring surface.

@yeze322
Copy link
Contributor Author

yeze322 commented Jul 30, 2020

See my earlier comment on needing to wire up a disabled/enabled heuristic. It needs to match what options are available in the authoring surface.

Updated the logic: Composer (renderer process) send an actionSelected status to Electron menu (main process) to control Electron's app menu status.

electron-app-menu-dynamic-statuis

@yeze322 yeze322 requested a review from cwhitten July 30, 2020 10:06
@yeze322
Copy link
Contributor Author

yeze322 commented Jul 31, 2020

@cwhitten I updated the code to fix UT.

Ideally, the failure on undefined ipcMain should be fixed by providing a mocked Electron package under __mock__/Electron.js, however, to make the fix simple, I just check the existence of ipcMain.

@cwhitten cwhitten merged commit 970320e into main Jul 31, 2020
@cwhitten cwhitten deleted the visual/appmenu branch July 31, 2020 17:50
alanlong9278 added a commit that referenced this pull request Aug 3, 2020
* main:
  feat: control Flow Editor via the Electron app menu (#3660)
  fix: LG/LU editing performance optimize (#3738)
liweitian added a commit that referenced this pull request Aug 3, 2020
* fix: LG/LU editing performance optimize (#3738)

* update luUtil interface

* update

* use structure luFile do CRUD

* refine lgUtile interface

* update worker

* update lu package

* update lg package

* update parse line number

* log

* parse still use worker

* lint fix

* clean up

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* wrap with formatMessage

Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>

* feat: control Flow Editor via the Electron app menu (#3660)

* draft: consume the EditorAPI in electron menu

* register global EditorAPI

* apply EditorAPI in ToolBar

* apply EditorAPI in Electron app menu

* add todos in undo/redo

* emit Electron menu events to renderer process

* use ipc channel to subscribe Electron menu events

* override default menu event

* add shortcuts

* remove duplicated usage of getEditorApi()

* fix UT

* update 'Redo' shortcut in Electron menu

* disable cut/copy/del menu when no action selected

* extract Electron logic to a hook

* check ipcMain in jest env

Co-authored-by: Chris Whitten <[email protected]>

* deploy logic change

* azure deploy bugfix

* yarn

* typecheck error

* fix: Luis publish missing parameter (#3764)

* fix luis publish

* remove empty space in setting page

* resolve conflict

Co-authored-by: Zhixiang Zhan <[email protected]>
Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>
Co-authored-by: zeye <[email protected]>
Co-authored-by: Long Alan <[email protected]>
Co-authored-by: Long Jun <[email protected]>
luhan2017 added a commit that referenced this pull request Aug 25, 2020
* rebuild qna CRUD and qna page UI (#3692)

* rebase

* Rebuild qna (#3701)

* add unique key to qna property

* import online file

* debug

* add qna trigger type (#3703)

* resolve conflict

* bug fix

* refine qna crud (#3711)

* Update Program.cs

* fix bug (#3715)

* bugfix: start bot pop error message for new echo bot

* revert the change on common.lg

* send qna endpointKey to runtime

* publish pop

* eslint

* Regression on publish page after recoil

* clean some code

* recognizer dropdown & custom default content

* migration

* fix files structure change

* fix object can only read

* add botProject interface and move some interface into shared folder

* fix lint

* update trigger action (#3720)

* merge publish error fixed

* Update package to include the resourc id fix

* add id for dialog & migrate it with old bot

* crosstrain config

* eslint & qna jump

* migration old bot for recognizer

* migration old bot for recognizer

* revert rootId in  luUtil

* change qna location

* refactor publish logic

* cross train when default recognizer

* sync cross train config logic with azure deploy

* fix bug (#3748)

* Update the sdk package to include expandText fix

* solve conflict

* resolve conflict

* cross train config filter no body trigger intent

* deploy logic change

* azure deploy bugfix

* yarn

* typecheck error

* Qna recognizer tmp (#3765)

* fix: LG/LU editing performance optimize (#3738)

* update luUtil interface

* update

* use structure luFile do CRUD

* refine lgUtile interface

* update worker

* update lu package

* update lg package

* update parse line number

* log

* parse still use worker

* lint fix

* clean up

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* wrap with formatMessage

Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>

* feat: control Flow Editor via the Electron app menu (#3660)

* draft: consume the EditorAPI in electron menu

* register global EditorAPI

* apply EditorAPI in ToolBar

* apply EditorAPI in Electron app menu

* add todos in undo/redo

* emit Electron menu events to renderer process

* use ipc channel to subscribe Electron menu events

* override default menu event

* add shortcuts

* remove duplicated usage of getEditorApi()

* fix UT

* update 'Redo' shortcut in Electron menu

* disable cut/copy/del menu when no action selected

* extract Electron logic to a hook

* check ipcMain in jest env

Co-authored-by: Chris Whitten <[email protected]>

* deploy logic change

* azure deploy bugfix

* yarn

* typecheck error

* fix: Luis publish missing parameter (#3764)

* fix luis publish

* remove empty space in setting page

* resolve conflict

Co-authored-by: Zhixiang Zhan <[email protected]>
Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>
Co-authored-by: zeye <[email protected]>
Co-authored-by: Long Alan <[email protected]>
Co-authored-by: Long Jun <[email protected]>

* set max memory for build

* refactor qna popup logic && form editor ux

* Update trigger (#3768)

* update trigger actions

* rebase

* update trigger (#3772)

* fix export bug (#3776)

* separates Form / Flow's ExtensionContext

* test fixed

* fix trigger actions bug (#3787)

* fix trigger bug (#3788)

* fix trigger bug

* update trigger text

* conflict err

* update bf-lu package & fix conflict err

* Creating qn a sample (#3819)

* create qnaSample bot flow

* update create qna bot flow

* fix bug

* fix bug (#3822)

* test for build qna & lu in server

* Update qn a flow (#3831)

* fix bug

* update import qna flow

* Fix ui bug (#3833)

* fix bug

* update import QNA UI

* Update autoEndDialog to false

* Navigate to qna page (#3834)

* fix bug

* navigate to qna page

* Updates

* Fix

* refine code

* refactor & add comment

* refine code"

* handle comments

* popup desc

* hidden the subsription key

* recognizer

* replace the default name with unique id

* use common component to show error

* comments

* update UI

* fix the qna icon reload issue

* fix UI bug

* change hover color

* remove toggle on row

* qna endpointKey

* popup

* add try catch for get qna endpointKey

* update UI

* remove the scroll bar and update the error display

* update qna UI

* input luis hoisting

* conflict

* comments

* test fixed

* test fixed

* handle comments

* separated QnAEditor & rename to knowledge-base (#3857)

* separated QnAEditor & rename to knowledge-base

* rename

* rename helper to utilities

* fix test case

* fix unit tests

* test

* qna-recognizer add tests (#3859)

* add triggerCreattionModal test

* triggerApi test

* add test for import modal

* add test

* dialog id

* fix bug

* fix bug

* wrong url

* conflict

* Update ComposerSettingsExtensions

* update the error message

* conflict fix

* Update ComposerSettingsExtensions.cs

* azure deploy

* lu build

* qna build bugfix

* code refine

* lint fix

* qna name

* code refine

* Update package to daily to fix the CrossTrainRecognizer issue

* concurrent import qna from urls and set call limits

* error message & e2e test

* e2e test

* code scan error

* fix code scanner error

* fix code scanner error

* update the get params

* fix UI

* update qna error logic

* Update package to 4.10.1

* encode qna urls

* refactor

* fix e2e todobot

Co-authored-by: Long Jun <[email protected]>
Co-authored-by: Long Alan <[email protected]>
Co-authored-by: Lu Han <[email protected]>
Co-authored-by: Wenyi Luo <[email protected]>
Co-authored-by: leilzh <[email protected]>
Co-authored-by: Zhixiang Zhan <[email protected]>
Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>
Co-authored-by: zeye <[email protected]>
Co-authored-by: zeye <[email protected]>
lei9444 pushed a commit to lei9444/BotFramework-Composer-1 that referenced this pull request Jun 15, 2021
* draft: consume the EditorAPI in electron menu

* register global EditorAPI

* apply EditorAPI in ToolBar

* apply EditorAPI in Electron app menu

* add todos in undo/redo

* emit Electron menu events to renderer process

* use ipc channel to subscribe Electron menu events

* override default menu event

* add shortcuts

* remove duplicated usage of getEditorApi()

* fix UT

* update 'Redo' shortcut in Electron menu

* disable cut/copy/del menu when no action selected

* extract Electron logic to a hook

* check ipcMain in jest env

Co-authored-by: Chris Whitten <[email protected]>
lei9444 added a commit to lei9444/BotFramework-Composer-1 that referenced this pull request Jun 15, 2021
* rebuild qna CRUD and qna page UI (microsoft#3692)

* rebase

* Rebuild qna (microsoft#3701)

* add unique key to qna property

* import online file

* debug

* add qna trigger type (microsoft#3703)

* resolve conflict

* bug fix

* refine qna crud (microsoft#3711)

* Update Program.cs

* fix bug (microsoft#3715)

* bugfix: start bot pop error message for new echo bot

* revert the change on common.lg

* send qna endpointKey to runtime

* publish pop

* eslint

* Regression on publish page after recoil

* clean some code

* recognizer dropdown & custom default content

* migration

* fix files structure change

* fix object can only read

* add botProject interface and move some interface into shared folder

* fix lint

* update trigger action (microsoft#3720)

* merge publish error fixed

* Update package to include the resourc id fix

* add id for dialog & migrate it with old bot

* crosstrain config

* eslint & qna jump

* migration old bot for recognizer

* migration old bot for recognizer

* revert rootId in  luUtil

* change qna location

* refactor publish logic

* cross train when default recognizer

* sync cross train config logic with azure deploy

* fix bug (microsoft#3748)

* Update the sdk package to include expandText fix

* solve conflict

* resolve conflict

* cross train config filter no body trigger intent

* deploy logic change

* azure deploy bugfix

* yarn

* typecheck error

* Qna recognizer tmp (microsoft#3765)

* fix: LG/LU editing performance optimize (microsoft#3738)

* update luUtil interface

* update

* use structure luFile do CRUD

* refine lgUtile interface

* update worker

* update lu package

* update lg package

* update parse line number

* log

* parse still use worker

* lint fix

* clean up

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* Update Composer/packages/client/src/recoilModel/dispatchers/lg.ts

Co-authored-by: Andy Brown <[email protected]>

* wrap with formatMessage

Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>

* feat: control Flow Editor via the Electron app menu (microsoft#3660)

* draft: consume the EditorAPI in electron menu

* register global EditorAPI

* apply EditorAPI in ToolBar

* apply EditorAPI in Electron app menu

* add todos in undo/redo

* emit Electron menu events to renderer process

* use ipc channel to subscribe Electron menu events

* override default menu event

* add shortcuts

* remove duplicated usage of getEditorApi()

* fix UT

* update 'Redo' shortcut in Electron menu

* disable cut/copy/del menu when no action selected

* extract Electron logic to a hook

* check ipcMain in jest env

Co-authored-by: Chris Whitten <[email protected]>

* deploy logic change

* azure deploy bugfix

* yarn

* typecheck error

* fix: Luis publish missing parameter (microsoft#3764)

* fix luis publish

* remove empty space in setting page

* resolve conflict

Co-authored-by: Zhixiang Zhan <[email protected]>
Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>
Co-authored-by: zeye <[email protected]>
Co-authored-by: Long Alan <[email protected]>
Co-authored-by: Long Jun <[email protected]>

* set max memory for build

* refactor qna popup logic && form editor ux

* Update trigger (microsoft#3768)

* update trigger actions

* rebase

* update trigger (microsoft#3772)

* fix export bug (microsoft#3776)

* separates Form / Flow's ExtensionContext

* test fixed

* fix trigger actions bug (microsoft#3787)

* fix trigger bug (microsoft#3788)

* fix trigger bug

* update trigger text

* conflict err

* update bf-lu package & fix conflict err

* Creating qn a sample (microsoft#3819)

* create qnaSample bot flow

* update create qna bot flow

* fix bug

* fix bug (microsoft#3822)

* test for build qna & lu in server

* Update qn a flow (microsoft#3831)

* fix bug

* update import qna flow

* Fix ui bug (microsoft#3833)

* fix bug

* update import QNA UI

* Update autoEndDialog to false

* Navigate to qna page (microsoft#3834)

* fix bug

* navigate to qna page

* Updates

* Fix

* refine code

* refactor & add comment

* refine code"

* handle comments

* popup desc

* hidden the subsription key

* recognizer

* replace the default name with unique id

* use common component to show error

* comments

* update UI

* fix the qna icon reload issue

* fix UI bug

* change hover color

* remove toggle on row

* qna endpointKey

* popup

* add try catch for get qna endpointKey

* update UI

* remove the scroll bar and update the error display

* update qna UI

* input luis hoisting

* conflict

* comments

* test fixed

* test fixed

* handle comments

* separated QnAEditor & rename to knowledge-base (microsoft#3857)

* separated QnAEditor & rename to knowledge-base

* rename

* rename helper to utilities

* fix test case

* fix unit tests

* test

* qna-recognizer add tests (microsoft#3859)

* add triggerCreattionModal test

* triggerApi test

* add test for import modal

* add test

* dialog id

* fix bug

* fix bug

* wrong url

* conflict

* Update ComposerSettingsExtensions

* update the error message

* conflict fix

* Update ComposerSettingsExtensions.cs

* azure deploy

* lu build

* qna build bugfix

* code refine

* lint fix

* qna name

* code refine

* Update package to daily to fix the CrossTrainRecognizer issue

* concurrent import qna from urls and set call limits

* error message & e2e test

* e2e test

* code scan error

* fix code scanner error

* fix code scanner error

* update the get params

* fix UI

* update qna error logic

* Update package to 4.10.1

* encode qna urls

* refactor

* fix e2e todobot

Co-authored-by: Long Jun <[email protected]>
Co-authored-by: Long Alan <[email protected]>
Co-authored-by: Lu Han <[email protected]>
Co-authored-by: Wenyi Luo <[email protected]>
Co-authored-by: leilzh <[email protected]>
Co-authored-by: Zhixiang Zhan <[email protected]>
Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: Andy Brown <[email protected]>
Co-authored-by: zeye <[email protected]>
Co-authored-by: zeye <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cut, copy paste appears to not work with a selected action
3 participants