mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
fileStorage: add archive actions
This allows users to back up all files to their computer.
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
} from '../ble/actions';
|
||||
import { didFailToSaveAs } from '../editor/actions';
|
||||
import {
|
||||
fileStorageDidFailToArchiveAllFiles,
|
||||
fileStorageDidFailToExportFile,
|
||||
fileStorageDidFailToInitialize,
|
||||
fileStorageDidFailToReadFile,
|
||||
@@ -92,6 +93,7 @@ test.each([
|
||||
fileStorageDidFailToReadFile('test.file', new Error('test error')),
|
||||
fileStorageDidFailToWriteFile('test.file', new Error('test error')),
|
||||
fileStorageDidFailToExportFile('test.file', new Error('test error')),
|
||||
fileStorageDidFailToArchiveAllFiles(new Error('test error')),
|
||||
])('actions that should show notification: %o', async (action: AnyAction) => {
|
||||
const getToasts = jest.fn().mockReturnValue([]);
|
||||
const show = jest.fn();
|
||||
@@ -128,6 +130,7 @@ test.each([
|
||||
'test.file',
|
||||
new DOMException('test message', 'AbortError'),
|
||||
),
|
||||
fileStorageDidFailToArchiveAllFiles(new DOMException('test message', 'AbortError')),
|
||||
])('actions that should not show a notification: %o', async (action: AnyAction) => {
|
||||
const getToasts = jest.fn().mockReturnValue([]);
|
||||
const show = jest.fn();
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from '../ble/actions';
|
||||
import { didFailToSaveAs } from '../editor/actions';
|
||||
import {
|
||||
fileStorageDidFailToArchiveAllFiles,
|
||||
fileStorageDidFailToExportFile,
|
||||
fileStorageDidFailToInitialize,
|
||||
fileStorageDidFailToReadFile,
|
||||
@@ -414,6 +415,17 @@ function* showFileStorageFailToExport(
|
||||
yield* showUnexpectedError(MessageId.FileStorageFailedToExport, action.error);
|
||||
}
|
||||
|
||||
function* showFileStorageFailToArchive(
|
||||
action: ReturnType<typeof fileStorageDidFailToArchiveAllFiles>,
|
||||
): Generator {
|
||||
if (action.error.name === 'AbortError') {
|
||||
// user clicked cancel button - not an error
|
||||
return;
|
||||
}
|
||||
|
||||
yield* showUnexpectedError(MessageId.FileStorageFailedToExport, action.error);
|
||||
}
|
||||
|
||||
export default function* (): Generator {
|
||||
yield* takeEvery(bleDeviceDidFailToConnect, showBleDeviceDidFailToConnectError);
|
||||
yield* takeEvery(bootloaderDidFailToConnect, showBootloaderDidFailToConnectError);
|
||||
@@ -429,4 +441,5 @@ export default function* (): Generator {
|
||||
yield* takeEvery(fileStorageDidFailToReadFile, showFileStorageFailToRead);
|
||||
yield* takeEvery(fileStorageDidFailToWriteFile, showFileStorageFailToWrite);
|
||||
yield* takeEvery(fileStorageDidFailToExportFile, showFileStorageFailToExport);
|
||||
yield* takeEvery(fileStorageDidFailToArchiveAllFiles, showFileStorageFailToArchive);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user