Skip to content

Commit

Permalink
fix: refine skip audit warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Sep 10, 2024
1 parent ee181e1 commit 48db5cd
Showing 1 changed file with 46 additions and 16 deletions.
62 changes: 46 additions & 16 deletions src/components/view/submit-modal/submit-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,44 @@ import styles from './submit-modal.module.css'
import { SuccessContent } from './success-content.js'
import { useAggregateDataExchangeMutation } from './use-aggregate-data-exchange-mutation.js'

const SkipAuditWarning = ({ exchangeSkipAudit, internalExchange }) => {
const { hasSkipAuditInfoAuthority } = useUserContext()

if (!exchangeSkipAudit) {
return null
}

if (!internalExchange) {
return (
<div className={styles.skipAuditWarning}>
<NoticeBox warning>
{i18n.t(
'This exchange is configured to skip audit information on submit. If the authentication for the external server does not have the Skip data import audit authority, the data will be ignored on submit.'
)}
</NoticeBox>
</div>
)
}

if (!hasSkipAuditInfoAuthority) {
return (
<div className={styles.skipAuditWarning}>
<NoticeBox warning>
{i18n.t(
'This exchange is configured to skip audit information on submit, but you do not have the Skip data import audit authority. If you submit this exchange, the data will be ignored.'
)}
</NoticeBox>
</div>
)
}

return null
}
SkipAuditWarning.propTypes = {
exchangeSkipAudit: PropTypes.bool,
internalExchange: PropTypes.bool,
}

const LoadingStateModalContent = () => (
<>
<ModalContent>
Expand Down Expand Up @@ -147,13 +185,12 @@ const ConfirmModalContent = ({ exchange, requests, onClose, onSubmit }) => {
// this is very wordy, but did not have luck with i18nextscanner picking up from more compact versions...
let reportTranslationsString
const { systemInfo } = useConfig()
const { hasSkipAuditInfoAuthority } = useUserContext()
const reportCount = requests.length
const exchangeName = exchange?.displayName
const exchangeURL =
exchange?.target?.type === 'INTERNAL'
? systemInfo?.contextPath
: exchange?.target?.api?.url
const internalExchange = exchange?.target?.type === 'INTERNAL'
const exchangeURL = internalExchange
? systemInfo?.contextPath
: exchange?.target?.api?.url
const exchangeHostName = exchangeURL?.split('//')[1] ?? exchangeURL // remove protocol
const exchangeSkipAudit = Boolean(exchange?.target?.request?.skipAudit)

Expand Down Expand Up @@ -215,17 +252,10 @@ const ConfirmModalContent = ({ exchange, requests, onClose, onSubmit }) => {
})}
</ul>
</div>

{exchangeSkipAudit && !hasSkipAuditInfoAuthority && (
<div className={styles.skipAuditWarning}>
<NoticeBox warning>
{i18n.t(
'This exchange is configured to skip audit information on submit, but you do not have the Skip data import audit authority. If you submit this exchange, the data will be ignored.'
)}
</NoticeBox>
</div>
)}

<SkipAuditWarning
exchangeSkipAudit={exchangeSkipAudit}
internalExchange={internalExchange}
/>
<div>
{i18n.t('Are you sure you want to submit this data?')}
</div>
Expand Down

0 comments on commit 48db5cd

Please sign in to comment.