-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add hint for the process ID field in Camunda 7
Closes #1038
- Loading branch information
1 parent
90ae4bb
commit 23c3974
Showing
7 changed files
with
230 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { | ||
getBusinessObject, | ||
is | ||
} from 'bpmn-js/lib/util/ModelUtil'; | ||
|
||
import { TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
import { useCallback } from '@bpmn-io/properties-panel/preact/hooks'; | ||
|
||
import { | ||
useService | ||
} from '../../../hooks'; | ||
|
||
import { | ||
isIdValid | ||
} from '../../../utils/ValidationUtil'; | ||
|
||
|
||
/** | ||
* @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry | ||
*/ | ||
|
||
/** | ||
* @returns {Array<Entry>} entries | ||
*/ | ||
export function IdProps() { | ||
return [ | ||
{ | ||
id: 'id', | ||
component: Id, | ||
isEdited: isTextFieldEntryEdited | ||
} | ||
]; | ||
} | ||
|
||
function Id(props) { | ||
const { | ||
element | ||
} = props; | ||
|
||
const modeling = useService('modeling'); | ||
const debounce = useService('debounceInput'); | ||
const translate = useService('translate'); | ||
|
||
const setValue = (value, error) => { | ||
if (error) { | ||
return; | ||
} | ||
|
||
modeling.updateProperties(element, { | ||
id: value | ||
}); | ||
}; | ||
|
||
const getValue = useCallback((element) => { | ||
return getBusinessObject(element).id; | ||
}, [ element ]); | ||
|
||
const validate = useCallback((value) => { | ||
const businessObject = getBusinessObject(element); | ||
|
||
return isIdValid(businessObject, value, translate); | ||
}, [ element, translate ]); | ||
|
||
const description = is(element, 'bpmn:Process') ? | ||
translate('This maps to the process definition key.') | ||
: null; | ||
|
||
return TextFieldEntry({ | ||
element, | ||
id: 'id', | ||
label: translate(is(element, 'bpmn:Participant') ? 'Participant ID' : 'ID'), | ||
getValue, | ||
setValue, | ||
debounce, | ||
validate, | ||
description | ||
}); | ||
} |
134 changes: 134 additions & 0 deletions
134
src/provider/camunda-platform/properties/ProcessProps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { is } from 'bpmn-js/lib/util/ModelUtil'; | ||
|
||
import { TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
import { useCallback } from '@bpmn-io/properties-panel/preact/hooks'; | ||
|
||
import { | ||
useService | ||
} from '../../../hooks'; | ||
|
||
import { | ||
isIdValid | ||
} from '../../../utils/ValidationUtil'; | ||
|
||
/** | ||
* @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry | ||
*/ | ||
|
||
/** | ||
* @returns {Array<Entry>} entries | ||
*/ | ||
export function ProcessProps(props) { | ||
const { | ||
element | ||
} = props; | ||
|
||
if (!hasProcessRef(element)) { | ||
return []; | ||
} | ||
|
||
return [ | ||
{ | ||
id: 'processId', | ||
component: ProcessId, | ||
isEdited: isTextFieldEntryEdited | ||
}, | ||
{ | ||
id: 'processName', | ||
component: ProcessName, | ||
isEdited: isTextFieldEntryEdited | ||
} | ||
]; | ||
} | ||
|
||
function ProcessName(props) { | ||
const { element } = props; | ||
|
||
const commandStack = useService('commandStack'); | ||
const translate = useService('translate'); | ||
const debounce = useService('debounceInput'); | ||
const process = element.businessObject.get('processRef'); | ||
|
||
const getValue = () => { | ||
return process.get('name'); | ||
}; | ||
|
||
const setValue = (value) => { | ||
commandStack.execute( | ||
'element.updateModdleProperties', | ||
{ | ||
element, | ||
moddleElement: process, | ||
properties: { | ||
name: value | ||
} | ||
} | ||
); | ||
}; | ||
|
||
return TextFieldEntry({ | ||
element, | ||
id: 'processName', | ||
label: translate('Process name'), | ||
getValue, | ||
setValue, | ||
debounce | ||
}); | ||
} | ||
|
||
function ProcessId(props) { | ||
const { element } = props; | ||
|
||
const commandStack = useService('commandStack'); | ||
const translate = useService('translate'); | ||
const debounce = useService('debounceInput'); | ||
const process = element.businessObject.get('processRef'); | ||
|
||
const getValue = () => { | ||
return process.get('id'); | ||
}; | ||
|
||
const setValue = (value, error) => { | ||
if (error) { | ||
return; | ||
} | ||
|
||
commandStack.execute( | ||
'element.updateModdleProperties', | ||
{ | ||
element, | ||
moddleElement: process, | ||
properties: { | ||
id: value | ||
} | ||
} | ||
); | ||
}; | ||
|
||
const validate = useCallback((value) => { | ||
return isIdValid(process, value, translate); | ||
}, [ process, translate ]); | ||
|
||
const description = is(element, 'bpmn:Participant') ? | ||
translate('This maps to the process definition key.') | ||
: null; | ||
|
||
return TextFieldEntry({ | ||
element, | ||
id: 'processId', | ||
label: translate('Process ID'), | ||
getValue, | ||
setValue, | ||
debounce, | ||
validate, | ||
description | ||
}); | ||
} | ||
|
||
|
||
// helper //////////////// | ||
|
||
function hasProcessRef(element) { | ||
return is(element, 'bpmn:Participant') && element.businessObject.get('processRef'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.