-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding cancel and remind actions to the budget assignment table
- Loading branch information
1 parent
5d2a736
commit 9d7fd32
Showing
5 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/components/learner-credit-management/AssignmentRowActionTableCell.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Icon, | ||
IconButton, | ||
OverlayTrigger, | ||
Stack, | ||
Tooltip, | ||
} from '@edx/paragon'; | ||
import { Mail, DoNotDisturbOn } from '@edx/paragon/icons'; | ||
|
||
const AssignmentRowActionTableCell = ({ row }) => { | ||
const cancelButtonMarginLeft = row.original.state === 'allocated' ? 'ml-2.5' : 'ml-auto'; | ||
return ( | ||
<div className="d-flex"> | ||
{row.original.state === 'allocated' && ( | ||
<> | ||
<OverlayTrigger | ||
key="Remind" | ||
placement="top" | ||
overlay={<Tooltip variant="light" id="tooltip-remind">Remind learner</Tooltip>} | ||
> | ||
<IconButton | ||
className="ml-auto mr-0" | ||
src={Mail} | ||
iconAs={Icon} | ||
// eslint-disable-next-line no-console | ||
onClick={() => console.log(`Reminding ${row.original.uuid}`)} | ||
data-testid={`remind-assignment-${row.original.uuid}`} | ||
/> | ||
</OverlayTrigger> | ||
<Stack direction="horizontal" gap={1} /> | ||
</> | ||
)} | ||
<OverlayTrigger | ||
key="Cancel" | ||
placement="top" | ||
overlay={<Tooltip variant="light" id="tooltip-cancel">Cancel assignment</Tooltip>} | ||
> | ||
<IconButton | ||
className={`${cancelButtonMarginLeft} mr-1 text-danger-500`} | ||
src={DoNotDisturbOn} | ||
iconAs={Icon} | ||
// eslint-disable-next-line no-console | ||
onClick={() => console.log(`Canceling ${row.original.uuid}`)} | ||
data-testid={`cancel-assignment-${row.original.uuid}`} | ||
/> | ||
</OverlayTrigger> | ||
</div> | ||
); | ||
}; | ||
|
||
AssignmentRowActionTableCell.propTypes = { | ||
row: PropTypes.shape({ | ||
original: PropTypes.shape({ | ||
uuid: PropTypes.string.isRequired, | ||
state: PropTypes.string.isRequired, | ||
}).isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default AssignmentRowActionTableCell; |
21 changes: 21 additions & 0 deletions
21
src/components/learner-credit-management/AssignmentTableCancel.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Button } from '@edx/paragon'; | ||
import { DoNotDisturbOn } from '@edx/paragon/icons'; | ||
|
||
const AssignmentTableCancelAction = ({ selectedFlatRows, ...rest }) => ( | ||
// eslint-disable-next-line no-console | ||
<Button variant="danger" iconBefore={DoNotDisturbOn} onClick={() => console.log('Cancel', selectedFlatRows, rest)}> | ||
{`Cancel (${selectedFlatRows.length})`} | ||
</Button> | ||
); | ||
|
||
AssignmentTableCancelAction.propTypes = { | ||
selectedFlatRows: PropTypes.arrayOf(PropTypes.shape()), | ||
}; | ||
|
||
AssignmentTableCancelAction.defaultProps = { | ||
selectedFlatRows: [], | ||
}; | ||
|
||
export default AssignmentTableCancelAction; |
29 changes: 29 additions & 0 deletions
29
src/components/learner-credit-management/AssignmentTableRemind.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Button } from '@edx/paragon'; | ||
import { Mail } from '@edx/paragon/icons'; | ||
|
||
const AssignmentTableRemindAction = ({ selectedFlatRows, ...rest }) => { | ||
const hideRemindAction = selectedFlatRows.some( | ||
row => row.original.state !== 'allocated', | ||
); | ||
if (hideRemindAction) { | ||
return null; | ||
} | ||
return ( | ||
// eslint-disable-next-line no-console | ||
<Button iconBefore={Mail} onClick={() => console.log('Remind', selectedFlatRows, rest)}> | ||
{`Remind (${selectedFlatRows.length})`} | ||
</Button> | ||
); | ||
}; | ||
|
||
AssignmentTableRemindAction.propTypes = { | ||
selectedFlatRows: PropTypes.arrayOf(PropTypes.shape()), | ||
}; | ||
|
||
AssignmentTableRemindAction.defaultProps = { | ||
selectedFlatRows: [], | ||
}; | ||
|
||
export default AssignmentTableRemindAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters