({ script, onClose })
| 27 | script?: Script; |
| 28 | onClose: () => void; |
| 29 | }> = ({ script, onClose }) => { |
| 30 | const [form] = Form.useForm(); |
| 31 | const [visible, setVisible] = React.useState(false); |
| 32 | const [cloudScriptType, setCloudScriptType] = React.useState<ExportTarget>("local"); |
| 33 | const [, setModel] = React.useState<Export>(); |
| 34 | const { t } = useTranslation(); |
| 35 | |
| 36 | const CloudScriptList = [ |
| 37 | { |
| 38 | key: "local", |
| 39 | name: t("local"), |
| 40 | }, |
| 41 | ]; |
| 42 | |
| 43 | useEffect(() => { |
| 44 | if (script) { |
| 45 | setVisible(true); |
| 46 | // 设置默认值 |
| 47 | // 从数据库中获取导出数据 |
| 48 | const dao = new ExportDAO(); |
| 49 | dao.findByScriptID(script.uuid).then((data) => { |
| 50 | setModel(data); |
| 51 | if (data && data.params[data.target]) { |
| 52 | setCloudScriptType(data.target); |
| 53 | form.setFieldsValue(data.params[data.target]); |
| 54 | } else { |
| 55 | setCloudScriptType("local"); |
| 56 | form.setFieldsValue(defaultParams(script)); |
| 57 | } |
| 58 | }); |
| 59 | } |
| 60 | }, [script]); |
| 61 | return ( |
| 62 | <Modal |
| 63 | title={ |
| 64 | <div> |
| 65 | <span |
| 66 | style={{ |
| 67 | height: "32px", |
| 68 | lineHeight: "32px", |
| 69 | }} |
| 70 | > |
| 71 | {script?.name} {t("upload_to_cloud")} |
| 72 | </span> |
| 73 | <Button |
| 74 | type="text" |
| 75 | icon={ |
| 76 | <IconQuestionCircleFill |
| 77 | style={{ |
| 78 | margin: 0, |
| 79 | }} |
| 80 | /> |
| 81 | } |
| 82 | href={`${DocumentationSite}${localePath}/docs/dev/cloudcat/`} |
| 83 | target="_blank" |
| 84 | iconOnly |
| 85 | /> |
| 86 | </div> |
nothing calls this directly
no test coverage detected