Skip to content

Commit

Permalink
feat: add gradebook button in class page
Browse files Browse the repository at this point in the history
  • Loading branch information
AuraAlba committed Dec 6, 2024
1 parent a80b269 commit 1b5c40b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/features/Classes/ClassesTable/_test_/columns.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describe('columns', () => {
expect(getByText('View class content')).toBeInTheDocument();
expect(getByText('Manage Instructors')).toBeInTheDocument();
expect(getByText('Edit Class')).toBeInTheDocument();
expect(getByText('Gradebook')).toBeInTheDocument();
expect(getByText('Delete Class')).toBeInTheDocument();
});
});
9 changes: 9 additions & 0 deletions src/features/Classes/ClassesTable/columns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const columns = [
const deletionState = useSelector((state) => state.courses.newClass.status);
const [isOpenModal, openModal, closeModal] = useToggle(false);
const [deletionClassState, setDeletionState] = useState(initialDeletionClassState);
const gradebookUrl = getConfig().GRADEBOOK_MICROFRONTEND_URL || getConfig().LMS_BASE_URL;

const handleResetDeletion = () => {
setDeletionState(initialDeletionClassState);
Expand All @@ -129,6 +130,10 @@ const columns = [
setDeletionState({ isModalOpen: true, isRequestComplete: false });
};

const handleGradebookButton = () => {
window.open(`${gradebookUrl}/gradebook/${classId}`, '_blank', 'noopener,noreferrer');
};

const handleDeleteClass = async (rowClassId) => {
try {
await dispatch(deleteClass(rowClassId));
Expand Down Expand Up @@ -187,6 +192,10 @@ const columns = [
<i className="fa-solid fa-pencil mr-2 mb-1" />
Edit Class
</Dropdown.Item>
<Dropdown.Item onClick={handleGradebookButton}>
<i className="fa-regular fa-book mr-2 mb-1" />
Gradebook
</Dropdown.Item>
<Dropdown.Item onClick={handleOpenDeleteModal} className="text-danger">
<i className="fa-regular fa-trash mr-2 mb-1" />
Delete Class
Expand Down

0 comments on commit 1b5c40b

Please sign in to comment.