import { ofType, unionize, UnionOf } from '~/common/unionize';
import { Dispatch } from "redux";
-import { reset, stopSubmit, startSubmit } from 'redux-form';
+import { reset, stopSubmit, startSubmit, FormErrors } from 'redux-form';
import { AxiosInstance } from "axios";
import { RootState } from "../store";
import { snackbarActions } from '~/store/snackbar/snackbar-actions';
export const openPublicKeyDialog = (name: string, publicKey: string) =>
dialogActions.OPEN_DIALOG({ id: SSH_KEY_PUBLIC_KEY_DIALOG, data: { name, publicKey } });
-export const openSshKeyAttributesDialog = (index: number) =>
+export const openSshKeyAttributesDialog = (uuid: string) =>
(dispatch: Dispatch, getState: () => RootState) => {
- const sshKey = getState().auth.sshKeys[index];
+ const sshKey = getState().auth.sshKeys.find(it => it.uuid === uuid);
dispatch(dialogActions.OPEN_DIALOG({ id: SSH_KEY_ATTRIBUTES_DIALOG, data: { sshKey } }));
};
} catch (e) {
const error = getAuthorizedKeysServiceError(e);
if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
- dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' }));
+ dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' } as FormErrors));
} else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
- dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' }));
+ dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' } as FormErrors));
}
}
};