Skip to content

Commit

Permalink
feat: disable the form in modal and set them TODo
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengShi-1 committed Mar 4, 2025
1 parent f0bae04 commit 7bee8eb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import { ExclamationTriangle } from 'react-bootstrap-icons'
import { Button, Modal, Spinner, Stack, Col, Form } from '@iqss/dataverse-design-system'
// import { ExclamationCircleFill, ExclamationTriangle } from 'react-bootstrap-icons'
import styles from './ConfirmRestrictFileModal.module.scss'
import { FormEvent, useState } from 'react'
import { ExclamationTriangle } from 'react-bootstrap-icons'

interface ConfirmRestrictFileModalProps {
show: boolean
Expand All @@ -29,8 +27,8 @@ export const ConfirmRestrictFileModal = ({
}: ConfirmRestrictFileModalProps) => {
const { t: tShared } = useTranslation('shared')
const { t } = useTranslation('file')
const [requestAccess, setRequestAccess] = useState(true) // TODO need connect to API
const [terms, setTerms] = useState(termsOfAccessForRestrictedFiles) // TODO need connect to API
const requestAccess = true // TODO need connect to API
const terms = termsOfAccessForRestrictedFiles // TODO need connect to API

return (
<Modal show={show} onHide={isRestrictingFile ? () => {} : handleClose} centered size="lg">
Expand Down Expand Up @@ -62,9 +60,6 @@ export const ConfirmRestrictFileModal = ({
data-testid="enable-access-request-checkbox"
id={'requestAccessCB'}
checked={requestAccess}
onChange={(event: FormEvent<HTMLInputElement>) =>
setRequestAccess(event.currentTarget.checked)
}
/>
</Col>
</Form.Group>
Expand All @@ -76,9 +71,7 @@ export const ConfirmRestrictFileModal = ({
<Form.Group.TextArea
data-testid="terms-of-access-textarea"
defaultValue={terms}
onChange={(event: FormEvent<HTMLInputElement>) =>
setTerms(event.currentTarget.value)
}
disabled
/>
</Col>
</Form.Group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,29 +220,29 @@ describe('EditFileMenu', () => {
).should('exist')
})

it('should disable Save button if no terms of acccess and disenable access request', () => {
cy.customMount(
<EditFileMenu
fileId={testFile.id}
fileRepository={new FileMockRepository()}
isRestricted={false}
datasetInfo={{
persistentId: testFile.datasetPersistentId,
releasedVersionExists: false
}}
/>
)

cy.findByRole('button', { name: 'Edit File' }).click()
cy.findByRole('button', { name: 'Restrict' }).click()
cy.findByRole('dialog').should('exist')
cy.findByRole('checkbox').uncheck()
cy.findByRole('button', { name: 'Save Changes' }).should('be.disabled')

cy.findByRole('button', { name: /Cancel/i }).click()

cy.findByRole('dialog').should('not.exist')
})
// it('should disable Save button if no terms of acccess and disenable access request', () => {
// cy.customMount(
// <EditFileMenu
// fileId={testFile.id}
// fileRepository={new FileMockRepository()}
// isRestricted={false}
// datasetInfo={{
// persistentId: testFile.datasetPersistentId,
// releasedVersionExists: false
// }}
// />
// )

// cy.findByRole('button', { name: 'Edit File' }).click()
// cy.findByRole('button', { name: 'Restrict' }).click()
// cy.findByRole('dialog').should('exist')
// cy.findByRole('checkbox').uncheck()
// cy.findByRole('button', { name: 'Save Changes' }).should('be.disabled')

// cy.findByRole('button', { name: /Cancel/i }).click()

// cy.findByRole('dialog').should('not.exist')
// })

it('closes the modal and shows toast success message when restrict file succeeds', () => {
cy.customMount(
Expand Down

0 comments on commit 7bee8eb

Please sign in to comment.