16659: Added copy of full token, fixed tests 16659-copy-api-token-to-clipboard
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Mon, 17 Aug 2020 18:37:55 +0000 (20:37 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Mon, 17 Aug 2020 18:37:55 +0000 (20:37 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

.env
src/store/collections-content-address-panel/collections-content-address-middleware-service.ts
src/store/data-explorer/data-explorer-middleware-service.ts
src/store/group-details-panel/group-details-panel-middleware-service.ts
src/store/sharing-dialog/sharing-dialog-actions.ts
src/store/users/users-actions.ts
src/store/workflow-panel/workflow-panel-actions.ts
src/views-components/current-token-dialog/current-token-dialog.test.tsx
src/views-components/current-token-dialog/current-token-dialog.tsx
src/views-components/sharing-dialog/participant-select.tsx

diff --git a/.env b/.env
index bd410081ebecca5b03e42a2695e9e842ee013401..fd91b99c6a28f33db092cf50f6405ba42020b17b 100644 (file)
--- a/.env
+++ b/.env
@@ -1,5 +1,5 @@
 # Copyright (C) The Arvados Authors. All rights reserved.
-# 
+#
 # SPDX-License-Identifier: AGPL-3.0
 
 REACT_APP_ARVADOS_CONFIG_URL=/config.json
index 72da1d2e0144927395175ad4739f227b9cb02071..a68d13bdec52aa3c6c7ddaf0d5d84593202ab47d 100644 (file)
@@ -77,25 +77,24 @@ export class CollectionsWithSameContentAddressMiddlewareService extends DataExpl
                     }
                 });
                 const responseUsers = await this.services.userService.list({
-                    limit: dataExplorer.rowsPerPage,
-                    offset: dataExplorer.page * dataExplorer.rowsPerPage,
                     filters: new FilterBuilder()
                         .addIn('uuid', userUuids)
-                        .getFilters()
+                        .getFilters(),
+                    count: "none"
                 });
                 const responseGroups = await this.services.groupsService.list({
-                    limit: dataExplorer.rowsPerPage,
-                    offset: dataExplorer.page * dataExplorer.rowsPerPage,
                     filters: new FilterBuilder()
                         .addIn('uuid', groupUuids)
-                        .getFilters()
+                        .getFilters(),
+                    count: "none"
                 });
                 responseUsers.items.map(it => {
                     api.dispatch<any>(ownerNameActions.SET_OWNER_NAME({
                         name: it.uuid === userUuid
                             ? 'User: Me'
                             : `User: ${getUserDisplayName(it)}`,
-                        uuid: it.uuid }));
+                        uuid: it.uuid
+                    }));
                 });
                 responseGroups.items.map(it => {
                     api.dispatch<any>(ownerNameActions.SET_OWNER_NAME({ name: `Project: ${it.name}`, uuid: it.uuid }));
index 219e76030a14e12470bafa55442094b9c6239f74..64e6e50baaa6cc18e51503fda4ece9d28b480a3d 100644 (file)
@@ -35,7 +35,7 @@ export const getDataExplorerColumnFilters = <T>(columns: DataColumns<T>, columnN
 
 export const dataExplorerToListParams = (dataExplorer: DataExplorer) => ({
     limit: dataExplorer.rowsPerPage,
-    offset: dataExplorer.page * dataExplorer.rowsPerPage,
+    offset: dataExplorer.page * dataExplorer.rowsPerPage
 });
 
 export const listResultsToDataExplorerItemsMeta = <R>({ itemsAvailable, offset, limit }: ListResults<R>) => ({
index 94f78a58e75116e32febd2164a6a346508a40fa4..5aff4e7b303fe34e8fcbdfd90647408c19da4478 100644 (file)
@@ -36,7 +36,8 @@ export class GroupDetailsPanelMiddlewareService extends DataExplorerMiddlewareSe
                 const users = await this.services.userService.list({
                     filters: new FilterBuilder()
                         .addIn('uuid', permissions.items.map(item => item.headUuid))
-                        .getFilters()
+                        .getFilters(),
+                    count: "none"
                 });
                 api.dispatch(GroupDetailsPanelActions.SET_ITEMS({
                     ...listResultsToDataExplorerItemsMeta(permissions),
index 671c10fc3088ba8dc4630f93c83afcd55066709d..58fc31987e57e8874bf29be177daf166709d1fa5 100644 (file)
@@ -79,8 +79,8 @@ const initializeManagementForm = (permissionLinks: PermissionResource[]) =>
             .addIn('uuid', permissionLinks.map(({ tailUuid }) => tailUuid))
             .getFilters();
 
-        const { items: users } = await userService.list({ filters });
-        const { items: groups} = await groupsService.list({ filters });
+        const { items: users } = await userService.list({ filters, count: "none" });
+        const { items: groups } = await groupsService.list({ filters, count: "none" });
 
         const getEmail = (tailUuid: string) => {
             const user = users.find(({ uuid }) => uuid === tailUuid);
index 7b12fe75633ec403a8978bb15c9ece5bc9012cce..8f696fa29ad6e0d9e7122b5cbdc82d04a1d93a3f 100644 (file)
@@ -157,7 +157,7 @@ export const userBindedActions = bindDataExplorerActions(USERS_PANEL_ID);
 
 export const loadUsersData = () =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        await services.userService.list();
+        await services.userService.list({ count: "none" });
     };
 
 export const loadUsersPanel = () =>
index 3f91c102624244b6cf507a55e6b17ef4e31637a5..bfd899fd38d973b62b627242bd657f11ecbcab69 100644 (file)
@@ -50,11 +50,11 @@ export const openRunProcess = (uuid: string) =>
     };
 
 export const getPublicUserUuid = (state: RootState) => {
-    const prefix = getProperty<string>(UUID_PREFIX_PROPERTY_NAME)(state.properties);
+    const prefix = state.auth.localCluster;
     return `${prefix}-tpzed-anonymouspublic`;
 };
 export const getPublicGroupUuid = (state: RootState) => {
-    const prefix = getProperty<string>(UUID_PREFIX_PROPERTY_NAME)(state.properties);
+    const prefix = state.auth.localCluster;
     return `${prefix}-j7d0g-anonymouspublic`;
 };
 
index 188076d7711ebbbe8d99b1fbaf31155aff3245b8..eb405e94a0ed6f7bf140f7afe0de4f6179eef0ee 100644 (file)
@@ -2,15 +2,18 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
-import { shallow, configure } from "enzyme";
-import * as Adapter from "enzyme-adapter-react-16";
-import * as CopyToClipboard from "react-copy-to-clipboard";
-import { CurrentTokenDialogComponent } from "./current-token-dialog";
+import * as React from 'react';
+import { Button } from '@material-ui/core';
+import { mount, configure } from 'enzyme';
+import * as Adapter from 'enzyme-adapter-react-16';
+import * as CopyToClipboard from 'react-copy-to-clipboard';
+import { CurrentTokenDialogComponent } from './current-token-dialog';
 
 configure({ adapter: new Adapter() });
 
-describe("<CurrentTokenDialog />", () => {
+jest.mock('toggle-selection', () => () => () => null);
+
+describe('<CurrentTokenDialog />', () => {
   let props;
   let wrapper;
 
@@ -18,29 +21,30 @@ describe("<CurrentTokenDialog />", () => {
     props = {
       classes: {},
       data: {
-        currentToken: "123123123123",
+        currentToken: '123123123123',
       },
+      open: true,
       dispatch: jest.fn(),
     };
   });
 
-  describe("copy to clipboard", () => {
+  describe('copy to clipboard', () => {
     beforeEach(() => {
-      wrapper = shallow(<CurrentTokenDialogComponent {...props} />);
+      wrapper = mount(<CurrentTokenDialogComponent {...props} />);
     });
 
-    it("should copy API TOKEN to the clipboard", () => {
+    it('should copy API TOKEN to the clipboard', () => {
       // when
-      wrapper.find(CopyToClipboard).props().onCopy();
+      wrapper.find(CopyToClipboard).find(Button).simulate('click');
 
-      // then
+      // and
       expect(props.dispatch).toHaveBeenCalledWith({
         payload: {
           hideDuration: 2000,
           kind: 1,
-          message: "Token copied to clipboard",
+          message: 'Token copied to clipboard',
         },
-        type: "OPEN_SNACKBAR",
+        type: 'OPEN_SNACKBAR',
       });
     });
   });
index 57b228f9391a3dad9c4b7a3578eeb967c01e2d32..0ea24690fd901c92e33ab5732e8aa398f3cc812f 100644 (file)
@@ -51,9 +51,9 @@ export class CurrentTokenDialogComponent extends React.Component<CurrentTokenPro
 
     getSnippet = ({ apiHost, currentToken }: CurrentTokenDialogData) =>
         `HISTIGNORE=$HISTIGNORE:'export ARVADOS_API_TOKEN=*'
-    export ARVADOS_API_TOKEN=${currentToken}
-    export ARVADOS_API_HOST=${apiHost}
-    unset ARVADOS_API_HOST_INSECURE`
+export ARVADOS_API_TOKEN=${currentToken}
+export ARVADOS_API_HOST=${apiHost}
+unset ARVADOS_API_HOST_INSECURE`
 
     render() {
         const { classes, open, closeDialog, ...data } = this.props;
@@ -66,32 +66,32 @@ export class CurrentTokenDialogComponent extends React.Component<CurrentTokenPro
             <DialogContent>
                 <Typography paragraph={true}>
                     The Arvados API token is a secret key that enables the Arvados SDKs to access Arvados with the proper permissions.
-                            <Typography component='p'>
-                        For more information see
-                                <a href='http://doc.arvados.org/user/reference/api-tokens.html' target='blank' className={classes.link}>
-                            Getting an API token.
-                                </a>
-                    </Typography>
+                        <Typography component='span'>
+                            For more information see
+                            <a href='http://doc.arvados.org/user/reference/api-tokens.html' target='blank' className={classes.link}>
+                                Getting an API token.
+                            </a>
+                        </Typography>
                 </Typography>
                 <Typography paragraph={true}>
-                    Paste the following lines at a shell prompt to set up the necessary environment for Arvados SDKs to authenticate to your klingenc account.
-                        </Typography>
+                    Paste the following lines at a shell prompt to set up the necessary environment for Arvados SDKs to authenticate to your account.
+                </Typography>
                 <DefaultCodeSnippet lines={[this.getSnippet(data)]} />
-                <CopyToClipboard text={data.currentToken} onCopy={() => this.onCopy('Token copied to clipboard')}>
+                <CopyToClipboard text={this.getSnippet(data)} onCopy={() => this.onCopy('Token copied to clipboard')}>
                     <Button
                         color="primary"
                         size="small"
                         variant="contained"
                         className={classes.copyButton}
                     >
-                        Copy Api Token
+                        COPY TO CLIPBOARD
                     </Button>
                 </CopyToClipboard>
                 <Typography >
                     Arvados
                             <a href='http://doc.arvados.org/user/reference/api-tokens.html' target='blank' className={classes.link}>virtual machines</a>
                     do this for you automatically. This setup is needed only when you use the API remotely (e.g., from your own workstation).
-                        </Typography>
+                </Typography>
             </DialogContent>
             <DialogActions>
                 <Button onClick={closeDialog} className={classes.button} color="primary">CLOSE</Button>
index 5d062da0ef7ae612179c2e9edfc14e5622eec739..ea3775e93ad652a8463b95b3e28656e74a8f03de 100644 (file)
@@ -41,7 +41,7 @@ interface ParticipantSelectState {
 }
 
 const getDisplayName = (item: GroupResource & UserResource) => {
-    switch(item.kind) {
+    switch (item.kind) {
         case ResourceKind.USER:
             return getUserDisplayName(item, true);
         case ResourceKind.GROUP:
@@ -131,14 +131,14 @@ export const ParticipantSelect = connect()(
             const filterUsers = new FilterBuilder()
                 .addILike('any', value)
                 .getFilters();
-            const userItems: ListResults<any> = await userService.list({ filters: filterUsers, limit });
+            const userItems: ListResults<any> = await userService.list({ filters: filterUsers, limit, count: "none" });
 
             const filterGroups = new FilterBuilder()
                 .addNotIn('group_class', [GroupClass.PROJECT])
                 .addILike('name', value)
                 .getFilters();
 
-            const groupItems: ListResults<any> = await groupsService.list({ filters: filterGroups, limit });
+            const groupItems: ListResults<any> = await groupsService.list({ filters: filterGroups, limit, count: "none" });
             this.setState({
                 suggestions: this.props.onlyPeople
                     ? userItems.items