Initial Modal Widget work tweaks MSC2790

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2020-09-25 14:08:27 +01:00
parent 342f1d5b43
commit 44bc8fc67e
10 changed files with 294 additions and 243 deletions

View File

@@ -26,8 +26,7 @@ import {IntegrationManagers} from "./integrations/IntegrationManagers";
import SettingsStore from "./settings/SettingsStore";
import {Capability, KnownWidgetActions} from "./widgets/WidgetApi";
import {objectClone} from "./utils/objects";
import {Action} from "./dispatcher/actions";
import {TempWidgetStore} from "./stores/TempWidgetStore";
import {ModalWidgetStore} from "./stores/ModalWidgetStore";
const WIDGET_API_VERSION = '0.0.2'; // Current API version
const SUPPORTED_WIDGET_API_VERSIONS = [
@@ -220,12 +219,16 @@ export default class FromWidgetPostMessageApi {
if (ActiveWidgetStore.widgetHasCapability(widgetId, Capability.AlwaysOnScreen)) {
ActiveWidgetStore.setWidgetPersistence(widgetId, val);
}
} else if (action === 'get_openid'
|| action === KnownWidgetActions.CloseWidget) {
} else if (action === 'get_openid' || action === KnownWidgetActions.CloseModalWidget) {
// Handled by caller
} else if (action === KnownWidgetActions.OpenTempWidget) {
TempWidgetStore.instance.openTempWidget(event.data.data, widgetId);
this.sendResponse(event, {}); // ack
} else if (action === KnownWidgetActions.OpenModalWidget) {
if (ModalWidgetStore.instance.canOpenModalWidget()) {
ModalWidgetStore.instance.openModalWidget(event.data.data, widgetId);
this.sendResponse(event, {}); // ack
} else {
this.sendError(event, {message: 'Unable to open modal at this time'}); // nak
}
} else {
console.warn('Widget postMessage event unhandled');
this.sendError(event, {message: 'The postMessage was unhandled'});