Merge branch 'master' into 14452-my-account
authorPawel Kromplewski <pawel.kromplewski@contractors.roche.com>
Mon, 3 Dec 2018 07:29:41 +0000 (08:29 +0100)
committerPawel Kromplewski <pawel.kromplewski@contractors.roche.com>
Mon, 3 Dec 2018 07:29:41 +0000 (08:29 +0100)
refs #14452

Arvados-DCO-1.1-Signed-off-by: Pawel Kromplewski <pawel.kromplewski@contractors.roche.com>

1  2 
src/models/user.ts
src/routes/route-change-handlers.ts
src/routes/routes.ts
src/services/auth-service/auth-service.ts
src/store/auth/auth-reducer.test.ts
src/store/navigation/navigation-action.ts
src/store/workbench/workbench-actions.ts
src/views-components/main-app-bar/account-menu.tsx
src/views/workbench/workbench.tsx

index eed135a21cf816133dc14deb4a656cce21953553,9f9c534763ca86ee40190c2361c89b4e81da2f95..dfb418892ef363192b73c5e8f6983c887910603b
@@@ -20,8 -10,7 +20,9 @@@ export interface User 
      lastName: string;
      uuid: string;
      ownerUuid: string;
 +    identityUrl: string;
 +    prefs: userPrefs;
+     isAdmin: boolean;
  }
  
  export const getUserFullname = (user?: User) => {
index f2aed2db48f0411b7ba3ebcffeb2ad60483d6169,22d0b7c711364d2a466b8b0af5e2b7d465cb73aa..1f3bd93fbae297f3461a1a7393280b7df80f9baa
@@@ -4,8 -4,8 +4,10 @@@
  
  import { History, Location } from 'history';
  import { RootStore } from '~/store/store';
 +import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchMyAccountRoute } from './routes';
 +import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadMyAccount } from '~/store/workbench/workbench-actions';
+ import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute } from './routes';
+ import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadVirtualMachines } from '~/store/workbench/workbench-actions';
  import { navigateToRootProject } from '~/store/navigation/navigation-action';
  import { loadSharedWithMe, loadRunProcess, loadWorkflow, loadSearchResults } from '~//store/workbench/workbench-actions';
  
