Skip to content

Commit

Permalink
CARDS-2618: Replace Livetable with MaterialReactTable in administrati…
Browse files Browse the repository at this point in the history
…on screens

Addressed codereview comments: refactoring EditButton code
  • Loading branch information
veronikaslc committed Jan 8, 2025
1 parent c1ac1b8 commit f7efce5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@ import QuestionnaireStyle from "../questionnaire/QuestionnaireStyle.jsx";
* A component that renders an icon to open the edit URL for an entry or to use local edit dialog.
*/
function EditButton(props) {
const { entryPath, entryType, size, className, admin, onClick, useEditDialog } = props;
const { entryPath, entryType, size, className, admin, onClick } = props;

let innerButton = <Tooltip title={entryType ? "Edit " + entryType : "Edit"}>
let innerButton =
<IconButton className={className} size={size} onClick={onClick}>
<EditIcon />
</IconButton>
</Tooltip>

return useEditDialog ? innerButton : (
<Link to={(admin ? "/content.html/admin" : "/content.html") + entryPath + ".edit"} underline="hover">
{innerButton}
</Link>
return (
<Tooltip title={entryType ? "Edit " + entryType.toLowerCase() : "Edit"}>
{ onClick
?
innerButton
:
<Link to={(admin ? "/content.html/admin" : "/content.html") + entryPath + ".edit"} underline="hover">
{innerButton}
</Link>
}
</Tooltip>
)
}

Expand All @@ -52,7 +58,7 @@ EditButton.propTypes = {
size: PropTypes.oneOf(["small", "medium", "large"]),
className: PropTypes.string,
admin: PropTypes.bool,
useEditDialog: PropTypes.bool,
onClick: PropTypes.func
}

EditButton.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function SubjectTypes(props) {
<EditButton
entryType={entryType}
onClick={() => {setIsEdit(true); setCurrentSubjectType(row.original); setDialogOpen(true);}}
useEditDialog
/>
<DeleteButton
entryPath={row.original["@path"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ function AdminStatistics(props) {
<EditButton
entryType={entryType}
onClick={() => {setDialogOpen(true); setNewStat(false); setCurrentId(row.original["@name"]);}}
useEditDialog
/>
<DeleteButton
entryPath={row.original["@path"]}
Expand Down

0 comments on commit f7efce5

Please sign in to comment.