[ARVADOS-WORKBENCH2] created: 2.3.0-184-g0e86ce96

Git user git at public.arvados.org
Fri Feb 18 21:57:14 UTC 2022


        at  0e86ce9638f17cf801b6dbf08e6dfd91edf89153 (commit)


commit 0e86ce9638f17cf801b6dbf08e6dfd91edf89153
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Fri Feb 18 18:56:39 2022 -0300

    17754: Avoids presenting account linking options whe LoginCluster is set.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/src/views/link-account-panel/link-account-panel-root.tsx b/src/views/link-account-panel/link-account-panel-root.tsx
index 9dc28d66..490e47dc 100644
--- a/src/views/link-account-panel/link-account-panel-root.tsx
+++ b/src/views/link-account-panel/link-account-panel-root.tsx
@@ -73,6 +73,18 @@ type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPane
 export const LinkAccountPanelRoot = withStyles(styles)(
     ({ classes, targetUser, userToLink, status, isProcessing, error, startLinking, cancelLinking, linkAccount,
         remoteHostsConfig, hasRemoteHosts, selectedCluster, setSelectedCluster, localCluster, loginCluster }: LinkAccountPanelRootProps) => {
+
+        // If a LoginFederation is configured, the self-serve account linking is not
+        // currently available.
+        if (loginCluster !== "") {
+            return <Card className={classes.root}><CardContent>
+                <Grid container spacing={16}>
+                    <Grid item xs={12}>
+                        If you would like to link this account to another one, please contact your administrator.
+                    </Grid>
+                </Grid>
+            </CardContent></Card>;
+        }
         return <Card className={classes.root}><CardContent>
             { isProcessing && <Grid container item direction="column" alignContent="center" spacing={24}>
                 <Grid item>

commit f8f33868de654c1bdded337cb2ad5c486ccf1c93
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Fri Feb 18 18:48:08 2022 -0300

    17754: Attempts to improve code layout for better readability.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/src/views/link-account-panel/link-account-panel-root.tsx b/src/views/link-account-panel/link-account-panel-root.tsx
index c5c86eb2..9dc28d66 100644
--- a/src/views/link-account-panel/link-account-panel-root.tsx
+++ b/src/views/link-account-panel/link-account-panel-root.tsx
@@ -73,125 +73,124 @@ type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPane
 export const LinkAccountPanelRoot = withStyles(styles)(
     ({ classes, targetUser, userToLink, status, isProcessing, error, startLinking, cancelLinking, linkAccount,
         remoteHostsConfig, hasRemoteHosts, selectedCluster, setSelectedCluster, localCluster, loginCluster }: LinkAccountPanelRootProps) => {
-        return <Card className={classes.root}>
-            <CardContent>
-                {isProcessing && <Grid container item direction="column" alignContent="center" spacing={24}>
-                    <Grid item>
-                        Loading user info. Please wait.
-	                </Grid>
-                    <Grid item style={{ alignSelf: 'center' }}>
-                        <CircularProgress />
+        return <Card className={classes.root}><CardContent>
+            { isProcessing && <Grid container item direction="column" alignContent="center" spacing={24}>
+                <Grid item>
+                    Loading user info. Please wait.
+                </Grid>
+                <Grid item style={{ alignSelf: 'center' }}>
+                    <CircularProgress />
+                </Grid>
+            </Grid> }
+
+            { !isProcessing && status === LinkAccountPanelStatus.INITIAL && targetUser && <div>
+                { isLocalUser(targetUser.uuid, localCluster)
+                ? <Grid container spacing={24}>
+                    <Grid container item direction="column" spacing={24}>
+                        <Grid item>
+                            You are currently logged in as {displayUser(targetUser, true)}
+                        </Grid>
+                        <Grid item>
+                            You can link Arvados accounts. After linking, either login will take you to the same account.
+                        </Grid >
                     </Grid>
-                </Grid>}
-                {!isProcessing && status === LinkAccountPanelStatus.INITIAL && targetUser && <div>
-                    {isLocalUser(targetUser.uuid, localCluster) ? <Grid container spacing={24}>
-                        <Grid container item direction="column" spacing={24}>
-                            <Grid item>
-                                You are currently logged in as {displayUser(targetUser, true)}
-                            </Grid>
-                            <Grid item>
-                                You can link Arvados accounts. After linking, either login will take you to the same account.
-		                    </Grid >
+                    <Grid container item direction="row" spacing={24}>
+                        <Grid item>
+                            <Button disabled={!targetUser.isActive} color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ADD_OTHER_LOGIN)}>
+                                Add another login to this account
+                            </Button>
                         </Grid>
-                        <Grid container item direction="row" spacing={24}>
-                            <Grid item>
-                                <Button disabled={!targetUser.isActive} color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ADD_OTHER_LOGIN)}>
-                                    Add another login to this account
-			                    </Button>
-                            </Grid>
-                            <Grid item>
-                                <Button color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ACCESS_OTHER_ACCOUNT)}>
-                                    Use this login to access another account
-			                    </Button>
-                            </Grid>
+                        <Grid item>
+                            <Button color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ACCESS_OTHER_ACCOUNT)}>
+                                Use this login to access another account
+                            </Button>
                         </Grid>
-                        {hasRemoteHosts && selectedCluster && <Grid container item direction="column" spacing={24}>
-                            <Grid item>
-                                You can also link {displayUser(targetUser, false)} with an account from a remote cluster.
-		                    </Grid>
-                            <Grid item>
-                                Please select the cluster that hosts the account you want to link with:
-                                <Select id="remoteHostsDropdown" native defaultValue={selectedCluster} style={{ marginLeft: "1em" }}
-                                    onChange={(event) => setSelectedCluster(event.target.value)}>
-                                    {Object.keys(remoteHostsConfig).map((k) => k !== localCluster ? <option key={k} value={k}>{k}</option> : null)}
-                                </Select>
-                            </Grid>
+                    </Grid>
+                    {hasRemoteHosts && selectedCluster && <Grid container item direction="column" spacing={24}>
+                        <Grid item>
+                            You can also link {displayUser(targetUser, false)} with an account from a remote cluster.
+                        </Grid>
+                        <Grid item>
+                            Please select the cluster that hosts the account you want to link with:
+                            <Select id="remoteHostsDropdown" native defaultValue={selectedCluster} style={{ marginLeft: "1em" }}
+                                onChange={(event) => setSelectedCluster(event.target.value)}>
+                                {Object.keys(remoteHostsConfig).map((k) => k !== localCluster ? <option key={k} value={k}>{k}</option> : null)}
+                            </Select>
+                        </Grid>
+                        <Grid item>
+                            <Button color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ACCESS_OTHER_REMOTE_ACCOUNT)}>
+                                Link with an account on {hasRemoteHosts ? <label>{selectedCluster} </label> : null}
+                            </Button>
+                        </Grid>
+                    </Grid>}
+                </Grid>
+                : <Grid container spacing={24}>
+                    <Grid container item direction="column" spacing={24}>
+                        <Grid item>
+                            You are currently logged in as {displayUser(targetUser, true, true)}
+                        </Grid>
+                        { targetUser.isActive
+                        ? (loginCluster === ""
+                            ? <> <Grid item>
+                                This a remote account. You can link a local Arvados account to this one.
+                                After linking, you can access the local account's data by logging into the
+                                <b>{localCluster}</b> cluster as user <b>{targetUser.email}</b>
+                                from <b>{targetUser.uuid.substring(0, 5)}</b>.
+                            </Grid >
                             <Grid item>
-                                <Button color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ACCESS_OTHER_REMOTE_ACCOUNT)}>
-                                    Link with an account on {hasRemoteHosts ? <label>{selectedCluster} </label> : null}
+                                <Button color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ADD_LOCAL_TO_REMOTE)}>
+                                    Link an account from {localCluster} to this account
                                 </Button>
-                            </Grid>
-                        </Grid>}
-                    </Grid> :
-                        <Grid container spacing={24}>
-                            <Grid container item direction="column" spacing={24}>
-                                <Grid item>
-                                    You are currently logged in as {displayUser(targetUser, true, true)}
-                                </Grid>
-                                {targetUser.isActive ?
-                                    (loginCluster === "" ?
-                                        <> <Grid item>
-                                            This a remote account. You can link a local Arvados account to this one.
-                                            After linking, you can access the local account's data by logging into the
-					                        <b>{localCluster}</b> cluster as user <b>{targetUser.email}</b>
-                                            from <b>{targetUser.uuid.substring(0, 5)}</b>.
-					                    </Grid >
-                                            <Grid item>
-                                                <Button color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ADD_LOCAL_TO_REMOTE)}>
-                                                    Link an account from {localCluster} to this account
-					                            </Button>
-                                            </Grid> </>
-                                        : <Grid item>Please visit cluster
-				                        <a href={remoteHostsConfig[loginCluster].workbench2Url + "/link_account"}>{loginCluster}</a>
-                                            to perform account linking.</Grid>
-                                    )
-                                    : <Grid item>
-                                        This an inactive remote account. An administrator must activate your
-                                        account before you can proceed.  After your accounts is activated,
-				                    you can link a local Arvados account hosted by the <b>{localCluster}</b>
-                                        cluster to this one.
-				                </Grid >}
-                            </Grid>
-                        </Grid>}
-                </div>}
-                {!isProcessing && (status === LinkAccountPanelStatus.LINKING || status === LinkAccountPanelStatus.ERROR) && userToLink && targetUser &&
-                    <Grid container spacing={24}>
-                        {status === LinkAccountPanelStatus.LINKING && <Grid container item direction="column" spacing={24}>
-                            <Grid item>
-                                Clicking 'Link accounts' will link {displayUser(userToLink, true, !isLocalUser(targetUser.uuid, localCluster))} to {displayUser(targetUser, true, !isLocalUser(targetUser.uuid, localCluster))}.
-		                    </Grid>
-                            {(isLocalUser(targetUser.uuid, localCluster)) && <Grid item>
-                                After linking, logging in as {displayUser(userToLink)} will log you into the same account as {displayUser(targetUser)}.
-		                    </Grid>}
-                            <Grid item>
-                                Any object owned by {displayUser(userToLink)} will be transfered to {displayUser(targetUser)}.
-		                    </Grid>
-                            {!isLocalUser(targetUser.uuid, localCluster) && <Grid item>
-                                You can access <b>{userToLink.email}</b> data by logging into <b>{localCluster}</b> with the <b>{targetUser.email}</b> account.
-		                    </Grid>}
+                            </Grid></>
+                            : <Grid item>Please visit cluster
+                                <a href={remoteHostsConfig[loginCluster].workbench2Url + "/link_account"}>{loginCluster}</a> to perform account linking.
+                            </Grid> )
+                        : <Grid item>
+                            This an inactive remote account. An administrator must activate your
+                            account before you can proceed.  After your accounts is activated,
+                            you can link a local Arvados account hosted by the <b>{localCluster}</b> cluster to this one.
+                        </Grid> }
+                    </Grid>
+                </Grid> }
+            </div> }
+
+            {!isProcessing && (status === LinkAccountPanelStatus.LINKING || status === LinkAccountPanelStatus.ERROR) && userToLink && targetUser &&
+                <Grid container spacing={24}>
+                    {status === LinkAccountPanelStatus.LINKING && <Grid container item direction="column" spacing={24}>
+                        <Grid item>
+                            Clicking 'Link accounts' will link {displayUser(userToLink, true, !isLocalUser(targetUser.uuid, localCluster))} to {displayUser(targetUser, true, !isLocalUser(targetUser.uuid, localCluster))}.
+                        </Grid>
+                        {(isLocalUser(targetUser.uuid, localCluster)) && <Grid item>
+                            After linking, logging in as {displayUser(userToLink)} will log you into the same account as {displayUser(targetUser)}.
                         </Grid>}
-                        {error === LinkAccountPanelError.NON_ADMIN && <Grid item>
-                            Cannot link admin account {displayUser(userToLink)} to non-admin account {displayUser(targetUser)}.
-		                </Grid>}
-                        {error === LinkAccountPanelError.SAME_USER && <Grid item>
-                            Cannot link {displayUser(targetUser)} to the same account.
-		                </Grid>}
-                        {error === LinkAccountPanelError.INACTIVE && <Grid item>
-                            Cannot link account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}.
-		                </Grid>}
-                        <Grid container item direction="row" spacing={24}>
-                            <Grid item>
-                                <Button variant="contained" onClick={() => cancelLinking()}>
-                                    Cancel
-			                    </Button>
-                            </Grid>
-                            <Grid item>
-                                <Button disabled={status === LinkAccountPanelStatus.ERROR} color="primary" variant="contained" onClick={() => linkAccount()}>
-                                    Link accounts
-			                    </Button>
-                            </Grid>
+                        <Grid item>
+                            Any object owned by {displayUser(userToLink)} will be transfered to {displayUser(targetUser)}.
                         </Grid>
+                        {!isLocalUser(targetUser.uuid, localCluster) && <Grid item>
+                            You can access <b>{userToLink.email}</b> data by logging into <b>{localCluster}</b> with the <b>{targetUser.email}</b> account.
+                        </Grid>}
+                    </Grid>}
+                    {error === LinkAccountPanelError.NON_ADMIN && <Grid item>
+                        Cannot link admin account {displayUser(userToLink)} to non-admin account {displayUser(targetUser)}.
+                    </Grid>}
+                    {error === LinkAccountPanelError.SAME_USER && <Grid item>
+                        Cannot link {displayUser(targetUser)} to the same account.
+                    </Grid>}
+                    {error === LinkAccountPanelError.INACTIVE && <Grid item>
+                        Cannot link account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}.
                     </Grid>}
