Support S3 delete
This commit is contained in:
@@ -159,8 +159,8 @@ exports.IPC_Install_Upgrade_Reply = 'install_upgrade_reply';
|
|||||||
exports.IPC_Mount_Drive = 'mount_drive';
|
exports.IPC_Mount_Drive = 'mount_drive';
|
||||||
exports.IPC_Mount_Drive_Reply = 'mount_drive_reply';
|
exports.IPC_Mount_Drive_Reply = 'mount_drive_reply';
|
||||||
|
|
||||||
exports.IPC_Remove_Remote_Mount = 'remove_remote_mount';
|
exports.IPC_Remove_Mount = 'remove_mount';
|
||||||
exports.IPC_Remove_Remote_Mount_Reply = 'remove_remote_mount_reply';
|
exports.IPC_Remove_Mount_Reply = 'remove_mount_reply';
|
||||||
|
|
||||||
exports.IPC_Reboot_System = 'reboot_system';
|
exports.IPC_Reboot_System = 'reboot_system';
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import configureImage from '../../../assets/images/configure.png';
|
|||||||
import RootElem from '../../../components/UI/RootElem/RootElem';
|
import RootElem from '../../../components/UI/RootElem/RootElem';
|
||||||
import {
|
import {
|
||||||
displayConfiguration,
|
displayConfiguration,
|
||||||
removeRemoteMount,
|
removeMount,
|
||||||
setProviderState
|
setProviderState
|
||||||
} from '../../../redux/actions/mount_actions';
|
} from '../../../redux/actions/mount_actions';
|
||||||
import {
|
import {
|
||||||
@@ -34,7 +34,7 @@ const mapDispatchToProps = dispatch => {
|
|||||||
displayConfiguration: (provider, remote, s3) => dispatch(displayConfiguration(provider, remote, s3)),
|
displayConfiguration: (provider, remote, s3) => dispatch(displayConfiguration(provider, remote, s3)),
|
||||||
displaySkynetExport: display => dispatch(displaySkynetExport(display)),
|
displaySkynetExport: display => dispatch(displaySkynetExport(display)),
|
||||||
displaySkynetImport: display => dispatch(displaySkynetImport(display)),
|
displaySkynetImport: display => dispatch(displaySkynetImport(display)),
|
||||||
removeRemoteMount: provider => dispatch(removeRemoteMount(provider)),
|
removeMount: provider => dispatch(removeMount(provider)),
|
||||||
setProviderState: (provider, state) => dispatch(setProviderState(provider, state)),
|
setProviderState: (provider, state) => dispatch(setProviderState(provider, state)),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -155,14 +155,14 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let removeControl;
|
let removeControl;
|
||||||
if (props.remote) {
|
if (props.allowRemove) {
|
||||||
const removeDisabled = !props.MState.AllowMount || props.MState.Mounted;
|
const removeDisabled = !props.MState.AllowMount || props.MState.Mounted;
|
||||||
const removeStyle = {
|
const removeStyle = {
|
||||||
cursor: removeDisabled ? 'no-drop' : 'pointer'
|
cursor: removeDisabled ? 'no-drop' : 'pointer'
|
||||||
};
|
};
|
||||||
const handleRemoveMount = () => {
|
const handleRemoveMount = () => {
|
||||||
if (!removeDisabled) {
|
if (!removeDisabled) {
|
||||||
props.removeRemoteMount(props.provider);
|
props.removeMount(props.provider);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
removeControl = (
|
removeControl = (
|
||||||
|
|||||||
@@ -95,31 +95,36 @@ export const displayConfiguration = (provider, remote, s3) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const removeRemoteMount = provider => {
|
export const removeMount = provider => {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch(confirmYesNo('Delete [' + provider.substr(6) + ']?'))
|
const isRemote = provider.startsWith('Remote');
|
||||||
|
dispatch(confirmYesNo('Delete [' + provider.substr(isRemote ? 6 : 2) + ']?'))
|
||||||
.then(confirmed => {
|
.then(confirmed => {
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
dispatch(removeRemoteMount2(provider));
|
dispatch(removeMount2(provider));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeRemoteMount2 = provider => {
|
const removeMount2 = provider => {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
const ipcRenderer = getIPCRenderer();
|
const ipcRenderer = getIPCRenderer();
|
||||||
ipcRenderer.once(Constants.IPC_Remove_Remote_Mount_Reply, (_, arg) => {
|
ipcRenderer.once(Constants.IPC_Remove_Mount_Reply, (_, arg) => {
|
||||||
if (arg.data.Success) {
|
if (arg.data.Success) {
|
||||||
dispatch(removeRemoteMount3(provider));
|
dispatch(removeMount3(provider));
|
||||||
dispatch(saveState());
|
dispatch(saveState());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ipcRenderer.send(Constants.IPC_Remove_Remote_Mount, provider.substr(6));
|
const isRemote = provider.startsWith('Remote');
|
||||||
|
ipcRenderer.send(Constants.IPC_Remove_Mount, {
|
||||||
|
Remote: isRemote,
|
||||||
|
Name: provider.substr(isRemote ? 6 : 2)
|
||||||
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const removeRemoteMount3 = createAction('mounts/removeRemoteMount3');
|
export const removeMount3 = createAction('mounts/removeMount3');
|
||||||
|
|
||||||
export const RESET_MOUNTS_STATE = 'mounts/resetMountsState';
|
export const RESET_MOUNTS_STATE = 'mounts/resetMountsState';
|
||||||
export const resetMountsState = () => {
|
export const resetMountsState = () => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
addRemoteMount2,
|
addRemoteMount2,
|
||||||
addS3Mount2,
|
addS3Mount2,
|
||||||
DISPLAY_CONFIGURATION,
|
DISPLAY_CONFIGURATION,
|
||||||
removeRemoteMount3,
|
removeMount3,
|
||||||
RESET_MOUNTS_STATE,
|
RESET_MOUNTS_STATE,
|
||||||
SET_ALLOW_MOUNT,
|
SET_ALLOW_MOUNT,
|
||||||
SET_AUTO_MOUNT_PROCESSED,
|
SET_AUTO_MOUNT_PROCESSED,
|
||||||
@@ -126,7 +126,7 @@ export const createMountReducer = state => {
|
|||||||
DisplayS3Configuration: action.payload.s3,
|
DisplayS3Configuration: action.payload.s3,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[removeRemoteMount3]: (state, action) => {
|
[removeMount3]: (state, action) => {
|
||||||
let mountState = {...state.MountState};
|
let mountState = {...state.MountState};
|
||||||
delete mountState[action.payload];
|
delete mountState[action.payload];
|
||||||
|
|
||||||
@@ -138,12 +138,15 @@ export const createMountReducer = state => {
|
|||||||
|
|
||||||
const remoteMounts =
|
const remoteMounts =
|
||||||
state.RemoteMounts.filter(i => i !== action.payload);
|
state.RemoteMounts.filter(i => i !== action.payload);
|
||||||
|
const s3Mounts =
|
||||||
|
state.S3Mounts.filter(i => i !== action.payload);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
AutoMountProcessed: autoMountProcessed,
|
AutoMountProcessed: autoMountProcessed,
|
||||||
MountState: mountState,
|
MountState: mountState,
|
||||||
ProviderState: providerState,
|
ProviderState: providerState,
|
||||||
RemoteMounts: remoteMounts,
|
RemoteMounts: remoteMounts,
|
||||||
|
S3Mounts: s3Mounts,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[RESET_MOUNTS_STATE]: (state, action) => {
|
[RESET_MOUNTS_STATE]: (state, action) => {
|
||||||
|
|||||||
@@ -241,15 +241,17 @@ const addListeners = (ipcMain, {setTrayImage, standardIPCReply}) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Remove_Remote_Mount, (event, data) => {
|
ipcMain.on(Constants.IPC_Remove_Mount, (event, data) => {
|
||||||
data = data.replace(':', '_');
|
if (data.Remote) {
|
||||||
const dataDirectory = path.resolve(path.join(helpers.getDataDirectory(), '..', 'remote', data));
|
data.Name = data.Name.replace(':', '_');
|
||||||
|
}
|
||||||
|
const dataDirectory = path.resolve(path.join(helpers.getDataDirectory(), '..', data.Remote ? 'remote' : 's3', data.Name));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
helpers.removeDirectoryRecursively(dataDirectory);
|
helpers.removeDirectoryRecursively(dataDirectory);
|
||||||
standardIPCReply(event, Constants.IPC_Remove_Remote_Mount_Reply, {DataDirectory: dataDirectory});
|
standardIPCReply(event, Constants.IPC_Remove_Mount_Reply, {DataDirectory: dataDirectory});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
standardIPCReply(event, Constants.IPC_Remove_Remote_Mount_Reply, {DataDirectory: dataDirectory}, e);
|
standardIPCReply(event, Constants.IPC_Remove_Mount_Reply, {DataDirectory: dataDirectory}, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user