Skip to content

Commit

Permalink
[FIX] Mini icon in node modal consistent with configuration (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
mproch authored Apr 28, 2020
1 parent 7ae979c commit c0c0f02
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
7 changes: 4 additions & 3 deletions ui/client/components/graph/EspNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ joint.shapes.devs.EspNode = joint.shapes.devs.Model.extend({
}, joint.shapes.devs.Model.prototype.defaults),
})

export function getIconHref(node, nodesSettings) {
const iconFromConfig = nodesSettings?.[ProcessUtils.findNodeConfigName(node)]?.icon
export function getIconHref(node, nodeSettings) {
const iconFromConfig = nodeSettings?.icon
const defaultIconName = `${node.type}.svg`
return absoluteBePath(`/assets/nodes/${iconFromConfig || defaultIconName}`)
}
Expand All @@ -161,7 +161,8 @@ export function makeElement(node, processCounts, nodesSettings) {
const hasCounts = !_.isEmpty(processCounts)
const width = rectWidth
const height = rectHeight
const iconHref = getIconHref(node, nodesSettings)
const nodeSettings = nodesSettings?.[ProcessUtils.findNodeConfigName(node)]
const iconHref = getIconHref(node, nodeSettings)
const testResultsHeight = 24
const pxPerChar = 8
const countsPadding = 8
Expand Down
6 changes: 3 additions & 3 deletions ui/client/components/graph/node-modal/NodeDetailsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class NodeDetailsModal extends React.Component {
}

render() {
const {nodeErrors, nodeToDisplay, nodeSetting, readOnly, showNodeDetailsModal, testResults} = this.props
const {nodeErrors, nodeToDisplay, nodeSettings, readOnly, showNodeDetailsModal, testResults} = this.props
const isOpen = !_.isEmpty(nodeToDisplay) && showNodeDetailsModal
const nodeTestResults = (id) => TestResultUtils.resultsForNode(testResults, id)

Expand All @@ -157,7 +157,7 @@ class NodeDetailsModal extends React.Component {
<div className="draggable-container">
<Draggable bounds="parent" handle=".modal-draggable-handle">
<div className="espModal">
<NodeDetailsModalHeader node={nodeToDisplay} docsUrl={nodeSetting.docsUrl}/>
<NodeDetailsModalHeader node={nodeToDisplay} nodeSettings={nodeSettings}/>
<div className="modalContentDark" id="modal-content">
<Scrollbars
hideTracksWhenNotNeeded={true}
Expand Down Expand Up @@ -215,7 +215,7 @@ function mapState(state) {

return {
nodeToDisplay: nodeToDisplay,
nodeSetting: _.get(processDefinitionData.nodesConfig, ProcessUtils.findNodeConfigName(nodeToDisplay)) || {},
nodeSettings: _.get(processDefinitionData.nodesConfig, ProcessUtils.findNodeConfigName(nodeToDisplay)) || {},
processId: state.graphReducer.processToDisplay.id,
subprocessVersions: state.graphReducer.processToDisplay.properties.subprocessVersions,
nodeErrors: errors,
Expand Down
10 changes: 6 additions & 4 deletions ui/client/components/graph/node-modal/NodeDetailsModalHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Docs = (props) => {

Docs.propTypes = {
className: PropTypes.string.isRequired,
docsUrl: PropTypes.string.isRequired,
nodeSettings: PropTypes.object.isRequired,
nodeClass: PropTypes.string,
}

Expand Down Expand Up @@ -76,13 +76,15 @@ const renderNodeClassDocs = (nodeClass, docsUrl) => {
}

const NodeDetailsModalHeader = (props) => {
const {docsUrl, node} = props
const {nodeSettings, node} = props
const docsUrl = nodeSettings.docsUrl

const attributes = getNodeAttributes(node)
const titleStyles = EspModalStyles.headerStyles(attributes.styles.fill, attributes.styles.color)
const variableLanguage = _.get(node, "value.language")
const variableLanguage = node?.value?.language
const header = (_.isEmpty(variableLanguage) ? "" : `${variableLanguage} `) + attributes.name

const nodeIcon = _.has(node, "type") ? getIconHref(node) : null
const nodeIcon = _.has(node, "type") ? getIconHref(node, nodeSettings) : null
const nodeClass = findNodeClass(node)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const periodFormatter: Formatter = {
}

//FIXME: this should not work this way. We should either provide some helper, or (even better) create mini-expression-languages for those types and do not try
//to convert to/from spel
//to convert to/from spel. Also: this is probably *not* performant enough to be used on per-event basis
const spelCronFormatter: Formatter = {
encode: (value: CronExpression) => `new com.cronutils.parser.CronParser(T(com.cronutils.model.definition.CronDefinitionBuilder).instanceDefinitionFor(T(com.cronutils.model.CronType).QUARTZ)).parse('${value}')`,
decode: value => {
Expand Down

0 comments on commit c0c0f02

Please sign in to comment.