mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
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:
@@ -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 });
|
||||
Reference in New Issue
Block a user