summaryrefslogtreecommitdiff
path: root/app/client
diff options
context:
space:
mode:
Diffstat (limited to 'app/client')
-rw-r--r--app/client/dataset/dataset.reducer.js1
-rw-r--r--app/client/modules/pix2pixhd/pix2pixhd.reducer.js12
-rw-r--r--app/client/modules/pix2pixhd/views/pix2pixhd.results.js22
3 files changed, 34 insertions, 1 deletions
diff --git a/app/client/dataset/dataset.reducer.js b/app/client/dataset/dataset.reducer.js
index 6b51715..3c2dddd 100644
--- a/app/client/dataset/dataset.reducer.js
+++ b/app/client/dataset/dataset.reducer.js
@@ -169,6 +169,7 @@ function handleFileUpdate(state, action){
}
function handleFileDestroy(state, action){
+ if (! state.data) return
// delete the key from fileLookup
let fileLookup = {
...state.data.fileLookup
diff --git a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js
index b6264ed..6b2366c 100644
--- a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js
+++ b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js
@@ -21,6 +21,18 @@ const pix2pixhdReducer = (state = pix2pixhdInitialState, action) => {
...state,
results: action.results,
}
+ case types.file.destroy:
+ console.log('file destroy', state.results)
+ if (! state.results) {
+ return state
+ }
+ return {
+ ...state,
+ results: {
+ ...state.results,
+ files: state.results.files.filter(file.id !== action.data.id)
+ }
+ }
default:
return state
}
diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.results.js b/app/client/modules/pix2pixhd/views/pix2pixhd.results.js
index d92a403..741060b 100644
--- a/app/client/modules/pix2pixhd/views/pix2pixhd.results.js
+++ b/app/client/modules/pix2pixhd/views/pix2pixhd.results.js
@@ -4,17 +4,24 @@ import { Link } from 'react-router-dom';
import { connect } from 'react-redux'
import util from '../../../util'
+import actions from '../../../actions'
+
import * as pix2pixhdActions from '../pix2pixhd.actions'
import * as pix2pixhdTasks from '../pix2pixhd.tasks'
import Loading from '../../../common/loading.component'
import { FileList, FileRow } from '../../../common/fileList.component'
+let yes_count = 0
+
class Pix2pixHDResults extends Component {
constructor(props){
super()
if (!props.pix2pixhd.results) props.actions.load_results()
}
+ componentDidMount(){
+ yes_count = 0
+ }
render(){
if (! this.props.pix2pixhd.results) return <Loading progress={this.props.pix2pixhd.progress} />
@@ -32,7 +39,20 @@ class Pix2pixHDResults extends Component {
linkFiles
files={files}
orderBy='date desc'
- fields={'name date size'}
+ fields={'name date size delete'}
+ onDelete={file => {
+ let yes;
+ if (yes_count < 3) {
+ yes = confirm('Are you sure you want to delete this file?')
+ } else {
+ yes = true
+ }
+ if (yes) {
+ yes_count += 1
+ console.log('delete: confirmed')
+ actions.file.destroy(file)
+ }
+ }}
/>
<br />