Skip to content

Commit

Permalink
force update of yaml property
Browse files Browse the repository at this point in the history
  • Loading branch information
LaviniaStiliadou committed Jul 26, 2023
1 parent 6ecb610 commit e3e6de9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Footer = Modal.Footer;
export default function YamlModal(props) {
const [uploadFile, setUploadFile] = useState(null);

const { onClose, element, wineryEndpoint } = props;
const { onClose, element, commandStack } = props;

const onSubmit = async () => {
// Process the uploaded file or text input here
Expand All @@ -39,6 +39,13 @@ export default function YamlModal(props) {
reader.onload = function () {
var fileContent = reader.result;
element.businessObject.yaml = fileContent;
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: element.businessObject,
properties: {
'yaml': fileContent
}
});
};
reader.readAsText(uploadFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import './yaml-modal.css';
export function YamlUpload(props) {
const { element } = props;
const translate = useService('translate');
const commandStack = useService('commandStack');

const onClick = () => {
const yamlUploadDiv = document.querySelector("#yamlUploadDiv");
Expand All @@ -23,7 +24,7 @@ export function YamlUpload(props) {
div.id = "yamlUploadDiv";
document.getElementById('main-div').appendChild(div);
const root = createRoot(document.getElementById("yamlUploadDiv"));
root.render(<YAMLModal element={element}/>);
root.render(<YAMLModal element={element} commandStack={commandStack}/>);
};

return HeaderButton({
Expand All @@ -39,16 +40,16 @@ export function YamlUpload(props) {

function YAMLModal(props) {
const [showModal, setShowModal] = useState(true);
const {element, wineryEndpoint} = props;
const {element, commandStack} = props;

function handleWizardClosed() {
function handleModalClosed() {
setShowModal(false);
}

return (
<div>
{showModal && (
<YamlModal onClose={handleWizardClosed} element={element} />
<YamlModal onClose={handleModalClosed} element={element} commandStack={commandStack}/>
)}
</div>
);
Expand Down

0 comments on commit e3e6de9

Please sign in to comment.