Skip to content

Commit

Permalink
Merge pull request #1490 from culturecreates/bugfix/issue-1488
Browse files Browse the repository at this point in the history
data-cy attributes added for concept table. closes #1488
  • Loading branch information
AbhishekPAnil authored Dec 5, 2024
2 parents 6a793d4 + ac95bde commit c865aaf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/components/DraggableTree/DraggableTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const DraggableTable = ({ data, setData, fallbackStatus, setFallbackStatus, tran
setData(filteredConceptData);
},
content: t('dashboard.taxonomy.addNew.concepts.deleteConceptMessage'),
okText: t('dashboard.settings.addUser.delete'),
okText: t('dashboard.taxonomy.addNew.concepts.delete'),
cancelText: t('dashboard.events.deleteEvent.cancel'),
});
};
Expand Down Expand Up @@ -79,6 +79,7 @@ const DraggableTable = ({ data, setData, fallbackStatus, setFallbackStatus, tran
dataIndex: contentLanguageKeyMap[language],
key: contentLanguageKeyMap[language],
editable: true,
['data-cy']: `taxonomy-concept-row-more-btn-${language}`,
}));

const moveRow = useCallback(
Expand Down Expand Up @@ -153,7 +154,7 @@ const DraggableTable = ({ data, setData, fallbackStatus, setFallbackStatus, tran

const menu = (record) => (
<Menu>
<Menu.Item key="delete" onClick={() => handleDelete(record?.key)}>
<Menu.Item key="delete" onClick={() => handleDelete(record?.key)} data-cy="taxonomy-concept-row-delete-btn">
{t('dashboard.taxonomy.addNew.concepts.delete')}
</Menu.Item>
</Menu>
Expand Down Expand Up @@ -186,7 +187,8 @@ const DraggableTable = ({ data, setData, fallbackStatus, setFallbackStatus, tran
justifyContent: 'center',
alignItems: 'center',
height: '100%',
}}>
}}
data-cy="taxonomy-concept-row-more-btn-wrapper">
<Dropdown overlay={menu(record)} trigger={['click']}>
<MoreOutlined style={{ cursor: 'pointer', fontSize: '18px' }} />
</Dropdown>
Expand Down Expand Up @@ -237,6 +239,12 @@ const DraggableTable = ({ data, setData, fallbackStatus, setFallbackStatus, tran
},
}}
rowClassName="editable-row"
onHeaderRow={() => {
return {
'data-cy': `taxonomy-concept-row-header`,
className: 'custom-header-row',
};
}}
onRow={(record, index) => {
const attr = {
index,
Expand Down
7 changes: 6 additions & 1 deletion src/components/DraggableTree/EditableCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ const EditableCell = ({ title, editable, children, dataIndex, record, handleSave
);
}

let dataCy = ``;
if (typeof value === 'string') {
dataCy = `taxonomy-concept-cell-${value.replace(/\s+/g, '')}-${recordKey}`;
}

return (
<td {...restProps}>
<td {...restProps} data-cy={dataCy}>
{editing ? (
<TextArea
ref={inputRef}
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en/translationEn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@
"placeHolder": "Enter {{language}} name",
"deleteConceptMessage": "Are you sure you want to permanently delete this concept? This action will also delete it everywhere it was used, including in events.",
"deleteConceptHeading": "Delete concept",
"delete": "delete"
"delete": "Delete"
}
}
}
Expand Down

0 comments on commit c865aaf

Please sign in to comment.