2022-06-15 17:34:45 -04:00
|
|
|
import { HeaderButton, TextAreaEntry, TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel';
|
2022-06-15 09:51:46 -04:00
|
|
|
import { useService } from 'bpmn-js-properties-panel';
|
|
|
|
|
|
|
|
export default function(element) {
|
|
|
|
|
2022-06-15 17:34:45 -04:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
id: 'pythonScript',
|
|
|
|
element,
|
|
|
|
component: PythonScript,
|
|
|
|
isEdited: isTextFieldEntryEdited
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'launchEditorButton',
|
|
|
|
element,
|
|
|
|
component: LaunchEditorButton,
|
|
|
|
isEdited: isTextFieldEntryEdited
|
|
|
|
},
|
|
|
|
]
|
2022-06-15 09:51:46 -04:00
|
|
|
}
|
|
|
|
|
2022-06-15 15:13:35 -04:00
|
|
|
function PythonScript(props) {
|
2022-06-15 09:51:46 -04:00
|
|
|
const { element, id } = props;
|
|
|
|
|
|
|
|
const modeling = useService('modeling');
|
|
|
|
const translate = useService('translate');
|
|
|
|
const debounce = useService('debounceInput');
|
|
|
|
|
|
|
|
const getValue = () => {
|
2022-06-15 15:13:35 -04:00
|
|
|
return element.businessObject.script || '';
|
2022-06-15 09:51:46 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const setValue = value => {
|
|
|
|
return modeling.updateProperties(element, {
|
2022-06-15 15:13:35 -04:00
|
|
|
scriptFormat: "python",
|
|
|
|
script: value
|
2022-06-15 09:51:46 -04:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-06-15 15:13:35 -04:00
|
|
|
return <TextAreaEntry
|
2022-06-15 09:51:46 -04:00
|
|
|
id={ id }
|
|
|
|
element={ element }
|
2022-06-15 15:13:35 -04:00
|
|
|
description={ translate('Python script to execute') }
|
|
|
|
label={ translate('Python Script') }
|
2022-06-15 09:51:46 -04:00
|
|
|
getValue={ getValue }
|
|
|
|
setValue={ setValue }
|
|
|
|
debounce={ debounce }
|
|
|
|
/>
|
|
|
|
}
|
2022-06-15 17:34:45 -04:00
|
|
|
|
|
|
|
function LaunchEditorButton(props) {
|
|
|
|
const { element, id } = props;
|
|
|
|
const eventBus = useService('eventBus');
|
|
|
|
const modeling = useService('modeling');
|
|
|
|
return <HeaderButton
|
2022-06-17 17:04:42 -04:00
|
|
|
className="spiffworkflow-properties-panel-button"
|
2022-06-15 17:34:45 -04:00
|
|
|
onClick={() => {
|
|
|
|
eventBus.fire('launch.script.editor', { element: element })
|
|
|
|
}}
|
|
|
|
>Launch Editor</HeaderButton>
|
|
|
|
}
|