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,
|
||||
faPen
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { Typography } from '@mui/material'
|
||||
import styles from '../UsersDetails.tsx/style.module.scss'
|
||||
|
||||
interface PdfMarkingProps {
|
||||
currentUserMarks: CurrentUserMark[]
|
||||
files: CurrentUserFile[]
|
||||
noFiles?: boolean
|
||||
handleExport: () => void
|
||||
handleEncryptedExport: () => void
|
||||
handleSign: () => void
|
||||
@ -42,6 +45,7 @@ interface PdfMarkingProps {
|
||||
const PdfMarking = (props: PdfMarkingProps) => {
|
||||
const {
|
||||
files,
|
||||
noFiles,
|
||||
currentUserMarks,
|
||||
setCurrentUserMarks,
|
||||
setUpdatedMarks,
|
||||
@ -131,6 +135,18 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
||||
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 (
|
||||
<>
|
||||
<Container className={signPageStyles.container}>
|
||||
@ -148,7 +164,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
right={meta !== null && <UsersDetails meta={meta} />}
|
||||
right={renderRightColumn()}
|
||||
leftIcon={faFileDownload}
|
||||
centerIcon={faPen}
|
||||
rightIcon={faCircleInfo}
|
||||
@ -156,21 +172,32 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
||||
<PdfView
|
||||
currentFile={currentFile}
|
||||
files={files}
|
||||
noFiles={noFiles}
|
||||
handleMarkClick={handleMarkClick}
|
||||
selectedMarkValue={selectedMarkValue}
|
||||
selectedMark={selectedMark}
|
||||
currentUserMarks={currentUserMarks}
|
||||
otherUserMarks={otherUserMarks}
|
||||
/>
|
||||
{noFiles ? (
|
||||
<Typography textAlign="center">
|
||||
We were not able to retrieve the files.
|
||||
</Typography>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</StickySideColumns>
|
||||
<MarkFormField
|
||||
handleSubmit={handleSubmit}
|
||||
handleSelectedMarkValueChange={handleChange}
|
||||
selectedMark={selectedMark}
|
||||
selectedMarkValue={selectedMarkValue}
|
||||
currentUserMarks={currentUserMarks}
|
||||
handleCurrentUserMarkChange={handleCurrentUserMarkChange}
|
||||
/>
|
||||
|
||||
{!noFiles && (
|
||||
<MarkFormField
|
||||
handleSubmit={handleSubmit}
|
||||
handleSelectedMarkValueChange={handleChange}
|
||||
selectedMark={selectedMark}
|
||||
selectedMarkValue={selectedMarkValue}
|
||||
currentUserMarks={currentUserMarks}
|
||||
handleCurrentUserMarkChange={handleCurrentUserMarkChange}
|
||||
/>
|
||||
)}
|
||||
</Container>
|
||||
</>
|
||||
)
|
||||
|
@ -10,6 +10,7 @@ interface PdfViewProps {
|
||||
currentFile: CurrentUserFile | null
|
||||
currentUserMarks: CurrentUserMark[]
|
||||
files: CurrentUserFile[]
|
||||
noFiles?: boolean
|
||||
handleMarkClick: (id: number) => void
|
||||
otherUserMarks: Mark[]
|
||||
selectedMark: CurrentUserMark | null
|
||||
@ -21,6 +22,7 @@ interface PdfViewProps {
|
||||
*/
|
||||
const PdfView = ({
|
||||
files,
|
||||
noFiles,
|
||||
currentUserMarks,
|
||||
handleMarkClick,
|
||||
selectedMarkValue,
|
||||
@ -76,6 +78,8 @@ const PdfView = ({
|
||||
<FileDivider key={`separator-${i}`} />,
|
||||
curr
|
||||
])
|
||||
) : noFiles ? (
|
||||
''
|
||||
) : (
|
||||
<LoadingSpinner variant="small" />
|
||||
)}
|
||||
|
@ -292,11 +292,12 @@ export const UsersDetails = ({ meta }: UsersDetailsProps) => {
|
||||
<div className={styles.section}>
|
||||
<p>File Servers</p>
|
||||
|
||||
{zipUrls.map((url) => (
|
||||
<span className={styles.detailsItem} key={url}>
|
||||
<FontAwesomeIcon icon={faServer} /> {getBaseUrl(url)}
|
||||
</span>
|
||||
))}
|
||||
{zipUrls &&
|
||||
zipUrls.map((url) => (
|
||||
<span className={styles.detailsItem} key={url}>
|
||||
<FontAwesomeIcon icon={faServer} /> {getBaseUrl(url)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : undefined
|
||||
|
@ -89,6 +89,7 @@ export const SignPage = () => {
|
||||
}
|
||||
|
||||
const [files, setFiles] = useState<{ [filename: string]: SigitFile }>({})
|
||||
const [noFiles, setNoFiles] = useState(false)
|
||||
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('')
|
||||
@ -290,6 +291,13 @@ export const SignPage = () => {
|
||||
|
||||
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++) {
|
||||
const zipUrl = zipUrls[i]
|
||||
const isLastZipUrl = i === zipUrls.length - 1
|
||||
@ -875,6 +883,7 @@ export const SignPage = () => {
|
||||
handleEncryptedExport={handleEncryptedExport}
|
||||
otherUserMarks={otherUserMarks}
|
||||
meta={meta}
|
||||
noFiles={noFiles}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ import { MarkRender } from '../../components/MarkTypeStrategy/MarkRender.tsx'
|
||||
|
||||
interface PdfViewProps {
|
||||
files: CurrentUserFile[]
|
||||
noFiles?: boolean
|
||||
currentFile: CurrentUserFile | null
|
||||
parsedSignatureEvents: {
|
||||
[signer: `npub1${string}`]: DocSignatureEvent
|
||||
@ -73,6 +74,7 @@ interface PdfViewProps {
|
||||
|
||||
const SlimPdfView = ({
|
||||
files,
|
||||
noFiles,
|
||||
currentFile,
|
||||
parsedSignatureEvents
|
||||
}: PdfViewProps) => {
|
||||
@ -162,6 +164,8 @@ const SlimPdfView = ({
|
||||
</React.Fragment>
|
||||
)
|
||||
})
|
||||
) : noFiles ? (
|
||||
''
|
||||
) : (
|
||||
<LoadingSpinner variant="small" />
|
||||
)}
|
||||
@ -404,9 +408,15 @@ export const VerifyPage = () => {
|
||||
setIsLoading(true)
|
||||
|
||||
// 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')
|
||||
|
||||
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++) {
|
||||
const zipUrl = zipUrls[i]
|
||||
const isLastZipUrl = i === zipUrls.length - 1
|
||||
@ -789,7 +799,15 @@ export const VerifyPage = () => {
|
||||
currentFile={currentFile}
|
||||
files={getCurrentUserFiles(files, currentFileHashes, fileHashes)}
|
||||
parsedSignatureEvents={parsedSignatureEvents}
|
||||
noFiles={!zipUrls || zipUrls.length === 0}
|
||||
/>
|
||||
{!zipUrls || zipUrls.length === 0 ? (
|
||||
<Typography textAlign="center">
|
||||
We were not able to retrieve the files.
|
||||
</Typography>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</StickySideColumns>
|
||||
)}
|
||||
</Container>
|
||||
|
Loading…
x
Reference in New Issue
Block a user