--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from 'react';
+import { mount, configure } from 'enzyme';
+import Adapter from "enzyme-adapter-react-16";
+import { CustomTheme } from 'common/custom-theme';
+import { InactivePanelStateProps, CssRules, InactivePanelRoot } from './inactive-panel';
+import { MuiThemeProvider, StyledComponentProps } from '@material-ui/core';
+
+configure({ adapter: new Adapter() });
+
+describe('InactivePanel', () => {
+ let props: InactivePanelStateProps & StyledComponentProps<CssRules>;
+
+ beforeEach(() => {
+ props = {
+ classes: {
+ root: 'root',
+ title: 'title',
+ ontop: 'ontop',
+ },
+ isLoginClusterFederation: false,
+ inactivePageText: 'Inactive page content',
+ };
+ });
+
+ it('should render content and link account option', () => {
+ // given
+ const expectedMessage = "Inactive page content";
+ const expectedLinkAccountText = 'If you would like to use this login to access another account click "Link Account"';
+
+ // when
+ const wrapper = mount(
+ <MuiThemeProvider theme={CustomTheme}>
+ <InactivePanelRoot {...props} />
+ </MuiThemeProvider>
+ );
+
+ // then
+ expect(wrapper.find('p').first().text()).toContain(expectedMessage);
+ expect(wrapper.find('p').at(1).text()).toContain(expectedLinkAccountText);
+ })
+
+ it('should render content and link account warning on LoginCluster federations', () => {
+ // given
+ props.isLoginClusterFederation = true;
+ const expectedMessage = "Inactive page content";
+ const expectedLinkAccountText = 'If you would like to use this login to access another account, please contact your administrator';
+
+ // when
+ const wrapper = mount(
+ <MuiThemeProvider theme={CustomTheme}>
+ <InactivePanelRoot {...props} />
+ </MuiThemeProvider>
+ );
+
+ // then
+ expect(wrapper.find('p').first().text()).toContain(expectedMessage);
+ expect(wrapper.find('p').at(1).text()).toContain(expectedLinkAccountText);
+ })
+});
\ No newline at end of file
import { navigateToLinkAccount } from 'store/navigation/navigation-action';
import { RootState } from 'store/store';
-type CssRules = 'root' | 'ontop' | 'title';
+export type CssRules = 'root' | 'ontop' | 'title';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
root: {
}
});
+const mapStateToProps = (state: RootState): InactivePanelStateProps => ({
+ inactivePageText: state.auth.config.clusterConfig.Workbench.InactivePageHTML,
+ isLoginClusterFederation: state.auth.config.clusterConfig.Login.LoginCluster !== '',
+});
+
export interface InactivePanelStateProps {
inactivePageText: string;
+ isLoginClusterFederation: boolean;
}
type InactivePanelProps = WithStyles<CssRules> & InactivePanelActionProps & InactivePanelStateProps;
-export const InactivePanel = connect((state: RootState) => ({
- inactivePageText: state.auth.config.clusterConfig.Workbench.InactivePageHTML
-}), mapDispatchToProps)(withStyles(styles)((({ classes, startLinking, inactivePageText }: InactivePanelProps) =>
+
+export const InactivePanelRoot = ({ classes, startLinking, inactivePageText, isLoginClusterFederation }: InactivePanelProps) =>
<Grid container justify="center" alignItems="center" direction="column" spacing={24}
className={classes.root}
style={{ marginTop: 56, height: "100%" }}>
<Grid item>
<Typography>
- <div dangerouslySetInnerHTML={{ __html: inactivePageText }} style={{ margin: "1em" }} />
+ <span dangerouslySetInnerHTML={{ __html: inactivePageText }} style={{ margin: "1em" }} />
</Typography>
</Grid>
- <Grid item>
+ { !isLoginClusterFederation
+ ? <><Grid item>
<Typography align="center">
- If you would like to use this login to access another account click "Link Account".
- </Typography>
+ If you would like to use this login to access another account click "Link Account".
+ </Typography>
</Grid>
<Grid item>
<Button className={classes.ontop} color="primary" variant="contained" onClick={() => startLinking()}>
Link Account
- </Button>
- </Grid>
- </Grid >
-)));
+ </Button>
+ </Grid></>
+ : <><Grid item>
+ <Typography align="center">
+ If you would like to use this login to access another account, please contact your administrator.
+ </Typography>
+ </Grid></> }
+ </Grid >;
+
+export const InactivePanel = connect(mapStateToProps, mapDispatchToProps)(
+ withStyles(styles)(InactivePanelRoot));