fix event UI
This commit is contained in:
parent
db57a7ab78
commit
b73e52afbd
|
@ -51,6 +51,8 @@ export default function ProcessInstanceShow() {
|
||||||
const [selectingEvent, setSelectingEvent] = useState<boolean>(false);
|
const [selectingEvent, setSelectingEvent] = useState<boolean>(false);
|
||||||
const [eventToSend, setEventToSend] = useState<any>({});
|
const [eventToSend, setEventToSend] = useState<any>({});
|
||||||
const [eventPayload, setEventPayload] = useState<string>('{}');
|
const [eventPayload, setEventPayload] = useState<string>('{}');
|
||||||
|
const [eventTextEditorEnabled, setEventTextEditorEnabled] =
|
||||||
|
useState<boolean>(false);
|
||||||
|
|
||||||
const setErrorMessage = (useContext as any)(ErrorContext)[1];
|
const setErrorMessage = (useContext as any)(ErrorContext)[1];
|
||||||
|
|
||||||
|
@ -413,7 +415,7 @@ export default function ProcessInstanceShow() {
|
||||||
const taskTypes = ['Event Based Gateway'];
|
const taskTypes = ['Event Based Gateway'];
|
||||||
return (
|
return (
|
||||||
taskTypes.filter((t) => t === task.type).length > 0 &&
|
taskTypes.filter((t) => t === task.type).length > 0 &&
|
||||||
task.state === 'WAITING' &&
|
task.state === 'WAITING' &&
|
||||||
showingLastSpiffStep(processInstance as any)
|
showingLastSpiffStep(processInstance as any)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -421,15 +423,18 @@ export default function ProcessInstanceShow() {
|
||||||
const getEvents = (task: any) => {
|
const getEvents = (task: any) => {
|
||||||
const handleMessage = (eventDefinition: any) => {
|
const handleMessage = (eventDefinition: any) => {
|
||||||
if (eventDefinition.typename === 'MessageEventDefinition') {
|
if (eventDefinition.typename === 'MessageEventDefinition') {
|
||||||
delete eventDefinition.message_var;
|
const newEvent = eventDefinition;
|
||||||
eventDefinition.payload = {};
|
delete newEvent.message_var;
|
||||||
|
newEvent.payload = {};
|
||||||
|
return newEvent;
|
||||||
}
|
}
|
||||||
return eventDefinition;
|
return eventDefinition;
|
||||||
};
|
};
|
||||||
if (task.event_definition && task.event_definition.event_definitions)
|
if (task.event_definition && task.event_definition.event_definitions)
|
||||||
return task.event_definition.event_definitions.map((e: any) => handleMessage(e));
|
return task.event_definition.event_definitions.map((e: any) =>
|
||||||
if (task.event_definition)
|
handleMessage(e)
|
||||||
return [handleMessage(task.event_definition)];
|
);
|
||||||
|
if (task.event_definition) return [handleMessage(task.event_definition)];
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -437,6 +442,7 @@ export default function ProcessInstanceShow() {
|
||||||
setEditingTaskData(false);
|
setEditingTaskData(false);
|
||||||
setSelectingEvent(false);
|
setSelectingEvent(false);
|
||||||
initializeTaskDataToDisplay(taskToDisplay);
|
initializeTaskDataToDisplay(taskToDisplay);
|
||||||
|
setEventPayload('{}');
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -522,10 +528,7 @@ export default function ProcessInstanceShow() {
|
||||||
);
|
);
|
||||||
} else if (selectingEvent) {
|
} else if (selectingEvent) {
|
||||||
buttons.push(
|
buttons.push(
|
||||||
<Button
|
<Button data-qa="create-script-unit-test-button" onClick={sendEvent}>
|
||||||
data-qa="create-script-unit-test-button"
|
|
||||||
onClick={sendEvent}
|
|
||||||
>
|
|
||||||
Send
|
Send
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
@ -582,9 +585,11 @@ export default function ProcessInstanceShow() {
|
||||||
height={300}
|
height={300}
|
||||||
width="auto"
|
width="auto"
|
||||||
defaultLanguage="json"
|
defaultLanguage="json"
|
||||||
|
defaultValue={eventPayload}
|
||||||
onChange={(value: any) => setEventPayload(value || '{}')}
|
onChange={(value: any) => setEventPayload(value || '{}')}
|
||||||
|
options={{ readOnly: !eventTextEditorEnabled }}
|
||||||
/>
|
/>
|
||||||
)
|
);
|
||||||
return selectingEvent ? (
|
return selectingEvent ? (
|
||||||
<Stack orientation="vertical">
|
<Stack orientation="vertical">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
@ -593,9 +598,14 @@ export default function ProcessInstanceShow() {
|
||||||
label="Select Event"
|
label="Select Event"
|
||||||
items={candidateEvents}
|
items={candidateEvents}
|
||||||
itemToString={(item: any) => item.name || item.label || item.typename}
|
itemToString={(item: any) => item.name || item.label || item.typename}
|
||||||
onChange={(value: any) => setEventToSend(value.selectedItem)}
|
onChange={(value: any) => {
|
||||||
|
setEventToSend(value.selectedItem);
|
||||||
|
setEventTextEditorEnabled(
|
||||||
|
value.selectedItem.typename === 'MessageEventDefinition'
|
||||||
|
);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{'payload' in eventToSend ? editor : ''}
|
{editor}
|
||||||
</Stack>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
taskDataContainer()
|
taskDataContainer()
|
||||||
|
@ -616,7 +626,9 @@ export default function ProcessInstanceShow() {
|
||||||
{taskToUse.name} ({taskToUse.type}): {taskToUse.state}
|
{taskToUse.name} ({taskToUse.type}): {taskToUse.state}
|
||||||
{taskDataButtons(taskToUse)}
|
{taskDataButtons(taskToUse)}
|
||||||
</Stack>
|
</Stack>
|
||||||
{selectingEvent ? eventSelector(candidateEvents) : taskDataContainer()}
|
{selectingEvent
|
||||||
|
? eventSelector(candidateEvents)
|
||||||
|
: taskDataContainer()}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue