Commit Graph
30 Commits
Author SHA1 Message Date
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 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 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 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 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 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 f704d4d612 editor: use file system api for save as
This makes use of the new web file system api for a better user
experience when saving a file. It now shows a proper save as dialog
instead of just downloading the file automatically.

Fixes: https://github.com/pybricks/support/issues/84
2021-12-27 12:38:51 -06:00
David Lechner 0738046ab1 editor: conver SaveAsButton to function 2021-12-27 12:38:49 -06:00
David Lechner 384cb78a74 editor: convert OpenButton to function 2021-12-27 12:38:49 -06:00
David Lechner 476998030c editor: convert Editor to function component 2021-12-27 12:38:46 -06:00
David Lechner 86c0e933f3 settings: add new hubName setting
This setting will be used to customize the hub name when flashing
firmware. This commit just implements the setting.

Some changes needed to be made to the existing settings infrastructure
since previously it only allowed boolean settings.
2021-11-19 20:48:06 -06:00
David Lechner 39c66eb98c yarn: add monaco-editor
react-monaco-editor changed to include monaco-editor as a peer dependency.

Also fix breakage for updated monaco-editor version.
2021-11-17 16:06:28 -06:00
David Lechner 2ba6d88c49 editor: remove gutter background override
This was carried over from the Ace editor, but doesn't work well with
the Monaco editor.

Fixes: https://github.com/pybricks/pybricks-code/issues/472
2021-07-08 15:57:16 -05:00
David Lechner 9ee2d1f102 editor: clean up keywords and builtins
- remove python 2 stuff
- separate builtins from keywords
2021-07-08 15:56:27 -05:00
David Lechner ad948dc152 editor: copy python language configuration
This copies the language configuration from https://github.com/microsoft/monaco-languages/blob/d7cc098c481059f63d51ce3753975c8ca8ab6030/src/python/python.ts

This fixes a number of editor features, like auto-indent.

Fixes: https://github.com/pybricks/pybricks-code/issues/470
2021-07-08 15:55:50 -05:00
David Lechner 4b0dc90e8d editor: improve template snippets
- fix always being suggested
- add more imports
- reduce duplicated code

Fixes https://github.com/pybricks/pybricks-code/issues/471
2021-07-08 15:55:03 -05:00
David Lechner d95c550248 editor: change from ace to monaco
This replaces the ace editor with the monaco editor. It fixes quite a
few small paper-cut bugs and should be easier to add code completion
to in the future.

Many of the snippets are omitted but can be added back later if needed.
Otherwise, we have tried to preserve the existing look and feel as much
as possible.
2021-07-02 20:59:09 -05:00
David Lechner ec6753c314 yarn lint
rules seem to have changed a bit after upgrading packages
2021-05-11 12:45:43 -05:00
David Lechner 9005e909ba refactor common context menu code 2021-02-01 10:26:06 -06:00
David Lechner 4b6817d9ad drop use of decorator for editor context menu 2021-02-01 10:26:06 -06:00
David Lechner 6ccb77a5ad add test for snippets 2021-02-01 10:26:06 -06:00
David Lechner 6ed5dca8ce add tests for editor reducers 2021-02-01 10:26:05 -06:00
David Lechner e5073399a0 drop explicit state interfaces
This could cause subtle bugs like the one fixed here where license
was renamed to licenses.
2021-02-01 10:26:05 -06:00
David Lechner 0c20e52a45 don't allow optional args in actions
This can lead to subtle bugs.

Fixes firmware flash button not working.
2021-02-01 10:26:05 -06:00
David Lechner 6f204a65f6 reorganize src/ directory
Makes for much less scrolling/jumping around.

https://redux.js.org/style-guide/style-guide#structure-files-as-feature-folders-or-ducks
2021-02-01 10:26:05 -06:00