Skip to content

Commit

Permalink
Refs #131062 use workflow title instead of id for workflow list
Browse files Browse the repository at this point in the history
  • Loading branch information
ichim-david committed Jun 10, 2021
1 parent bf986ba commit fc98c2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions src/customizations/volto/components/manage/Workflow/Workflow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ const customSelectStyles = {
}),
};

/* #131062 use title instead of id if we find the current workflow id in the history props */
const selectedWorkflow = (props, workflow_id) => {
const current_state = props.history.filter((value) => {
return value.review_state === props.content.review_state;
});
return (current_state.length && current_state[0]['title']) || workflow_id;
};

/**
* Workflow container class.
* @class Workflow
Expand Down Expand Up @@ -195,7 +203,10 @@ class Workflow extends Component {

state = {
selectedOption: this.props.content.review_state
? getWorkflowMapping(null, this.props.content.review_state)
? getWorkflowMapping(
this.props.content.review_state,
selectedWorkflow(this.props, this.props.content.review_state),
)
: {},
};

Expand Down Expand Up @@ -231,7 +242,7 @@ class Workflow extends Component {
toast.success(
<Toast
success
title={this.props.intl.formatMessage(messages.messageUpdated)}
content={this.props.intl.formatMessage(messages.messageUpdated)}
/>,
);
};
Expand Down Expand Up @@ -300,10 +311,9 @@ class Workflow extends Component {
this.props.transitions.length === 0
}
options={uniqBy(
this.props.transitions.map((transition) =>
getWorkflowMapping(transition['@id']),
),
'label',
this.props.transitions.map((transition) => {
return getWorkflowMapping(transition['@id'], transition['title']);
}, 'label'),
).concat(selectedOption)}
styles={customSelectStyles}
theme={selectTheme}
Expand Down
2 changes: 1 addition & 1 deletion src/customizations/volto/constants/Workflows.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function getWorkflowMapping(url, current) {
return mapping[key];
}

return { value: key, label: key, color: '#000', url };
return { value: key, label: current || key, color: '#000', url };
}

if (current in mapping) {
Expand Down

0 comments on commit fc98c2e

Please sign in to comment.