-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from openedx/knguyen2/ent-7980
feat: add alert and help text
- Loading branch information
Showing
23 changed files
with
185 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
src/Configuration/Provisioning/ProvisioningForm/ProvisioningFormHelpText.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,26 @@ | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Icon, Form, | ||
} from '@edx/paragon'; | ||
import { WarningFilled } from '@edx/paragon/icons'; | ||
import PROVISIONING_PAGE_TEXT from '../data/constants'; | ||
|
||
const ProvisioningFormHelpText = ({ className }) => { | ||
const { HELP_TEXT } = PROVISIONING_PAGE_TEXT.FORM; | ||
|
||
return ( | ||
<Form.Control.Feedback className={className} icon={<Icon src={WarningFilled} />}> | ||
{HELP_TEXT.LABEL} | ||
</Form.Control.Feedback> | ||
); | ||
}; | ||
|
||
ProvisioningFormHelpText.propTypes = { | ||
className: PropTypes.string, | ||
}; | ||
|
||
ProvisioningFormHelpText.defaultProps = { | ||
className: null, | ||
}; | ||
|
||
export default ProvisioningFormHelpText; |
42 changes: 42 additions & 0 deletions
42
src/Configuration/Provisioning/ProvisioningForm/ProvisioningFormInstructionAlert.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,42 @@ | ||
import PropTypes from 'prop-types'; | ||
import { Alert, useToggle } from '@edx/paragon'; | ||
import { Edit } from '@edx/paragon/icons'; | ||
import PROVISIONING_PAGE_TEXT from '../data/constants'; | ||
|
||
const ProvisioningFormInstructionAlert = ({ formMode }) => { | ||
const { ALERTS: { NEW_FORM, EDIT_FORM, VIEW_FORM }, MODE } = PROVISIONING_PAGE_TEXT.FORM; | ||
const [isOpen, , close] = useToggle(true); | ||
|
||
let alertContent; | ||
if (formMode === MODE.NEW) { | ||
alertContent = NEW_FORM; | ||
} else if (formMode === MODE.EDIT) { | ||
alertContent = EDIT_FORM; | ||
} else { | ||
alertContent = VIEW_FORM; | ||
} | ||
|
||
return ( | ||
<article> | ||
<Alert | ||
variant="info" | ||
icon={Edit} | ||
dismissible | ||
show={isOpen} | ||
closeLabel="Dismiss" | ||
onClose={close} | ||
> | ||
<Alert.Heading>{alertContent.TITLE}</Alert.Heading> | ||
<p> | ||
{alertContent.DESCRIPTION} | ||
</p> | ||
</Alert> | ||
</article> | ||
); | ||
}; | ||
|
||
ProvisioningFormInstructionAlert.propTypes = { | ||
formMode: PropTypes.oneOf(['new', 'edit', 'view']).isRequired, | ||
}; | ||
|
||
export default ProvisioningFormInstructionAlert; |
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
10 changes: 10 additions & 0 deletions
10
src/Configuration/Provisioning/ProvisioningForm/tests/ProvisioningFormHelpText.test.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,10 @@ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { screen, render } from '@testing-library/react'; | ||
import ProvisioningFormHelpText from '../ProvisioningFormHelpText'; | ||
|
||
describe('ProvisioningFormInstructionAlert', () => { | ||
test('should render help text', () => { | ||
render(<ProvisioningFormHelpText />); | ||
expect(screen.getByText('Not editable')).toBeInTheDocument(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
...nfiguration/Provisioning/ProvisioningForm/tests/ProvisioningFormInstructionAlert.test.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,18 @@ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { screen, render } from '@testing-library/react'; | ||
import PROVISIONING_PAGE_TEXT from '../../data/constants'; | ||
import ProvisioningFormInstructionAlert from '../ProvisioningFormInstructionAlert'; | ||
|
||
const { ALERTS } = PROVISIONING_PAGE_TEXT.FORM; | ||
|
||
describe('ProvisioningFormInstructionAlert', () => { | ||
test.each([ | ||
['new', ALERTS.NEW_FORM], | ||
['view', ALERTS.VIEW_FORM], | ||
['edit', ALERTS.EDIT_FORM], | ||
])('should render the correct content for %s mode', (mode, content) => { | ||
render(<ProvisioningFormInstructionAlert formMode={mode} />); | ||
expect(screen.getByText(content.TITLE)).toBeInTheDocument(); | ||
expect(screen.getByText(content.DESCRIPTION)).toBeInTheDocument(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.