Skip to content

Commit

Permalink
Update Workflow State icons
Browse files Browse the repository at this point in the history
Before
======

Icons were working for Tasks
Icons were only displaying play for all others

After
=====

Icons are displaying for all Tasks
  • Loading branch information
kbrock committed Jun 5, 2024
1 parent 486e88a commit bbf70d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/javascript/components/miq-data-table/miq-table-cell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ const MiqTableCell = ({
};

/** Function to render icon(s) in cell. */
const renderIcon = (icon, style, showText) => {
const renderIcon = (icon, style, showText, title = '') => {
const hasBackground = Object.keys(style).includes('background');
const styledIconClass = hasBackground ? 'styled_icon' : '';
const longerTextClass = hasBackground && veryLongText ? 'styled_icon_margin' : '';
return (
<div className={cellClass}>
<div className={cellClass} title={title}>
{
typeof (icon) === 'string'
? returnIcon(icon, style, styledIconClass, longerTextClass)
Expand All @@ -111,7 +111,7 @@ const MiqTableCell = ({
if (showText) {
const color = item.props ? item.props.style : {};
const iconStyle = item.background ? { background: item.background, color: '#FFF' } : color;
return renderIcon(item.icon, iconStyle, showText);
return renderIcon(item.icon, iconStyle, showText, item.title);
}
const { className, style } = item.props ? item.props : { className: item.icon, style: { color: '#000' } };
return renderIcon(className, style, showText);
Expand Down
19 changes: 13 additions & 6 deletions app/javascript/components/request-workflow-status/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,19 @@ const convertDuration = (duration) => {
};

const getItemIcon = (item) => {
if (item.RunnerContext && item.RunnerContext.success) {
return { icon: 'carbon--CheckmarkOutline' };
} if (item.RunnerContext && item.RunnerContext.Error) {
return { icon: 'carbon--MisuseOutline' };
if (item.FinishedTime) {
if (item.Output && item.Output.Error) {
if (item.RetryCount) {
return { icon: 'carbon--RetryFailed' }
} else {
return { icon: 'carbon--MisuseOutline' }
}
} else {
return { icon: 'carbon--CheckmarkOutline' }
}
} else {
return { icon: 'carbon--PlayOutline' }
}
return { icon: 'carbon--PlayOutline' };
};

/** Function to get the row data of workflow states table. */
Expand All @@ -97,7 +104,7 @@ export const workflowStatusData = (response) => {

rows.push({
id: state.Guid.toString(),
name: { text: state.Name, icon: 'carbon--PlayOutline' },
name: { text: state.Name, ...getItemIcon(state) },
enteredTime: convertDate(state.EnteredTime.toString()),
finishedTime: '',
duration: convertDuration(durationTime),
Expand Down
4 changes: 4 additions & 0 deletions app/stylesheet/miq-data-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,8 @@ table.miq_preview {
.carbon--PlayOutline {
color: var(--yellow)
}

.carbon--RetryFailed {
color: var(--red);
}
}

0 comments on commit bbf70d8

Please sign in to comment.