import React from "react"; import {clearCompletedDownloads, clearFailedDownloads, deleteDownload, killDownload, restartDownload} from "../../api"; import {Link} from "react-router-dom"; import { APIButton, DisableDownloadsToggle, ErrorMessage, isoDatetimeToElapsedPopup, secondsToFrequency, textEllipsis, useTitle, WROLModeMessage } from "../Common"; import { Button as SButton, Loader, PlaceholderLine, TableBody, TableCell, TableFooter, TableHeader, TableHeaderCell, TableRow } from "semantic-ui-react"; import {Button, Header, Modal, ModalActions, ModalContent, ModalHeader, Placeholder, Segment, Table} from "../Theme"; import {useDownloads} from "../../hooks/customHooks"; import {toast} from "react-semantic-toasts-2"; function ClearCompleteDownloads({callback}) { async function localClearDownloads() { try { await clearCompletedDownloads(); } finally { if (callback) { callback() } } } return <> Clear Completed } function ClearFailedDownloads({callback}) { async function localDeleteFailed() { try { await clearFailedDownloads(); } finally { if (callback) { callback() } } } return Clear Failed } class RecurringDownloadRow extends React.Component { constructor(props) { super(props); this.state = { errorModalOpen: false, } } handleDelete = async () => { const {id} = this.props; try { await deleteDownload(id); } finally { if (this.props.fetchDownloads) { this.props.fetchDownloads(); } } } handleRestart = async () => { const {id} = this.props; try { const response = await restartDownload(id); if (response.status !== 204) { throw Error('Unable to restart download'); } } catch (e) { toast({ type: 'error', title: 'Error', description: 'Unable to restart download', time: 5000, }) throw e; } finally { if (this.props.fetchDownloads) { this.props.fetchDownloads(); } } } render() { let {url, frequency, last_successful_download, status, location, next_download, error} = this.props; const {errorModalOpen} = this.state; const link = location ? (text) => {text} : (text) => {text}; const errorModal = this.setState({errorModalOpen: false})} onOpen={() => this.setState({errorModalOpen: true})} open={errorModalOpen} trigger={