Added remove remote mount
This commit is contained in:
@@ -3,6 +3,45 @@ import {createAction} from 'redux-starter-kit';
|
||||
import {getIPCRenderer} from '../../utils';
|
||||
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
let yesNoResolvers = [];
|
||||
|
||||
export const confirmYesNo = title => {
|
||||
return dispatch => {
|
||||
return new Promise(resolve => {
|
||||
dispatch(handleConfirmYesNo(true, title, resolve));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const hideConfirmYesNo = confirmed => {
|
||||
return dispatch => {
|
||||
dispatch(handleConfirmYesNo(false, confirmed));
|
||||
};
|
||||
};
|
||||
|
||||
const handleConfirmYesNo = (show, titleOrConfirmed, resolve) => {
|
||||
return dispatch => {
|
||||
if (show) {
|
||||
yesNoResolvers.push(resolve);
|
||||
dispatch(displayConfirmYesNo(show, titleOrConfirmed))
|
||||
} else {
|
||||
yesNoResolvers[0](titleOrConfirmed);
|
||||
yesNoResolvers.splice(0, 1);
|
||||
dispatch(displayConfirmYesNo(false))
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const DISPLAY_CONFIRM_YES_NO = 'common/displayConfirmYesNo';
|
||||
const displayConfirmYesNo = (show, title) => {
|
||||
return {
|
||||
type: DISPLAY_CONFIRM_YES_NO,
|
||||
payload: {
|
||||
show,
|
||||
title
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const displaySelectAppPlatform = display => {
|
||||
return dispatch => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as Constants from '../../constants';
|
||||
import {createAction} from 'redux-starter-kit';
|
||||
import {getIPCRenderer} from '../../utils';
|
||||
import {confirmYesNo, displayConfirmYesNo} from './common_actions';
|
||||
|
||||
export const DISPLAY_CONFIGURATION = 'mounts/displayConfiguration';
|
||||
export const displayConfiguration = (provider, remote) => {
|
||||
@@ -13,6 +14,31 @@ export const displayConfiguration = (provider, remote) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const removeRemoteMount = provider => {
|
||||
return dispatch => {
|
||||
dispatch(confirmYesNo('Delete [' + provider.substr(6) + ']?'))
|
||||
.then(confirmed => {
|
||||
if (confirmed) {
|
||||
dispatch(removeRemoteMount2(provider));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const removeRemoteMount2 = provider => {
|
||||
return dispatch => {
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
ipcRenderer.once(Constants.IPC_Remove_Remote_Mount_Reply, (_, arg) => {
|
||||
if (arg.data.Success) {
|
||||
dispatch(removeRemoteMount3(provider));
|
||||
}
|
||||
});
|
||||
ipcRenderer.send(Constants.IPC_Remove_Remote_Mount, provider.substr(6));
|
||||
};
|
||||
};
|
||||
|
||||
export const removeRemoteMount3 = createAction('mounts/removeRemoteMount3');
|
||||
|
||||
export const RESET_MOUNTS_STATE = 'mounts/resetMountsState';
|
||||
export const resetMountsState = () => {
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {createReducer} from 'redux-starter-kit';
|
||||
import {
|
||||
DISPLAY_CONFIRM_YES_NO,
|
||||
notifyRebootRequired,
|
||||
setAllowMount,
|
||||
setApplicationReady,
|
||||
@@ -12,11 +13,20 @@ export const createCommonReducer = (platformInfo, version) => {
|
||||
AllowMount: false,
|
||||
AppPlatform: platformInfo.AppPlatform,
|
||||
AppReady: false,
|
||||
DisplayConfirmYesNo: false,
|
||||
ConfirmTitle: null,
|
||||
DisplaySelectAppPlatform: false,
|
||||
Platform: platformInfo.Platform,
|
||||
RebootRequired: false,
|
||||
Version: version,
|
||||
}, {
|
||||
[DISPLAY_CONFIRM_YES_NO]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
DisplayConfirmYesNo: action.payload.show,
|
||||
ConfirmTitle: action.payload.show ? action.payload.title : null,
|
||||
}
|
||||
},
|
||||
[SET_DISPLAY_SELECT_APPPLATFORM]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as Constants from '../../constants';
|
||||
import {createReducer} from 'redux-starter-kit';
|
||||
import {
|
||||
DISPLAY_CONFIGURATION,
|
||||
removeRemoteMount3,
|
||||
RESET_MOUNTS_STATE,
|
||||
SET_ALLOW_MOUNT,
|
||||
setAutoMountProcessed,
|
||||
@@ -62,6 +63,16 @@ export const createMountReducer = state => {
|
||||
DisplayRemoteConfiguration: action.payload.remote,
|
||||
};
|
||||
},
|
||||
[removeRemoteMount3]: (state, action) => {
|
||||
let providerState = {...state.ProviderState};
|
||||
delete providerState[action.payload];
|
||||
const remoteMounts = state.RemoteMounts.filter(i => i !== action.payload);
|
||||
return {
|
||||
...state,
|
||||
ProviderState: providerState,
|
||||
RemoteMounts: remoteMounts,
|
||||
};
|
||||
},
|
||||
[RESET_MOUNTS_STATE]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
|
||||
Reference in New Issue
Block a user