refactor: review suggestions for web/../integrity.service.ts

Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
izzy
2026-02-12 10:30:47 +00:00
parent 477d43290b
commit 8cb63ebb51
+15 -13
View File
@@ -11,7 +11,7 @@ export const getIntegrityReportActions = ($t: MessageFormatter, reportType: Inte
type: $t('command'), type: $t('command'),
title: $t('admin.download_csv'), title: $t('admin.download_csv'),
icon: mdiDownload, icon: mdiDownload,
onAction() { onAction: () => {
handleDownloadIntegrityReportCsv(reportType); handleDownloadIntegrityReportCsv(reportType);
}, },
}; };
@@ -21,7 +21,7 @@ export const getIntegrityReportActions = ($t: MessageFormatter, reportType: Inte
title: $t('trash_page_delete_all'), title: $t('trash_page_delete_all'),
icon: mdiTrashCanOutline, icon: mdiTrashCanOutline,
color: 'danger', color: 'danger',
onAction() { onAction: () => {
void handleRemoveAllIntegrityReportItems(reportType); void handleRemoveAllIntegrityReportItems(reportType);
}, },
}; };
@@ -34,22 +34,20 @@ export const getIntegrityReportItemActions = (
reportId: string, reportId: string,
reportType: IntegrityReportType, reportType: IntegrityReportType,
) => { ) => {
const Download = const Download = {
reportType === IntegrityReportType.UntrackedFile || reportType === IntegrityReportType.ChecksumMismatch
? {
title: $t('download'), title: $t('download'),
icon: mdiDownload, icon: mdiDownload,
onAction() { onAction: () => {
void handleDownloadIntegrityReportFile(reportId); void handleDownloadIntegrityReportFile(reportId);
}, },
} $if: reportType === IntegrityReportType.UntrackedFile || reportType === IntegrityReportType.ChecksumMismatch,
: undefined; };
const Delete = { const Delete = {
title: $t('delete'), title: $t('delete'),
icon: mdiTrashCanOutline, icon: mdiTrashCanOutline,
color: 'danger', color: 'danger',
onAction() { onAction: () => {
void handleRemoveIntegrityReportItem(reportId); void handleRemoveIntegrityReportItem(reportId);
}, },
}; };
@@ -71,7 +69,10 @@ export const handleRemoveAllIntegrityReportItems = async (reportType: IntegrityR
confirmText: $t('delete'), confirmText: $t('delete'),
}); });
if (confirm) { if (!confirm) {
return;
}
let name: ManualJobName; let name: ManualJobName;
switch (reportType) { switch (reportType) {
case IntegrityReportType.UntrackedFile: { case IntegrityReportType.UntrackedFile: {
@@ -108,7 +109,6 @@ export const handleRemoveAllIntegrityReportItems = async (reportType: IntegrityR
isDeleting: false, isDeleting: false,
}); });
} }
}
}; };
export const handleRemoveIntegrityReportItem = async (reportId: string) => { export const handleRemoveIntegrityReportItem = async (reportId: string) => {
@@ -117,7 +117,10 @@ export const handleRemoveIntegrityReportItem = async (reportId: string) => {
confirmText: $t('delete'), confirmText: $t('delete'),
}); });
if (confirm) { if (!confirm) {
return;
}
try { try {
eventManager.emit('IntegrityReportDeleteStatus', { eventManager.emit('IntegrityReportDeleteStatus', {
id: reportId, id: reportId,
@@ -139,5 +142,4 @@ export const handleRemoveIntegrityReportItem = async (reportId: string) => {
isDeleting: false, isDeleting: false,
}); });
} }
}
}; };