-
Notifications
You must be signed in to change notification settings - Fork 140
feat: updating help section and new slots created #530
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
brian-smith-tcril
merged 11 commits into
openedx:master
from
jacobo-dominguez-wgu:feat/update-footer-links-and-slots
May 30, 2025
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
62b99ef
feat: updating help links and refactoring component structure
jacobo-dominguez-wgu ab2f3c6
feat: creating plugins files for footer slots
jacobo-dominguez-wgu 584178a
feat: ading readmes for help slots
jacobo-dominguez-wgu 10f599e
Merge branch 'master' into feat/update-footer-links-and-slots
jacobo-dominguez-wgu cc57bf0
Merge branch 'master' into feat/update-footer-links-and-slots
jacobo-dominguez-wgu 6696fba
fix: fixing slot names and readmes contents
jacobo-dominguez-wgu 988de34
Merge branch 'feat/update-footer-links-and-slots' of https://github.c…
jacobo-dominguez-wgu 77b61d0
revert: returning to the four classic help buttons
jacobo-dominguez-wgu 6b086e9
Merge branch 'master' into feat/update-footer-links-and-slots
jacobo-dominguez-wgu e6c531a
chore: removing aliases for slots and passing param from parent to he…
jacobo-dominguez-wgu bd3370f
chore: remove container props from plugin props
jacobo-dominguez-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
32 changes: 32 additions & 0 deletions
32
src/components/studio-footer/help-components/HelpButton.jsx
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,32 @@ | ||
| import React from 'react'; | ||
| import { useIntl } from '@edx/frontend-platform/i18n'; | ||
| import { | ||
| Button, | ||
| } from '@openedx/paragon'; | ||
| import { ExpandLess, ExpandMore, Help } from '@openedx/paragon/icons'; | ||
| import PropTypes from 'prop-types'; | ||
| import messages from '../messages'; | ||
|
|
||
| const HelpButton = ({ isOpen, setIsOpen }) => { | ||
| const intl = useIntl(); | ||
| return ( | ||
| <Button | ||
| data-testid="helpToggleButton" | ||
| variant="outline-primary" | ||
| onClick={() => setIsOpen(!isOpen)} | ||
| iconBefore={Help} | ||
| iconAfter={isOpen ? ExpandLess : ExpandMore} | ||
| size="sm" | ||
| > | ||
| {isOpen ? intl.formatMessage(messages.closeHelpButtonLabel) | ||
| : intl.formatMessage(messages.openHelpButtonLabel)} | ||
| </Button> | ||
| ); | ||
| }; | ||
|
|
||
| HelpButton.propTypes = { | ||
| setIsOpen: PropTypes.func.isRequired, | ||
| isOpen: PropTypes.bool.isRequired, | ||
| }; | ||
|
|
||
| export default HelpButton; |
55 changes: 55 additions & 0 deletions
55
src/components/studio-footer/help-components/HelpButton.test.jsx
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,55 @@ | ||
| import React, { useMemo } from 'react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
| import { AppContext } from '@edx/frontend-platform/react'; | ||
| import HelpButton from './HelpButton'; | ||
| import '@testing-library/jest-dom'; | ||
|
|
||
| // eslint-disable-next-line react/prop-types | ||
| const ButtonWithContext = ({ locale = 'en', isOpen, setIsOpen }) => { | ||
| const contextValue = useMemo(() => ({ | ||
| authenticatedUser: null, | ||
| config: { }, | ||
| }), []); | ||
|
|
||
| return ( | ||
| <IntlProvider locale={locale}> | ||
| <AppContext.Provider | ||
| value={contextValue} | ||
| > | ||
| <HelpButton isOpen={isOpen} setIsOpen={setIsOpen} /> | ||
| </AppContext.Provider> | ||
| </IntlProvider> | ||
| ); | ||
| }; | ||
|
|
||
| describe('HelpButton', () => { | ||
| const mockSetIsOpen = jest.fn(); | ||
|
|
||
| beforeEach(() => { | ||
| mockSetIsOpen.mockClear(); | ||
| }); | ||
|
|
||
| it('renders with "open" label when isOpen is false', () => { | ||
| render(<ButtonWithContext isOpen={false} setIsOpen={mockSetIsOpen} />); | ||
| expect(screen.getByTestId('helpToggleButton')).toBeInTheDocument(); | ||
| expect(screen.getByRole('button')).toHaveTextContent(/help|open/i); | ||
| }); | ||
|
|
||
| it('renders with "close" label when isOpen is true', () => { | ||
| render(<ButtonWithContext isOpen setIsOpen={mockSetIsOpen} />); | ||
| expect(screen.getByTestId('helpToggleButton')).toBeInTheDocument(); | ||
| expect(screen.getByRole('button')).toHaveTextContent(/close|help/i); | ||
| }); | ||
|
|
||
| it('calls setIsOpen with the toggled value when clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| const { rerender } = render(<ButtonWithContext isOpen={false} setIsOpen={mockSetIsOpen} />); | ||
| await user.click(screen.getByTestId('helpToggleButton')); | ||
| expect(mockSetIsOpen).toHaveBeenCalledWith(true); | ||
| rerender(<ButtonWithContext isOpen setIsOpen={mockSetIsOpen} />); | ||
| await user.click(screen.getByTestId('helpToggleButton')); | ||
| expect(mockSetIsOpen).toHaveBeenCalledWith(false); | ||
| }); | ||
| }); |
62 changes: 62 additions & 0 deletions
62
src/components/studio-footer/help-components/HelpContent.jsx
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,62 @@ | ||
| import React, { useContext } from 'react'; | ||
| import { AppContext } from '@edx/frontend-platform/react'; | ||
| import isEmpty from 'lodash/isEmpty'; | ||
| import { ensureConfig } from '@edx/frontend-platform'; | ||
| import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
| import { | ||
| ActionRow, | ||
| Button, | ||
| } from '@openedx/paragon'; | ||
| import messages from '../messages'; | ||
|
|
||
| ensureConfig([ | ||
| 'SUPPORT_EMAIL', | ||
| ], 'Studio Footer Help Content component'); | ||
|
|
||
| const BUTTONS = [ | ||
| { | ||
| as: 'a', | ||
| href: 'https://docs.openedx.org/en/latest/educators/quickstarts/build_a_course.html', | ||
| size: 'sm', | ||
| message: messages.educatorsDocsButtonLabel, | ||
| dataTestid: null, | ||
| }, | ||
| { | ||
| as: 'a', | ||
| href: 'https://sandbox.openedx.org/courses/course-v1:OpenedX+01-2024+2024-1/about', | ||
| size: 'sm', | ||
| message: messages.openEdxDemoCourseButtonLabel, | ||
| dataTestid: 'openEdXDemoCourseButton', | ||
| }, | ||
| ]; | ||
|
|
||
| const HelpContent = () => { | ||
| const { config } = useContext(AppContext); | ||
| return ( | ||
| <ActionRow key="help-link-button-row" className="py-4" data-testid="helpButtonRow"> | ||
| <ActionRow.Spacer /> | ||
|
|
||
| {BUTTONS.map(({ | ||
| as, href, size, message, dataTestid, | ||
| }) => ( | ||
| <Button as={as} href={href} size={size} key={message.id} data-testid={dataTestid}> | ||
| <FormattedMessage {...message} /> | ||
| </Button> | ||
| ))} | ||
|
|
||
| {!isEmpty(config.SUPPORT_EMAIL) && ( | ||
| <Button | ||
| as="a" | ||
| href={`mailto:${config.SUPPORT_EMAIL}`} | ||
| size="sm" | ||
| data-testid="contactUsButton" | ||
| > | ||
| <FormattedMessage {...messages.contactUsButtonLabel} /> | ||
| </Button> | ||
| )} | ||
| <ActionRow.Spacer /> | ||
| </ActionRow> | ||
| ); | ||
| }; | ||
|
|
||
| export default HelpContent; |
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.