Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-81058 || Make rule name clickable #3378

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ import styles from './ruleItem.scss';

const cx = classNames.bind(styles);

export const RuleItem = ({ item, actions, onToggle, disabled, content, onClick }) => {
export const RuleItem = ({
item,
actions,
onToggle,
disabled,
content,
onClick,
onRuleNameClick,
}) => {
const [shown, setShown] = useState(false);
const { enabled, name } = item;
const isRuleNameClickable = Boolean(onRuleNameClick);

const onToggleActive = (val) => {
onToggle(val, item);
};
Expand All @@ -35,6 +45,11 @@ export const RuleItem = ({ item, actions, onToggle, disabled, content, onClick }
setShown(!shown);
};

const handleRuleNameClick = (event) => {
event.stopPropagation();
onRuleNameClick(item);
};

return (
<div className={cx('container')} data-automation-id="listItem">
<span className={cx('toggle')}>
Expand All @@ -47,8 +62,14 @@ export const RuleItem = ({ item, actions, onToggle, disabled, content, onClick }
</span>
<div className={cx('panel-wrapper')}>
<div className={cx('panel')} onClick={onClickHandler}>
<span className={cx('name')} title={name}>
{name}
<span className={cx('name-wrapper')} title={name}>
{isRuleNameClickable ? (
<i className={cx('name')} onClick={handleRuleNameClick}>
{name}
</i>
) : (
<>{name}</>
)}
</span>
{actions.length > 0 && !disabled && (
<span className={cx('actions')}>
Expand Down Expand Up @@ -87,11 +108,13 @@ RuleItem.propTypes = {
disabled: PropTypes.bool,
content: PropTypes.node,
onClick: PropTypes.func,
onRuleNameClick: PropTypes.oneOfType(PropTypes.func, PropTypes.instanceOf(null)),
};
RuleItem.defaultProps = {
actions: [],
onToggle: () => {},
disabled: false,
content: null,
onClick: () => {},
onRuleNameClick: null,
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
cursor: pointer;
}

.name {
.name-wrapper {
flex: 1;
width: 0;
padding: 12px 0;
Expand All @@ -60,6 +60,14 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;

.name:hover {
color: $COLOR--topaz-hover;
}

.name:active {
color: $COLOR--topaz-pressed;
}
}

.actions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const RuleList = ({
ruleItemContent,
handleRuleItemClick,
dataAutomationId,
onRuleNameClick,
}) => {
const Content = ruleItemContent;
return (
Expand All @@ -43,6 +44,7 @@ export const RuleList = ({
disabled={disabled}
content={ruleItemContent && <Content item={item} />}
onClick={handleRuleItemClick}
onRuleNameClick={onRuleNameClick}
/>
))}
</div>
Expand All @@ -56,6 +58,7 @@ RuleList.propTypes = {
ruleItemContent: PropTypes.elementType,
handleRuleItemClick: PropTypes.func,
dataAutomationId: PropTypes.string,
onRuleNameClick: PropTypes.oneOfType(PropTypes.func, PropTypes.instanceOf(null)),
};
RuleList.defaultProps = {
actions: [],
Expand All @@ -64,4 +67,5 @@ RuleList.defaultProps = {
ruleItemContent: null,
handleRuleItemClick: () => {},
dataAutomationId: '',
onRuleNameClick: null,
};