Add remote mount
This commit is contained in:
@@ -5,6 +5,43 @@ import {
|
||||
confirmYesNo,
|
||||
saveState
|
||||
} from './common_actions';
|
||||
import {notifyError} from './error_actions';
|
||||
|
||||
export const addRemoteMount = (hostNameOrIp, port, token) => {
|
||||
return (dispatch, getState) => {
|
||||
const ipcRenderer = getIPCRenderer();
|
||||
|
||||
const provider = 'Remote' + hostNameOrIp + ':' + port;
|
||||
dispatch(addRemoteMount2(provider));
|
||||
dispatch(setBusy(true));
|
||||
|
||||
ipcRenderer.once(Constants.IPC_Set_Config_Values_Reply, (_, arg) => {
|
||||
if (arg.data.Success) {
|
||||
ipcRenderer.send(Constants.IPC_Detect_Mounts, {
|
||||
RemoteMounts: getState().mounts.RemoteMounts,
|
||||
Version: getState().relver.InstalledVersion,
|
||||
});
|
||||
} else {
|
||||
dispatch(notifyError('Failed to set \'RemoteToken\': ' + arg.data.Error));
|
||||
dispatch(setBusy(false));
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.send(Constants.IPC_Set_Config_Values, {
|
||||
Items: [
|
||||
{Name: 'RemoteMount.RemoteHostNameOrIp', Value: hostNameOrIp},
|
||||
{Name: 'RemoteMount.RemoteToken', Value: token},
|
||||
{Name: 'RemoteMount.RemotePort', Value: port},
|
||||
{Name: 'RemoteMount.IsRemoteMount', Value: 'true'},
|
||||
],
|
||||
Provider: provider,
|
||||
Remote: true,
|
||||
Version: getState().relver.InstalledVersion,
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const addRemoteMount2 = createAction('mounts/addRemoteMount2');
|
||||
|
||||
export const DISPLAY_CONFIGURATION = 'mounts/displayConfiguration';
|
||||
export const displayConfiguration = (provider, remote) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as Constants from '../../constants';
|
||||
import {createReducer} from 'redux-starter-kit';
|
||||
import {
|
||||
addRemoteMount2,
|
||||
DISPLAY_CONFIGURATION,
|
||||
removeRemoteMount3,
|
||||
RESET_MOUNTS_STATE,
|
||||
@@ -56,6 +57,27 @@ export const createMountReducer = state => {
|
||||
ProviderState: providerState,
|
||||
RemoteMounts: state.RemoteMounts ? state.RemoteMounts : ['Remotelocalhost:20000'],
|
||||
}, {
|
||||
[addRemoteMount2]: (state, action) => {
|
||||
let mountState = {...state.MountState};
|
||||
mountState[action.payload] = {
|
||||
AllowMount: false,
|
||||
DriveLetters: [],
|
||||
Mounted: false,
|
||||
};
|
||||
|
||||
let providerState = {...state.ProviderState};
|
||||
providerState[action.payload] = {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
};
|
||||
return {
|
||||
...state,
|
||||
MountState: mountState,
|
||||
ProviderState: providerState,
|
||||
RemoteMounts: [...state.RemoteMounts, action.payload],
|
||||
}
|
||||
},
|
||||
[DISPLAY_CONFIGURATION]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
|
||||
Reference in New Issue
Block a user