Merge pull request 'fix(portal): en idempotensnyckel per vald fil' (#460) from fix/ui-upload-key into main
Security Scan (SIAX Cloud) / security (push) Successful in 34s
CI (SIAX Cloud) / security (push) Successful in 42s
CI (SIAX Cloud) / sonar (push) Successful in 1m13s
CI (SIAX Cloud) / quality (push) Successful in 1m32s
Release chain (G17, ADR-W16-003) / Build, push, G17 (SBOM/scan/attest/verify/evidence) (push) Successful in 1m35s
Deploy to Coolify / deploy (push) Successful in 1m38s
CI (SIAX Cloud) / integration (push) Successful in 10m10s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (push) Successful in 7s
masterplan-lock / check (pull_request) Successful in 6s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 16s
CI (SIAX Cloud) / security (pull_request) Successful in 19s
CI (SIAX Cloud) / integration (pull_request) Successful in 59s
CI (SIAX Cloud) / quality (pull_request) Successful in 11m57s
Security Scan (SIAX Cloud) / security (push) Successful in 34s
CI (SIAX Cloud) / security (push) Successful in 42s
CI (SIAX Cloud) / sonar (push) Successful in 1m13s
CI (SIAX Cloud) / quality (push) Successful in 1m32s
Release chain (G17, ADR-W16-003) / Build, push, G17 (SBOM/scan/attest/verify/evidence) (push) Successful in 1m35s
Deploy to Coolify / deploy (push) Successful in 1m38s
CI (SIAX Cloud) / integration (push) Successful in 10m10s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (push) Successful in 7s
masterplan-lock / check (pull_request) Successful in 6s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 16s
CI (SIAX Cloud) / security (pull_request) Successful in 19s
CI (SIAX Cloud) / integration (pull_request) Successful in 59s
CI (SIAX Cloud) / quality (pull_request) Successful in 11m57s
This commit was merged in pull request #460.
This commit is contained in:
@@ -73,6 +73,10 @@ export default function DocumentsPage() {
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [unknownOutcome, setUnknownOutcome] = useState<unknown | null>(null);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
// One idempotency key per selected file: a retry (double click, network
|
||||
// error, reload-and-pick-the-same-file) returns the SAME document instead of
|
||||
// creating a duplicate. Picking a different file resets it.
|
||||
const uploadKey = useRef<string | null>(null);
|
||||
|
||||
const [instruction, setInstruction] = useState('');
|
||||
const [fields, setFields] = useState<FieldRow[]>([{ name: 'organization', type: 'string' }]);
|
||||
@@ -119,7 +123,9 @@ export default function DocumentsPage() {
|
||||
const form = new FormData();
|
||||
form.set('file', file);
|
||||
form.set('project_id', projectId.trim());
|
||||
form.set('idempotency_key', crypto.randomUUID());
|
||||
const key = uploadKey.current ?? crypto.randomUUID();
|
||||
uploadKey.current = key;
|
||||
form.set('idempotency_key', key);
|
||||
form.set('classification', 'restricted');
|
||||
try {
|
||||
const response = await fetch('/api/0pt/documents/upload', {
|
||||
@@ -293,7 +299,10 @@ export default function DocumentsPage() {
|
||||
ref={inputRef}
|
||||
type="file"
|
||||
className="hidden"
|
||||
onChange={(event) => setFile(event.target.files?.[0] ?? null)}
|
||||
onChange={(event) => {
|
||||
uploadKey.current = null;
|
||||
setFile(event.target.files?.[0] ?? null);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user