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));
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 };
"remoteHost": "https://zzzzz.arvadosapi.com",
"status": 2,
"token": "token",
- "username": "John Doe"
+ "name": "John Doe"
+ "uuid": "zzzzz-tpzed-abcefg",
}, {
"active": false,
"baseUrl": "",
"remoteHost": "xc59z.arvadosapi.com",
"status": 1,
"token": "",
- "username": ""
+ "name": "",
+ "uuid": "",
}],
user: {
email: "test@test.com",
CardContent,
CircularProgress,
Grid,
+ IconButton,
StyleRulesCallback,
Table,
TableBody,
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' |
export interface SiteManagerPanelRootActionProps {
toggleSession: (session: Session) => void;
+ removeSession: (session: Session) => void;
}
export interface SiteManagerPanelRootDataProps {
}
}),
withStyles(styles))
- (({ classes, sessions, handleSubmit, toggleSession, remoteHostsConfig }: SiteManagerPanelRootProps) =>
+ (({ classes, sessions, handleSubmit, toggleSession, removeSession, remoteHostsConfig }: SiteManagerPanelRootProps) =>
<Card className={classes.root}>
<CardContent>
<Grid container direction="row">
<TableCell>Email</TableCell>
<TableCell>UUID</TableCell>
<TableCell>Status</TableCell>
+ <TableCell>Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>
{validating ? "Validating" : (session.loggedIn ? "Logged in" : "Logged out")}
</Button>
</TableCell>
+ <IconButton onClick={() => removeSession(session)}>
+ <TrashIcon />
+ </IconButton>
</TableRow>;
})}
</TableBody>
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 {
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);