[ARVADOS-WORKBENCH2] updated: 1.4.1-87-gceb4f50a
Git user
git at public.curoverse.com
Mon Nov 4 21:36:04 UTC 2019
Summary of changes:
src/store/auth/auth-action-session.ts | 36 +++++++++++++---------
src/store/auth/auth-action.test.ts | 6 ++--
.../site-manager-panel/site-manager-panel-root.tsx | 9 +++++-
.../site-manager-panel/site-manager-panel.tsx | 7 +++--
4 files changed, 38 insertions(+), 20 deletions(-)
via ceb4f50aeca2bb6b0354a7bd96a599b4a14147fe (commit)
from d6538e3ec3a545258ff9073ef88501fe2c75a4f0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit ceb4f50aeca2bb6b0354a7bd96a599b4a14147fe
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date: Mon Nov 4 16:34:39 2019 -0500
15736: Add delete button to site manager
* Add delete button to remove sessions from site manager
* Adjust error handling flow in validateSession to ensure that
failures still are marked as finished validating
* Fix tests
diff --git a/src/store/auth/auth-action-session.ts b/src/store/auth/auth-action-session.ts
index 9190dc1a..2a9733f0 100644
--- a/src/store/auth/auth-action-session.ts
+++ b/src/store/auth/auth-action-session.ts
@@ -139,28 +139,27 @@ export const validateSession = (session: Session, activeSession: Session) =>
session.loggedIn = true;
};
- const info = await getRemoteHostInfo(session.remoteHost);
- if (!info) {
- throw new Error(`Could not get config for ${session.remoteHost}`);
- }
-
let fail: Error | null = null;
- try {
- const { user, token } = await validateCluster(info, session.token);
- setupSession(info.baseUrl, user, token);
- } catch (e) {
- fail = new Error(`Getting current user for ${session.remoteHost}: ${e.message}`);
+ const info = await getRemoteHostInfo(session.remoteHost);
+ if (info !== null) {
try {
- const { user, token } = await validateCluster(info, activeSession.token);
+ const { user, token } = await validateCluster(info, session.token);
setupSession(info.baseUrl, user, token);
- fail = null;
} catch (e) {
- if (e.message === invalidV2Token) {
- fail = new Error(`Getting current user for ${session.remoteHost}: ${e.message}`);
+ fail = new Error(`Getting current user for ${session.remoteHost}: ${e.message}`);
+ try {
+ const { user, token } = await validateCluster(info, activeSession.token);
+ setupSession(info.baseUrl, user, token);
+ fail = null;
+ } catch (e2) {
+ if (e.message === invalidV2Token) {
+ fail = new Error(`Getting current user for ${session.remoteHost}: ${e2.message}`);
+ }
}
}
+ } else {
+ fail = new Error(`Could not get config for ${session.remoteHost}`);
}
-
session.status = SessionStatus.VALIDATED;
dispatch(authActions.UPDATE_SESSION(session));
@@ -259,6 +258,13 @@ export const addSession = (remoteHost: string, token?: string, sendToLogin?: boo
return Promise.reject(new Error("Could not validate cluster"));
};
+
+export const removeSession = (clusterId: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ await dispatch(authActions.REMOVE_SESSION(clusterId));
+ services.authService.saveSessions(getState().auth.sessions);
+ };
+
export const toggleSession = (session: Session) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
const s: Session = { ...session };
diff --git a/src/store/auth/auth-action.test.ts b/src/store/auth/auth-action.test.ts
index 801d9e33..a543fc18 100644
--- a/src/store/auth/auth-action.test.ts
+++ b/src/store/auth/auth-action.test.ts
@@ -90,7 +90,8 @@ describe('auth-actions', () => {
"remoteHost": "https://zzzzz.arvadosapi.com",
"status": 2,
"token": "token",
- "username": "John Doe"
+ "name": "John Doe"
+ "uuid": "zzzzz-tpzed-abcefg",
}, {
"active": false,
"baseUrl": "",
@@ -100,7 +101,8 @@ describe('auth-actions', () => {
"remoteHost": "xc59z.arvadosapi.com",
"status": 1,
"token": "",
- "username": ""
+ "name": "",
+ "uuid": "",
}],
user: {
email: "test at test.com",
diff --git a/src/views/site-manager-panel/site-manager-panel-root.tsx b/src/views/site-manager-panel/site-manager-panel-root.tsx
index f4022111..bc2303da 100644
--- a/src/views/site-manager-panel/site-manager-panel-root.tsx
+++ b/src/views/site-manager-panel/site-manager-panel-root.tsx
@@ -8,6 +8,7 @@ import {
CardContent,
CircularProgress,
Grid,
+ IconButton,
StyleRulesCallback,
Table,
TableBody,
@@ -28,6 +29,7 @@ import { addSession } from "~/store/auth/auth-action-session";
import { SITE_MANAGER_REMOTE_HOST_VALIDATION } from "~/validators/validators";
import { Config } from '~/common/config';
import { ResourceCluster } from '~/views-components/data-explorer/renderers';
+import { TrashIcon } from "~/components/icon/icon";
type CssRules = 'root' | 'link' | 'buttonContainer' | 'table' | 'tableRow' |
'remoteSiteInfo' | 'buttonAdd' | 'buttonLoggedIn' | 'buttonLoggedOut' |
@@ -86,6 +88,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
export interface SiteManagerPanelRootActionProps {
toggleSession: (session: Session) => void;
+ removeSession: (session: Session) => void;
}
export interface SiteManagerPanelRootDataProps {
@@ -117,7 +120,7 @@ export const SiteManagerPanelRoot = compose(
}
}),
withStyles(styles))
- (({ classes, sessions, handleSubmit, toggleSession, remoteHostsConfig }: SiteManagerPanelRootProps) =>
+ (({ classes, sessions, handleSubmit, toggleSession, removeSession, remoteHostsConfig }: SiteManagerPanelRootProps) =>
<Card className={classes.root}>
<CardContent>
<Grid container direction="row">
@@ -136,6 +139,7 @@ export const SiteManagerPanelRoot = compose(
<TableCell>Email</TableCell>
<TableCell>UUID</TableCell>
<TableCell>Status</TableCell>
+ <TableCell>Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>
@@ -156,6 +160,9 @@ export const SiteManagerPanelRoot = compose(
{validating ? "Validating" : (session.loggedIn ? "Logged in" : "Logged out")}
</Button>
</TableCell>
+ <IconButton onClick={() => removeSession(session)}>
+ <TrashIcon />
+ </IconButton>
</TableRow>;
})}
</TableBody>
diff --git a/src/views/site-manager-panel/site-manager-panel.tsx b/src/views/site-manager-panel/site-manager-panel.tsx
index 0f48565d..59897f2c 100644
--- a/src/views/site-manager-panel/site-manager-panel.tsx
+++ b/src/views/site-manager-panel/site-manager-panel.tsx
@@ -10,7 +10,7 @@ import {
SiteManagerPanelRootDataProps
} from "~/views/site-manager-panel/site-manager-panel-root";
import { Session } from "~/models/session";
-import { toggleSession } from "~/store/auth/auth-action-session";
+import { toggleSession, removeSession } from "~/store/auth/auth-action-session";
const mapStateToProps = (state: RootState): SiteManagerPanelRootDataProps => {
return {
@@ -22,7 +22,10 @@ const mapStateToProps = (state: RootState): SiteManagerPanelRootDataProps => {
const mapDispatchToProps = (dispatch: Dispatch): SiteManagerPanelRootActionProps => ({
toggleSession: (session: Session) => {
dispatch<any>(toggleSession(session));
- }
+ },
+ removeSession: (session: Session) => {
+ dispatch<any>(removeSession(session.clusterId));
+ },
});
export const SiteManagerPanel = connect(mapStateToProps, mapDispatchToProps)(SiteManagerPanelRoot);
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list