feat: handling of opening a SIGIT without retrievable files
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 39s
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 39s
This commit is contained in:
parent
41ce2f4aff
commit
1fd2e27df7
@ -20,10 +20,13 @@ import {
|
|||||||
faFileDownload,
|
faFileDownload,
|
||||||
faPen
|
faPen
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { Typography } from '@mui/material'
|
||||||
|
import styles from '../UsersDetails.tsx/style.module.scss'
|
||||||
|
|
||||||
interface PdfMarkingProps {
|
interface PdfMarkingProps {
|
||||||
currentUserMarks: CurrentUserMark[]
|
currentUserMarks: CurrentUserMark[]
|
||||||
files: CurrentUserFile[]
|
files: CurrentUserFile[]
|
||||||
|
noFiles?: boolean
|
||||||
handleExport: () => void
|
handleExport: () => void
|
||||||
handleEncryptedExport: () => void
|
handleEncryptedExport: () => void
|
||||||
handleSign: () => void
|
handleSign: () => void
|
||||||
@ -42,6 +45,7 @@ interface PdfMarkingProps {
|
|||||||
const PdfMarking = (props: PdfMarkingProps) => {
|
const PdfMarking = (props: PdfMarkingProps) => {
|
||||||
const {
|
const {
|
||||||
files,
|
files,
|
||||||
|
noFiles,
|
||||||
currentUserMarks,
|
currentUserMarks,
|
||||||
setCurrentUserMarks,
|
setCurrentUserMarks,
|
||||||
setUpdatedMarks,
|
setUpdatedMarks,
|
||||||
@ -131,6 +135,18 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
|||||||
setSelectedMarkValue(value)
|
setSelectedMarkValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderRightColumn = () => {
|
||||||
|
if (meta !== null) return <UsersDetails meta={meta} />
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.container}>
|
||||||
|
<div className={styles.section}>
|
||||||
|
<Typography>No meta found</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Container className={signPageStyles.container}>
|
<Container className={signPageStyles.container}>
|
||||||
@ -148,7 +164,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
right={meta !== null && <UsersDetails meta={meta} />}
|
right={renderRightColumn()}
|
||||||
leftIcon={faFileDownload}
|
leftIcon={faFileDownload}
|
||||||
centerIcon={faPen}
|
centerIcon={faPen}
|
||||||
rightIcon={faCircleInfo}
|
rightIcon={faCircleInfo}
|
||||||
@ -156,13 +172,23 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
|||||||
<PdfView
|
<PdfView
|
||||||
currentFile={currentFile}
|
currentFile={currentFile}
|
||||||
files={files}
|
files={files}
|
||||||
|
noFiles={noFiles}
|
||||||
handleMarkClick={handleMarkClick}
|
handleMarkClick={handleMarkClick}
|
||||||
selectedMarkValue={selectedMarkValue}
|
selectedMarkValue={selectedMarkValue}
|
||||||
selectedMark={selectedMark}
|
selectedMark={selectedMark}
|
||||||
currentUserMarks={currentUserMarks}
|
currentUserMarks={currentUserMarks}
|
||||||
otherUserMarks={otherUserMarks}
|
otherUserMarks={otherUserMarks}
|
||||||
/>
|
/>
|
||||||
|
{noFiles ? (
|
||||||
|
<Typography textAlign="center">
|
||||||
|
We were not able to retrieve the files.
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
</StickySideColumns>
|
</StickySideColumns>
|
||||||
|
|
||||||
|
{!noFiles && (
|
||||||
<MarkFormField
|
<MarkFormField
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
handleSelectedMarkValueChange={handleChange}
|
handleSelectedMarkValueChange={handleChange}
|
||||||
@ -171,6 +197,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
|||||||
currentUserMarks={currentUserMarks}
|
currentUserMarks={currentUserMarks}
|
||||||
handleCurrentUserMarkChange={handleCurrentUserMarkChange}
|
handleCurrentUserMarkChange={handleCurrentUserMarkChange}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -10,6 +10,7 @@ interface PdfViewProps {
|
|||||||
currentFile: CurrentUserFile | null
|
currentFile: CurrentUserFile | null
|
||||||
currentUserMarks: CurrentUserMark[]
|
currentUserMarks: CurrentUserMark[]
|
||||||
files: CurrentUserFile[]
|
files: CurrentUserFile[]
|
||||||
|
noFiles?: boolean
|
||||||
handleMarkClick: (id: number) => void
|
handleMarkClick: (id: number) => void
|
||||||
otherUserMarks: Mark[]
|
otherUserMarks: Mark[]
|
||||||
selectedMark: CurrentUserMark | null
|
selectedMark: CurrentUserMark | null
|
||||||
@ -21,6 +22,7 @@ interface PdfViewProps {
|
|||||||
*/
|
*/
|
||||||
const PdfView = ({
|
const PdfView = ({
|
||||||
files,
|
files,
|
||||||
|
noFiles,
|
||||||
currentUserMarks,
|
currentUserMarks,
|
||||||
handleMarkClick,
|
handleMarkClick,
|
||||||
selectedMarkValue,
|
selectedMarkValue,
|
||||||
@ -76,6 +78,8 @@ const PdfView = ({
|
|||||||
<FileDivider key={`separator-${i}`} />,
|
<FileDivider key={`separator-${i}`} />,
|
||||||
curr
|
curr
|
||||||
])
|
])
|
||||||
|
) : noFiles ? (
|
||||||
|
''
|
||||||
) : (
|
) : (
|
||||||
<LoadingSpinner variant="small" />
|
<LoadingSpinner variant="small" />
|
||||||
)}
|
)}
|
||||||
|
@ -292,7 +292,8 @@ export const UsersDetails = ({ meta }: UsersDetailsProps) => {
|
|||||||
<div className={styles.section}>
|
<div className={styles.section}>
|
||||||
<p>File Servers</p>
|
<p>File Servers</p>
|
||||||
|
|
||||||
{zipUrls.map((url) => (
|
{zipUrls &&
|
||||||
|
zipUrls.map((url) => (
|
||||||
<span className={styles.detailsItem} key={url}>
|
<span className={styles.detailsItem} key={url}>
|
||||||
<FontAwesomeIcon icon={faServer} /> {getBaseUrl(url)}
|
<FontAwesomeIcon icon={faServer} /> {getBaseUrl(url)}
|
||||||
</span>
|
</span>
|
||||||
|
@ -89,6 +89,7 @@ export const SignPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [files, setFiles] = useState<{ [filename: string]: SigitFile }>({})
|
const [files, setFiles] = useState<{ [filename: string]: SigitFile }>({})
|
||||||
|
const [noFiles, setNoFiles] = useState(false)
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('')
|
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('')
|
||||||
@ -290,6 +291,13 @@ export const SignPage = () => {
|
|||||||
|
|
||||||
const { zipUrls, encryptionKey } = res
|
const { zipUrls, encryptionKey } = res
|
||||||
|
|
||||||
|
if (!zipUrls || zipUrls.length === 0) {
|
||||||
|
toast.warning('No zip files found in the zipUrls')
|
||||||
|
setIsLoading(false)
|
||||||
|
setNoFiles(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < zipUrls.length; i++) {
|
for (let i = 0; i < zipUrls.length; i++) {
|
||||||
const zipUrl = zipUrls[i]
|
const zipUrl = zipUrls[i]
|
||||||
const isLastZipUrl = i === zipUrls.length - 1
|
const isLastZipUrl = i === zipUrls.length - 1
|
||||||
@ -875,6 +883,7 @@ export const SignPage = () => {
|
|||||||
handleEncryptedExport={handleEncryptedExport}
|
handleEncryptedExport={handleEncryptedExport}
|
||||||
otherUserMarks={otherUserMarks}
|
otherUserMarks={otherUserMarks}
|
||||||
meta={meta}
|
meta={meta}
|
||||||
|
noFiles={noFiles}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ import { MarkRender } from '../../components/MarkTypeStrategy/MarkRender.tsx'
|
|||||||
|
|
||||||
interface PdfViewProps {
|
interface PdfViewProps {
|
||||||
files: CurrentUserFile[]
|
files: CurrentUserFile[]
|
||||||
|
noFiles?: boolean
|
||||||
currentFile: CurrentUserFile | null
|
currentFile: CurrentUserFile | null
|
||||||
parsedSignatureEvents: {
|
parsedSignatureEvents: {
|
||||||
[signer: `npub1${string}`]: DocSignatureEvent
|
[signer: `npub1${string}`]: DocSignatureEvent
|
||||||
@ -73,6 +74,7 @@ interface PdfViewProps {
|
|||||||
|
|
||||||
const SlimPdfView = ({
|
const SlimPdfView = ({
|
||||||
files,
|
files,
|
||||||
|
noFiles,
|
||||||
currentFile,
|
currentFile,
|
||||||
parsedSignatureEvents
|
parsedSignatureEvents
|
||||||
}: PdfViewProps) => {
|
}: PdfViewProps) => {
|
||||||
@ -162,6 +164,8 @@ const SlimPdfView = ({
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
) : noFiles ? (
|
||||||
|
''
|
||||||
) : (
|
) : (
|
||||||
<LoadingSpinner variant="small" />
|
<LoadingSpinner variant="small" />
|
||||||
)}
|
)}
|
||||||
@ -404,9 +408,15 @@ export const VerifyPage = () => {
|
|||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
|
|
||||||
// We have multiple zipUrls, we should fetch one by one and take the first one which successfully decrypts
|
// We have multiple zipUrls, we should fetch one by one and take the first one which successfully decrypts
|
||||||
// If file is altered decrytption will fail
|
// If a file is altered decrytption will fail
|
||||||
setLoadingSpinnerDesc('Fetching file from file server')
|
setLoadingSpinnerDesc('Fetching file from file server')
|
||||||
|
|
||||||
|
if (!zipUrls || zipUrls.length === 0) {
|
||||||
|
toast.warning('No zip files found in the zipUrls')
|
||||||
|
setIsLoading(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < zipUrls.length; i++) {
|
for (let i = 0; i < zipUrls.length; i++) {
|
||||||
const zipUrl = zipUrls[i]
|
const zipUrl = zipUrls[i]
|
||||||
const isLastZipUrl = i === zipUrls.length - 1
|
const isLastZipUrl = i === zipUrls.length - 1
|
||||||
@ -789,7 +799,15 @@ export const VerifyPage = () => {
|
|||||||
currentFile={currentFile}
|
currentFile={currentFile}
|
||||||
files={getCurrentUserFiles(files, currentFileHashes, fileHashes)}
|
files={getCurrentUserFiles(files, currentFileHashes, fileHashes)}
|
||||||
parsedSignatureEvents={parsedSignatureEvents}
|
parsedSignatureEvents={parsedSignatureEvents}
|
||||||
|
noFiles={!zipUrls || zipUrls.length === 0}
|
||||||
/>
|
/>
|
||||||
|
{!zipUrls || zipUrls.length === 0 ? (
|
||||||
|
<Typography textAlign="center">
|
||||||
|
We were not able to retrieve the files.
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
</StickySideColumns>
|
</StickySideColumns>
|
||||||
)}
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user