explorer: new delete alert dialog

This replaces the delete notification with a new alert dialog. This
makes for better keyboard interaction and forces the user to make a
decision before doing anything else.

Also fixes closing the editor before deleting the file.
This commit is contained in:
David Lechner
2022-04-08 12:53:12 -05:00
parent 1c30683b93
commit d238e68deb
16 changed files with 412 additions and 114 deletions
+36
View File
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
import { Reducer, combineReducers } from 'redux';
import {
deleteFileAlertDidAccept,
deleteFileAlertDidCancel,
deleteFileAlertShow,
} from './actions';
/** Controls the delete file alert dialog isOpen state. */
const isOpen: Reducer<boolean> = (state = false, action) => {
if (deleteFileAlertShow.matches(action)) {
return true;
}
if (
deleteFileAlertDidAccept.matches(action) ||
deleteFileAlertDidCancel.matches(action)
) {
return false;
}
return state;
};
/** Controls the file name displayed in the file alert dialog. */
const fileName: Reducer<string> = (state = '', action) => {
if (deleteFileAlertShow.matches(action)) {
return action.fileName;
}
return state;
};
export default combineReducers({ isOpen, fileName });