Skip to content

Commit

Permalink
Upgrade file-selector becasue of react-dropzone/react-dropzone#1397 (…
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Jan 26, 2025
1 parent 4b5e322 commit 9d3c0e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/adapter-react-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@mui/material": "^6.4.1",
"@sentry/browser": "^8.51.0",
"cronstrue": "^2.53.0",
"file-selector": "^2.1.2",
"react-color": "^2.19.3",
"react-colorful": "^5.6.1",
"react-cropper": "^2.3.3",
Expand Down
30 changes: 19 additions & 11 deletions packages/adapter-react-v5/src/Components/FileBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
Input,
Breadcrumbs,
Box,
Checkbox,
FormControlLabel,
} from '@mui/material';

// MUI Icons
Expand Down Expand Up @@ -559,6 +561,7 @@ interface FileBrowserState {
addFolder: boolean;
uploadFile: boolean | 'dragging';
deleteItem: string;
suppressDeleteConfirm: boolean;
viewer: string;
formatEditFile: string | null;
path: string;
Expand Down Expand Up @@ -715,6 +718,7 @@ export class FileBrowserClass extends Component<FileBrowserProps, FileBrowserSta
showTypesMenu: null,
restrictToFolder: props.restrictToFolder || '',
pathFocus: false,
suppressDeleteConfirm: false,
};

this.imagePrefix = this.props.imagePrefix || './files/';
Expand Down Expand Up @@ -2283,8 +2287,11 @@ export class FileBrowserClass extends Component<FileBrowserProps, FileBrowserSta

deleteItem(deleteItem: string): void {
deleteItem = deleteItem || this.state.deleteItem;
if (this.state.suppressDeleteConfirm) {
this.suppressDeleteConfirm = Date.now() + 60000 * 5;
}

this.setState({ deleteItem: '' }, () =>
this.setState({ deleteItem: '', suppressDeleteConfirm: false }, () =>
this.deleteRecursive(deleteItem).then(() => {
const newState: Partial<FileBrowserState> = {};
const pos = this.state.expanded.indexOf(deleteItem);
Expand Down Expand Up @@ -2341,18 +2348,19 @@ export class FileBrowserClass extends Component<FileBrowserProps, FileBrowserSta
</DialogTitle>
<DialogContent>
<DialogContentText>{this.props.t('ra_Are you sure?')}</DialogContentText>
<FormControlLabel
control={
<Checkbox
checked={this.state.suppressDeleteConfirm}
onChange={() => {
this.setState({ suppressDeleteConfirm: !this.state.suppressDeleteConfirm });
}}
/>
}
label={this.props.t('ra_no confirm for 5 mins')}
/>
</DialogContent>
<DialogActions>
<Button
color="grey"
variant="contained"
onClick={() => {
this.suppressDeleteConfirm = Date.now() + 60000 * 5;
this.deleteItem('');
}}
>
{this.props.t('ra_Delete (no confirm for 5 mins)')}
</Button>
<Button
variant="contained"
onClick={() => this.deleteItem('')}
Expand Down

0 comments on commit 9d3c0e3

Please sign in to comment.