Log errors for post message
Remove tranfer array field
This commit is contained in:
parent
a9ba6d705d
commit
8c4c1823c5
|
|
@ -358,7 +358,6 @@ export enum FieldType {
|
|||
CLEAR_INTERVAL_ID_FIELD = "CLEAR_INTERVAL_ID_FIELD",
|
||||
MESSAGE_FIELD = "MESSAGE_FIELD",
|
||||
TARGET_ORIGIN_FIELD = "TARGET_ORIGIN_FIELD",
|
||||
TRANSFER_ARRAY_FIELD = "TRANSFER_ARRAY_FIELD",
|
||||
}
|
||||
|
||||
type FieldConfig = {
|
||||
|
|
@ -649,15 +648,6 @@ const fieldConfigs: FieldConfigs = {
|
|||
},
|
||||
view: ViewTypes.TEXT_VIEW,
|
||||
},
|
||||
[FieldType.TRANSFER_ARRAY_FIELD]: {
|
||||
getter: (value: string) => {
|
||||
return textGetter(value, 2);
|
||||
},
|
||||
setter: (value: string, currentValue: string) => {
|
||||
return textSetter(value, currentValue, 2);
|
||||
},
|
||||
view: ViewTypes.TEXT_VIEW,
|
||||
},
|
||||
};
|
||||
|
||||
function renderField(props: {
|
||||
|
|
@ -831,7 +821,6 @@ function renderField(props: {
|
|||
case FieldType.CLEAR_INTERVAL_ID_FIELD:
|
||||
case FieldType.MESSAGE_FIELD:
|
||||
case FieldType.TARGET_ORIGIN_FIELD:
|
||||
case FieldType.TRANSFER_ARRAY_FIELD:
|
||||
let fieldLabel = "";
|
||||
if (fieldType === FieldType.ALERT_TEXT_FIELD) {
|
||||
fieldLabel = "Message";
|
||||
|
|
@ -861,8 +850,6 @@ function renderField(props: {
|
|||
fieldLabel = "Message";
|
||||
} else if (fieldType === FieldType.TARGET_ORIGIN_FIELD) {
|
||||
fieldLabel = "Target origin";
|
||||
} else if (fieldType === FieldType.TRANSFER_ARRAY_FIELD) {
|
||||
fieldLabel = "Transfer array (optional)";
|
||||
}
|
||||
viewElement = (view as (props: TextViewProps) => JSX.Element)({
|
||||
label: fieldLabel,
|
||||
|
|
|
|||
|
|
@ -387,9 +387,6 @@ function getFieldFromValue(
|
|||
{
|
||||
field: FieldType.TARGET_ORIGIN_FIELD,
|
||||
},
|
||||
{
|
||||
field: FieldType.TRANSFER_ARRAY_FIELD,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ export type PostMessageDescription = {
|
|||
payload: {
|
||||
message: any;
|
||||
targetOrigin: string;
|
||||
transfer?: any[];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ export function* executeActionTriggers(
|
|||
}
|
||||
break;
|
||||
case ActionTriggerType.POST_MESSAGE:
|
||||
yield call(postMessageSaga, trigger.payload);
|
||||
yield call(postMessageSaga, trigger.payload, triggerMeta);
|
||||
break;
|
||||
default:
|
||||
log.error("Trigger type unknown", trigger);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,27 @@
|
|||
import { spawn } from "redux-saga/effects";
|
||||
import { PostMessageDescription } from "../../entities/DataTree/actionTriggers";
|
||||
import { TriggerFailureError } from "sagas/ActionExecution/errorUtils";
|
||||
import { logActionExecutionError } from "sagas/ActionExecution/errorUtils";
|
||||
import { TriggerMeta } from "./ActionExecutionSagas";
|
||||
|
||||
export function* postMessageSaga(payload: PostMessageDescription["payload"]) {
|
||||
yield spawn(executePostMessage, payload);
|
||||
export function* postMessageSaga(
|
||||
payload: PostMessageDescription["payload"],
|
||||
triggerMeta: TriggerMeta,
|
||||
) {
|
||||
yield spawn(executePostMessage, payload, triggerMeta);
|
||||
}
|
||||
|
||||
function* executePostMessage(payload: PostMessageDescription["payload"]) {
|
||||
const { message, targetOrigin, transfer } = payload;
|
||||
function* executePostMessage(
|
||||
payload: PostMessageDescription["payload"],
|
||||
triggerMeta: TriggerMeta,
|
||||
) {
|
||||
const { message, targetOrigin } = payload;
|
||||
try {
|
||||
window.parent.postMessage(message, targetOrigin, transfer || undefined);
|
||||
window.parent.postMessage(message, targetOrigin, undefined);
|
||||
} catch (error) {
|
||||
throw new TriggerFailureError(error.message);
|
||||
logActionExecutionError(
|
||||
error.message,
|
||||
triggerMeta.source,
|
||||
triggerMeta.triggerPropertyName,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,17 +261,12 @@ const DATA_TREE_FUNCTIONS: Record<
|
|||
};
|
||||
},
|
||||
},
|
||||
postMessageToTargetWindow: function(
|
||||
message: any,
|
||||
targetOrigin: string,
|
||||
transfer?: any[],
|
||||
) {
|
||||
postMessageToTargetWindow: function(message: any, targetOrigin: string) {
|
||||
return {
|
||||
type: ActionTriggerType.POST_MESSAGE,
|
||||
payload: {
|
||||
message,
|
||||
targetOrigin,
|
||||
transfer,
|
||||
},
|
||||
executionType: ExecutionType.TRIGGER,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user