Skip to content

Commit

Permalink
Merge pull request #1515 from dhis2/add-test-id-to-sharing-dialog
Browse files Browse the repository at this point in the history
feat: add data test prop to sharing dialog
  • Loading branch information
flaminic authored Jun 6, 2024
2 parents 2dc0405 + 5a1d81d commit 1ae38d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 7 additions & 2 deletions components/sharing-dialog/src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import i18n from '../locales/index.js'

export const Modal = ({ onClose, name, children }) => {
export const Modal = ({ onClose, name, children, dataTest }) => {
const title = name
? i18n.t('Sharing and access: {{- objectName}}', {
objectName: name,
Expand All @@ -18,7 +18,7 @@ export const Modal = ({ onClose, name, children }) => {
: i18n.t('Sharing and access')

return (
<Dhis2Modal large position="top" onClose={onClose}>
<Dhis2Modal large position="top" onClose={onClose} dataTest={dataTest}>
<ModalTitle>{title}</ModalTitle>
<ModalContent>{children}</ModalContent>
<ModalActions>
Expand All @@ -32,8 +32,13 @@ export const Modal = ({ onClose, name, children }) => {
)
}

Modal.defaultProps = {
dataTest: 'dhis2-uicore-sharingdialog-modal',
}

Modal.propTypes = {
children: PropTypes.node.isRequired,
dataTest: PropTypes.string,
name: PropTypes.string,
onClose: PropTypes.func,
}
10 changes: 8 additions & 2 deletions components/sharing-dialog/src/sharing-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const SharingDialog = ({
onError,
onSave,
initialSharingSettings,
dataTest,
}) => {
const { show: showError } = useAlert((error) => error, { critical: true })

Expand Down Expand Up @@ -159,7 +160,11 @@ export const SharingDialog = ({

return (
<FetchingContext.Provider value={mutating || fetching}>
<Modal onClose={onClose} name={object.displayName || object.name}>
<Modal
onClose={onClose}
name={object.displayName || object.name}
dataTest={dataTest}
>
<TabbedContent
id={id}
users={users}
Expand Down Expand Up @@ -187,6 +192,7 @@ SharingDialog.defaultProps = {
onClose: () => {},
onError: () => {},
onSave: () => {},
dataTest: 'dhis2-uicore-sharingdialog',
}

SharingDialog.propTypes = {
Expand All @@ -199,7 +205,7 @@ SharingDialog.propTypes = {
EVENT_VISUALIZATION,
INTERPRETATION,
]).isRequired,
/** Used to seed the component with data to show whilst loading */
dataTest: PropTypes.string,
initialSharingSettings: PropTypes.shape({
allowPublic: PropTypes.bool.isRequired,
groups: PropTypes.objectOf(
Expand Down

0 comments on commit 1ae38d9

Please sign in to comment.