generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 6
Date extensions Action buttons #63
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
Merged
diana-villalvazo-wgu
merged 8 commits into
openedx:main
from
WGU-Open-edX:58/action-buttons
Feb 6, 2026
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
613b7a5
feat: reset extensions modal
diana-villalvazo-wgu 3316195
feat: success message toast
diana-villalvazo-wgu 6791d39
test: edit unit tests
diana-villalvazo-wgu 73dce3d
chore: improving querykeys
diana-villalvazo-wgu bf6b5e9
refactor: update endpoint
diana-villalvazo-wgu d5b0cbd
fix: format date
diana-villalvazo-wgu 0aaed3b
feat: adding alerts and toasts
diana-villalvazo-wgu 623fbe4
fix: mutation courseId onSuccess, validation
diana-villalvazo-wgu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
45 changes: 45 additions & 0 deletions
45
src/dateExtensions/components/ResetExtensionsModal.test.tsx
This file contains hidden or 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,45 @@ | ||
| import { screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import ResetExtensionsModal from './ResetExtensionsModal'; | ||
| import { renderWithIntl } from '../../testUtils'; | ||
| import messages from '../messages'; | ||
|
|
||
| describe('ResetExtensionsModal', () => { | ||
| const defaultProps = { | ||
| isOpen: true, | ||
| message: 'Test message', | ||
| title: 'Test title', | ||
| onCancelReset: jest.fn(), | ||
| onClose: jest.fn(), | ||
| onConfirmReset: jest.fn(), | ||
| }; | ||
|
|
||
| const renderModal = (props = {}) => renderWithIntl( | ||
| <ResetExtensionsModal {...defaultProps} {...props} /> | ||
| ); | ||
|
|
||
| it('renders modal with correct title and message', () => { | ||
| renderModal(); | ||
| expect(screen.getByText('Test title')).toBeInTheDocument(); | ||
| expect(screen.getByText('Test message')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('calls onCancelReset when cancel button is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| renderModal(); | ||
| await user.click(screen.getByRole('button', { name: messages.cancel.defaultMessage })); | ||
| expect(defaultProps.onCancelReset).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('calls onConfirmReset when confirm button is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| renderModal(); | ||
| await user.click(screen.getByRole('button', { name: messages.confirm.defaultMessage })); | ||
| expect(defaultProps.onConfirmReset).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('does not render when isOpen is false', () => { | ||
| renderModal({ isOpen: false }); | ||
| expect(screen.queryByText('Test title')).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
This file contains hidden or 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,35 @@ | ||
| import { useIntl } from '@openedx/frontend-base'; | ||
| import { ModalDialog, ActionRow, Button } from '@openedx/paragon'; | ||
| import messages from '../messages'; | ||
|
|
||
| interface ResetExtensionsModalProps { | ||
| isOpen: boolean, | ||
| message: string, | ||
| title: string, | ||
| onCancelReset: () => void, | ||
| onClose: () => void, | ||
| onConfirmReset: () => void, | ||
| } | ||
|
|
||
| const ResetExtensionsModal = ({ | ||
| isOpen, | ||
| message, | ||
| title, | ||
| onCancelReset, | ||
| onClose, | ||
| onConfirmReset, | ||
| }: ResetExtensionsModalProps) => { | ||
| const intl = useIntl(); | ||
| return ( | ||
| <ModalDialog isOpen={isOpen} onClose={onClose} hasCloseButton={false} title={title} isOverflowVisible={false} className="p-4"> | ||
| <h4 className="mb-2.5">{title}</h4> | ||
| <p className="mb-2.5">{message}</p> | ||
| <ActionRow> | ||
| <Button variant="tertiary" onClick={onCancelReset}>{intl.formatMessage(messages.cancel)}</Button> | ||
| <Button variant="primary" onClick={onConfirmReset}>{intl.formatMessage(messages.confirm)}</Button> | ||
| </ActionRow> | ||
| </ModalDialog> | ||
| ); | ||
| }; | ||
|
|
||
| export default ResetExtensionsModal; |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,10 +1,22 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { getDateExtensions, PaginationQueryKeys } from './api'; | ||
| import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | ||
| import { getDateExtensions, PaginationQueryKeys, resetDateExtension } from './api'; | ||
| import { dateExtensionsQueryKeys } from './queryKeys'; | ||
| import { ResetDueDateParams } from '../types'; | ||
|
|
||
| export const useDateExtensions = (courseId: string, pagination: PaginationQueryKeys) => ( | ||
| useQuery({ | ||
| queryKey: dateExtensionsQueryKeys.byCoursePaginated(courseId, pagination), | ||
| queryFn: () => getDateExtensions(courseId, pagination), | ||
| }) | ||
| ); | ||
|
|
||
| export const useResetDateExtensionMutation = () => { | ||
| const queryClient = useQueryClient(); | ||
| return useMutation({ | ||
| mutationFn: ({ courseId, params }: { courseId: string, params: ResetDueDateParams }) => | ||
| resetDateExtension(courseId, params), | ||
| onSuccess: ({ courseId }) => { | ||
diana-villalvazo-wgu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| queryClient.invalidateQueries({ queryKey: dateExtensionsQueryKeys.byCourse(courseId), exact: false }); | ||
| }, | ||
| }); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.