@@@ -27,9 -27,9 +29,10 @@@ const handleLocationChange = (store: Ro
      const searchResultsMatch = matchSearchResultsRoute(pathname);
      const sharedWithMeMatch = matchSharedWithMeRoute(pathname);
      const runProcessMatch = matchRunProcessRoute(pathname);
+     const virtualMachineMatch = matchVirtualMachineRoute(pathname);
      const workflowMatch = matchWorkflowRoute(pathname);
      const sshKeysMatch = matchSshKeysRoute(pathname);
 +    const myAccountMatch = matchMyAccountRoute(pathname);
  
      if (projectMatch) {
          store.dispatch(loadProject(projectMatch.params.id));
index 988b4cb4a8427eba202d287d8a678e42095c1b96,71cdfdacad218da9ea51cf636ffacd2cf95916ad..a27b4274c707002a57b5a358d5aecbb9e03c6385
@@@ -19,10 -19,10 +19,11 @@@ export const Routes = 
      REPOSITORIES: '/repositories',
      SHARED_WITH_ME: '/shared-with-me',
      RUN_PROCESS: '/run-process',
+     VIRTUAL_MACHINES: '/virtual-machines',
      WORKFLOWS: '/workflows',
      SEARCH_RESULTS: '/search-results',
 -    SSH_KEYS: `/ssh-keys`
 +    SSH_KEYS: `/ssh-keys`,
 +    MY_ACCOUNT: '/my-account'
  };
  
  export const getResourceUrl = (uuid: string) => {
index d4e81e42ee76c88bec04814e70953cd7bcbfa335,edc6e24fce752b628a7573899f21af2e6063073b..6faaf99ee7a37109a93021cd9cafeb31c4fa57a3
@@@ -13,8 -13,7 +13,9 @@@ export const USER_FIRST_NAME_KEY = 'use
  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_IDENTITY_URL = 'identityUrl';
 +export const USER_PREFS = 'prefs';
  
  export interface UserDetailsResponse {
      email: string;
@@@ -58,12 -59,12 +63,14 @@@ export class AuthService 
          const email = localStorage.getItem(USER_EMAIL_KEY);
          const firstName = localStorage.getItem(USER_FIRST_NAME_KEY);
          const lastName = localStorage.getItem(USER_LAST_NAME_KEY);
-         const uuid = localStorage.getItem(USER_UUID_KEY);
-         const ownerUuid = localStorage.getItem(USER_OWNER_UUID_KEY);
+         const uuid = this.getUuid();
+         const ownerUuid = this.getOwnerUuid();
+         const isAdmin = this.getIsAdmin();
 +        const identityUrl = localStorage.getItem(USER_IDENTITY_URL);
 +        const prefs = JSON.parse(localStorage.getItem(USER_PREFS) || '{"profile": {}}');
 -        return email && firstName && lastName && uuid && ownerUuid
 -            ? { email, firstName, lastName, uuid, ownerUuid, isAdmin }
 +        return email && firstName && lastName && uuid && ownerUuid && identityUrl && prefs
-             ? { email, firstName, lastName, uuid, ownerUuid, identityUrl, prefs }
++            ? { email, firstName, lastName, uuid, ownerUuid, isAdmin, identityUrl, prefs }
              : undefined;
      }
  
@@@ -73,8 -74,7 +80,9 @@@
          localStorage.setItem(USER_LAST_NAME_KEY, user.lastName);
          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_IDENTITY_URL, user.identityUrl);
 +        localStorage.setItem(USER_PREFS, JSON.stringify(user.prefs));
      }
  
      public removeUser() {
@@@ -83,8 -83,7 +91,9 @@@
          localStorage.removeItem(USER_LAST_NAME_KEY);
          localStorage.removeItem(USER_UUID_KEY);
          localStorage.removeItem(USER_OWNER_UUID_KEY);
+         localStorage.removeItem(USER_IS_ADMIN);
 +        localStorage.removeItem(USER_IDENTITY_URL);
 +        localStorage.removeItem(USER_PREFS);
      }
  
      public login() {
                      lastName: resp.data.last_name,
                      uuid: resp.data.uuid,
                      ownerUuid: resp.data.owner_uuid,
 -                    isAdmin: resp.data.is_admin
++                    isAdmin: resp.data.is_admin,
 +                    identityUrl: resp.data.identity_url,
 +                    prefs
                  };
              })
              .catch(e => {
index 592191caec493503bcce69174c78f81fdedefee4,a4017db3be7af4b83a69543fdc85d825516ec149..b9f768f1cb0a42a9653d119cc577e516b21407ba
@@@ -30,8 -30,7 +30,9 @@@ describe('auth-reducer', () => 
              lastName: "Doe",
              uuid: "uuid",
              ownerUuid: "ownerUuid",
-             prefs: {}
 +            identityUrl: "identityUrl",
++            prefs: {},
+             isAdmin: false
          };
          const state = reducer(initialState, authActions.INIT({ user, token: "token" }));
          expect(state).toEqual({
@@@ -60,8 -60,7 +62,9 @@@
              lastName: "Doe",
              uuid: "uuid",
              ownerUuid: "ownerUuid",
-             prefs: {}
 +            identityUrl: "identityUrl",
++            prefs: {},
+             isAdmin: false
          };
  
          const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user));
index b93bfcfbedecf90de608d3acb2eb90ab62d26c7e,ca88021ccdb04c6491ec5389f94dade7ccd35424..0aedee9001c4bde86a49950502e3622feae5b624
@@@ -12,7 -12,8 +12,8 @@@ import { logout } from '~/store/auth/au
  import { RootState } from "~/store/store";
  import { openCurrentTokenDialog } from '~/store/current-token-dialog/current-token-dialog-actions';
  import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
 -import { navigateToSshKeys } from '~/store/navigation/navigation-action';
 +import { navigateToSshKeys, navigateToMyAccount } from '~/store/navigation/navigation-action';
+ import { openVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
  
  interface AccountMenuProps {
      user?: User;
index 8542e6ca36a278a54e59c395ea63c4900e6c9ce0,3914f64632e716bfe0aa4aca8265ae42a6a6bc93..2cff4317e5576470c44e22ff910a043302a4aa3f
@@@ -128,9 -128,9 +129,10 @@@ export const WorkbenchPanel 
                                  <Route path={Routes.RUN_PROCESS} component={RunProcessPanel} />
                                  <Route path={Routes.WORKFLOWS} component={WorkflowPanel} />
                                  <Route path={Routes.SEARCH_RESULTS} component={SearchResultsPanel} />
+                                 <Route path={Routes.VIRTUAL_MACHINES} component={VirtualMachinePanel} />
                                  <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
                                  <Route path={Routes.SSH_KEYS} component={SshKeyPanel} />
 +                                <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
                              </Switch>
                          </Grid>
                      </Grid>