This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
refactor: migrate off paragon modal deprecated component #76
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ | |
Component for displaying and modifying a user's access level for a library. | ||
*/ | ||
import { | ||
ActionRow, | ||
Badge, | ||
Button, Card, Col, Modal, Row, | ||
Button, Card, Col, ModalDialog, Row, | ||
} from '@edx/paragon'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faTrash } from '@fortawesome/free-solid-svg-icons'; | ||
|
@@ -40,99 +41,121 @@ export const UserAccessWidget = ({ | |
</span> | ||
</Col> | ||
{isAdmin && ( | ||
<Col xs={12} md={6}> | ||
<Row> | ||
{(user.access_level === LIBRARY_ACCESS.ADMIN) && adminLocked && ( | ||
<Col xs={12} className="text-center text-md-right"> | ||
<small>{intl.formatMessage(messages['library.access.info.admin_unlock'])}</small> | ||
</Col> | ||
)} | ||
{user.access_level === LIBRARY_ACCESS.ADMIN && multipleAdmins && ( | ||
<Col xs={10} className="text-left text-md-right"> | ||
<Button size="lg" variant="secondary" onClick={() => setShowDeprivModal(true)}> | ||
{intl.formatMessage(messages['library.access.remove_admin'])} | ||
</Button> | ||
<Modal | ||
open={showDeprivModal} | ||
title={intl.formatMessage(messages['library.access.modal.remove_admin.title'])} | ||
onClose={() => setShowDeprivModal(false)} | ||
body={( | ||
<div> | ||
<p> | ||
{intl.formatMessage( | ||
messages['library.access.modal.remove_admin.body'], | ||
{ library: library.title, email: user.email }, | ||
)} | ||
</p> | ||
</div> | ||
)} | ||
buttons={[ | ||
<Button | ||
onClick={() => setAccessLevel(LIBRARY_ACCESS.AUTHOR).then(setShowDeprivModal(false))} | ||
<Col xs={12} md={6}> | ||
<Row> | ||
{(user.access_level === LIBRARY_ACCESS.ADMIN) && adminLocked && ( | ||
<Col xs={12} className="text-center text-md-right"> | ||
<small>{intl.formatMessage(messages['library.access.info.admin_unlock'])}</small> | ||
</Col> | ||
)} | ||
{user.access_level === LIBRARY_ACCESS.ADMIN && multipleAdmins && ( | ||
<Col xs={10} className="text-left text-md-right"> | ||
<Button size="lg" variant="secondary" onClick={() => setShowDeprivModal(true)}> | ||
{intl.formatMessage(messages['library.access.remove_admin'])} | ||
</Button> | ||
<ModalDialog | ||
isOpen={showDeprivModal} | ||
onClose={() => setShowDeprivModal(false)} | ||
> | ||
{intl.formatMessage(commonMessages['library.common.forms.button.yes'])} | ||
</Button>, | ||
]} | ||
/> | ||
</Col> | ||
)} | ||
{user.access_level === LIBRARY_ACCESS.READ && ( | ||
<Col xs={10} className="text-left text-md-right"> | ||
<Button size="lg" variant="primary" onClick={() => setAccessLevel(LIBRARY_ACCESS.AUTHOR)}> | ||
{intl.formatMessage(messages['library.access.add_author'])} | ||
</Button> | ||
</Col> | ||
)} | ||
{user.access_level === LIBRARY_ACCESS.AUTHOR && ( | ||
<> | ||
<Col xs={5} className="text-left text-md-right pl-md-1"> | ||
<Button size="lg" variant="secondary" onClick={() => setAccessLevel(LIBRARY_ACCESS.READ)}> | ||
{intl.formatMessage(messages['library.access.remove_author'])} | ||
|
||
<ModalDialog.Header> | ||
<ModalDialog.Title> | ||
{intl.formatMessage(messages['library.access.modal.remove_admin.title'])} | ||
</ModalDialog.Title> | ||
</ModalDialog.Header> | ||
<ModalDialog.Body> | ||
<div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as previous comment about probably not needing this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved |
||
<p> | ||
{intl.formatMessage( | ||
messages['library.access.modal.remove_admin.body'], | ||
{ library: library.title, email: user.email }, | ||
)} | ||
</p> | ||
</div> | ||
</ModalDialog.Body> | ||
<ModalDialog.Footer> | ||
<ActionRow> | ||
<ModalDialog.CloseButton variant="link"> | ||
Close | ||
</ModalDialog.CloseButton> | ||
<Button | ||
onClick={() => setAccessLevel(LIBRARY_ACCESS.AUTHOR).then(setShowDeprivModal(false))} | ||
> | ||
{intl.formatMessage(commonMessages['library.common.forms.button.yes'])} | ||
</Button>, | ||
</ActionRow> | ||
</ModalDialog.Footer> | ||
</ModalDialog> | ||
</Col> | ||
)} | ||
{user.access_level === LIBRARY_ACCESS.READ && ( | ||
<Col xs={10} className="text-left text-md-right"> | ||
<Button size="lg" variant="primary" onClick={() => setAccessLevel(LIBRARY_ACCESS.AUTHOR)}> | ||
{intl.formatMessage(messages['library.access.add_author'])} | ||
</Button> | ||
</Col> | ||
<Col xs={5} className="text-left text-md-right pl-md-1"> | ||
<Button size="lg" variant="primary" onClick={() => setAccessLevel(LIBRARY_ACCESS.ADMIN)}> | ||
{intl.formatMessage(messages['library.access.add_admin'])} | ||
)} | ||
{user.access_level === LIBRARY_ACCESS.AUTHOR && ( | ||
<> | ||
<Col xs={5} className="text-left text-md-right pl-md-1"> | ||
<Button size="lg" variant="secondary" onClick={() => setAccessLevel(LIBRARY_ACCESS.READ)}> | ||
{intl.formatMessage(messages['library.access.remove_author'])} | ||
</Button> | ||
</Col> | ||
<Col xs={5} className="text-left text-md-right pl-md-1"> | ||
<Button size="lg" variant="primary" onClick={() => setAccessLevel(LIBRARY_ACCESS.ADMIN)}> | ||
{intl.formatMessage(messages['library.access.add_admin'])} | ||
</Button> | ||
</Col> | ||
</> | ||
)} | ||
{(!((user.access_level === LIBRARY_ACCESS.ADMIN) && adminLocked)) && ( | ||
<Col xs={2} className="text-right text-md-center"> | ||
<Button | ||
size="lg" | ||
variant="danger" | ||
onClick={() => setShowRemoveModal(true)} | ||
aria-label={ | ||
intl.formatMessage(messages['library.access.remove_user']) | ||
} | ||
> | ||
<FontAwesomeIcon icon={faTrash} /> | ||
</Button> | ||
<ModalDialog | ||
isOpen={showRemoveModal} | ||
onClose={() => setShowRemoveModal(false)} | ||
> | ||
|
||
<ModalDialog.Header> | ||
<ModalDialog.Title> | ||
{intl.formatMessage(messages['library.access.modal.remove.title'])} | ||
</ModalDialog.Title> | ||
</ModalDialog.Header> | ||
<ModalDialog.Body> | ||
<div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved |
||
<p> | ||
{intl.formatMessage( | ||
messages['library.access.modal.remove.body'], | ||
{ library: library.title, email: user.email }, | ||
)} | ||
</p> | ||
</div> | ||
</ModalDialog.Body> | ||
<ModalDialog.Footer> | ||
<ActionRow> | ||
<ModalDialog.CloseButton variant="link"> | ||
Close | ||
</ModalDialog.CloseButton> | ||
<Button onClick={() => removeAccess()}> | ||
{intl.formatMessage(commonMessages['library.common.forms.button.yes'])} | ||
</Button>, | ||
</ActionRow> | ||
</ModalDialog.Footer> | ||
</ModalDialog> | ||
</Col> | ||
</> | ||
)} | ||
{(!((user.access_level === LIBRARY_ACCESS.ADMIN) && adminLocked)) && ( | ||
<Col xs={2} className="text-right text-md-center"> | ||
<Button | ||
size="lg" | ||
variant="danger" | ||
onClick={() => setShowRemoveModal(true)} | ||
aria-label={ | ||
intl.formatMessage(messages['library.access.remove_user']) | ||
} | ||
> | ||
<FontAwesomeIcon icon={faTrash} /> | ||
</Button> | ||
<Modal | ||
open={showRemoveModal} | ||
title={intl.formatMessage(messages['library.access.modal.remove.title'])} | ||
onClose={() => setShowRemoveModal(false)} | ||
body={( | ||
<div> | ||
<p> | ||
{intl.formatMessage( | ||
messages['library.access.modal.remove.body'], | ||
{ library: library.title, email: user.email }, | ||
)} | ||
</p> | ||
</div> | ||
)} | ||
buttons={[ | ||
<Button onClick={() => removeAccess()}> | ||
{intl.formatMessage(commonMessages['library.common.forms.button.yes'])} | ||
</Button>, | ||
]} | ||
/> | ||
</Col> | ||
)} | ||
</Row> | ||
</Col> | ||
)} | ||
</Row> | ||
</Col> | ||
)} | ||
</Row> | ||
</Card.Body> | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the
<div>
and the<p>
here? my assumption would be that the<div>
was needed before because the body wasn't a component, but now that we have<ModalDialog.Body>
it might be redundant.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved