CloudLibrary
1 year ago
Settings
1 year ago
StarterSites
3 years ago
App.js
2 years ago
Card.js
3 years ago
CategoriesTabs.js
3 years ago
CategorySelector.js
2 years ago
CustomTooltip.js
3 years ago
DocNotice.js
2 years ago
EditorSelector.js
2 years ago
EditorTabs.js
4 years ago
Header.js
2 years ago
Icon.js
2 years ago
ImportModal.js
1 year ago
ImportModalError.js
2 years ago
ImportModalMock.js
4 years ago
ImportModalNote.js
4 years ago
ImportStepper.js
1 year ago
InstallModal.js
1 year ago
License.js
2 years ago
LicensePanelContext.js
3 years ago
Loading.js
4 years ago
Main.js
1 year ago
Migration.js
4 years ago
NewTCNotice.js
1 year ago
Notification.js
4 years ago
OnboardingContent.js
4 years ago
PreviewFrame.js
3 years ago
Search.js
2 years ago
StarterSiteCard.js
3 years ago
ImportModalError.js
73 lines
| 1 | import { Dashicon, Button } from '@wordpress/components'; |
| 2 | import { __ } from '@wordpress/i18n'; |
| 3 | import {useEffect, useState} from "@wordpress/element"; |
| 4 | import {getLogsFromServer} from "../../../onboarding/src/utils/rest"; |
| 5 | import {textToFileURL} from "../../../onboarding/src/utils/common"; |
| 6 | |
| 7 | const ImportModalError = ( { message, code } ) => { |
| 8 | |
| 9 | const [logs, setLogs] = useState( {} ); |
| 10 | |
| 11 | useEffect(() => { |
| 12 | getLogsFromServer({ |
| 13 | success: function (response) { |
| 14 | setLogs({ |
| 15 | raw: response, |
| 16 | url: textToFileURL(response), |
| 17 | }); |
| 18 | }, |
| 19 | }); |
| 20 | |
| 21 | return () => { |
| 22 | if ( logs?.url ) { |
| 23 | URL.revokeObjectURL(logs.url); |
| 24 | } |
| 25 | } |
| 26 | }, []); |
| 27 | |
| 28 | return ( |
| 29 | <div className="well error"> |
| 30 | { message && ( |
| 31 | <h3> |
| 32 | <Dashicon icon="warning" /> |
| 33 | <span>{ message }</span> |
| 34 | </h3> |
| 35 | ) } |
| 36 | <ul> |
| 37 | <li |
| 38 | dangerouslySetInnerHTML={ { |
| 39 | __html: tiobDash.onboarding.i18n.troubleshooting, |
| 40 | } } |
| 41 | /> |
| 42 | <li |
| 43 | dangerouslySetInnerHTML={ { |
| 44 | __html: tiobDash.onboarding.i18n.support, |
| 45 | } } |
| 46 | /> |
| 47 | { code && ( |
| 48 | <li> |
| 49 | { __( 'Error code', 'templates-patterns-collection' ) }:{ ' ' } |
| 50 | <code>{ code }</code> |
| 51 | </li> |
| 52 | ) } |
| 53 | <li> |
| 54 | { __( 'Error log', 'templates-patterns-collection' ) }:{ ' ' } |
| 55 | <a download={"ti_theme_onboarding.log"} href={logs.url}> |
| 56 | { __( 'Download Logs File', 'templates-patterns-collection' ) } |
| 57 | </a> |
| 58 | <details> |
| 59 | <summary> |
| 60 | { __( 'See logs', 'templates-patterns-collection' ) } |
| 61 | </summary> |
| 62 | <div> |
| 63 | { logs.raw } |
| 64 | </div> |
| 65 | </details> |
| 66 | </li> |
| 67 | </ul> |
| 68 | </div> |
| 69 | ); |
| 70 | }; |
| 71 | |
| 72 | export default ImportModalError; |
| 73 |