| @@ -1,10 +1,9 @@ | ||
| 1 | +import { TIMEOUTS } from '../../../tests/e2e/helpers/constants' | |
| 1 | 2 | import { getSnippetType } from './snippets/snippets' |
| 2 | 3 | import type { SnippetsExport } from '../types/schema/SnippetsExport' |
| 3 | 4 | import type { Snippet } from '../types/Snippet' |
| 4 | 5 | |
| 5 | -const SECOND_IN_MS = 1000 | |
| 6 | -const TIMEOUT_SECONDS = 40 | |
| 7 | 6 | const JSON_INDENT_SPACES = 2 |
| 8 | 7 | const EXPORT_FILENAME = 'snippets' |
| 9 | 8 | const EXPORT_GENERATOR = 'Code Snippets' |
| 10 | 9 | const DEFAULT_PRIORITY = 10 |
| @@ -23,9 +22,9 @@ | ||
| 23 | 22 | const link = document.createElement('a') |
| 24 | 23 | link.download = filename |
| 25 | 24 | link.href = URL.createObjectURL(new Blob([content], { type })) |
| 26 | 25 | |
| 27 | - setTimeout(() => URL.revokeObjectURL(link.href), TIMEOUT_SECONDS * SECOND_IN_MS) | |
| 26 | + setTimeout(() => URL.revokeObjectURL(link.href), TIMEOUTS.DEFAULT) | |
| 28 | 27 | |
| 29 | 28 | // Some browsers (notably headless Chromium) can ignore programmatic clicks on detached anchors. |
| 30 | 29 | // Appending the link to the DOM before clicking improves reliability. |
| 31 | 30 | link.style.display = 'none' |
| @@ -99,10 +98,10 @@ | ||
| 99 | 98 | conditionId, |
| 100 | 99 | lastActive, |
| 101 | 100 | code_error, |
| 102 | 101 | code_error_trace |
| 103 | -}: Snippet): SnippetsExport['snippets'][number] => { | |
| 104 | - const exportSnippet: SnippetsExport['snippets'][number] = Object.fromEntries( | |
| 102 | +}: Snippet): SnippetsExport['snippets'][number] => | |
| 103 | + Object.fromEntries( | |
| 105 | 104 | Object.entries({ |
| 106 | 105 | id, |
| 107 | 106 | name, |
| 108 | 107 | desc, |
| @@ -121,11 +120,8 @@ | ||
| 121 | 120 | code_error, |
| 122 | 121 | code_error_trace |
| 123 | 122 | }).filter(([field, value]) => !isDefaultExportValue(field, value)) |
| 124 | 123 | ) |
| 125 | - | |
| 126 | - return exportSnippet | |
| 127 | -} | |
| 128 | 124 | |
| 129 | 125 | export const downloadBulkSnippetExportFile = (snippets: readonly Snippet[]) => { |
| 130 | 126 | if (0 === snippets.length) { |
| 131 | 127 | return |