-            </CardContent>
-        </Card>;
+                    <Grid container item direction="row" spacing={24}>
+                        <Grid item>
+                            <Button variant="contained" onClick={() => cancelLinking()}>
+                                Cancel
+                            </Button>
+                        </Grid>
+                        <Grid item>
+                            <Button disabled={status === LinkAccountPanelStatus.ERROR} color="primary" variant="contained" onClick={() => linkAccount()}>
+                                Link accounts
+                            </Button>
+                        </Grid>
+                    </Grid>
+                </Grid>}
+        </CardContent></Card>;
     });

commit 219e27b40906188857d9d85123dd565fd33bb916
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Fri Feb 18 16:30:57 2022 -0300

    17754: Disables self-serve account linking offering on inactive account page.
    
    (when LoginCluster is set)
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/src/views/inactive-panel/inactive-panel.test.tsx b/src/views/inactive-panel/inactive-panel.test.tsx
new file mode 100644
index 00000000..c694f9db
--- /dev/null
+++ b/src/views/inactive-panel/inactive-panel.test.tsx
@@ -0,0 +1,63 @@
+// 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
diff --git a/src/views/inactive-panel/inactive-panel.tsx b/src/views/inactive-panel/inactive-panel.tsx
index 6d8bbf59..8a7c7928 100644
--- a/src/views/inactive-panel/inactive-panel.tsx
+++ b/src/views/inactive-panel/inactive-panel.tsx
@@ -11,7 +11,7 @@ import { ArvadosTheme } from 'common/custom-theme';
 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: {
@@ -47,32 +47,45 @@ const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({
     }
 });
 
+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));

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list