David Lechner
93111b6af4
explorer: implement import action
2022-03-11 15:41:16 -06:00
David Lechner
7b095765ac
pybricksMicropython/lib: add pythonFileExtensionRegex
...
This can be reused in code to work with file names.
2022-03-11 15:41:16 -06:00
David Lechner
e36a30de4c
pybricksMicropython/lib: add module
...
This creates a new module for dealing with stuff specific to Pybricks
MicroPython.
2022-03-11 15:41:16 -06:00
David Lechner
38b9bb6656
explorer: confirm file deletion
...
Since deleting files cannot be undone, we need to be extra sure before
actually deleting the file.
2022-03-10 13:48:57 -06:00
David Lechner
a995c52e04
notifications: add helper function to simplify tests
...
This reduces duplicate code and uses more of the real implementation.
2022-03-10 13:48:11 -06:00
David Lechner
63fc715f20
fileStorage: add didDeleteFile and didFailToDeleteFile actions
...
This will allow handling errors if removing a file from storage fails.
2022-03-10 13:45:10 -06:00
David Lechner
96f0dd16fd
explorer: create new file wizard
2022-03-10 02:22:29 -06:00
David Lechner
fd120bb5a6
fileStorage: fix incorrect suggested file name
2022-03-10 02:10:34 -06:00
David Lechner
ddbf3a20f4
explorer: add more UI tests
2022-03-10 02:02:20 -06:00
David Lechner
b37209683b
test: extend testRender to return spy on dispatch
2022-03-10 02:00:14 -06:00
David Lechner
41fc961661
fileStorage: implement delete action
2022-03-10 01:02:18 -06:00
David Lechner
03d12feb89
explorer: add basic file explorer
...
This is the beginnings of a file explorer. Most actions are not yet
implemented.
2022-03-09 20:54:04 -06:00
David Lechner
6afee4b6d6
test: add testRender()
...
This adds a testRender() helper function to simplify UI tests. Instead
of mocking the redux store, we use the real thing.
2022-03-09 17:24:46 -06:00
David Lechner
1469d2146e
app: rework service worker registration
...
- registration is moved from top-level index to app/sagas.
- mock implementation is provided for tests
- actions are renamed to include "app" prefix
- actions are changed to not use non-serializable arguments
- reducers are changed to not use non-serializable state
2022-03-09 15:48:30 -06:00
David Lechner
907826cf0e
app: rework BeforeInstallPromptEvent
...
This removed passing the BeforeInstallPromptEvent as an action argument
(action arguments should be serializable). Instead the saga just keeps
a reference to the event and actions are used only to resolve the state
of the UI.
2022-03-08 13:37:43 -06:00
David Lechner
7884f047b5
service-worker: rename actions
...
This adds a prefix to the actions so that we won't have to use aliases.
2022-03-07 17:46:26 -06:00
David Lechner
d767ca0784
notifications/sagas: fix rename in comment
...
This was missed when actions were refactored to remove ActionType enums.
2022-03-05 12:39:30 -06:00
David Lechner
569217d5dc
editor: don't put editor in redux store
...
The redux store should not have non-serializable objects like the editor
in it.
2022-03-02 18:56:47 -06:00
David Lechner
bc7e9e2a20
fileStorage: add archive actions
...
This allows users to back up all files to their computer.
2022-03-02 10:33:21 -06:00
David Lechner
12f34eb210
utils: add new timestamp function
...
This will be used to create suggested file names that include a timestamp.
2022-03-01 14:42:45 -06:00
David Lechner
a87e2c664c
fileStorage: add export actions
...
These are largely copied from the editor saveAs actions and allow
exporting ("downloading") a file from the browser local storage to
the file system.
2022-03-01 13:44:08 -06:00
David Lechner
80219d297f
licenses/reducers: use ReadonlyArray
...
This helps protect against mistakes in future changes.
2022-03-01 12:00:29 -06:00
David Lechner
55c6841fae
fileStorage/reducers: drop use of Set
...
Using set causes problems with tooling that mocks the global app state,
so stick with arrays.
2022-03-01 11:58:50 -06:00
David Lechner
31600c6f37
editor: fix error if main.py does not exist
...
The editor saga was assuming that main.py always exists, which is not
the case for the first use of the app. This fixes the issue by checking
to see if the file exists before attempting to open it. This also
revealed a bug in fileStorage where the list of files was not populated
during initialization.
2022-02-28 12:24:46 -06:00
David Lechner
97363b4327
actions: improve type inference
...
It seems like there should be a better way to do this.
2022-02-28 12:22:08 -06:00
David Lechner
02d7672155
react-dropzone: fix for breaking change in v12
...
This fixes a breaking change from upgrading to react-dropzone to v12.
2022-02-28 11:01:59 -06:00
David Lechner
994540e263
actions: fix missed refactoring
...
Missed some renames when refactoring that weren't picked up locally
for some reason.
2022-02-26 12:55:49 -06:00
David Lechner
a9f4eaa32d
actions: simplify usage of Matchable
...
This removes use of the pseudo-internal toString() function and also
removes extraneous uses of ReturnType<>. Also, a new when() method
is added to simplify additional uses.
2022-02-26 12:43:10 -06:00
David Lechner
9641898a75
actions: refactor actions
...
The pattern we were using for actions required actions to be defined in
three places, an enum member containing the type string, an type
definition and a function. This combines all three of these into one by
using a helper function based on the ideas from [1].
[1]: https://phryneas.de/redux-typescript-no-discriminating-union
2022-02-25 17:58:30 -06:00
David Lechner
8f377b3909
app/actions: fix duplicate type name
...
This fixes a duplicate type name shared by didInstallPrompt and
didInstall actions.
2022-02-25 10:02:26 -06:00
David Lechner
cf8744a6cd
actions: drop typed dispatch
...
This doesn't provide much benefit and is just one more rule to remember,
so we can do without it.
2022-02-24 17:16:52 -06:00
David Lechner
e4b7a9aec7
fileStorage: new file storage backend
...
This replaces the localStorage file storage with a new backend that uses
localForage (indexeddb) for storing the file contents. This will also
allow storing multiple files.
2022-02-24 16:59:49 -06:00
David Lechner
a0a1ae7126
"@blueprintjs/core": "^3.53.0"
...
This allows us to drop the monkey patch to work around an upstream bug.
2022-02-22 14:23:20 -06:00
David Lechner
a0da9f7111
Improve code coverage
2022-02-22 12:32:20 -06:00
David Lechner
b3ed75f02b
status-bar: add titles
...
This adds titles to interactive elements. This causes a small (browser-
native) tooltip to display when hovering.
2022-02-22 12:32:20 -06:00
David Lechner
2f857acbb7
utils/monkey-patch: remove try/catch in test
...
The try/catch would also suppress the fail() which would make the test
always succeed even when it should fail.
Jest has a .rejects API that can be used instead.
2022-02-22 12:32:19 -06:00
David Lechner
fd09783a45
toolbar: work around tooltip bugs
...
This works around several bugs where tooltips don't close when expected.
Fixes: https://github.com/pybricks/pybricks-code/issues/275
2021-12-28 18:55:20 -06:00
David Lechner
54ec447061
actions: added typed useDispatch() hook
2021-12-27 18:01:51 -06:00
David Lechner
8d26f768bf
reducers: use typed useSelector hook
...
This refactors the code to use a typed useSelector() hook.
2021-12-27 17:48:41 -06:00
David Lechner
8527cf86b2
app: refactor dark mode class hook
...
This moves the hook for applying the global dark mode style to the App component.
2021-12-27 17:30:15 -06:00
David Lechner
42051ba924
status-bar: add basic battery indicator
...
This adds a basic battery indicator that just shows green for OK and red
for low battery warning. This is all we can do for now since that is
the only information that the hub sends currently.
Fixes: https://github.com/pybricks/support/issues/559
2021-12-27 17:05:40 -06:00
David Lechner
4c4061561d
ble-nordic-uart-service: rename directory
...
This follows the pattern of other ble service directories.
2021-12-27 13:30:36 -06:00
David Lechner
1e4bce6a14
ble: move sagas
...
This saga uses all ble services, not just NUS, so move it to the common
ble folder.
2021-12-27 13:20:36 -06:00
David Lechner
8d4680ba82
status-bar: add connected hub indicator
...
This adds an indicator to the status bar that shows the hub name. When
clicked, a popover will be displayed that lists more detailed information
about the connected hub.
2021-12-27 13:04:13 -06:00
David Lechner
78dd03d80f
ble-device-info-service/protocol: document PnP ID
...
This explains the Pybricks-specific usage of the PnP ID fields.
2021-12-27 12:38:51 -06:00
David Lechner
5f7a63fe5a
ble-lwp3-service/protocol: add enums for hub types
...
This is the full list of hub types.
2021-12-27 12:38:51 -06:00
David Lechner
0759a0878f
editor: add newlines to end of template
2021-12-27 12:38:51 -06:00
David Lechner
0cc577faad
editor: add Essential hub snippet
2021-12-27 12:38:51 -06:00
David Lechner
ade06ab2cc
ble: add id and name to didConnect action
2021-12-27 12:38:51 -06:00
David Lechner
e92d5c1511
ble-device-info-service: add actions
...
This adds actions that are triggered when the device info service
characteristics are read.
2021-12-27 12:38:51 -06:00