X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/e1605f7c93aeb41ae31e0dd88a9afd8709136b62..refs/heads/18881-process-runtime-status:/src/store/auth/auth-action-ssh.ts diff --git a/src/store/auth/auth-action-ssh.ts b/src/store/auth/auth-action-ssh.ts index 2c3a2722..3ba5f3a9 100644 --- a/src/store/auth/auth-action-ssh.ts +++ b/src/store/auth/auth-action-ssh.ts @@ -2,21 +2,20 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { dialogActions } from "~/store/dialog/dialog-actions"; +import { dialogActions } from "store/dialog/dialog-actions"; import { Dispatch } from "redux"; -import { RootState } from "~/store/store"; -import { ServiceRepository } from "~/services/services"; -import { snackbarActions } from "~/store/snackbar/snackbar-actions"; +import { RootState } from "store/store"; +import { getUserUuid } from "common/getuser"; +import { ServiceRepository } from "services/services"; +import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; import { FormErrors, reset, startSubmit, stopSubmit } from "redux-form"; -import { KeyType } from "~/models/ssh-key"; +import { KeyType } from "models/ssh-key"; import { AuthorizedKeysServiceError, getAuthorizedKeysServiceError -} from "~/services/authorized-keys-service/authorized-keys-service"; -import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions"; -import { - authActions, -} from "~/store/auth/auth-action"; +} from "services/authorized-keys-service/authorized-keys-service"; +import { setBreadcrumbs } from "store/breadcrumbs/breadcrumbs-actions"; +import { authActions } from "store/auth/auth-action"; export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName'; export const SSH_KEY_PUBLIC_KEY_DIALOG = 'sshKeyPublicKeyDialog'; @@ -54,15 +53,16 @@ export const openSshKeyRemoveDialog = (uuid: string) => export const removeSshKey = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...', kind: SnackbarKind.INFO })); await services.authorizedKeysService.delete(uuid); dispatch(authActions.REMOVE_SSH_KEY(uuid)); - dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Public Key has been successfully removed.', hideDuration: 2000 })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Public Key has been successfully removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS })); }; export const createSshKey = (data: SshKeyCreateFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const userUuid = getState().auth.user!.uuid; + const userUuid = getUserUuid(getState()); + if (!userUuid) { return; } const { name, publicKey } = data; dispatch(startSubmit(SSH_KEY_CREATE_FORM_NAME)); try { @@ -77,7 +77,8 @@ export const createSshKey = (data: SshKeyCreateFormDialogData) => dispatch(reset(SSH_KEY_CREATE_FORM_NAME)); dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Public key has been successfully created.", - hideDuration: 2000 + hideDuration: 2000, + kind: SnackbarKind.SUCCESS })); } catch (e) { const error = getAuthorizedKeysServiceError(e); @@ -92,11 +93,10 @@ export const createSshKey = (data: SshKeyCreateFormDialogData) => export const loadSshKeysPanel = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { try { - dispatch(setBreadcrumbs([{ label: 'SSH Keys'}])); + dispatch(setBreadcrumbs([{ label: 'SSH Keys' }])); const response = await services.authorizedKeysService.list(); dispatch(authActions.SET_SSH_KEYS(response.items)); } catch (e) { return; } }; -