diff --git a/app/src/components/Download.js b/app/src/components/Download.js
index a6bea126..887bbddd 100644
--- a/app/src/components/Download.js
+++ b/app/src/components/Download.js
@@ -1767,6 +1767,29 @@ export function EditScrapeFilesDownloadForm({download, onDelete, onCancel, onSuc
/>
}
+/** A Git Download is created and changed by its Repo, so it can only be deleted here (e.g. after its Repo was
+ * deleted but the Download was not). */
+export function EditGitDownloadForm({download, onDelete, onCancel}) {
+ const orphaned = !download.collection_id;
+ return
+
+
+ {orphaned
+ ? This download's Repo no longer exists. Delete this download to stop it.
+ : This download is managed by its Repo. Change it on the Repos page.}
+
+ Delete
+
+
+
+}
+
/** URL field for a single URL. */
function UrlField({form, required = true, name = 'url', path = 'url', disabled = false}) {
const validator = (i) => validURL(i) ? null : 'Invalid URL';
diff --git a/app/src/components/Vars.js b/app/src/components/Vars.js
index 06ef47c4..6591cad5 100644
--- a/app/src/components/Vars.js
+++ b/app/src/components/Vars.js
@@ -200,6 +200,7 @@ export function audioContainerForCodec(codec) {
export const Downloaders = {
Archive: 'archive',
File: 'file',
+ Git: 'git',
Torrent: 'torrent',
KiwixCatalog: 'kiwix_catalog',
KiwixZim: 'kiwix_zim',
diff --git a/app/src/components/admin/Downloads.js b/app/src/components/admin/Downloads.js
index 98ec5ead..7b11b999 100644
--- a/app/src/components/admin/Downloads.js
+++ b/app/src/components/admin/Downloads.js
@@ -45,6 +45,7 @@ import {useDownloads} from "../../hooks/customHooks";
import {
EditArchiveDownloadForm,
EditChannelDownloadForm,
+ EditGitDownloadForm,
EditRSSDownloadForm,
EditScrapeFilesDownloadForm,
EditVideosDownloadForm,
@@ -310,6 +311,12 @@ function RecurringDownloadRow({download, fetchDownloads, onDelete}) {
onCancel={handleEditClose}
onSuccess={onSuccess}
/>;
+ } else if (downloader === Downloaders.Git) {
+ editForm = ;
} else if (downloader === Downloaders.ScrapeHtml) {
editForm = {
});
});
});
+
+describe('RecurringDownloadsTable', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('a Git download whose Repo was deleted can be deleted from its edit form', async () => {
+ const fetchDownloads = jest.fn();
+ const onDelete = jest.fn();
+ const downloads = [{
+ id: 16, url: 'https://example.com/repo', downloader: 'git', frequency: 604800, status: 'deferred',
+ collection_id: null,
+ }];
+ renderWithProviders(
+
+ );
+
+ fireEvent.click(screen.getByLabelText('Edit download'));
+ expect(await screen.findByText(/Repo no longer exists/))
+ .toBeInTheDocument();
+ expect(screen.getByDisplayValue('https://example.com/repo')).toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', {name: 'Delete'}));
+ // Confirm the deletion.
+ await screen.findByText('Delete this Download?');
+ const deleteButtons = screen.getAllByRole('button', {name: 'Delete'});
+ expect(deleteButtons.length).toBeGreaterThan(1);
+ await act(async () => fireEvent.click(deleteButtons[deleteButtons.length - 1]));
+
+ await waitFor(() => expect(deleteDownload).toHaveBeenCalledWith(16));
+ await waitFor(() => expect(onDelete).toHaveBeenCalled());
+ });
+});