[ARVADOS-WORKBENCH2] updated: 1.3.1-367-g2ba76201
Git user
git at public.curoverse.com
Mon Feb 25 15:18:13 EST 2019
Summary of changes:
src/models/user.ts | 1 +
src/services/auth-service/auth-service.ts | 15 ++++-
src/store/auth/auth-action-session.ts | 1 +
src/store/auth/auth-action.test.ts | 11 ++-
src/store/auth/auth-reducer.test.ts | 9 ++-
src/views-components/main-app-bar/account-menu.tsx | 14 ++--
src/views-components/main-app-bar/main-app-bar.tsx | 2 +-
src/views/inactive-panel/inactive-panel.tsx | 78 ++++++++++++++++++++++
.../inactive-panel.tsx~} | 0
src/views/login-panel/login-panel.tsx | 2 +-
src/views/main-panel/main-panel-root.tsx | 3 +-
11 files changed, 120 insertions(+), 16 deletions(-)
create mode 100644 src/views/inactive-panel/inactive-panel.tsx
copy src/views/{login-panel/login-panel.tsx => inactive-panel/inactive-panel.tsx~} (100%)
via 2ba76201944d5ad4ef84aaf16c18f5bbb38a8b89 (commit)
from 8f09b3335729ba3c15c2c55c088b569cae56e6b4 (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 2ba76201944d5ad4ef84aaf16c18f5bbb38a8b89
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date: Mon Feb 25 15:17:42 2019 -0500
14841: Add inactive user page.
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/src/models/user.ts b/src/models/user.ts
index 6477dc53..24978645 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -23,6 +23,7 @@ export interface User {
username: string;
prefs: UserPrefs;
isAdmin: boolean;
+ isActive: boolean;
}
export const getUserFullname = (user?: User) => {
diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts
index 3fd67fc0..8ce8034e 100644
--- a/src/services/auth-service/auth-service.ts
+++ b/src/services/auth-service/auth-service.ts
@@ -17,6 +17,7 @@ export const USER_LAST_NAME_KEY = 'userLastName';
export const USER_UUID_KEY = 'userUuid';
export const USER_OWNER_UUID_KEY = 'userOwnerUuid';
export const USER_IS_ADMIN = 'isAdmin';
+export const USER_IS_ACTIVE = 'isActive';
export const USER_USERNAME = 'username';
export const USER_PREFS = 'prefs';
@@ -27,6 +28,7 @@ export interface UserDetailsResponse {
uuid: string;
owner_uuid: string;
is_admin: boolean;
+ is_active: boolean;
username: string;
prefs: UserPrefs;
}
@@ -62,6 +64,11 @@ export class AuthService {
return localStorage.getItem(USER_IS_ADMIN) === 'true';
}
+ public getIsActive(): boolean {
+ console.log(`uia ${localStorage.getItem(USER_IS_ACTIVE)}`)
+ return localStorage.getItem(USER_IS_ACTIVE) === 'true';
+ }
+
public getUser(): User | undefined {
const email = localStorage.getItem(USER_EMAIL_KEY);
const firstName = localStorage.getItem(USER_FIRST_NAME_KEY);
@@ -69,11 +76,14 @@ export class AuthService {
const uuid = this.getUuid();
const ownerUuid = this.getOwnerUuid();
const isAdmin = this.getIsAdmin();
+ const isActive = this.getIsActive();
const username = localStorage.getItem(USER_USERNAME);
const prefs = JSON.parse(localStorage.getItem(USER_PREFS) || '{"profile": {}}');
+ console.log(`leg! ${isActive}`)
+
return email && firstName && lastName && uuid && ownerUuid && username && prefs
- ? { email, firstName, lastName, uuid, ownerUuid, isAdmin, username, prefs }
+ ? { email, firstName, lastName, uuid, ownerUuid, isAdmin, isActive, username, prefs }
: undefined;
}
@@ -84,6 +94,7 @@ export class AuthService {
localStorage.setItem(USER_UUID_KEY, user.uuid);
localStorage.setItem(USER_OWNER_UUID_KEY, user.ownerUuid);
localStorage.setItem(USER_IS_ADMIN, JSON.stringify(user.isAdmin));
+ localStorage.setItem(USER_IS_ACTIVE, JSON.stringify(user.isActive));
localStorage.setItem(USER_USERNAME, user.username);
localStorage.setItem(USER_PREFS, JSON.stringify(user.prefs));
}
@@ -95,6 +106,7 @@ export class AuthService {
localStorage.removeItem(USER_UUID_KEY);
localStorage.removeItem(USER_OWNER_UUID_KEY);
localStorage.removeItem(USER_IS_ADMIN);
+ localStorage.removeItem(USER_IS_ACTIVE);
localStorage.removeItem(USER_USERNAME);
localStorage.removeItem(USER_PREFS);
}
@@ -124,6 +136,7 @@ export class AuthService {
uuid: resp.data.uuid,
ownerUuid: resp.data.owner_uuid,
isAdmin: resp.data.is_admin,
+ isActive: resp.data.is_active,
username: resp.data.username,
prefs
};
diff --git a/src/store/auth/auth-action-session.ts b/src/store/auth/auth-action-session.ts
index 986230ed..5bb192b8 100644
--- a/src/store/auth/auth-action-session.ts
+++ b/src/store/auth/auth-action-session.ts
@@ -92,6 +92,7 @@ const clusterLogin = async (clusterId: string, baseUrl: string, activeSession: S
ownerUuid: user.owner_uuid,
email: user.email,
isAdmin: user.is_admin,
+ isActive: user.is_active,
username: user.username,
prefs: user.prefs
},
diff --git a/src/store/auth/auth-action.test.ts b/src/store/auth/auth-action.test.ts
index db3211c4..11f29e45 100644
--- a/src/store/auth/auth-action.test.ts
+++ b/src/store/auth/auth-action.test.ts
@@ -11,7 +11,10 @@ import {
USER_LAST_NAME_KEY,
USER_OWNER_UUID_KEY,
USER_UUID_KEY,
- USER_IS_ADMIN, USER_USERNAME, USER_PREFS
+ USER_IS_ADMIN,
+ USER_IS_ACTIVE,
+ USER_USERNAME,
+ USER_PREFS
} from "~/services/auth-service/auth-service";
import 'jest-localstorage-mock';
@@ -45,7 +48,8 @@ describe('auth-actions', () => {
localStorage.setItem(USER_USERNAME, "username");
localStorage.setItem(USER_PREFS, JSON.stringify({}));
localStorage.setItem(USER_OWNER_UUID_KEY, "ownerUuid");
- localStorage.setItem(USER_IS_ADMIN, JSON.stringify("false"));
+ localStorage.setItem(USER_IS_ADMIN, JSON.stringify(false));
+ localStorage.setItem(USER_IS_ACTIVE, JSON.stringify(true));
const config: any = {
rootUrl: "https://zzzzz.arvadosapi.com",
@@ -93,7 +97,8 @@ describe('auth-actions', () => {
ownerUuid: "ownerUuid",
username: "username",
prefs: {},
- isAdmin: false
+ isAdmin: false,
+ isActive: true
}
});
});
diff --git a/src/store/auth/auth-reducer.test.ts b/src/store/auth/auth-reducer.test.ts
index 166f6d30..38cf1581 100644
--- a/src/store/auth/auth-reducer.test.ts
+++ b/src/store/auth/auth-reducer.test.ts
@@ -32,7 +32,8 @@ describe('auth-reducer', () => {
ownerUuid: "ownerUuid",
username: "username",
prefs: {},
- isAdmin: false
+ isAdmin: false,
+ isActive: true
};
const state = reducer(initialState, authActions.INIT({ user, token: "token" }));
expect(state).toEqual({
@@ -72,7 +73,8 @@ describe('auth-reducer', () => {
ownerUuid: "ownerUuid",
username: "username",
prefs: {},
- isAdmin: false
+ isAdmin: false,
+ isActive: true
};
const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user));
@@ -91,7 +93,8 @@ describe('auth-reducer', () => {
ownerUuid: "ownerUuid",
username: "username",
prefs: {},
- isAdmin: false
+ isAdmin: false,
+ isActive: true
}
});
});
diff --git a/src/views-components/main-app-bar/account-menu.tsx b/src/views-components/main-app-bar/account-menu.tsx
index 16bb8c13..3481814d 100644
--- a/src/views-components/main-app-bar/account-menu.tsx
+++ b/src/views-components/main-app-bar/account-menu.tsx
@@ -68,12 +68,14 @@ export const AccountMenu = withStyles(styles)(
<MenuItem disabled>
{getUserFullname(user)} {user.uuid.substr(0, 5) !== localCluster && `(${user.uuid.substr(0, 5)})`}
</MenuItem>
- <MenuItem onClick={() => dispatch(openUserVirtualMachines())}>Virtual Machines</MenuItem>
- {!user.isAdmin && <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>}
- <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
- <MenuItem onClick={() => dispatch(navigateToSshKeysUser)}>Ssh Keys</MenuItem>
- <MenuItem onClick={() => dispatch(navigateToSiteManager)}>Site Manager</MenuItem>
- <MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>
+ {user.isActive ? <>
+ <MenuItem onClick={() => dispatch(openUserVirtualMachines())}>Virtual Machines</MenuItem>
+ {!user.isAdmin && <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>}
+ <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
+ <MenuItem onClick={() => dispatch(navigateToSshKeysUser)}>Ssh Keys</MenuItem>
+ <MenuItem onClick={() => dispatch(navigateToSiteManager)}>Site Manager</MenuItem>
+ <MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>)
+ </> : null}
<MenuItem>
<a href={`${workbenchURL.replace(/\/$/, "")}/${wb1URL(currentRoute)}?api_token=${apiToken}`}
className={classes.link}>
diff --git a/src/views-components/main-app-bar/main-app-bar.tsx b/src/views-components/main-app-bar/main-app-bar.tsx
index d2a05837..475b29e1 100644
--- a/src/views-components/main-app-bar/main-app-bar.tsx
+++ b/src/views-components/main-app-bar/main-app-bar.tsx
@@ -54,7 +54,7 @@ export const MainAppBar = withStyles(styles)(
xs={6}
container
alignItems="center">
- {props.user && <SearchBar />}
+ {props.user && props.user.isActive && <SearchBar />}
</Grid>
<Grid
item
diff --git a/src/views/inactive-panel/inactive-panel.tsx b/src/views/inactive-panel/inactive-panel.tsx
new file mode 100644
index 00000000..abfa1f81
--- /dev/null
+++ b/src/views/inactive-panel/inactive-panel.tsx
@@ -0,0 +1,78 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { connect, DispatchProp } from 'react-redux';
+import { Grid, Typography, Button, Select } from '@material-ui/core';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
+import { login, authActions } from '~/store/auth/auth-action';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { RootState } from '~/store/store';
+import * as classNames from 'classnames';
+
+type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ position: 'relative',
+ backgroundColor: theme.palette.grey["200"],
+ '&::after': {
+ content: `''`,
+ position: 'absolute',
+ top: 0,
+ left: 0,
+ bottom: 0,
+ right: 0,
+ background: 'url("arvados-logo-big.png") no-repeat center center',
+ opacity: 0.2,
+ }
+ },
+ container: {
+ width: '560px',
+ zIndex: 10
+ },
+ title: {
+ marginBottom: theme.spacing.unit * 6,
+ color: theme.palette.grey["800"]
+ },
+ content: {
+ marginBottom: theme.spacing.unit * 3,
+ lineHeight: '1.2rem',
+ color: theme.palette.grey["800"]
+ },
+ 'content__bolder': {
+ fontWeight: 'bolder'
+ },
+ button: {
+ boxShadow: 'none'
+ }
+});
+
+type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
+ remoteHosts: { [key: string]: string },
+ homeCluster: string,
+ uuidPrefix: string
+};
+
+export const InactivePanel = withStyles(styles)(
+ connect((state: RootState) => ({
+ remoteHosts: state.auth.remoteHosts,
+ homeCluster: state.auth.homeCluster,
+ uuidPrefix: state.auth.localCluster
+ }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix }: LoginPanelProps) =>
+ <Grid container justify="center" alignItems="center"
+ className={classes.root}
+ style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
+ <Grid item className={classes.container}>
+ <Typography variant='h6' align="center" className={classes.title}>
+ Hi! You're logged in, but...
+ </Typography>
+ <Typography>
+ Your account is inactive.
+
+ An administrator must activate your account before you can get any further.
+ </Typography>
+ </Grid>
+ </Grid >
+ ));
diff --git a/src/views/login-panel/login-panel.tsx b/src/views/inactive-panel/inactive-panel.tsx~
similarity index 100%
copy from src/views/login-panel/login-panel.tsx
copy to src/views/inactive-panel/inactive-panel.tsx~
diff --git a/src/views/login-panel/login-panel.tsx b/src/views/login-panel/login-panel.tsx
index eac4034b..b9f3194a 100644
--- a/src/views/login-panel/login-panel.tsx
+++ b/src/views/login-panel/login-panel.tsx
@@ -63,7 +63,7 @@ export const LoginPanel = withStyles(styles)(
}))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix }: LoginPanelProps) =>
<Grid container justify="center" alignItems="center"
className={classes.root}
- style={{ marginTop: 56, overflowY: "auto" }}>
+ style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
<Grid item className={classes.container}>
<Typography variant='h6' align="center" className={classes.title}>
Welcome to the Arvados Workbench
diff --git a/src/views/main-panel/main-panel-root.tsx b/src/views/main-panel/main-panel-root.tsx
index b96e3cc8..4c64b0b8 100644
--- a/src/views/main-panel/main-panel-root.tsx
+++ b/src/views/main-panel/main-panel-root.tsx
@@ -8,6 +8,7 @@ import { User } from "~/models/user";
import { ArvadosTheme } from '~/common/custom-theme';
import { WorkbenchPanel } from '~/views/workbench/workbench';
import { LoginPanel } from '~/views/login-panel/login-panel';
+import { InactivePanel } from '~/views/inactive-panel/inactive-panel';
import { WorkbenchLoadingScreen } from '~/views/workbench/workbench-loading-screen';
import { MainAppBar } from '~/views-components/main-app-bar/main-app-bar';
@@ -43,7 +44,7 @@ export const MainPanelRoot = withStyles(styles)(
{working ? <LinearProgress color="secondary" /> : null}
</MainAppBar>
<Grid container direction="column" className={classes.root}>
- {user ? <WorkbenchPanel /> : <LoginPanel />}
+ {user ? (user.isActive ? <WorkbenchPanel /> : <InactivePanel />) : <LoginPanel />}
</Grid>
</>
);
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list