Commit Graph
70 Commits
Author SHA1 Message Date
David Lechner 41e826d73b editor: save view state on change
Instead of trying to save the view state when a window "closes", which
is unreliable, we just save the state on every change.
2022-05-31 17:43:54 -05:00
David Lechner 818865462e editor: handle files by uuid
This changes things up a bit so that files are handled by uuid instead
of path. The allows for files to be renamed without breaking things.

Also some improvements with persistence of the view state for each
file is made.
2022-05-31 17:21:29 -05:00
David Lechner a3e55c828a move useI18n to i18n.ts
Since we are using the react-i18n babel loader plugin, useI18n can only
be used once per file. Also we have to remember to add the istanbul
ignore next comment each time we use it. By moving this to a common
file, it can be easily copied and pasted when a new submodule is
created and we don't have to remember the rules when calling it.
2022-05-21 13:57:58 -05:00
David Lechner e7366c8afd rework alerts
This starts moving alerts to the same subsystem where they are relevant
instead of putting everything in notifications.

So far, only the explorer file in use error is handled like this.
2022-05-20 19:25:18 -05:00
David Lechner 3dc03f3879 editor: save file to correct path
previously, all files were being saved as main.py
2022-05-19 10:44:31 -05:00
David Lechner 057ba4bab9 spelling 2022-05-18 18:21:01 -05:00
David Lechner d02e38795b editor/sagas: fix error creating model on hot reload 2022-05-18 17:47:29 -05:00
David Lechner 325562996b replace useUniqueId() with useId()
there should only be one way to do a thing...
2022-05-18 17:16:32 -05:00
David Lechner 4580869e6f editor: don't keep file open when editing
Since open takes a lock on the file, it prevented other file operations.
2022-05-18 13:11:06 -05:00
David Lechner 5dc6b2e4cb util: drop preventBrowserNativeContextMenu
This is done once at the top-level app, so is no longer needed.
2022-05-12 19:20:46 -05:00
David Lechner fa0a9a109c editor: improve a18y and visual appearance 2022-05-12 16:14:48 -05:00
David Lechner edd8ebfd64 Add Activities
This adds a new Activities tab list and view similar to VS code. The
Explorer and Settings are migrated to this view.
2022-05-12 12:33:21 -05:00
David Lechner 65623f801d update for breaking blueprintjs style changes
it is no longer feasible to build the blueprintjs css ourselves, so we
just use all of the default variable values and override things using
selectors instead.
2022-05-11 18:13:36 -05:00
David Lechner 5ee74187eb optimize svgs
The new webpack doesn't like the xml namespaces and refuses to compile
so we have to save the svg files in optimized form.
2022-05-10 20:26:58 -05:00
David Lechner 8ffaf64292 fileStorage: add file create option
When opening a file, sometimes we want to create it if it does not
exist and sometimes we don't.
2022-04-08 18:29:05 -05:00
David Lechner 8ac77560fb editor: add tabs for controlling open/active files 2022-04-07 21:17:09 -05:00
David Lechner 158e8f2693 fix typo 2022-04-06 09:01:14 -05:00
David Lechner 89a2019a98 explorer: add action for activating file
this simply forwards the action to the editor module
2022-04-05 18:10:06 -05:00
David Lechner b9dbaaa5cb fileStorage: implement file locks
This breaks down reading and writing into low-level and high level sagas.

Opening now takes a lock on the file so that it can only have one writer
or have multiple readers. The low-level read and write sagas use the
file descriptor to determine if the file is still open before actually
performing the action.

Since we are using the web locks api, these locks should work across
browser tabs/windows.

The high-level read/write sagas perform the low-level open, read/write,
close operations in a single call.

The high-level delete and rename sagas are also updated to take locks
on the files while performing the respective operations and will fail
if the file is already being used somewhere else.
2022-04-04 15:24:08 -05:00
David Lechner 1709591afc fileStorage: untangle file id/name
We were using file UUID and path interchangeable. This adds a new UUID
type for static checking and fixes a bunch of issues found.
2022-04-01 17:24:00 -05:00
David Lechner 1515e5ae4f fileStorage: add file handles
This changes how files work. There is now an open function that
translates a path to a file handle (id). Then this handle is used
to perform other actions on the file. The file contents are moved
to a separate table so that the actual file storage is independent
of the database (e.g. in the future, we may use File Access API).

We store a hash of the file contents in the metadata file so we can
detect file changes without having to compare file contents.

We also separate the change and add actions.
2022-04-01 13:41:10 -05:00
David Lechner 54a475cebc drop 'editor' saga context
This is no longer used.
2022-03-26 13:52:33 -05:00
David Lechner c158e4f0e2 editor: add editorGetValue() saga
This is another step towards removing the 'editor' context.
2022-03-26 13:44:55 -05:00
David Lechner 79d5b06136 editor: move isReady state from app
This is a step towards getting rid of the 'editor' context.
2022-03-26 12:03:08 -05:00
David Lechner 3eac7d384f fileStorage/sagas: remove editor init from fileStorage
This is still a bit of a hack but is one step towards being able to
remove the 'editor' context.
2022-03-26 11:49:23 -05:00
David Lechner 3c48d115d7 editor/Editor: use hooks to configure editor
This fixes the issue of the editor not being updated when properties
change.
2022-03-25 17:49:56 -05:00
David Lechner 2be1c26f82 editor/Editor: drop unused argument 2022-03-25 16:26:56 -05:00
David Lechner f36e774d1e coverage: ignore useI18n 2022-03-25 15:54:04 -05:00
David Lechner 9f254f035f i18n: use babel-loader plugin 2022-03-25 15:54:04 -05:00
David Lechner a4660e979c settings: switch to useTernaryDarkMode
useDarkMode kept reverting back to the system default during development
2022-03-15 17:40:46 -05:00
David Lechner 6cfc37b947 settings: use react hook for showDocs setting
The moves the setting from redux state to a react hook.
2022-03-15 15:35:45 -05:00
David Lechner 9518a21241 settings: replace darkMode with useDarkMode hook
This is a minor breaking change for users that don't have dark mode
set to the default value since the localStorage key has changed (hard-
coded in 3rd party library).
2022-03-14 16:39:17 -05:00
David Lechner c75f3720f5 editor: drop EditorContext
We want to rely less on directly accessing the editor object.
2022-03-12 18:29:56 -06:00
David Lechner ceeb34436f monaco-extension: add types for internal methods 2022-03-12 18:18:17 -06:00
David Lechner cf8438c689 toolbar: drop open and saveAs buttons
These have been replace by the explorer.
2022-03-12 15:45:36 -06:00
David Lechner 31fb3b9e4c test: drop state from AsyncSaga constructor params
This uses the real rootReducer to populate the initial state in the test
AsyncSaga. This way we don't have to populate default values. Since it
isn't used often, we can omit the parameter and just call the updateState()
method after creating the object if modifications are needed.
2022-03-11 16:04:09 -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 96f0dd16fd explorer: create new file wizard 2022-03-10 02:22:29 -06:00
David Lechner b37209683b test: extend testRender to return spy on dispatch 2022-03-10 02:00:14 -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 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