@inboxsdk/core 0.2.28-alpha.3 → 0.2.28-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/inboxsdk.js +1 -1
- package/inboxsdk.js.map +1 -1
- package/package.json +5 -1
- package/src/build/exec.js +26 -0
- package/src/build/spawn.js +17 -0
- package/src/common/ajax.js +90 -0
- package/src/common/cachebust-url.js +10 -0
- package/src/common/censorHTMLstring.js +37 -0
- package/src/common/censorHTMLtree.js +28 -0
- package/src/common/censorJSONTree.js +15 -0
- package/src/common/connectivity-test.js +21 -0
- package/src/common/defer.js +11 -0
- package/src/common/find-parent.js +10 -0
- package/src/common/get-extension-id.js +7 -0
- package/src/common/get-or-fail.js +8 -0
- package/src/common/get-session-id.js +14 -0
- package/src/common/get-stack-trace.js +6 -0
- package/src/common/html-to-text.js +7 -0
- package/src/common/isElementVisible.js +6 -0
- package/src/common/load-script.js +127 -0
- package/src/common/log-error.js +191 -0
- package/src/common/quoted-split.js +18 -0
- package/src/common/rate-limit-queuer.js +57 -0
- package/src/common/rate-limit.js +14 -0
- package/src/common/version.js +6 -0
- package/src/inboxsdk-js/check-requirements.js +7 -3
- package/src/inboxsdk-js/header.js +1 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.js +5 -6
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.js +4 -3
- package/src/inboxsdk-js/inboxsdk-REMOTE.js +3 -1
- package/src/inboxsdk-js/inboxsdk-TEST.js +4 -3
- package/src/inboxsdk-js/inboxsdk.js +33 -39
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.js +15 -18
- package/src/inboxsdk-js/loading/platform-implementation-loader.js +27 -0
- package/src/injected-js/gmail/constants.js +2 -0
- package/src/injected-js/gmail/modify-suggestions.js +106 -0
- package/src/injected-js/gmail/modify-suggestions.test.js +8 -9
- package/src/injected-js/gmail/setup-gmail-interceptor.js +340 -579
- package/src/injected-js/gmail/setup-gmonkey-handler.js +49 -0
- package/src/injected-js/gmail/sync-compose-processor-20220909.js +298 -0
- package/src/injected-js/gmail/sync-compose-processor.js +55 -0
- package/src/injected-js/gmail/sync-compose-request-processor.js +110 -0
- package/src/injected-js/gmail/sync-compose-request-processor.test.js +39 -49
- package/src/injected-js/gmail/thread-identifier/click-and-get-popup-url.js +20 -33
- package/src/injected-js/gmail/thread-identifier/index.js +57 -93
- package/src/injected-js/gmail/thread-identifier/thread-row-parser.js +22 -31
- package/src/injected-js/gmail/thread-identifier/thread-row-parser.test.js +12 -28
- package/src/injected-js/inbox/setupAjaxInterceptor.js +64 -121
- package/src/injected-js/inbox/setupClickAndGetNewIframeSrc.js +53 -66
- package/src/injected-js/inbox/setupComposeViewDraftIDFinder.js +20 -36
- package/src/injected-js/inbox/setupInboxFakeWindowResizeListener.js +13 -13
- package/src/injected-js/injected-logger.js +50 -0
- package/src/injected-js/main.js +11 -24
- package/src/injected-js/message-metadata-holder.js +52 -82
- package/src/injected-js/setup-data-exposer.js +89 -148
- package/src/injected-js/setup-error-silencer.js +21 -21
- package/src/injected-js/setup-event-reemitter.js +30 -22
- package/src/injected-js/setupCustomViewEventAssassin.js +90 -0
- package/src/injected-js/setupInboxCustomViewLinkFixer.js +24 -29
- package/src/injected-js/setupPushStateListener.js +18 -11
- package/src/injected-js/xhr-helper.js +62 -65
- package/src/injected-js/xhr-proxy-factory.js +195 -445
- package/src/injected-js/xhr-proxy-factory.test.js +824 -991
- package/src/platform-implementation-js/constants/nav-item-types.js +19 -0
- package/src/platform-implementation-js/constants/router.js +14 -9
- package/src/platform-implementation-js/constants/toolbars.js +8 -3
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.js +13 -13
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.js +115 -136
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.js +21 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-collapsible-panel.js +28 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-nav-item.js +98 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-support-item.js +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.js +13 -14
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.js +27 -48
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/encodeDraftUrlId.js +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.js +31 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.js +30 -40
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-rfc-message-id-for-gmail-message-id.js +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-rfc-message-id-for-gmail-thread-id.js +33 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.js +10 -18
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.js +21 -28
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadFromSyncThreadId.js +33 -45
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/gmail-load-event.js +31 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.js +58 -65
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/isIntegratedViewGmail.js +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.js +40 -124
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.js +17 -22
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-draft-by-message-id.js +44 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-draft-by-message-id.test.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.js +44 -80
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.js +19 -26
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.js +71 -147
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.js +91 -148
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.js +150 -166
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.test.js +70 -120
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.js +15 -15
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.js +44 -67
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.js +230 -379
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.test.js +121 -307
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.js +17 -24
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.js +41 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.js +30 -40
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.js +28 -60
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.js +61 -133
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-gmail-styles.js +95 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.js +30 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.test.js +52 -46
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +354 -694
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter/get-main-content-element-changed-stream.js +38 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter/wait-for-gmail-mode-to-settle.js +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.js +253 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-page-communicator.js +200 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-response-processor.js +533 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-sync-response-processor.js +289 -0
- package/src/platform-implementation-js/dom-driver/gmail/is-compose-titlebar-light-color.js +21 -0
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.js +77 -93
- package/src/platform-implementation-js/dom-driver/gmail/makePageParserTree.js +28 -0
- package/src/platform-implementation-js/dom-driver/gmail/pageParserOptions.js +19 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-menu-item-view.js +126 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.js +35 -82
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.test.js +44 -94
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-global-icon-area.js +12 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-thread-icon-area.js +17 -29
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-to-icon-area.js +26 -26
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/index.js +391 -797
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view/monitor-top-banner-size-and-react.js +7 -9
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.js +60 -109
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-area-view.js +95 -135
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.js +103 -211
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.test.js +61 -61
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.js +17 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.js +188 -541
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-button.js +67 -135
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-compose-notice.js +27 -49
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-inner-sidebar.js +7 -13
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-outer-sidebar.js +9 -22
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-recipient-row.js +36 -63
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-status-bar.js +101 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-tooltip-to-button.js +38 -113
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/detectClassicRecipientsArea.js +38 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-app-button-toolbars-are-closed.js +11 -16
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-grouping-is-open.js +11 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/focus.js +8 -11
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/from-manager.js +27 -47
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-additional-action-toolbar.js +11 -24
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-address-changes-stream.js +59 -111
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-address-information-extractor.js +28 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-body-changes-stream.js +15 -14
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-formatting-area-offset-left.js +11 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-minimized-stream.js +18 -24
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-recipients.js +22 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-response-type-changes-stream.js +19 -23
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/gmail-compose-button-view.js +233 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/insert-link-into-body.js +11 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/manage-button-grouping.js +141 -376
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/monitor-selection-range.js +17 -28
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/override-edit-subject.js +34 -70
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/page-parser.js +223 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/position-formatting-toolbar.js +10 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/set-recipients.js +157 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/setupLinkPopovers.js +109 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/size-fixer.js +83 -137
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/update-insert-more-area-left.js +10 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.js +632 -1190
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view/attachment-icon.js +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view/get-updated-contact.js +29 -38
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.js +327 -617
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.js +759 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-processor.js +26 -49
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +188 -380
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.js +104 -194
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-support-item-view.js +84 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.js +382 -811
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view/add-icon-area.js +34 -58
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.js +330 -581
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.test.js +123 -277
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view/width-manager.js +15 -35
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.js +216 -571
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.js +152 -336
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.js +87 -211
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/button-color-classes.js +33 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/button-view.js +325 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/create-accessory-button-view.js +58 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/create-parent-accessory-button-view.js +55 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/inbox-dropdown-button-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/modal-button-view.js +96 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/more-dropdown-button-view.js +30 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/more-parent-accessory-button-view.js +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-action-button-view.js +20 -29
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-dropdown-view.js +22 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-label-view.js +41 -76
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.js +45 -99
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +76 -128
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-tooltip-view.js +128 -319
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.js +45 -78
- package/src/platform-implementation-js/dom-driver/inbox/__mocks__/getSidebarClassnames.js +8 -4
- package/src/platform-implementation-js/dom-driver/inbox/addNavItem.js +36 -54
- package/src/platform-implementation-js/dom-driver/inbox/addRecipientRow.js +35 -53
- package/src/platform-implementation-js/dom-driver/inbox/createLink.js +13 -15
- package/src/platform-implementation-js/dom-driver/inbox/createLink.test.js +15 -18
- package/src/platform-implementation-js/dom-driver/inbox/custom-style.js +14 -13
- package/src/platform-implementation-js/dom-driver/inbox/detection/appToolbarLocation/parser.js +14 -20
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentCard/parser.js +14 -13
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentOverlay/parser.js +35 -67
- package/src/platform-implementation-js/dom-driver/inbox/detection/chatSidebar/parser.js +16 -18
- package/src/platform-implementation-js/dom-driver/inbox/detection/compose/parser.js +68 -185
- package/src/platform-implementation-js/dom-driver/inbox/detection/message/parser.js +28 -56
- package/src/platform-implementation-js/dom-driver/inbox/detection/nativeDrawer/parser.js +12 -10
- package/src/platform-implementation-js/dom-driver/inbox/detection/searchBar/parser.js +16 -16
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread/parser.js +24 -35
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread-row/parser.js +37 -89
- package/src/platform-implementation-js/dom-driver/inbox/getComposeViewDriverLiveSet.js +56 -78
- package/src/platform-implementation-js/dom-driver/inbox/getInboxMessageIdForInboxThreadId.js +26 -32
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.js +52 -109
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.test.js +7 -8
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.js +16 -20
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.test.js +15 -16
- package/src/platform-implementation-js/dom-driver/inbox/inbox-butter-bar-driver.js +75 -83
- package/src/platform-implementation-js/dom-driver/inbox/inbox-driver.js +530 -822
- package/src/platform-implementation-js/dom-driver/inbox/inbox-page-communicator.js +48 -61
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.js +9 -12
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.test.js +12 -19
- package/src/platform-implementation-js/dom-driver/inbox/makePageParserTree.js +24 -33
- package/src/platform-implementation-js/dom-driver/inbox/pageParserOptions.js +201 -388
- package/src/platform-implementation-js/dom-driver/inbox/registerSearchSuggestionsProvider.js +249 -265
- package/src/platform-implementation-js/dom-driver/inbox/setupCustomAutocompleteSelectionHandling.js +84 -152
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.js +55 -67
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.test.js +43 -65
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxLabelView.js +31 -56
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxMoleViewDriver.js +191 -294
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarButtonView.js +32 -45
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarView.js +21 -39
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-sidebar-view.js +153 -240
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-button-view.js +75 -150
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-tooltip-view.js +20 -37
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-card-view.js +60 -114
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-overlay-view.js +47 -65
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-backdrop.js +41 -52
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-chat-sidebar-view.js +27 -36
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-button-view.js +52 -80
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-view.js +465 -649
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.js +37 -58
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.test.js +14 -26
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.js +118 -235
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dropdown-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dummy-route-view.js +28 -46
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-message-view.js +131 -202
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-modal-view.js +40 -80
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-route-view.js +35 -61
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-row-view.js +124 -221
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.js +125 -213
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.test.js +104 -126
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-tooltip-view.js +36 -51
- package/src/platform-implementation-js/dom-driver/inbox/views/inboxNavItemView.js +158 -297
- package/src/platform-implementation-js/dom-driver/inbox/waitForAnimationClickBlockerGone.js +21 -35
- package/src/platform-implementation-js/driver-common/compose/getDiscardStream.js +24 -43
- package/src/platform-implementation-js/driver-common/compose/getPresendingStream.js +39 -68
- package/src/platform-implementation-js/driver-common/getAccountUrlPart.js +17 -0
- package/src/platform-implementation-js/driver-common/getGmailMessageIdForSyncMessageId.js +14 -19
- package/src/platform-implementation-js/driver-common/getGmailThreadIdForRfcMessageId.js +27 -35
- package/src/platform-implementation-js/driver-common/getOriginalMessagePage.js +33 -0
- package/src/platform-implementation-js/driver-common/getRfcMessageIdForSyncMessageId.js +16 -22
- package/src/platform-implementation-js/driver-common/getSyncThreadsForSearch.js +49 -0
- package/src/platform-implementation-js/driver-common/getThreadIdFromMessageId.js +14 -14
- package/src/platform-implementation-js/driver-common/gmailAjax.js +65 -0
- package/src/platform-implementation-js/driver-common/inboxAjax.js +12 -7
- package/src/platform-implementation-js/driver-common/render-custom-icon.js +16 -0
- package/src/platform-implementation-js/driver-common/requestGmailThread.js +19 -20
- package/src/platform-implementation-js/driver-common/sidebar/AppSidebar.js +197 -306
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.js +113 -161
- package/src/platform-implementation-js/driver-common/update-icon.js +90 -0
- package/src/platform-implementation-js/driver-interfaces/compose-view-driver.js +1 -114
- package/src/platform-implementation-js/driver-interfaces/driver.js +1 -131
- package/src/platform-implementation-js/driver-interfaces/message-view-driver.js +4 -48
- package/src/platform-implementation-js/driver-interfaces/mole-view-driver.js +1 -29
- package/src/platform-implementation-js/driver-interfaces/route-view-driver.js +1 -32
- package/src/platform-implementation-js/driver-interfaces/thread-row-view-driver.js +1 -11
- package/src/platform-implementation-js/lib/ErrorCollector.js +47 -0
- package/src/platform-implementation-js/lib/Membrane.js +22 -0
- package/src/platform-implementation-js/lib/ScrollableContainByScreen.js +30 -0
- package/src/platform-implementation-js/lib/array-to-lifetimes.js +43 -41
- package/src/platform-implementation-js/lib/array-to-lifetimes.test.js +139 -155
- package/src/platform-implementation-js/lib/attemptWithRetries.js +16 -0
- package/src/platform-implementation-js/lib/common-page-communicator.js +137 -0
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.js +19 -38
- package/src/platform-implementation-js/lib/css-selector-escape.js +7 -3
- package/src/platform-implementation-js/lib/delay-asap.js +12 -0
- package/src/platform-implementation-js/lib/delay-idle.js +16 -0
- package/src/platform-implementation-js/lib/dom/block-and-reemit-keyboard-events.js +36 -0
- package/src/platform-implementation-js/lib/dom/element-view-mapper.js +8 -11
- package/src/platform-implementation-js/lib/dom/generic-button-view.js +39 -0
- package/src/platform-implementation-js/lib/dom/get-insert-before-element.js +39 -0
- package/src/platform-implementation-js/lib/dom/get-selection.js +23 -52
- package/src/platform-implementation-js/lib/dom/insert-element-in-order.js +38 -0
- package/src/platform-implementation-js/lib/dom/insert-html-at-cursor.js +69 -101
- package/src/platform-implementation-js/lib/dom/is-node-in-range.js +8 -10
- package/src/platform-implementation-js/lib/dom/keyboard-shortcut-stream.js +12 -0
- package/src/platform-implementation-js/lib/dom/make-element-child-stream.js +79 -0
- package/src/platform-implementation-js/lib/dom/make-element-stream-merger.js +28 -0
- package/src/platform-implementation-js/lib/dom/make-element-view-stream.js +15 -0
- package/src/platform-implementation-js/lib/dom/make-mutation-observer-chunked-stream.js +15 -0
- package/src/platform-implementation-js/lib/dom/make-mutation-observer-stream.js +5 -0
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.js +15 -17
- package/src/platform-implementation-js/lib/dom/outsideClicksAndEscape.js +39 -0
- package/src/platform-implementation-js/lib/dom/parentNodes.js +8 -0
- package/src/platform-implementation-js/lib/dom/querySelectorOne.js +8 -11
- package/src/platform-implementation-js/lib/dom/querySelectorOrFail.js +6 -0
- package/src/platform-implementation-js/lib/dom/reemitClickEventForReact.js +22 -0
- package/src/platform-implementation-js/lib/dom/set-css.js +7 -3
- package/src/platform-implementation-js/lib/dom/set-value-and-dispatch-event.js +9 -11
- package/src/platform-implementation-js/lib/dom/simulate-drag-and-drop.js +32 -33
- package/src/platform-implementation-js/lib/dom/simulate-key.js +46 -0
- package/src/platform-implementation-js/lib/dom/simulate-mouse-event.js +16 -0
- package/src/platform-implementation-js/lib/dom/trigger-relay-event.js +7 -0
- package/src/platform-implementation-js/lib/extract-contact-from-email-contact-string.js +25 -0
- package/src/platform-implementation-js/lib/extract-contact-from-email-contact-string.test.js +23 -26
- package/src/platform-implementation-js/lib/fake-window-resize.js +5 -0
- package/src/platform-implementation-js/lib/from-event-target-capture.js +12 -0
- package/src/platform-implementation-js/lib/fromEventsWithOptions.js +10 -0
- package/src/platform-implementation-js/lib/handle-compose-link-chips.js +86 -149
- package/src/platform-implementation-js/lib/handler-registry.js +67 -0
- package/src/platform-implementation-js/lib/idMap.js +45 -0
- package/src/platform-implementation-js/lib/imageRequest.js +8 -0
- package/src/platform-implementation-js/lib/incrementName.js +7 -0
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.js +14 -0
- package/src/platform-implementation-js/lib/inject-script.js +33 -0
- package/src/platform-implementation-js/lib/insert-link-chip-into-body.js +42 -57
- package/src/platform-implementation-js/lib/is-valid-app-id.js +27 -0
- package/src/platform-implementation-js/lib/is-valid-email.js +14 -0
- package/src/platform-implementation-js/lib/isNotNil.js +5 -0
- package/src/platform-implementation-js/lib/isStreakAppId.js +11 -0
- package/src/platform-implementation-js/lib/logger.js +441 -0
- package/src/platform-implementation-js/lib/make-revocable-function.js +19 -21
- package/src/platform-implementation-js/lib/make-revocable-function.test.js +20 -22
- package/src/platform-implementation-js/lib/parseParamsFromRouteID.js +15 -17
- package/src/platform-implementation-js/lib/parseParamsFromRouteID.test.js +9 -18
- package/src/platform-implementation-js/lib/persistent-queue.js +107 -0
- package/src/platform-implementation-js/lib/populateRouteID.js +8 -9
- package/src/platform-implementation-js/lib/populateRouteID.test.js +20 -19
- package/src/platform-implementation-js/lib/react/ElementContainer.js +23 -20
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.js +10 -9
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.test.js +13 -20
- package/src/platform-implementation-js/lib/routeIDmatchesHash.js +13 -18
- package/src/platform-implementation-js/lib/routeIDmatchesHash.test.js +11 -17
- package/src/platform-implementation-js/lib/safe-event-emitter.js +17 -0
- package/src/platform-implementation-js/lib/shared-style.js +14 -13
- package/src/platform-implementation-js/lib/stopper-pool.js +41 -0
- package/src/platform-implementation-js/lib/stream-wait-for.js +30 -0
- package/src/platform-implementation-js/lib/toItemWithLifetimeStream.js +18 -17
- package/src/platform-implementation-js/lib/toLiveSet.js +17 -15
- package/src/platform-implementation-js/lib/wait-for.js +28 -0
- package/src/platform-implementation-js/lib/waitForAsync.js +19 -0
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.js +6 -5
- package/src/platform-implementation-js/main.js +9 -24
- package/src/platform-implementation-js/namespaces/app-menu.d.ts.map +1 -1
- package/src/platform-implementation-js/namespaces/app-menu.js +31 -0
- package/src/platform-implementation-js/namespaces/butter-bar.js +163 -0
- package/src/platform-implementation-js/namespaces/compose.js +37 -60
- package/src/platform-implementation-js/namespaces/conversations.js +52 -124
- package/src/platform-implementation-js/namespaces/global.js +27 -39
- package/src/platform-implementation-js/namespaces/keyboard.js +29 -33
- package/src/platform-implementation-js/namespaces/lists.js +25 -31
- package/src/platform-implementation-js/namespaces/modal.js +34 -28
- package/src/platform-implementation-js/namespaces/nav-menu.js +30 -45
- package/src/platform-implementation-js/namespaces/router.js +70 -137
- package/src/platform-implementation-js/namespaces/search.js +19 -17
- package/src/platform-implementation-js/namespaces/toolbars.js +71 -117
- package/src/platform-implementation-js/namespaces/user.js +36 -37
- package/src/platform-implementation-js/namespaces/widgets.js +54 -61
- package/src/platform-implementation-js/platform-implementation.js +98 -229
- package/src/platform-implementation-js/views/SimpleElementView.js +16 -0
- package/src/platform-implementation-js/views/app-menu-item-view.js +257 -0
- package/src/platform-implementation-js/views/app-toolbar-button-view.js +26 -47
- package/src/platform-implementation-js/views/collapsible-panel-view.js +222 -0
- package/src/platform-implementation-js/views/collapsible-section-view.js +66 -63
- package/src/platform-implementation-js/views/compose-button-view.js +45 -0
- package/src/platform-implementation-js/views/compose-view.js +312 -0
- package/src/platform-implementation-js/views/content-panel-view.js +28 -30
- package/src/platform-implementation-js/views/conversations/attachment-card-view.js +21 -44
- package/src/platform-implementation-js/views/conversations/custom-message-view.js +44 -104
- package/src/platform-implementation-js/views/conversations/message-view.js +131 -202
- package/src/platform-implementation-js/views/conversations/thread-view.js +75 -127
- package/src/platform-implementation-js/views/keyboard-shortcut-handle.js +14 -0
- package/src/platform-implementation-js/views/native-nav-item-view.js +32 -65
- package/src/platform-implementation-js/views/nav-item-view.js +51 -115
- package/src/platform-implementation-js/views/route-view/custom-route-view.js +25 -20
- package/src/platform-implementation-js/views/route-view/dummy-route-view-driver.js +18 -18
- package/src/platform-implementation-js/views/route-view/list-route-view.js +30 -52
- package/src/platform-implementation-js/views/route-view/route-view.js +24 -35
- package/src/platform-implementation-js/views/section-view.js +60 -52
- package/src/platform-implementation-js/views/thread-row-view.js +49 -74
- package/src/platform-implementation-js/widgets/buttons/basic-button-view-controller.js +39 -0
- package/src/platform-implementation-js/widgets/buttons/dropdown-button-view-controller.js +98 -0
- package/src/platform-implementation-js/widgets/buttons/dropdown-view.js +122 -0
- package/src/platform-implementation-js/widgets/drawer-view.js +29 -36
- package/src/platform-implementation-js/widgets/modal-view.js +39 -68
- package/src/platform-implementation-js/widgets/mole-view.js +22 -22
- package/src/platform-implementation-js/widgets/top-message-bar-view.js +13 -10
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import addToIconArea from './add-to-icon-area';
|
|
33
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _find = _interopRequireDefault(require("lodash/find"));
|
|
10
|
+
var _findIndex = _interopRequireDefault(require("lodash/findIndex"));
|
|
11
|
+
var _ud = require("ud");
|
|
12
|
+
var _autoHtml = _interopRequireDefault(require("auto-html"));
|
|
13
|
+
var _asap = _interopRequireDefault(require("asap"));
|
|
14
|
+
var _kefir = _interopRequireDefault(require("kefir"));
|
|
15
|
+
var _kefirBus = _interopRequireDefault(require("kefir-bus"));
|
|
16
|
+
var _kefirStopper = _interopRequireDefault(require("kefir-stopper"));
|
|
17
|
+
var _orderManager = _interopRequireDefault(require("order-manager"));
|
|
18
|
+
var _react = _interopRequireDefault(require("react"));
|
|
19
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
20
|
+
var _AppSidebar = _interopRequireDefault(require("../../../../../driver-common/sidebar/AppSidebar"));
|
|
21
|
+
var _gmailElementGetter = _interopRequireDefault(require("../../../gmail-element-getter"));
|
|
22
|
+
var _idMap = _interopRequireDefault(require("../../../../../lib/idMap"));
|
|
23
|
+
var _incrementName = _interopRequireDefault(require("../../../../../lib/incrementName"));
|
|
24
|
+
var _querySelectorOrFail = _interopRequireDefault(require("../../../../../lib/dom/querySelectorOrFail"));
|
|
25
|
+
var _makeMutationObserverChunkedStream = _interopRequireDefault(require("../../../../../lib/dom/make-mutation-observer-chunked-stream"));
|
|
26
|
+
var _makeElementChildStream = _interopRequireDefault(require("../../../../../lib/dom/make-element-child-stream"));
|
|
27
|
+
var _simulateMouseEvent = require("../../../../../lib/dom/simulate-mouse-event");
|
|
28
|
+
var _fakeWindowResize = _interopRequireDefault(require("../../../../../lib/fake-window-resize"));
|
|
29
|
+
var _addCompanionThreadIconArea = _interopRequireDefault(require("./add-companion-thread-icon-area"));
|
|
30
|
+
var _addCompanionGlobalIconArea = _interopRequireDefault(require("./add-companion-global-icon-area"));
|
|
31
|
+
var _addToIconArea = _interopRequireDefault(require("./add-to-icon-area"));
|
|
34
32
|
const ACTIVE_ADD_ON_ICON_SELECTOR = '.aT5-aOt-I-KO';
|
|
35
33
|
const COMPANION_SIDEBAR_CONTENT_CLOSED_SHADOW_CLASS = 'brC-brG-btc';
|
|
36
34
|
|
|
@@ -39,75 +37,54 @@ const COMPANION_SIDEBAR_CONTENT_CLOSED_SHADOW_CLASS = 'brC-brG-btc';
|
|
|
39
37
|
// instances (including from other extensions) communicate with this Primary
|
|
40
38
|
// through DOM events.
|
|
41
39
|
class GmailAppSidebarPrimary {
|
|
42
|
-
_stopper = kefirStopper();
|
|
43
|
-
|
|
44
|
-
// There could be multiple InboxSDK instances (and therefore GmailDrivers)
|
|
45
|
-
// talking to this Primary, so we shouldn't privilege the specific GmailDriver
|
|
46
|
-
// that happened to create the Primary. Only use this GmailDriver for
|
|
47
|
-
// logging-related functionality!
|
|
48
|
-
_driver: GmailDriver;
|
|
49
|
-
|
|
50
40
|
// This Primary has an identifier used by the DOM events to specify they're
|
|
51
41
|
// talking to this Primary. This leaves us some room for having multiple
|
|
52
42
|
// Primary instances (representing different visual locations in Gmail) or
|
|
53
43
|
// multiple classes that make use of the same DOM events, but we don't make
|
|
54
44
|
// use of that now. Mainly I didn't want to risk baking in the singleton
|
|
55
45
|
// nature too deeply; that always seems to bite me.
|
|
56
|
-
_instanceId: string = `${Date.now()}-${Math.random()}`;
|
|
57
|
-
|
|
58
|
-
_companionSidebarContentContainerEl: HTMLElement;
|
|
59
|
-
_instanceIdsToDescriptors: Map<string, Object> = new Map();
|
|
60
|
-
|
|
61
|
-
_threadSidebarComponent: ?AppSidebar = null;
|
|
62
|
-
|
|
63
|
-
_threadIconArea: ?HTMLElement = null;
|
|
64
|
-
_globalIconArea: ?HTMLElement = null;
|
|
65
|
-
|
|
66
|
-
_globalButtonContainers: Map<string, HTMLElement> = new Map();
|
|
67
|
-
_threadButtonContainers: Map<string, HTMLElement> = new Map();
|
|
68
|
-
_contentContainers: Map<string, HTMLElement> = new Map();
|
|
69
46
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
constructor(driver, companionSidebarContentContainerElement) {
|
|
48
|
+
(0, _defineProperty2.default)(this, "_stopper", (0, _kefirStopper.default)());
|
|
49
|
+
(0, _defineProperty2.default)(this, "_instanceId", `${Date.now()}-${Math.random()}`);
|
|
50
|
+
(0, _defineProperty2.default)(this, "_instanceIdsToDescriptors", new Map());
|
|
51
|
+
(0, _defineProperty2.default)(this, "_threadSidebarComponent", null);
|
|
52
|
+
(0, _defineProperty2.default)(this, "_threadIconArea", null);
|
|
53
|
+
(0, _defineProperty2.default)(this, "_globalIconArea", null);
|
|
54
|
+
(0, _defineProperty2.default)(this, "_globalButtonContainers", new Map());
|
|
55
|
+
(0, _defineProperty2.default)(this, "_threadButtonContainers", new Map());
|
|
56
|
+
(0, _defineProperty2.default)(this, "_contentContainers", new Map());
|
|
57
|
+
(0, _defineProperty2.default)(this, "_threadSidebarContainerEl", null);
|
|
58
|
+
(0, _defineProperty2.default)(this, "_currentIds", new Set());
|
|
59
|
+
(0, _defineProperty2.default)(this, "_orderManager", new _orderManager.default({
|
|
60
|
+
get() {
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(global.localStorage.getItem('inboxsdk__sidebar_ordering') || 'null');
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.error('failed to read sidebar order data', err); //eslint-disable-line no-console
|
|
65
|
+
}
|
|
66
|
+
},
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} catch (err) {
|
|
82
|
-
console.error('failed to read sidebar order data', err); //eslint-disable-line no-console
|
|
68
|
+
set(data) {
|
|
69
|
+
try {
|
|
70
|
+
global.localStorage.setItem('inboxsdk__sidebar_ordering', JSON.stringify(data));
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error('failed to set sidebar order data', err); //eslint-disable-line no-console
|
|
73
|
+
}
|
|
83
74
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
JSON.stringify(data)
|
|
90
|
-
);
|
|
91
|
-
} catch (err) {
|
|
92
|
-
console.error('failed to set sidebar order data', err); //eslint-disable-line no-console
|
|
75
|
+
}));
|
|
76
|
+
(0, _defineProperty2.default)(this, "_updateHighlightedAppThreadIconBus", (0, _kefirBus.default)());
|
|
77
|
+
(0, _defineProperty2.default)(this, "_appSidebarRefSetter", threadSidebarComponent => {
|
|
78
|
+
if (threadSidebarComponent) {
|
|
79
|
+
this._threadSidebarComponent = threadSidebarComponent;
|
|
93
80
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
_containerProp: () => HTMLElement;
|
|
98
|
-
_updateHighlightedAppThreadIconBus: Bus<null> = kefirBus();
|
|
99
|
-
|
|
100
|
-
constructor(
|
|
101
|
-
driver: GmailDriver,
|
|
102
|
-
companionSidebarContentContainerElement: HTMLElement
|
|
103
|
-
) {
|
|
81
|
+
});
|
|
82
|
+
(0, _defineProperty2.default)(this, "_closeButton", null);
|
|
104
83
|
this._driver = driver;
|
|
105
|
-
this._companionSidebarContentContainerEl =
|
|
106
|
-
companionSidebarContentContainerElement;
|
|
84
|
+
this._companionSidebarContentContainerEl = companionSidebarContentContainerElement;
|
|
107
85
|
this._setupElement();
|
|
108
86
|
}
|
|
109
|
-
|
|
110
|
-
getInstanceId(): string {
|
|
87
|
+
getInstanceId() {
|
|
111
88
|
return this._instanceId;
|
|
112
89
|
}
|
|
113
90
|
|
|
@@ -121,310 +98,207 @@ class GmailAppSidebarPrimary {
|
|
|
121
98
|
// This value controls whether the app sidebar should automatically open
|
|
122
99
|
// itself when available when the chat sidebar isn't present. It's only set
|
|
123
100
|
// if the user interacts with the app sidebar button.
|
|
124
|
-
_getShouldGlobalAppSidebarOpen()
|
|
125
|
-
return (
|
|
126
|
-
global.localStorage.getItem(
|
|
127
|
-
'inboxsdk__global_app_sidebar_should_open'
|
|
128
|
-
) === 'true'
|
|
129
|
-
);
|
|
101
|
+
_getShouldGlobalAppSidebarOpen() {
|
|
102
|
+
return global.localStorage.getItem('inboxsdk__global_app_sidebar_should_open') === 'true';
|
|
130
103
|
}
|
|
131
|
-
|
|
132
|
-
_setShouldGlobalAppSidebarOpen(open: boolean) {
|
|
104
|
+
_setShouldGlobalAppSidebarOpen(open) {
|
|
133
105
|
try {
|
|
134
|
-
global.localStorage.setItem(
|
|
135
|
-
'inboxsdk__global_app_sidebar_should_open',
|
|
136
|
-
String(open)
|
|
137
|
-
);
|
|
106
|
+
global.localStorage.setItem('inboxsdk__global_app_sidebar_should_open', String(open));
|
|
138
107
|
} catch (err) {
|
|
139
108
|
console.error('error saving', err); //eslint-disable-line no-console
|
|
140
109
|
}
|
|
141
110
|
}
|
|
142
111
|
|
|
143
|
-
_getShouldThreadAppSidebarOpen()
|
|
144
|
-
return (
|
|
145
|
-
global.localStorage.getItem(
|
|
146
|
-
'inboxsdk__thread_app_sidebar_should_open'
|
|
147
|
-
) !== 'false'
|
|
148
|
-
);
|
|
112
|
+
_getShouldThreadAppSidebarOpen() {
|
|
113
|
+
return global.localStorage.getItem('inboxsdk__thread_app_sidebar_should_open') !== 'false';
|
|
149
114
|
}
|
|
150
|
-
|
|
151
|
-
_setShouldThreadAppSidebarOpen(open: boolean) {
|
|
115
|
+
_setShouldThreadAppSidebarOpen(open) {
|
|
152
116
|
try {
|
|
153
|
-
global.localStorage.setItem(
|
|
154
|
-
'inboxsdk__thread_app_sidebar_should_open',
|
|
155
|
-
String(open)
|
|
156
|
-
);
|
|
117
|
+
global.localStorage.setItem('inboxsdk__thread_app_sidebar_should_open', String(open));
|
|
157
118
|
} catch (err) {
|
|
158
119
|
console.error('error saving', err); //eslint-disable-line no-console
|
|
159
120
|
}
|
|
160
121
|
}
|
|
161
122
|
|
|
162
|
-
_createThreadSidebarIfNeeded()
|
|
123
|
+
_createThreadSidebarIfNeeded() {
|
|
163
124
|
if (this._threadSidebarContainerEl) return this._threadSidebarContainerEl;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
threadSidebarContainerEl.classList.add(
|
|
168
|
-
'thread_app_sidebar',
|
|
169
|
-
idMap('app_sidebar_container'),
|
|
170
|
-
'addon_sidebar'
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
this._companionSidebarContentContainerEl.insertBefore(
|
|
174
|
-
threadSidebarContainerEl,
|
|
175
|
-
this._companionSidebarContentContainerEl.firstElementChild
|
|
176
|
-
);
|
|
177
|
-
|
|
125
|
+
const threadSidebarContainerEl = this._threadSidebarContainerEl = document.createElement('div');
|
|
126
|
+
threadSidebarContainerEl.classList.add('thread_app_sidebar', (0, _idMap.default)('app_sidebar_container'), 'addon_sidebar');
|
|
127
|
+
this._companionSidebarContentContainerEl.insertBefore(threadSidebarContainerEl, this._companionSidebarContentContainerEl.firstElementChild);
|
|
178
128
|
this._containerProp = () => threadSidebarContainerEl;
|
|
179
129
|
|
|
180
130
|
// Kefir flow type def has wrong type for bufferWithTimeOrCount
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
const absoluteScrollOfViewportTop = threadSidebarContainerEl.scrollTop;
|
|
204
|
-
const absoluteScrollOfViewportMidpoint =
|
|
205
|
-
absoluteScrollOfViewportTop + containerBoundingBox.height / 2;
|
|
206
|
-
|
|
207
|
-
let titleBar = titleBars.find((t) => {
|
|
208
|
-
const tBoundingBox = t.getBoundingClientRect();
|
|
131
|
+
this._updateHighlightedAppThreadIconBus.bufferWithTimeOrCount(150, 100).filter(events => events.length > 0).takeUntilBy(this._stopper).onValue(() => {
|
|
132
|
+
// Before touching this code, make sure you understand the meaning of the clientRect
|
|
133
|
+
// values and of scrollTop. In particular, make sure you understand the distinction of
|
|
134
|
+
// absolute (the scroll[Top|Bottom|Height] values) vs relative (the BoundingRect top
|
|
135
|
+
// and bottom values) scroll values.
|
|
136
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect
|
|
137
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop
|
|
138
|
+
|
|
139
|
+
const containerBoundingBox = threadSidebarContainerEl.getBoundingClientRect();
|
|
140
|
+
const titleBars = Array.from(threadSidebarContainerEl.querySelectorAll(`.${(0, _idMap.default)('app_sidebar_content_panel')}.${(0, _idMap.default)('expanded')} .${(0, _idMap.default)('app_sidebar_content_panel_top_line')}`));
|
|
141
|
+
const absoluteScrollOfViewportTop = threadSidebarContainerEl.scrollTop;
|
|
142
|
+
const absoluteScrollOfViewportMidpoint = absoluteScrollOfViewportTop + containerBoundingBox.height / 2;
|
|
143
|
+
let titleBar = titleBars.find(t => {
|
|
144
|
+
const tBoundingBox = t.getBoundingClientRect();
|
|
145
|
+
const relativeScrollOfTitleBottom = tBoundingBox.bottom;
|
|
146
|
+
const absoluteScrollOfTitleBottom = relativeScrollOfTitleBottom + absoluteScrollOfViewportTop;
|
|
147
|
+
|
|
148
|
+
// Return true for an element that is below the top of the viewport but above its midpoint
|
|
149
|
+
return absoluteScrollOfTitleBottom > absoluteScrollOfViewportTop && absoluteScrollOfTitleBottom < absoluteScrollOfViewportMidpoint;
|
|
150
|
+
});
|
|
209
151
|
|
|
152
|
+
// If titleBar is falsey then there isn't a title element in the top half of the viewport.
|
|
153
|
+
// In this case, find the first title element above the viewport.
|
|
154
|
+
if (!titleBar) {
|
|
155
|
+
// We make the assumption here that ordering of the elements in titleBars matches the
|
|
156
|
+
// ordering of how they appear in the sidebar (i.e. their ordering from top to bottom).
|
|
157
|
+
let lastElementAboveViewPort;
|
|
158
|
+
for (let i = 0; i < titleBars.length; i++) {
|
|
159
|
+
const tElement = titleBars[i];
|
|
160
|
+
const tBoundingBox = tElement.getBoundingClientRect();
|
|
210
161
|
const relativeScrollOfTitleBottom = tBoundingBox.bottom;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
absoluteScrollOfTitleBottom > absoluteScrollOfViewportTop &&
|
|
217
|
-
absoluteScrollOfTitleBottom < absoluteScrollOfViewportMidpoint
|
|
218
|
-
);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// If titleBar is falsey then there isn't a title element in the top half of the viewport.
|
|
222
|
-
// In this case, find the first title element above the viewport.
|
|
223
|
-
if (!titleBar) {
|
|
224
|
-
// We make the assumption here that ordering of the elements in titleBars matches the
|
|
225
|
-
// ordering of how they appear in the sidebar (i.e. their ordering from top to bottom).
|
|
226
|
-
let lastElementAboveViewPort;
|
|
227
|
-
for (let i = 0; i < titleBars.length; i++) {
|
|
228
|
-
const tElement = titleBars[i];
|
|
229
|
-
const tBoundingBox = tElement.getBoundingClientRect();
|
|
230
|
-
|
|
231
|
-
const relativeScrollOfTitleBottom = tBoundingBox.bottom;
|
|
232
|
-
if (relativeScrollOfTitleBottom < 0) {
|
|
233
|
-
lastElementAboveViewPort = tElement;
|
|
234
|
-
} else if (relativeScrollOfTitleBottom > 0) {
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
162
|
+
if (relativeScrollOfTitleBottom < 0) {
|
|
163
|
+
lastElementAboveViewPort = tElement;
|
|
164
|
+
} else if (relativeScrollOfTitleBottom > 0) {
|
|
165
|
+
break;
|
|
237
166
|
}
|
|
238
|
-
|
|
239
|
-
titleBar = lastElementAboveViewPort;
|
|
240
167
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
);
|
|
252
|
-
if (activeButtonContainer) {
|
|
253
|
-
activeButtonContainer.classList.remove(
|
|
254
|
-
'sidebar_button_container_active'
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
appButton.classList.add('sidebar_button_container_active');
|
|
168
|
+
titleBar = lastElementAboveViewPort;
|
|
169
|
+
}
|
|
170
|
+
if (titleBar) {
|
|
171
|
+
const instanceId = titleBar.getAttribute('data-instance-id');
|
|
172
|
+
const appName = titleBar.getAttribute('data-app-name');
|
|
173
|
+
if (!appName) return;
|
|
174
|
+
const appButton = this._threadButtonContainers.get(appName);
|
|
175
|
+
if (!appButton || !this._threadIconArea) return;
|
|
176
|
+
const activeButtonContainer = this._threadIconArea.querySelector('.sidebar_button_container_active');
|
|
177
|
+
if (activeButtonContainer) {
|
|
178
|
+
activeButtonContainer.classList.remove('sidebar_button_container_active');
|
|
259
179
|
}
|
|
260
|
-
|
|
180
|
+
appButton.classList.add('sidebar_button_container_active');
|
|
181
|
+
}
|
|
182
|
+
});
|
|
261
183
|
|
|
262
184
|
//listen for scroll and update active icon if needed
|
|
263
|
-
this._updateHighlightedAppThreadIconBus.plug(
|
|
264
|
-
Kefir.fromEvents(threadSidebarContainerEl, 'scroll').map(() => null)
|
|
265
|
-
);
|
|
185
|
+
this._updateHighlightedAppThreadIconBus.plug(_kefir.default.fromEvents(threadSidebarContainerEl, 'scroll').map(() => null));
|
|
266
186
|
|
|
267
187
|
// handle rendering thread sidebar contents
|
|
268
188
|
this._renderThreadSidebar();
|
|
269
189
|
return threadSidebarContainerEl;
|
|
270
190
|
}
|
|
271
|
-
|
|
272
191
|
_renderThreadSidebarIfPresent() {
|
|
273
192
|
if (!this._threadSidebarContainerEl) {
|
|
274
193
|
return;
|
|
275
194
|
}
|
|
276
195
|
this._renderThreadSidebar();
|
|
277
196
|
}
|
|
278
|
-
|
|
279
|
-
_appSidebarRefSetter: (el: ?AppSidebar) => void = (
|
|
280
|
-
threadSidebarComponent
|
|
281
|
-
) => {
|
|
282
|
-
if (threadSidebarComponent) {
|
|
283
|
-
this._threadSidebarComponent = threadSidebarComponent;
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
_renderThreadSidebar(): Promise<AppSidebar> {
|
|
197
|
+
_renderThreadSidebar() {
|
|
288
198
|
const threadSidebarContainerEl = this._threadSidebarContainerEl;
|
|
289
199
|
if (!threadSidebarContainerEl) {
|
|
290
|
-
throw new Error(
|
|
291
|
-
'_renderThreadSidebar should not be called when _threadSidebarContainerEl is unset'
|
|
292
|
-
);
|
|
200
|
+
throw new Error('_renderThreadSidebar should not be called when _threadSidebarContainerEl is unset');
|
|
293
201
|
}
|
|
294
|
-
return new Promise(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
onExpandedToggle={() => {
|
|
304
|
-
this._updateHighlightedAppThreadIconBus.emit(null);
|
|
305
|
-
}}
|
|
306
|
-
container={this._containerProp}
|
|
307
|
-
/>,
|
|
308
|
-
threadSidebarContainerEl,
|
|
309
|
-
() => {
|
|
310
|
-
if (!this._threadSidebarComponent) {
|
|
311
|
-
throw new Error('Should not happen');
|
|
312
|
-
}
|
|
313
|
-
resolve(this._threadSidebarComponent);
|
|
202
|
+
return new Promise(resolve => {
|
|
203
|
+
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_AppSidebar.default, {
|
|
204
|
+
ref: this._appSidebarRefSetter,
|
|
205
|
+
panels: this._orderManager.getOrderedItems().map(x => x.value),
|
|
206
|
+
onMoveEnd: (newList, movedItem, oldIndex, newIndex) => {
|
|
207
|
+
this._orderManager.moveItem(oldIndex, newIndex);
|
|
208
|
+
this._renderThreadSidebar();
|
|
209
|
+
},
|
|
210
|
+
onExpandedToggle: () => {
|
|
314
211
|
this._updateHighlightedAppThreadIconBus.emit(null);
|
|
212
|
+
},
|
|
213
|
+
container: this._containerProp
|
|
214
|
+
}), threadSidebarContainerEl, () => {
|
|
215
|
+
if (!this._threadSidebarComponent) {
|
|
216
|
+
throw new Error('Should not happen');
|
|
315
217
|
}
|
|
316
|
-
|
|
218
|
+
resolve(this._threadSidebarComponent);
|
|
219
|
+
this._updateHighlightedAppThreadIconBus.emit(null);
|
|
220
|
+
});
|
|
317
221
|
});
|
|
318
222
|
}
|
|
319
|
-
|
|
320
|
-
_getActiveButtonContainer(): ?HTMLElement {
|
|
223
|
+
_getActiveButtonContainer() {
|
|
321
224
|
let activeButtonContainer;
|
|
322
225
|
if (this._globalIconArea) {
|
|
323
|
-
activeButtonContainer = this._globalIconArea.querySelector(
|
|
324
|
-
'.sidebar_button_container_active'
|
|
325
|
-
);
|
|
226
|
+
activeButtonContainer = this._globalIconArea.querySelector('.sidebar_button_container_active');
|
|
326
227
|
}
|
|
327
228
|
if (!activeButtonContainer && this._threadIconArea) {
|
|
328
|
-
activeButtonContainer = this._threadIconArea.querySelector(
|
|
329
|
-
'.sidebar_button_container_active'
|
|
330
|
-
);
|
|
229
|
+
activeButtonContainer = this._threadIconArea.querySelector('.sidebar_button_container_active');
|
|
331
230
|
}
|
|
332
231
|
return activeButtonContainer;
|
|
333
232
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
_addButton(iconArea: HTMLElement, event: Object, isGlobal: boolean) {
|
|
233
|
+
_addButton(iconArea, event, isGlobal) {
|
|
234
|
+
var _this = this;
|
|
338
235
|
// we put adding the content panel icon in the iconArea in an asap so that we
|
|
339
236
|
// get consistent ordering. The ordering of the icons is based on the position of the FIRST
|
|
340
237
|
// panel with that app name. This means we need to wait for all the panels for a particular appName
|
|
341
238
|
// to be added first, and then we can get the correct position
|
|
342
|
-
|
|
239
|
+
(0, _asap.default)(() => {
|
|
343
240
|
if (!iconArea) throw new Error('should not happen');
|
|
344
|
-
|
|
345
241
|
const instanceId = event.detail.instanceId;
|
|
346
|
-
const iconUrl =
|
|
347
|
-
isGlobal && event.detail.iconUrl
|
|
348
|
-
? event.detail.iconUrl
|
|
349
|
-
: event.detail.appIconUrl;
|
|
242
|
+
const iconUrl = isGlobal && event.detail.iconUrl ? event.detail.iconUrl : event.detail.appIconUrl;
|
|
350
243
|
const appName = event.detail.appName;
|
|
351
244
|
const iconClass = event.detail.iconClass || '';
|
|
352
245
|
|
|
353
246
|
// If there's an existing button for the app, then just increment its
|
|
354
247
|
// data-count attribute instead of adding a new button.
|
|
355
|
-
const existingButtonContainer = isGlobal
|
|
356
|
-
? this._globalButtonContainers.get(appName)
|
|
357
|
-
: this._threadButtonContainers.get(appName);
|
|
358
|
-
|
|
248
|
+
const existingButtonContainer = isGlobal ? this._globalButtonContainers.get(appName) : this._threadButtonContainers.get(appName);
|
|
359
249
|
let buttonContainer;
|
|
360
250
|
if (existingButtonContainer) {
|
|
361
|
-
const currentCount =
|
|
362
|
-
|
|
363
|
-
existingButtonContainer.setAttribute(
|
|
364
|
-
'data-count',
|
|
365
|
-
String(currentCount + 1)
|
|
366
|
-
);
|
|
251
|
+
const currentCount = Number(existingButtonContainer.getAttribute('data-count')) || 1;
|
|
252
|
+
existingButtonContainer.setAttribute('data-count', String(currentCount + 1));
|
|
367
253
|
buttonContainer = existingButtonContainer;
|
|
368
254
|
} else {
|
|
369
255
|
buttonContainer = document.createElement('div');
|
|
370
|
-
buttonContainer.className =
|
|
256
|
+
buttonContainer.className = (0, _idMap.default)('sidebar_button_container');
|
|
371
257
|
buttonContainer.setAttribute('data-app-name', appName);
|
|
372
|
-
buttonContainer.innerHTML =
|
|
258
|
+
buttonContainer.innerHTML = (0, _autoHtml.default)`
|
|
373
259
|
<button class="inboxsdk__button_icon ${iconClass}" type="button" data-tooltip="${appName}">
|
|
374
260
|
<img class="inboxsdk__button_iconImg" src="${iconUrl}">
|
|
375
261
|
</button>
|
|
376
262
|
<div class="inboxsdk__button_selectedIndicator"></div>
|
|
377
263
|
`;
|
|
378
|
-
|
|
379
264
|
if (event.detail.primaryColor) {
|
|
380
|
-
|
|
381
|
-
buttonContainer,
|
|
382
|
-
'.inboxsdk__button_selectedIndicator'
|
|
383
|
-
).style.backgroundColor = event.detail.primaryColor;
|
|
265
|
+
(0, _querySelectorOrFail.default)(buttonContainer, '.inboxsdk__button_selectedIndicator').style.backgroundColor = event.detail.primaryColor;
|
|
384
266
|
}
|
|
385
|
-
|
|
386
267
|
if (isGlobal) {
|
|
387
268
|
this._globalButtonContainers.set(appName, buttonContainer);
|
|
388
269
|
} else {
|
|
389
270
|
this._threadButtonContainers.set(appName, buttonContainer);
|
|
390
271
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const activeButtonContainer =
|
|
394
|
-
|
|
272
|
+
const activate = function () {
|
|
273
|
+
let dontScrollIntoView = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
274
|
+
const activeButtonContainer = _this._getActiveButtonContainer();
|
|
395
275
|
if (activeButtonContainer === buttonContainer) {
|
|
396
276
|
// button was clicked while its panel was open, so close it.
|
|
397
|
-
if (!
|
|
398
|
-
|
|
277
|
+
if (!_this._closeButton) throw new Error();
|
|
278
|
+
_this._closeButton(true);
|
|
399
279
|
} else {
|
|
400
280
|
// button was clicked while its own panel wasn't open, so open it.
|
|
401
281
|
|
|
402
|
-
if (
|
|
403
|
-
|
|
282
|
+
if (_this._closeButton) {
|
|
283
|
+
_this._closeButton(true);
|
|
404
284
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
else this._setShouldThreadAppSidebarOpen(true);
|
|
408
|
-
|
|
409
|
-
this._openSidebarAndActivateButton(buttonContainer, isGlobal);
|
|
410
|
-
|
|
285
|
+
if (isGlobal) _this._setShouldGlobalAppSidebarOpen(true);else _this._setShouldThreadAppSidebarOpen(true);
|
|
286
|
+
_this._openSidebarAndActivateButton(buttonContainer, isGlobal);
|
|
411
287
|
if (isGlobal) {
|
|
412
|
-
const contentEl =
|
|
288
|
+
const contentEl = _this._contentContainers.get(appName);
|
|
413
289
|
if (contentEl) contentEl.style.display = '';
|
|
414
|
-
|
|
415
|
-
'companion_global_app_sidebar_visible'
|
|
416
|
-
);
|
|
290
|
+
_this._companionSidebarContentContainerEl.classList.add('companion_global_app_sidebar_visible');
|
|
417
291
|
|
|
418
292
|
// let app listen for activate event
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
);
|
|
293
|
+
document.body.dispatchEvent(new CustomEvent('inboxsdkSidebarPanelActivated', {
|
|
294
|
+
bubbles: true,
|
|
295
|
+
cancelable: false,
|
|
296
|
+
detail: {
|
|
297
|
+
instanceId
|
|
298
|
+
}
|
|
299
|
+
}));
|
|
426
300
|
} else {
|
|
427
|
-
const threadSidebarComponent =
|
|
301
|
+
const threadSidebarComponent = _this._threadSidebarComponent;
|
|
428
302
|
if (!threadSidebarComponent) {
|
|
429
303
|
throw new Error('sidebar not mounted');
|
|
430
304
|
}
|
|
@@ -433,58 +307,45 @@ class GmailAppSidebarPrimary {
|
|
|
433
307
|
threadSidebarComponent.scrollPanelIntoView(instanceId, true);
|
|
434
308
|
}
|
|
435
309
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
const activeButtonContainer = this._getActiveButtonContainer();
|
|
310
|
+
_this._closeButton = userClick => {
|
|
311
|
+
_this._closeButton = null;
|
|
312
|
+
const activeButtonContainer = _this._getActiveButtonContainer();
|
|
441
313
|
if (!activeButtonContainer) {
|
|
442
314
|
throw new Error('Expected activeButtonContainer');
|
|
443
315
|
}
|
|
444
|
-
|
|
445
|
-
|
|
316
|
+
_this._closeSidebarAndDeactivateButton(activeButtonContainer);
|
|
446
317
|
if (isGlobal) {
|
|
447
|
-
if (userClick)
|
|
448
|
-
|
|
449
|
-
const contentEl = this._contentContainers.get(appName);
|
|
318
|
+
if (userClick) _this._setShouldGlobalAppSidebarOpen(false);
|
|
319
|
+
const contentEl = _this._contentContainers.get(appName);
|
|
450
320
|
if (contentEl) {
|
|
451
321
|
contentEl.style.display = 'none';
|
|
452
322
|
} else {
|
|
453
|
-
|
|
454
|
-
.getLogger()
|
|
455
|
-
.error(new Error('Unexpected: contentEl not set'));
|
|
323
|
+
_this._driver.getLogger().error(new Error('Unexpected: contentEl not set'));
|
|
456
324
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
);
|
|
325
|
+
document.body.dispatchEvent(new CustomEvent('inboxsdkSidebarPanelDeactivated', {
|
|
326
|
+
bubbles: true,
|
|
327
|
+
cancelable: false,
|
|
328
|
+
detail: {
|
|
329
|
+
instanceId
|
|
330
|
+
}
|
|
331
|
+
}));
|
|
465
332
|
} else {
|
|
466
|
-
if (userClick)
|
|
333
|
+
if (userClick) _this._setShouldThreadAppSidebarOpen(false);
|
|
467
334
|
}
|
|
468
335
|
//fake a window resize after closing so gmail fixes any heights that are messed up
|
|
469
|
-
|
|
336
|
+
(0, _fakeWindowResize.default)();
|
|
470
337
|
};
|
|
471
338
|
|
|
472
339
|
//fake a window resize after opening so gmail fixes any heights that are messed up
|
|
473
|
-
|
|
340
|
+
(0, _fakeWindowResize.default)();
|
|
474
341
|
}
|
|
475
342
|
};
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
event.stopPropagation();
|
|
481
|
-
activate();
|
|
482
|
-
},
|
|
483
|
-
true
|
|
484
|
-
);
|
|
485
|
-
|
|
343
|
+
(0, _querySelectorOrFail.default)(buttonContainer, 'button').addEventListener('click', event => {
|
|
344
|
+
event.stopPropagation();
|
|
345
|
+
activate();
|
|
346
|
+
}, true);
|
|
486
347
|
if (iconArea) {
|
|
487
|
-
|
|
348
|
+
(0, _addToIconArea.default)(this._orderManager, appName, buttonContainer, iconArea);
|
|
488
349
|
}
|
|
489
350
|
|
|
490
351
|
// if we last had an SDK sidebar open then bring up the SDK sidebar when the first
|
|
@@ -493,20 +354,14 @@ class GmailAppSidebarPrimary {
|
|
|
493
354
|
const activeButtonContainer = this._getActiveButtonContainer();
|
|
494
355
|
if (isGlobal) {
|
|
495
356
|
if (this._getShouldGlobalAppSidebarOpen()) {
|
|
496
|
-
const activeButtonContainerPresentAndIsForGlobal =
|
|
497
|
-
this._globalIconArea &&
|
|
498
|
-
activeButtonContainer &&
|
|
499
|
-
this._globalIconArea.contains(activeButtonContainer);
|
|
357
|
+
const activeButtonContainerPresentAndIsForGlobal = this._globalIconArea && activeButtonContainer && this._globalIconArea.contains(activeButtonContainer);
|
|
500
358
|
if (!activeButtonContainerPresentAndIsForGlobal) {
|
|
501
359
|
activate(true);
|
|
502
360
|
}
|
|
503
361
|
}
|
|
504
362
|
} else {
|
|
505
363
|
if (this._getShouldThreadAppSidebarOpen()) {
|
|
506
|
-
const activeButtonContainerPresentAndIsForThread =
|
|
507
|
-
this._threadIconArea &&
|
|
508
|
-
activeButtonContainer &&
|
|
509
|
-
this._threadIconArea.contains(activeButtonContainer);
|
|
364
|
+
const activeButtonContainerPresentAndIsForThread = this._threadIconArea && activeButtonContainer && this._threadIconArea.contains(activeButtonContainer);
|
|
510
365
|
if (!activeButtonContainerPresentAndIsForThread) {
|
|
511
366
|
activate(true);
|
|
512
367
|
}
|
|
@@ -516,42 +371,22 @@ class GmailAppSidebarPrimary {
|
|
|
516
371
|
}
|
|
517
372
|
});
|
|
518
373
|
}
|
|
519
|
-
|
|
520
|
-
_removeButton(
|
|
521
|
-
event: Object,
|
|
522
|
-
buttonContainers: Map<string, HTMLElement>,
|
|
523
|
-
iconArea: ?HTMLElement
|
|
524
|
-
) {
|
|
374
|
+
_removeButton(event, buttonContainers, iconArea) {
|
|
525
375
|
const appName = event.detail.appName;
|
|
526
|
-
|
|
527
376
|
const container = buttonContainers.get(appName);
|
|
528
377
|
if (!iconArea || !container) {
|
|
529
|
-
throw new Error(
|
|
530
|
-
'should not happen: tried to remove button without container or iconArea'
|
|
531
|
-
);
|
|
378
|
+
throw new Error('should not happen: tried to remove button without container or iconArea');
|
|
532
379
|
}
|
|
533
|
-
|
|
534
380
|
const currentCount = Number(container.getAttribute('data-count'));
|
|
535
381
|
if (currentCount <= 1) {
|
|
536
|
-
const activeButtonContainer = iconArea.querySelector(
|
|
537
|
-
'.sidebar_button_container_active'
|
|
538
|
-
);
|
|
382
|
+
const activeButtonContainer = iconArea.querySelector('.sidebar_button_container_active');
|
|
539
383
|
if (container === activeButtonContainer) {
|
|
540
384
|
if (!this._closeButton) throw new Error();
|
|
541
385
|
this._closeButton(false);
|
|
542
|
-
|
|
543
|
-
this.
|
|
544
|
-
|
|
545
|
-
);
|
|
546
|
-
this._companionSidebarContentContainerEl.classList.remove(
|
|
547
|
-
'companion_app_sidebar_visible'
|
|
548
|
-
);
|
|
549
|
-
const contentContainer =
|
|
550
|
-
this._companionSidebarOuterWrapper.previousElementSibling;
|
|
551
|
-
if (contentContainer)
|
|
552
|
-
contentContainer.classList.remove(
|
|
553
|
-
'companion_container_app_sidebar_visible'
|
|
554
|
-
);
|
|
386
|
+
this._companionSidebarOuterWrapper.classList.remove('companion_app_sidebar_wrapper_visible');
|
|
387
|
+
this._companionSidebarContentContainerEl.classList.remove('companion_app_sidebar_visible');
|
|
388
|
+
const contentContainer = this._companionSidebarOuterWrapper.previousElementSibling;
|
|
389
|
+
if (contentContainer) contentContainer.classList.remove('companion_container_app_sidebar_visible');
|
|
555
390
|
}
|
|
556
391
|
container.remove();
|
|
557
392
|
buttonContainers.delete(appName);
|
|
@@ -561,39 +396,17 @@ class GmailAppSidebarPrimary {
|
|
|
561
396
|
container.setAttribute('data-count', String(currentCount - 1));
|
|
562
397
|
}
|
|
563
398
|
}
|
|
564
|
-
|
|
565
|
-
_closeSidebarAndDeactivateButton(activeButtonContainer: HTMLElement) {
|
|
399
|
+
_closeSidebarAndDeactivateButton(activeButtonContainer) {
|
|
566
400
|
activeButtonContainer.classList.remove('sidebar_button_container_active');
|
|
567
|
-
this._companionSidebarOuterWrapper.classList.remove(
|
|
568
|
-
|
|
569
|
-
);
|
|
570
|
-
this.
|
|
571
|
-
|
|
572
|
-
);
|
|
573
|
-
this._companionSidebarContentContainerEl.classList.remove(
|
|
574
|
-
'companion_app_sidebar_visible',
|
|
575
|
-
'companion_global_app_sidebar_visible'
|
|
576
|
-
);
|
|
577
|
-
|
|
578
|
-
const contentContainer =
|
|
579
|
-
this._companionSidebarOuterWrapper.previousElementSibling;
|
|
580
|
-
if (contentContainer)
|
|
581
|
-
contentContainer.classList.remove(
|
|
582
|
-
'companion_container_app_sidebar_visible'
|
|
583
|
-
);
|
|
401
|
+
this._companionSidebarOuterWrapper.classList.remove('companion_app_sidebar_wrapper_visible');
|
|
402
|
+
this._companionSidebarContentContainerEl.classList.add(COMPANION_SIDEBAR_CONTENT_CLOSED_SHADOW_CLASS);
|
|
403
|
+
this._companionSidebarContentContainerEl.classList.remove('companion_app_sidebar_visible', 'companion_global_app_sidebar_visible');
|
|
404
|
+
const contentContainer = this._companionSidebarOuterWrapper.previousElementSibling;
|
|
405
|
+
if (contentContainer) contentContainer.classList.remove('companion_container_app_sidebar_visible');
|
|
584
406
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
isGlobal: boolean
|
|
589
|
-
) {
|
|
590
|
-
const companionSidebarIconContainerEl =
|
|
591
|
-
GmailElementGetter.getCompanionSidebarIconContainerElement();
|
|
592
|
-
if (!companionSidebarIconContainerEl)
|
|
593
|
-
throw new Error(
|
|
594
|
-
'Could not find companion sidebar icon container element'
|
|
595
|
-
);
|
|
596
|
-
|
|
407
|
+
_openSidebarAndActivateButton(buttonContainer, isGlobal) {
|
|
408
|
+
const companionSidebarIconContainerEl = _gmailElementGetter.default.getCompanionSidebarIconContainerElement();
|
|
409
|
+
if (!companionSidebarIconContainerEl) throw new Error('Could not find companion sidebar icon container element');
|
|
597
410
|
const activeButtonContainer = this._getActiveButtonContainer();
|
|
598
411
|
if (activeButtonContainer) {
|
|
599
412
|
throw new Error('activeButtonContainer should not be true');
|
|
@@ -602,407 +415,203 @@ class GmailAppSidebarPrimary {
|
|
|
602
415
|
|
|
603
416
|
{
|
|
604
417
|
// If a gmail addon is active, close it.
|
|
605
|
-
const nativeActiveAddOnIcon =
|
|
606
|
-
companionSidebarIconContainerEl.querySelector(
|
|
607
|
-
ACTIVE_ADD_ON_ICON_SELECTOR
|
|
608
|
-
);
|
|
418
|
+
const nativeActiveAddOnIcon = companionSidebarIconContainerEl.querySelector(ACTIVE_ADD_ON_ICON_SELECTOR);
|
|
609
419
|
if (nativeActiveAddOnIcon) {
|
|
610
|
-
simulateClick(nativeActiveAddOnIcon);
|
|
420
|
+
(0, _simulateMouseEvent.simulateClick)(nativeActiveAddOnIcon);
|
|
611
421
|
}
|
|
612
422
|
}
|
|
613
|
-
|
|
614
423
|
buttonContainer.classList.add('sidebar_button_container_active');
|
|
615
|
-
this._companionSidebarOuterWrapper.classList.add(
|
|
616
|
-
|
|
617
|
-
);
|
|
618
|
-
this.
|
|
619
|
-
|
|
620
|
-
);
|
|
621
|
-
this._companionSidebarContentContainerEl.classList.remove(
|
|
622
|
-
COMPANION_SIDEBAR_CONTENT_CLOSED_SHADOW_CLASS
|
|
623
|
-
);
|
|
624
|
-
|
|
625
|
-
const contentContainer =
|
|
626
|
-
this._companionSidebarOuterWrapper.previousElementSibling;
|
|
627
|
-
if (contentContainer)
|
|
628
|
-
contentContainer.classList.add('companion_container_app_sidebar_visible');
|
|
629
|
-
if (isGlobal)
|
|
630
|
-
this._companionSidebarContentContainerEl.classList.add(
|
|
631
|
-
'companion_global_app_sidebar_visible'
|
|
632
|
-
);
|
|
424
|
+
this._companionSidebarOuterWrapper.classList.add('companion_app_sidebar_wrapper_visible');
|
|
425
|
+
this._companionSidebarContentContainerEl.classList.add('companion_app_sidebar_visible');
|
|
426
|
+
this._companionSidebarContentContainerEl.classList.remove(COMPANION_SIDEBAR_CONTENT_CLOSED_SHADOW_CLASS);
|
|
427
|
+
const contentContainer = this._companionSidebarOuterWrapper.previousElementSibling;
|
|
428
|
+
if (contentContainer) contentContainer.classList.add('companion_container_app_sidebar_visible');
|
|
429
|
+
if (isGlobal) this._companionSidebarContentContainerEl.classList.add('companion_global_app_sidebar_visible');
|
|
633
430
|
}
|
|
634
|
-
|
|
635
431
|
_setupElement() {
|
|
636
|
-
const companionSidebarIconContainerEl =
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
throw new Error(
|
|
640
|
-
'Could not find companion sidebar icon container element'
|
|
641
|
-
);
|
|
642
|
-
|
|
643
|
-
this._companionSidebarContentContainerEl.setAttribute(
|
|
644
|
-
'data-sdk-sidebar-instance-id',
|
|
645
|
-
this._instanceId
|
|
646
|
-
);
|
|
432
|
+
const companionSidebarIconContainerEl = _gmailElementGetter.default.getCompanionSidebarIconContainerElement();
|
|
433
|
+
if (!companionSidebarIconContainerEl) throw new Error('Could not find companion sidebar icon container element');
|
|
434
|
+
this._companionSidebarContentContainerEl.setAttribute('data-sdk-sidebar-instance-id', this._instanceId);
|
|
647
435
|
|
|
648
436
|
// TODO: Once the changes to the GMail DOM have been entirely ramped, drop the ternary here and
|
|
649
437
|
// always get the parentElement. (Jun 20, 2018)
|
|
650
|
-
this._companionSidebarOuterWrapper =
|
|
651
|
-
this._companionSidebarContentContainerEl.classList.contains('bq9')
|
|
652
|
-
? this._companionSidebarContentContainerEl
|
|
653
|
-
: (this._companionSidebarContentContainerEl.parentElement: any);
|
|
654
|
-
|
|
438
|
+
this._companionSidebarOuterWrapper = this._companionSidebarContentContainerEl.classList.contains('bq9') ? this._companionSidebarContentContainerEl : this._companionSidebarContentContainerEl.parentElement;
|
|
655
439
|
if (!this._companionSidebarOuterWrapper) {
|
|
656
|
-
throw new Error(
|
|
657
|
-
'should not happen: failed to find companionSidebarOuterWrapper'
|
|
658
|
-
);
|
|
440
|
+
throw new Error('should not happen: failed to find companionSidebarOuterWrapper');
|
|
659
441
|
}
|
|
660
|
-
|
|
661
|
-
const contentContainer =
|
|
662
|
-
this._companionSidebarOuterWrapper.previousElementSibling;
|
|
442
|
+
const contentContainer = this._companionSidebarOuterWrapper.previousElementSibling;
|
|
663
443
|
if (contentContainer) {
|
|
664
|
-
contentContainer.classList.add(
|
|
665
|
-
idMap('companion_container_app_sidebar_in_use')
|
|
666
|
-
);
|
|
444
|
+
contentContainer.classList.add((0, _idMap.default)('companion_container_app_sidebar_in_use'));
|
|
667
445
|
}
|
|
668
|
-
this._companionSidebarContentContainerEl.classList.add(
|
|
669
|
-
|
|
670
|
-
);
|
|
671
|
-
|
|
672
|
-
if (
|
|
673
|
-
!((document.body: any): HTMLElement).querySelector(
|
|
674
|
-
'.' + idMap('app_sidebar_waiting_platform')
|
|
675
|
-
)
|
|
676
|
-
) {
|
|
446
|
+
this._companionSidebarContentContainerEl.classList.add((0, _idMap.default)('app_sidebar_in_use'));
|
|
447
|
+
if (!document.body.querySelector('.' + (0, _idMap.default)('app_sidebar_waiting_platform'))) {
|
|
677
448
|
const waitingPlatform = document.createElement('div');
|
|
678
|
-
waitingPlatform.className =
|
|
679
|
-
|
|
449
|
+
waitingPlatform.className = (0, _idMap.default)('app_sidebar_waiting_platform');
|
|
450
|
+
document.body.appendChild(waitingPlatform);
|
|
680
451
|
}
|
|
681
452
|
|
|
682
453
|
// thread sidebar content panels
|
|
683
454
|
{
|
|
684
|
-
|
|
685
|
-
.
|
|
686
|
-
.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
.
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
id = incrementName(id);
|
|
702
|
-
}
|
|
703
|
-
this._currentIds.add(id);
|
|
704
|
-
|
|
705
|
-
const appName = event.detail.appName;
|
|
706
|
-
this._orderManager.addItem({
|
|
707
|
-
groupId: event.detail.appId,
|
|
455
|
+
_kefir.default.fromEvents(window, 'storage').filter(e => e.key === 'inboxsdk__sidebar_ordering').takeUntilBy(this._stopper).onValue(() => {
|
|
456
|
+
this._orderManager.reload();
|
|
457
|
+
this._renderThreadSidebarIfPresent();
|
|
458
|
+
});
|
|
459
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkNewSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
460
|
+
this._createThreadSidebarIfNeeded();
|
|
461
|
+
let id = event.detail.id;
|
|
462
|
+
while (this._currentIds.has(id)) {
|
|
463
|
+
id = (0, _incrementName.default)(id);
|
|
464
|
+
}
|
|
465
|
+
this._currentIds.add(id);
|
|
466
|
+
const appName = event.detail.appName;
|
|
467
|
+
this._orderManager.addItem({
|
|
468
|
+
groupId: event.detail.appId,
|
|
469
|
+
id,
|
|
470
|
+
orderHint: event.detail.orderHint,
|
|
471
|
+
value: {
|
|
708
472
|
id,
|
|
709
|
-
|
|
710
|
-
value: {
|
|
711
|
-
id,
|
|
712
|
-
appName,
|
|
713
|
-
appId: event.detail.appId,
|
|
714
|
-
instanceId: event.detail.instanceId,
|
|
715
|
-
title: event.detail.title,
|
|
716
|
-
iconClass: event.detail.iconClass,
|
|
717
|
-
iconUrl: event.detail.iconUrl,
|
|
718
|
-
hideTitleBar: event.detail.hideTitleBar,
|
|
719
|
-
el: event.target,
|
|
720
|
-
},
|
|
721
|
-
});
|
|
722
|
-
this._renderThreadSidebar();
|
|
723
|
-
|
|
724
|
-
let threadIconArea = (this._threadIconArea =
|
|
725
|
-
companionSidebarIconContainerEl.querySelector(
|
|
726
|
-
'.sidebar_thread_iconArea'
|
|
727
|
-
));
|
|
728
|
-
if (!threadIconArea) {
|
|
729
|
-
threadIconArea = this._threadIconArea =
|
|
730
|
-
document.createElement('div');
|
|
731
|
-
threadIconArea.className = idMap('sidebar_iconArea');
|
|
732
|
-
threadIconArea.classList.add('sidebar_thread_iconArea');
|
|
733
|
-
addCompanionThreadIconArea(
|
|
734
|
-
this._driver.getLogger(),
|
|
735
|
-
threadIconArea,
|
|
736
|
-
companionSidebarIconContainerEl
|
|
737
|
-
);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
this._addButton(threadIconArea, event, false);
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
Kefir.fromEvents((document.body: any), 'inboxsdkUpdateSidebarPanel')
|
|
744
|
-
.filter(
|
|
745
|
-
(e) => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal
|
|
746
|
-
)
|
|
747
|
-
.takeUntilBy(this._stopper)
|
|
748
|
-
.onValue((event) => {
|
|
749
|
-
const orderedItems = this._orderManager.getOrderedItems();
|
|
750
|
-
const index = findIndex(
|
|
751
|
-
orderedItems,
|
|
752
|
-
(x) => x.value.instanceId === event.detail.instanceId
|
|
753
|
-
);
|
|
754
|
-
if (index === -1)
|
|
755
|
-
throw new Error('should not happen: failed to find orderItem');
|
|
756
|
-
this._orderManager.updateItemValueByIndex(index, {
|
|
757
|
-
id: orderedItems[index].value.id,
|
|
473
|
+
appName,
|
|
758
474
|
appId: event.detail.appId,
|
|
759
|
-
appName: event.detail.appName || event.detail.title,
|
|
760
475
|
instanceId: event.detail.instanceId,
|
|
761
476
|
title: event.detail.title,
|
|
762
477
|
iconClass: event.detail.iconClass,
|
|
763
478
|
iconUrl: event.detail.iconUrl,
|
|
764
479
|
hideTitleBar: event.detail.hideTitleBar,
|
|
765
|
-
el: event.target
|
|
766
|
-
});
|
|
767
|
-
this._renderThreadSidebar();
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
Kefir.fromEvents((document.body: any), 'inboxsdkRemoveSidebarPanel')
|
|
771
|
-
.filter(
|
|
772
|
-
(e) => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal
|
|
773
|
-
)
|
|
774
|
-
.takeUntilBy(this._stopper)
|
|
775
|
-
.onValue((event) => {
|
|
776
|
-
const orderedItems = this._orderManager.getOrderedItems();
|
|
777
|
-
const index = findIndex(
|
|
778
|
-
orderedItems,
|
|
779
|
-
(x) => x.value.instanceId === event.detail.instanceId
|
|
780
|
-
);
|
|
781
|
-
if (index === -1)
|
|
782
|
-
throw new Error('should not happen: failed to find orderItem');
|
|
783
|
-
this._currentIds.delete(orderedItems[index].id);
|
|
784
|
-
this._orderManager.removeItemByIndex(index);
|
|
785
|
-
|
|
786
|
-
this._renderThreadSidebar();
|
|
787
|
-
this._removeButton(
|
|
788
|
-
event,
|
|
789
|
-
this._threadButtonContainers,
|
|
790
|
-
this._threadIconArea
|
|
791
|
-
);
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
Kefir.fromEvents(
|
|
795
|
-
(document.body: any),
|
|
796
|
-
'inboxsdkSidebarPanelScrollIntoView'
|
|
797
|
-
)
|
|
798
|
-
.filter(
|
|
799
|
-
(e) => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal
|
|
800
|
-
)
|
|
801
|
-
.takeUntilBy(this._stopper)
|
|
802
|
-
.onValue((event) => {
|
|
803
|
-
if (this._threadSidebarComponent)
|
|
804
|
-
this._threadSidebarComponent.scrollPanelIntoView(
|
|
805
|
-
event.detail.instanceId
|
|
806
|
-
);
|
|
807
|
-
});
|
|
808
|
-
|
|
809
|
-
Kefir.fromEvents((document.body: any), 'inboxsdkSidebarPanelClose')
|
|
810
|
-
.filter(
|
|
811
|
-
(e) => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal
|
|
812
|
-
)
|
|
813
|
-
.takeUntilBy(this._stopper)
|
|
814
|
-
.onValue((event) => {
|
|
815
|
-
if (this._threadSidebarComponent)
|
|
816
|
-
this._threadSidebarComponent.closePanel(event.detail.instanceId);
|
|
817
|
-
});
|
|
818
|
-
|
|
819
|
-
Kefir.fromEvents((document.body: any), 'inboxsdkSidebarPanelOpen')
|
|
820
|
-
.filter(
|
|
821
|
-
(e) => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal
|
|
822
|
-
)
|
|
823
|
-
.takeUntilBy(this._stopper)
|
|
824
|
-
.onValue((e) => {
|
|
825
|
-
this._renderThreadSidebar().then((threadSidebarComponent) => {
|
|
826
|
-
const descriptor = this._instanceIdsToDescriptors.get(
|
|
827
|
-
e.detail.instanceId
|
|
828
|
-
);
|
|
829
|
-
if (!descriptor) return;
|
|
830
|
-
|
|
831
|
-
const buttonContainer = this._threadButtonContainers.get(
|
|
832
|
-
descriptor.appName
|
|
833
|
-
);
|
|
834
|
-
if (!buttonContainer) {
|
|
835
|
-
throw new Error('missing button container');
|
|
836
|
-
}
|
|
837
|
-
const activeButtonContainer = this._getActiveButtonContainer();
|
|
838
|
-
if (activeButtonContainer !== buttonContainer) {
|
|
839
|
-
querySelector(buttonContainer, 'button').click();
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
// global sidebar content panels
|
|
846
|
-
{
|
|
847
|
-
Kefir.fromEvents((document.body: any), 'inboxsdkNewSidebarPanel')
|
|
848
|
-
.filter(
|
|
849
|
-
(e) => e.detail.sidebarId === this._instanceId && e.detail.isGlobal
|
|
850
|
-
)
|
|
851
|
-
.takeUntilBy(this._stopper)
|
|
852
|
-
.onValue((event) => {
|
|
853
|
-
let id = event.detail.id;
|
|
854
|
-
while (this._currentIds.has(id)) {
|
|
855
|
-
id = incrementName(id);
|
|
480
|
+
el: event.target
|
|
856
481
|
}
|
|
857
|
-
this._currentIds.add(id);
|
|
858
|
-
|
|
859
|
-
const appName = event.detail.appName;
|
|
860
|
-
|
|
861
|
-
let globalIconArea = (this._globalIconArea =
|
|
862
|
-
companionSidebarIconContainerEl.querySelector(
|
|
863
|
-
'.sidebar_global_iconArea'
|
|
864
|
-
));
|
|
865
|
-
if (!globalIconArea) {
|
|
866
|
-
globalIconArea = this._globalIconArea =
|
|
867
|
-
document.createElement('div');
|
|
868
|
-
globalIconArea.className = idMap('sidebar_iconArea');
|
|
869
|
-
globalIconArea.classList.add('sidebar_global_iconArea');
|
|
870
|
-
addCompanionGlobalIconArea(
|
|
871
|
-
this._driver.getLogger(),
|
|
872
|
-
globalIconArea,
|
|
873
|
-
companionSidebarIconContainerEl
|
|
874
|
-
);
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
const sdkContentContainerEl = document.createElement('div');
|
|
878
|
-
sdkContentContainerEl.classList.add(
|
|
879
|
-
'addon_sidebar',
|
|
880
|
-
idMap('app_sidebar_container'),
|
|
881
|
-
'global_app_sidebar'
|
|
882
|
-
);
|
|
883
|
-
this._companionSidebarContentContainerEl.insertAdjacentElement(
|
|
884
|
-
'afterbegin',
|
|
885
|
-
sdkContentContainerEl
|
|
886
|
-
);
|
|
887
|
-
this._contentContainers.set(appName, sdkContentContainerEl);
|
|
888
|
-
|
|
889
|
-
sdkContentContainerEl.appendChild(event.target);
|
|
890
|
-
sdkContentContainerEl.style.display = 'none';
|
|
891
|
-
|
|
892
|
-
this._addButton(globalIconArea, event, true);
|
|
893
482
|
});
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
(e) => e.detail.sidebarId === this._instanceId && e.detail.isGlobal
|
|
919
|
-
)
|
|
920
|
-
.takeUntilBy(this._stopper)
|
|
921
|
-
.onValue((event) => {
|
|
922
|
-
this._currentIds.delete(event.detail.id);
|
|
923
|
-
this._removeButton(
|
|
924
|
-
event,
|
|
925
|
-
this._globalButtonContainers,
|
|
926
|
-
this._globalIconArea
|
|
927
|
-
);
|
|
483
|
+
this._renderThreadSidebar();
|
|
484
|
+
let threadIconArea = this._threadIconArea = companionSidebarIconContainerEl.querySelector('.sidebar_thread_iconArea');
|
|
485
|
+
if (!threadIconArea) {
|
|
486
|
+
threadIconArea = this._threadIconArea = document.createElement('div');
|
|
487
|
+
threadIconArea.className = (0, _idMap.default)('sidebar_iconArea');
|
|
488
|
+
threadIconArea.classList.add('sidebar_thread_iconArea');
|
|
489
|
+
(0, _addCompanionThreadIconArea.default)(this._driver.getLogger(), threadIconArea, companionSidebarIconContainerEl);
|
|
490
|
+
}
|
|
491
|
+
this._addButton(threadIconArea, event, false);
|
|
492
|
+
});
|
|
493
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkUpdateSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
494
|
+
const orderedItems = this._orderManager.getOrderedItems();
|
|
495
|
+
const index = (0, _findIndex.default)(orderedItems, x => x.value.instanceId === event.detail.instanceId);
|
|
496
|
+
if (index === -1) throw new Error('should not happen: failed to find orderItem');
|
|
497
|
+
this._orderManager.updateItemValueByIndex(index, {
|
|
498
|
+
id: orderedItems[index].value.id,
|
|
499
|
+
appId: event.detail.appId,
|
|
500
|
+
appName: event.detail.appName || event.detail.title,
|
|
501
|
+
instanceId: event.detail.instanceId,
|
|
502
|
+
title: event.detail.title,
|
|
503
|
+
iconClass: event.detail.iconClass,
|
|
504
|
+
iconUrl: event.detail.iconUrl,
|
|
505
|
+
hideTitleBar: event.detail.hideTitleBar,
|
|
506
|
+
el: event.target
|
|
928
507
|
});
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
)
|
|
934
|
-
|
|
935
|
-
.
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
508
|
+
this._renderThreadSidebar();
|
|
509
|
+
});
|
|
510
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkRemoveSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
511
|
+
const orderedItems = this._orderManager.getOrderedItems();
|
|
512
|
+
const index = (0, _findIndex.default)(orderedItems, x => x.value.instanceId === event.detail.instanceId);
|
|
513
|
+
if (index === -1) throw new Error('should not happen: failed to find orderItem');
|
|
514
|
+
this._currentIds.delete(orderedItems[index].id);
|
|
515
|
+
this._orderManager.removeItemByIndex(index);
|
|
516
|
+
this._renderThreadSidebar();
|
|
517
|
+
this._removeButton(event, this._threadButtonContainers, this._threadIconArea);
|
|
518
|
+
});
|
|
519
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkSidebarPanelScrollIntoView').filter(e => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
520
|
+
if (this._threadSidebarComponent) this._threadSidebarComponent.scrollPanelIntoView(event.detail.instanceId);
|
|
521
|
+
});
|
|
522
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkSidebarPanelClose').filter(e => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
523
|
+
if (this._threadSidebarComponent) this._threadSidebarComponent.closePanel(event.detail.instanceId);
|
|
524
|
+
});
|
|
525
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkSidebarPanelOpen').filter(e => e.detail.sidebarId === this._instanceId && !e.detail.isGlobal).takeUntilBy(this._stopper).onValue(e => {
|
|
526
|
+
this._renderThreadSidebar().then(threadSidebarComponent => {
|
|
527
|
+
const descriptor = this._instanceIdsToDescriptors.get(e.detail.instanceId);
|
|
939
528
|
if (!descriptor) return;
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
);
|
|
944
|
-
if (!buttonContainer) return;
|
|
945
|
-
|
|
946
|
-
const activeButtonContainer = this._getActiveButtonContainer();
|
|
947
|
-
if (activeButtonContainer === buttonContainer) {
|
|
948
|
-
if (!this._closeButton) {
|
|
949
|
-
throw new Error('Expected this._closeButton');
|
|
950
|
-
}
|
|
951
|
-
this._closeButton(true);
|
|
529
|
+
const buttonContainer = this._threadButtonContainers.get(descriptor.appName);
|
|
530
|
+
if (!buttonContainer) {
|
|
531
|
+
throw new Error('missing button container');
|
|
952
532
|
}
|
|
953
|
-
});
|
|
954
|
-
|
|
955
|
-
Kefir.fromEvents((document.body: any), 'inboxsdkSidebarPanelOpen')
|
|
956
|
-
.filter(
|
|
957
|
-
(e) => e.detail.sidebarId === this._instanceId && e.detail.isGlobal
|
|
958
|
-
)
|
|
959
|
-
.takeUntilBy(this._stopper)
|
|
960
|
-
.onValue((event) => {
|
|
961
|
-
const descriptor = this._instanceIdsToDescriptors.get(
|
|
962
|
-
event.detail.instanceId
|
|
963
|
-
);
|
|
964
|
-
if (!descriptor) return;
|
|
965
|
-
|
|
966
|
-
const buttonContainer = this._globalButtonContainers.get(
|
|
967
|
-
descriptor.appName
|
|
968
|
-
);
|
|
969
|
-
if (!buttonContainer) return;
|
|
970
|
-
|
|
971
533
|
const activeButtonContainer = this._getActiveButtonContainer();
|
|
972
534
|
if (activeButtonContainer !== buttonContainer) {
|
|
973
|
-
|
|
535
|
+
(0, _querySelectorOrFail.default)(buttonContainer, 'button').click();
|
|
974
536
|
}
|
|
975
537
|
});
|
|
538
|
+
});
|
|
976
539
|
}
|
|
977
540
|
|
|
978
|
-
//
|
|
541
|
+
// global sidebar content panels
|
|
979
542
|
{
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
543
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkNewSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId && e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
544
|
+
let id = event.detail.id;
|
|
545
|
+
while (this._currentIds.has(id)) {
|
|
546
|
+
id = (0, _incrementName.default)(id);
|
|
547
|
+
}
|
|
548
|
+
this._currentIds.add(id);
|
|
549
|
+
const appName = event.detail.appName;
|
|
550
|
+
let globalIconArea = this._globalIconArea = companionSidebarIconContainerEl.querySelector('.sidebar_global_iconArea');
|
|
551
|
+
if (!globalIconArea) {
|
|
552
|
+
globalIconArea = this._globalIconArea = document.createElement('div');
|
|
553
|
+
globalIconArea.className = (0, _idMap.default)('sidebar_iconArea');
|
|
554
|
+
globalIconArea.classList.add('sidebar_global_iconArea');
|
|
555
|
+
(0, _addCompanionGlobalIconArea.default)(this._driver.getLogger(), globalIconArea, companionSidebarIconContainerEl);
|
|
556
|
+
}
|
|
557
|
+
const sdkContentContainerEl = document.createElement('div');
|
|
558
|
+
sdkContentContainerEl.classList.add('addon_sidebar', (0, _idMap.default)('app_sidebar_container'), 'global_app_sidebar');
|
|
559
|
+
this._companionSidebarContentContainerEl.insertAdjacentElement('afterbegin', sdkContentContainerEl);
|
|
560
|
+
this._contentContainers.set(appName, sdkContentContainerEl);
|
|
561
|
+
sdkContentContainerEl.appendChild(event.target);
|
|
562
|
+
sdkContentContainerEl.style.display = 'none';
|
|
563
|
+
this._addButton(globalIconArea, event, true);
|
|
564
|
+
});
|
|
565
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkUpdateSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId && e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
566
|
+
const buttonContainer = this._globalButtonContainers.get(event.detail.appName);
|
|
567
|
+
if (!buttonContainer) return;
|
|
568
|
+
const iconClass = event.detail.iconClass || '';
|
|
569
|
+
const iconUrl = event.detail.iconUrl || event.detail.appIconUrl;
|
|
570
|
+
const imgElement = (0, _querySelectorOrFail.default)(buttonContainer, 'img');
|
|
571
|
+
imgElement.setAttribute('src', iconUrl);
|
|
572
|
+
const button = (0, _querySelectorOrFail.default)(buttonContainer, 'button');
|
|
573
|
+
button.setAttribute('class', `inboxsdk__button_icon ${iconClass}`);
|
|
574
|
+
});
|
|
575
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkRemoveSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId && e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
576
|
+
this._currentIds.delete(event.detail.id);
|
|
577
|
+
this._removeButton(event, this._globalButtonContainers, this._globalIconArea);
|
|
578
|
+
});
|
|
579
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkSidebarPanelClose').filter(e => e.detail.sidebarId === this._instanceId && e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
580
|
+
const descriptor = this._instanceIdsToDescriptors.get(event.detail.instanceId);
|
|
581
|
+
if (!descriptor) return;
|
|
582
|
+
const buttonContainer = this._globalButtonContainers.get(descriptor.appName);
|
|
583
|
+
if (!buttonContainer) return;
|
|
584
|
+
const activeButtonContainer = this._getActiveButtonContainer();
|
|
585
|
+
if (activeButtonContainer === buttonContainer) {
|
|
586
|
+
if (!this._closeButton) {
|
|
587
|
+
throw new Error('Expected this._closeButton');
|
|
588
|
+
}
|
|
589
|
+
this._closeButton(true);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkSidebarPanelOpen').filter(e => e.detail.sidebarId === this._instanceId && e.detail.isGlobal).takeUntilBy(this._stopper).onValue(event => {
|
|
593
|
+
const descriptor = this._instanceIdsToDescriptors.get(event.detail.instanceId);
|
|
594
|
+
if (!descriptor) return;
|
|
595
|
+
const buttonContainer = this._globalButtonContainers.get(descriptor.appName);
|
|
596
|
+
if (!buttonContainer) return;
|
|
597
|
+
const activeButtonContainer = this._getActiveButtonContainer();
|
|
598
|
+
if (activeButtonContainer !== buttonContainer) {
|
|
599
|
+
(0, _querySelectorOrFail.default)(buttonContainer, 'button').click();
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
996
603
|
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
.
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
604
|
+
// instance id to descriptor management
|
|
605
|
+
{
|
|
606
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkNewSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId).takeUntilBy(this._stopper).onValue(event => {
|
|
607
|
+
this._instanceIdsToDescriptors.set(event.detail.instanceId, event.detail);
|
|
608
|
+
});
|
|
609
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkRemoveSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId).takeUntilBy(this._stopper).onValue(event => {
|
|
610
|
+
this._instanceIdsToDescriptors.delete(event.detail.instanceId);
|
|
611
|
+
});
|
|
612
|
+
_kefir.default.fromEvents(document.body, 'inboxsdkUpdateSidebarPanel').filter(e => e.detail.sidebarId === this._instanceId).takeUntilBy(this._stopper).onValue(event => {
|
|
613
|
+
this._instanceIdsToDescriptors.set(event.detail.instanceId, event.detail);
|
|
614
|
+
});
|
|
1006
615
|
}
|
|
1007
616
|
|
|
1008
617
|
// at this point the companionSidebar has 2 children
|
|
@@ -1014,35 +623,20 @@ class GmailAppSidebarPrimary {
|
|
|
1014
623
|
// or the thread add-on content element are visible
|
|
1015
624
|
// if they are both display: '' or display: none then the native sidebar
|
|
1016
625
|
// contents are not visible
|
|
1017
|
-
const globalAddOnContentContainer =
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
)
|
|
1031
|
-
.filter(
|
|
1032
|
-
() =>
|
|
1033
|
-
globalAddOnContentContainer.style.display !==
|
|
1034
|
-
threadAddOnContentContainer.style.display
|
|
1035
|
-
)
|
|
1036
|
-
.takeUntilBy(this._stopper)
|
|
1037
|
-
.onValue(() => {
|
|
1038
|
-
// TODO What is this block for? It closes the current section whenever
|
|
1039
|
-
// one of the Gmail addons bar elements changes?
|
|
1040
|
-
const activeButtonContainer = this._getActiveButtonContainer();
|
|
1041
|
-
if (activeButtonContainer) {
|
|
1042
|
-
querySelector(activeButtonContainer, 'button').click();
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
626
|
+
const globalAddOnContentContainer = this._companionSidebarContentContainerEl.children[0];
|
|
627
|
+
const threadAddOnContentContainer = this._companionSidebarContentContainerEl.children[1];
|
|
628
|
+
_kefir.default.merge([globalAddOnContentContainer, threadAddOnContentContainer].map(addonContentEl => (0, _makeMutationObserverChunkedStream.default)(addonContentEl, {
|
|
629
|
+
attributes: true,
|
|
630
|
+
attributeFilter: ['style']
|
|
631
|
+
}))).filter(() => globalAddOnContentContainer.style.display !== threadAddOnContentContainer.style.display).takeUntilBy(this._stopper).onValue(() => {
|
|
632
|
+
// TODO What is this block for? It closes the current section whenever
|
|
633
|
+
// one of the Gmail addons bar elements changes?
|
|
634
|
+
const activeButtonContainer = this._getActiveButtonContainer();
|
|
635
|
+
if (activeButtonContainer) {
|
|
636
|
+
(0, _querySelectorOrFail.default)(activeButtonContainer, 'button').click();
|
|
637
|
+
}
|
|
638
|
+
});
|
|
1045
639
|
}
|
|
1046
640
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
641
|
+
var _default = (0, _ud.defn)(module, GmailAppSidebarPrimary);
|
|
642
|
+
exports.default = _default;
|