Add site manager and initial validation
authorDaniel Kos <daniel.kos@contractors.roche.com>
Sun, 16 Dec 2018 21:10:23 +0000 (22:10 +0100)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Sun, 16 Dec 2018 21:10:23 +0000 (22:10 +0100)
Feature #14478

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>

33 files changed:
src/common/config.ts
src/components/text-field/text-field.tsx
src/index.tsx
src/models/client-authorization.ts [new file with mode: 0644]
src/models/session.ts [new file with mode: 0644]
src/routes/route-change-handlers.ts
src/routes/routes.ts
src/services/auth-service/auth-service.ts
src/services/client-authorizations-service/client-authorizations-service.ts [new file with mode: 0644]
src/services/common-service/common-resource-service.ts
src/services/services.ts
src/store/auth/auth-action-session.ts [new file with mode: 0644]
src/store/auth/auth-action-ssh.ts [new file with mode: 0644]
src/store/auth/auth-action.test.ts [moved from src/store/auth/auth-actions.test.ts with 93% similarity]
src/store/auth/auth-action.ts
src/store/auth/auth-reducer.ts
src/store/navigation/navigation-action.ts
src/store/workbench/workbench-actions.ts
src/validators/is-remote-host.tsx [new file with mode: 0644]
src/validators/validators.tsx
src/views-components/context-menu/action-sets/ssh-key-action-set.ts
src/views-components/dialog-create/dialog-ssh-key-create.tsx
src/views-components/dialog-forms/create-ssh-key-dialog.ts
src/views-components/main-app-bar/account-menu.tsx
src/views-components/main-content-bar/main-content-bar.tsx
src/views-components/rename-file-dialog/rename-file-dialog.tsx
src/views-components/ssh-keys-dialog/attributes-dialog.tsx
src/views-components/ssh-keys-dialog/public-key-dialog.tsx
src/views-components/ssh-keys-dialog/remove-dialog.tsx
src/views/site-manager-panel/site-manager-panel-root.tsx [new file with mode: 0644]
src/views/site-manager-panel/site-manager-panel.tsx [new file with mode: 0644]
src/views/ssh-key-panel/ssh-key-panel.tsx
src/views/workbench/workbench.tsx

index b7b89bd9e4930100188725b7f117f67abf076587..d801c5fa67b1189278daecb3df0138a7cd4dc5a8 100644 (file)
@@ -35,7 +35,9 @@ export interface Config {
     packageVersion: string;
     parameters: {};
     protocol: string;
-    remoteHosts: string;
+    remoteHosts: {
+        [key: string]: string
+    };
     remoteHostsViaDNS: boolean;
     resources: {};
     revision: string;
@@ -50,6 +52,7 @@ export interface Config {
     websocketUrl: string;
     workbenchUrl: string;
     vocabularyUrl: string;
+    origin: string;
 }
 
 export const fetchConfig = () => {
@@ -59,10 +62,10 @@ export const fetchConfig = () => {
         .catch(() => Promise.resolve(getDefaultConfig()))
         .then(config => Axios
             .get<Config>(getDiscoveryURL(config.API_HOST))
-            .then(response => ({ 
+            .then(response => ({
                 // TODO: After tests delete `|| '/vocabulary-example.json'`
-                config: {...response.data, vocabularyUrl: config.VOCABULARY_URL || '/vocabulary-example.json' }, 
-                apiHost: config.API_HOST, 
+                config: {...response.data, vocabularyUrl: config.VOCABULARY_URL || '/vocabulary-example.json' },
+                apiHost: config.API_HOST,
             })));
 
 };
@@ -96,7 +99,7 @@ export const mockConfig = (config: Partial<Config>): Config => ({
     packageVersion: '',
     parameters: {},
     protocol: '',
-    remoteHosts: '',
+    remoteHosts: {},
     remoteHostsViaDNS: false,
     resources: {},
     revision: '',
@@ -111,6 +114,7 @@ export const mockConfig = (config: Partial<Config>): Config => ({
     websocketUrl: '',
     workbenchUrl: '',
     vocabularyUrl: '',
+    origin: '',
     ...config
 });
 
@@ -124,4 +128,5 @@ const getDefaultConfig = (): ConfigJSON => ({
     VOCABULARY_URL: "",
 });
 
-const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/discovery/v1/apis/arvados/v1/rest`;
+export const DISCOVERY_URL = 'discovery/v1/apis/arvados/v1/rest';
+const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${DISCOVERY_URL}`;
index d57c4a8c41c4a7a11f0c9152c5f1172c9ed0b022..0aeaeb85f663ccb3394965b4ff5dff21912e13ee 100644 (file)
@@ -5,8 +5,15 @@
 import * as React from 'react';
 import { WrappedFieldProps } from 'redux-form';
 import { ArvadosTheme } from '~/common/custom-theme';
-import { TextField as MaterialTextField, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import {
+    TextField as MaterialTextField,
+    StyleRulesCallback,
+    WithStyles,
+    withStyles,
+    PropTypes
+} from '@material-ui/core';
 import RichTextEditor from 'react-rte';
+import Margin = PropTypes.Margin;
 
 type CssRules = 'textField';
 
@@ -18,8 +25,8 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 type TextFieldProps = WrappedFieldProps & WithStyles<CssRules>;
 
-export const TextField = withStyles(styles)((props: TextFieldProps & { 
-    label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, children: React.ReactNode
+export const TextField = withStyles(styles)((props: TextFieldProps & {
+    label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, children: React.ReactNode, margin?: Margin
 }) =>
     <MaterialTextField
         helperText={props.meta.touched && props.meta.error}
@@ -33,6 +40,7 @@ export const TextField = withStyles(styles)((props: TextFieldProps & {
         required={props.required}
         select={props.select}
         children={props.children}
+        margin={props.margin}
         {...props.input}
     />);
 
@@ -78,4 +86,4 @@ export const DateTextField = withStyles(styles)
             onChange={props.input.onChange}
             value={props.input.value}
         />
-    );
\ No newline at end of file
+    );
index fbd6c9a88e1bb8ac18d66bd3ff4c681f38ab89ee..aaca125eae9f0b3bd7f73f66686aa7f0b6699cf1 100644 (file)
@@ -91,7 +91,7 @@ fetchConfig()
         const store = configureStore(history, services);
 
         store.subscribe(initListener(history, store, services, config));
-        store.dispatch(initAuth());
+        store.dispatch(initAuth(config));
         store.dispatch(setBuildInfo());
         store.dispatch(setCurrentTokenDialogApiHost(apiHost));
         store.dispatch(setUuidPrefix(config.uuidPrefix));
diff --git a/src/models/client-authorization.ts b/src/models/client-authorization.ts
new file mode 100644 (file)
index 0000000..767916e
--- /dev/null
@@ -0,0 +1,12 @@
+export interface ClientAuthorizationResource {
+    uuid: string;
+    apiToken: string;
+    apiClientId: number;
+    userId: number;
+    createdByIpAddress: string;
+    lastUsedByIpAddress: string;
+    lastUsedAt: string;
+    expiresAt: string;
+    ownerUuid: string;
+    scopes: string[];
+}
diff --git a/src/models/session.ts b/src/models/session.ts
new file mode 100644 (file)
index 0000000..8a5002b
--- /dev/null
@@ -0,0 +1,9 @@
+export interface Session {
+    clusterId: string;
+    remoteHost: string;
+    username: string;
+    email: string;
+    token: string;
+    loggedIn: boolean;
+    validated: boolean;
+}
index f2304acaa77d2b8d0b69789cafa93626446b47e2..0637a3848b5539008ca69bc6540c1e1c157b739d 100644 (file)
@@ -29,6 +29,7 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const virtualMachineMatch = Routes.matchVirtualMachineRoute(pathname);
     const workflowMatch = Routes.matchWorkflowRoute(pathname);
     const sshKeysMatch = Routes.matchSshKeysRoute(pathname);
+    const siteManagerMatch = Routes.matchSiteManagerRoute(pathname);
     const keepServicesMatch = Routes.matchKeepServicesRoute(pathname);
     const computeNodesMatch = Routes.matchComputeNodesRoute(pathname);
 
@@ -60,6 +61,8 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
         store.dispatch(WorkbenchActions.loadRepositories);
     } else if (sshKeysMatch) {
         store.dispatch(WorkbenchActions.loadSshKeys);
+    } else if (siteManagerMatch) {
+        store.dispatch(WorkbenchActions.loadSiteManager);
     } else if (keepServicesMatch) {
         store.dispatch(WorkbenchActions.loadKeepServices);
     } else if (computeNodesMatch) {
index 8f8fa06bd0379232d6da87ea6a47dad5673b811d..b5cb0aca460a4e8aa64e717c63cf5f66fb0a5501 100644 (file)
@@ -23,6 +23,7 @@ export const Routes = {
     WORKFLOWS: '/workflows',
     SEARCH_RESULTS: '/search-results',
     SSH_KEYS: `/ssh-keys`,
+    SITE_MANAGER: `/site-manager`,
     KEEP_SERVICES: `/keep-services`,
     COMPUTE_NODES: `/nodes`
 };
@@ -84,15 +85,18 @@ export const matchSearchResultsRoute = (route: string) =>
 
 export const matchVirtualMachineRoute = (route: string) =>
     matchPath<ResourceRouteParams>(route, { path: Routes.VIRTUAL_MACHINES });
-    
+
 export const matchRepositoriesRoute = (route: string) =>
     matchPath<ResourceRouteParams>(route, { path: Routes.REPOSITORIES });
-    
+
 export const matchSshKeysRoute = (route: string) =>
     matchPath(route, { path: Routes.SSH_KEYS });
 
+export const matchSiteManagerRoute = (route: string) =>
+    matchPath(route, { path: Routes.SITE_MANAGER });
+
 export const matchKeepServicesRoute = (route: string) =>
     matchPath(route, { path: Routes.KEEP_SERVICES });
 
 export const matchComputeNodesRoute = (route: string) =>
-    matchPath(route, { path: Routes.COMPUTE_NODES });
\ No newline at end of file
+    matchPath(route, { path: Routes.COMPUTE_NODES });
index 98c0321598090b11002375823fba7ffa1a374aee..ffd81ef12c86bf1638213d44e0422d527ea91868 100644 (file)
@@ -2,10 +2,13 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { User } from "~/models/user";
+import { getUserFullname, User } from "~/models/user";
 import { AxiosInstance } from "axios";
 import { ApiActions } from "~/services/api/api-actions";
 import * as uuid from "uuid/v4";
+import { Session } from "~/models/session";
+import { Config } from "~/common/config";
+import { merge, uniqWith, uniqBy } from "lodash";
 
 export const API_TOKEN_KEY = 'apiToken';
 export const USER_EMAIL_KEY = 'userEmail';
@@ -61,7 +64,7 @@ export class AuthService {
         const lastName = localStorage.getItem(USER_LAST_NAME_KEY);
         const uuid = this.getUuid();
         const ownerUuid = this.getOwnerUuid();
-        const isAdmin = this.getIsAdmin();   
+        const isAdmin = this.getIsAdmin();
 
         return email && firstName && lastName && uuid && ownerUuid
             ? { email, firstName, lastName, uuid, ownerUuid, isAdmin }
@@ -124,4 +127,47 @@ export class AuthService {
         const uuidParts = uuid ? uuid.split('-') : [];
         return uuidParts.length > 1 ? `${uuidParts[0]}-${uuidParts[1]}` : undefined;
     }
+
+    public getSessions(): Session[] {
+        try {
+            const sessions = JSON.parse(localStorage.getItem("sessions") || '');
+            return sessions;
+        } catch {
+            return [];
+        }
+    }
+
+    public saveSessions(sessions: Session[]) {
+        localStorage.setItem("sessions", JSON.stringify(sessions));
+    }
+
+    public buildSessions(cfg: Config, user?: User) {
+        const currentSession = {
+            clusterId: cfg.uuidPrefix,
+            remoteHost: cfg.baseUrl,
+            username: getUserFullname(user),
+            email: user ? user.email : '',
+            token: this.getApiToken(),
+            loggedIn: true
+        } as Session;
+        const localSessions = this.getSessions();
+        const cfgSessions = Object.keys(cfg.remoteHosts).map(clusterId => {
+            const remoteHost = cfg.remoteHosts[clusterId];
+            return {
+                clusterId,
+                remoteHost,
+                username: '',
+                email: '',
+                token: '',
+                loggedIn: false
+            } as Session;
+        });
+        const sessions = [currentSession]
+            .concat(cfgSessions)
+            .concat(localSessions);
+
+        const uniqSessions = uniqBy(sessions, 'clusterId');
+
+        return uniqSessions;
+    }
 }
diff --git a/src/services/client-authorizations-service/client-authorizations-service.ts b/src/services/client-authorizations-service/client-authorizations-service.ts
new file mode 100644 (file)
index 0000000..6975d63
--- /dev/null
@@ -0,0 +1,12 @@
+import { CommonResourceService } from "~/services/common-service/common-resource-service";
+import { AxiosInstance } from "axios";
+import { ApiActions } from "~/services/api/api-actions";
+import { ClientAuthorizationResource } from "~/models/client-authorization";
+
+export class ClientAuthorizationsService extends CommonResourceService<ClientAuthorizationResource> {
+    constructor(serverApi: AxiosInstance, actions: ApiActions) {
+        super(serverApi, "api_client_authorizations", actions);
+    }
+}
+//
+// "{"9tee4":{"user":{"href":"/users/c97qk-tpzed-h733ef2x1ux1xig","kind":"arvados#user","etag":"71xgfqki00pfo7kc5mnnqtef0","uuid":"c97qk-tpzed-h733ef2x1ux1xig","owner_uuid":"9tee4-tpzed-000000000000000","created_at":"2018-11-21T08:19:20.215298180Z","modified_by_client_uuid":null,"modified_by_user_uuid":"9tee4-tpzed-000000000000000","modified_at":"2018-11-21T08:19:20.437345000Z","email":"unodgs@gmail.com","username":"unodgs","full_name":"Daniel Kos","first_name":"Daniel","last_name":"Kos","identity_url":null,"is_active":true,"is_admin":false,"is_invited":true,"prefs":{"profile":{"organization":"Digital Software","organization_email":"unodgs@gmail.com","lab":"","website_url":"","role":"Software Developer"}},"writable_by":["9tee4-tpzed-000000000000000","c97qk-tpzed-h733ef2x1ux1xig","9tee4-j7d0g-000000000000000"]},"baseURL":"https://9tee4.arvadosapi.com/","token":"v2/c97qk-gj3su-5c8sbdggl81a66k/deeb5637ae08f44a7856abdf53a7c037bdcbe7a6","listedHost":true},"4xphq":{"user":{"href":"/users/c97qk-tpzed-h733ef2x1ux1xig","kind":"arvados#user","etag":"7fivqub7mwmf0fhky6dqr27nx","uuid":"c97qk-tpzed-h733ef2x1ux1xig","owner_uuid":"4xphq-tpzed-000000000000000","created_at":"2018-11-21T08:19:23.000623836Z","modified_by_client_uuid":null,"modified_by_user_uuid":"4xphq-tpzed-000000000000000","modified_at":"2018-11-21T08:19:24.615112000Z","email":"unodgs@gmail.com","username":"unodgs2","full_name":"Daniel Kos","first_name":"Daniel","last_name":"Kos","identity_url":null,"is_active":true,"is_admin":false,"is_invited":true,"prefs":{"profile":{"organization":"Digital Software","organization_email":"unodgs@gmail.com","lab":"","website_url":"","role":"Software Developer"}},"writable_by":["4xphq-tpzed-000000000000000","c97qk-tpzed-h733ef2x1ux1xig","4xphq-j7d0g-000000000000000"]},"baseURL":"https://4xphq.arvadosapi.com/","token":"v2/c97qk-gj3su-5c8sbdggl81a66k/988337de59eb9ea3f484df0b92ca6b6502a77985","listedHost":true}}"
index 6114c560526e7b598c033b0a9c6ae4435bd10047..077e23dbaa228f6504122db9a7779307a36d570b 100644 (file)
@@ -4,7 +4,6 @@
 
 import * as _ from "lodash";
 import { AxiosInstance, AxiosPromise } from "axios";
-import { Resource } from "src/models/resource";
 import * as uuid from "uuid/v4";
 import { ApiActions } from "~/services/api/api-actions";
 
@@ -40,7 +39,7 @@ export enum CommonResourceServiceError {
     NONE = 'None'
 }
 
-export class CommonResourceService<T extends Resource> {
+export class CommonResourceService<T> {
 
     static mapResponseKeys = (response: { data: any }) =>
         CommonResourceService.mapKeys(_.camelCase)(response.data)
index d524405fe62000a889d980520e00ef0b9e771e79..7bb83b0dbf956d8de9b2c127c441cfb2eb3a1cc1 100644 (file)
@@ -29,6 +29,7 @@ import { RepositoriesService } from '~/services/repositories-service/repositorie
 import { AuthorizedKeysService } from '~/services/authorized-keys-service/authorized-keys-service';
 import { VocabularyService } from '~/services/vocabulary-service/vocabulary-service';
 import { NodeService } from '~/services/node-service/node-service';
+import { ClientAuthorizationsService } from "~/services/client-authorizations-service/client-authorizations-service";
 
 export type ServiceRepository = ReturnType<typeof createServices>;
 
@@ -40,6 +41,7 @@ export const createServices = (config: Config, actions: ApiActions) => {
     webdavClient.defaults.baseURL = config.keepWebServiceUrl;
 
     const authorizedKeysService = new AuthorizedKeysService(apiClient, actions);
+    const clientAuthorizationsService = new ClientAuthorizationsService(apiClient, actions);
     const containerRequestService = new ContainerRequestService(apiClient, actions);
     const containerService = new ContainerService(apiClient, actions);
     const groupsService = new GroupsService(apiClient, actions);
@@ -68,6 +70,7 @@ export const createServices = (config: Config, actions: ApiActions) => {
         apiClient,
         authService,
         authorizedKeysService,
+        clientAuthorizationsService,
         collectionFilesService,
         collectionService,
         containerRequestService,
diff --git a/src/store/auth/auth-action-session.ts b/src/store/auth/auth-action-session.ts
new file mode 100644 (file)
index 0000000..c70bcfb
--- /dev/null
@@ -0,0 +1,81 @@
+import { Dispatch } from "redux";
+import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import Axios from "axios";
+import { getUserFullname } from "~/models/user";
+import { authActions } from "~/store/auth/auth-action";
+import { Config, DISCOVERY_URL } from "~/common/config";
+import { Session } from "~/models/session";
+import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { UserDetailsResponse } from "~/services/auth-service/auth-service";
+
+
+const getSessionOrigin = async (session: Session) => {
+    let url = session.remoteHost;
+    if (url.indexOf('://') < 0) {
+        url = 'https://' + url;
+    }
+    const origin = new URL(url).origin;
+    try {
+        const resp = await Axios.get<Config>(`${origin}/${DISCOVERY_URL}`);
+        return resp.data.origin;
+    } catch (err) {
+        try {
+            const resp = await Axios.get<any>(`${origin}/status.json`);
+            return resp.data.apiBaseURL;
+        } catch (err) {
+        }
+    }
+    return null;
+};
+
+const getUserDetails = async (origin: string, token: string): Promise<UserDetailsResponse> => {
+    const resp = await Axios.get<UserDetailsResponse>(`${origin}/arvados/v1/users/current`, {
+        headers: {
+            Authorization: `OAuth2 ${token}`
+        }
+    });
+    return resp.data;
+};
+
+const validateSessions = () =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        const sessions = getState().auth.sessions;
+        dispatch(progressIndicatorActions.START_WORKING("sessionsValidation"));
+        for (const session of sessions) {
+            if (!session.validated) {
+                const origin = await getSessionOrigin(session);
+                const user = await getUserDetails(origin, session.token);
+            }
+        }
+        dispatch(progressIndicatorActions.STOP_WORKING("sessionsValidation"));
+    };
+
+export const addSession = (remoteHost: string) =>
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const user = getState().auth.user!;
+        const clusterId = remoteHost.match(/^(\w+)\./)![1];
+
+        dispatch(authActions.ADD_SESSION({
+            loggedIn: false,
+            validated: false,
+            email: user.email,
+            username: getUserFullname(user),
+            remoteHost,
+            clusterId,
+            token: ''
+        }));
+
+        services.authService.saveSessions(getState().auth.sessions);
+    };
+
+export const loadSiteManagerPanel = () =>
+    async (dispatch: Dispatch<any>) => {
+        try {
+            dispatch(setBreadcrumbs([{ label: 'Site Manager'}]));
+            dispatch(validateSessions());
+        } catch (e) {
+            return;
+        }
+    };
diff --git a/src/store/auth/auth-action-ssh.ts b/src/store/auth/auth-action-ssh.ts
new file mode 100644 (file)
index 0000000..4175d29
--- /dev/null
@@ -0,0 +1,98 @@
+import { dialogActions } from "~/store/dialog/dialog-actions";
+import { Dispatch } from "redux";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import { snackbarActions } from "~/store/snackbar/snackbar-actions";
+import { FormErrors, reset, startSubmit, stopSubmit } from "redux-form";
+import { KeyType } from "~/models/ssh-key";
+import {
+    AuthorizedKeysServiceError,
+    getAuthorizedKeysServiceError
+} from "~/services/authorized-keys-service/authorized-keys-service";
+import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
+import {
+    authActions,
+} from "~/store/auth/auth-action";
+
+export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName';
+export const SSH_KEY_PUBLIC_KEY_DIALOG = 'sshKeyPublicKeyDialog';
+export const SSH_KEY_REMOVE_DIALOG = 'sshKeyRemoveDialog';
+export const SSH_KEY_ATTRIBUTES_DIALOG = 'sshKeyAttributesDialog';
+
+export interface SshKeyCreateFormDialogData {
+    publicKey: string;
+    name: string;
+}
+
+export const openSshKeyCreateDialog = () => dialogActions.OPEN_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME, data: {} });
+
+export const openPublicKeyDialog = (name: string, publicKey: string) =>
+    dialogActions.OPEN_DIALOG({ id: SSH_KEY_PUBLIC_KEY_DIALOG, data: { name, publicKey } });
+
+export const openSshKeyAttributesDialog = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState) => {
+        const sshKey = getState().auth.sshKeys.find(it => it.uuid === uuid);
+        dispatch(dialogActions.OPEN_DIALOG({ id: SSH_KEY_ATTRIBUTES_DIALOG, data: { sshKey } }));
+    };
+
+export const openSshKeyRemoveDialog = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState) => {
+        dispatch(dialogActions.OPEN_DIALOG({
+            id: SSH_KEY_REMOVE_DIALOG,
+            data: {
+                title: 'Remove public key',
+                text: 'Are you sure you want to remove this public key?',
+                confirmButtonLabel: 'Remove',
+                uuid
+            }
+        }));
+    };
+
+export const removeSshKey = (uuid: string) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
+        await services.authorizedKeysService.delete(uuid);
+        dispatch(authActions.REMOVE_SSH_KEY(uuid));
+        dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Public Key has been successfully removed.', hideDuration: 2000 }));
+    };
+
+export const createSshKey = (data: SshKeyCreateFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const userUuid = getState().auth.user!.uuid;
+        const { name, publicKey } = data;
+        dispatch(startSubmit(SSH_KEY_CREATE_FORM_NAME));
+        try {
+            const newSshKey = await services.authorizedKeysService.create({
+                name,
+                publicKey,
+                keyType: KeyType.SSH,
+                authorizedUserUuid: userUuid
+            });
+            dispatch(authActions.ADD_SSH_KEY(newSshKey));
+            dispatch(dialogActions.CLOSE_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME }));
+            dispatch(reset(SSH_KEY_CREATE_FORM_NAME));
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Public key has been successfully created.",
+                hideDuration: 2000
+            }));
+        } catch (e) {
+            const error = getAuthorizedKeysServiceError(e);
+            if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
+                dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' } as FormErrors));
+            } else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
+                dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' } as FormErrors));
+            }
+        }
+    };
+
+export const loadSshKeysPanel = () =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            dispatch(setBreadcrumbs([{ label: 'SSH Keys'}]));
+            const response = await services.authorizedKeysService.list();
+            dispatch(authActions.SET_SSH_KEYS(response.items));
+        } catch (e) {
+            return;
+        }
+    };
+
similarity index 93%
rename from src/store/auth/auth-actions.test.ts
rename to src/store/auth/auth-action.test.ts
index aeee2b3b7c8f66d90b4e26c6bb4c09a3c10337e2..6d28eb47332c68a814e5e87514b623284a7cea9f 100644 (file)
@@ -18,7 +18,7 @@ import 'jest-localstorage-mock';
 import { createServices } from "~/services/services";
 import { configureStore, RootStore } from "../store";
 import createBrowserHistory from "history/createBrowserHistory";
-import { mockConfig } from '~/common/config';
+import { Config, mockConfig } from '~/common/config';
 import { ApiActions } from "~/services/api/api-actions";
 
 describe('auth-actions', () => {
@@ -45,7 +45,11 @@ describe('auth-actions', () => {
         localStorage.setItem(USER_OWNER_UUID_KEY, "ownerUuid");
         localStorage.setItem(USER_IS_ADMIN, JSON.stringify("false"));
 
-        store.dispatch(initAuth());
+        const config: any = {
+            remoteHosts: { "xc59": "xc59.api.arvados.com" }
+        };
+
+        store.dispatch(initAuth(config));
 
         expect(store.getState().auth).toEqual({
             apiToken: "token",
index 4ed348751faa6a516eb07bcf3cb2c18688534e01..8c1673d7c5d8c81ff152325ae2968a897b0f5bc7 100644 (file)
@@ -4,16 +4,13 @@
 
 import { ofType, unionize, UnionOf } from '~/common/unionize';
 import { Dispatch } from "redux";
-import { reset, stopSubmit, startSubmit, FormErrors } from 'redux-form';
 import { AxiosInstance } from "axios";
 import { RootState } from "../store";
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { dialogActions } from '~/store/dialog/dialog-actions';
-import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
 import { ServiceRepository } from "~/services/services";
-import { getAuthorizedKeysServiceError, AuthorizedKeysServiceError } from '~/services/authorized-keys-service/authorized-keys-service';
-import { KeyType, SshKeyResource } from '~/models/ssh-key';
+import { SshKeyResource } from '~/models/ssh-key';
 import { User } from "~/models/user";
+import { Session } from "~/models/session";
+import { Config } from '~/common/config';
 
 export const authActions = unionize({
     SAVE_API_TOKEN: ofType<string>(),
@@ -24,19 +21,12 @@ export const authActions = unionize({
     USER_DETAILS_SUCCESS: ofType<User>(),
     SET_SSH_KEYS: ofType<SshKeyResource[]>(),
     ADD_SSH_KEY: ofType<SshKeyResource>(),
-    REMOVE_SSH_KEY: ofType<string>()
+    REMOVE_SSH_KEY: ofType<string>(),
+    SET_SESSIONS: ofType<Session[]>(),
+    ADD_SESSION: ofType<Session>(),
+    REMOVE_SESSION: ofType<string>()
 });
 
-export const SSH_KEY_CREATE_FORM_NAME = 'sshKeyCreateFormName';
-export const SSH_KEY_PUBLIC_KEY_DIALOG = 'sshKeyPublicKeyDialog';
-export const SSH_KEY_REMOVE_DIALOG = 'sshKeyRemoveDialog';
-export const SSH_KEY_ATTRIBUTES_DIALOG = 'sshKeyAttributesDialog';
-
-export interface SshKeyCreateFormDialogData {
-    publicKey: string;
-    name: string;
-}
-
 function setAuthorizationHeader(services: ServiceRepository, token: string) {
     services.apiClient.defaults.headers.common = {
         Authorization: `OAuth2 ${token}`
@@ -50,7 +40,7 @@ function removeAuthorizationHeader(client: AxiosInstance) {
     delete client.defaults.headers.common.Authorization;
 }
 
-export const initAuth = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     const user = services.authService.getUser();
     const token = services.authService.getApiToken();
     if (token) {
@@ -59,6 +49,9 @@ export const initAuth = () => (dispatch: Dispatch, getState: () => RootState, se
     if (token && user) {
         dispatch(authActions.INIT({ user, token }));
     }
+    const sessions = services.authService.buildSessions(config, user);
+    services.authService.saveSessions(sessions);
+    dispatch(authActions.SET_SESSIONS(sessions));
 };
 
 export const saveApiToken = (token: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
@@ -89,77 +82,4 @@ export const getUserDetails = () => (dispatch: Dispatch, getState: () => RootSta
     });
 };
 
-export const openSshKeyCreateDialog = () => dialogActions.OPEN_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME, data: {} });
-
-export const openPublicKeyDialog = (name: string, publicKey: string) =>
-    dialogActions.OPEN_DIALOG({ id: SSH_KEY_PUBLIC_KEY_DIALOG, data: { name, publicKey } });
-
-export const openSshKeyAttributesDialog = (uuid: string) =>
-    (dispatch: Dispatch, getState: () => RootState) => {
-        const sshKey = getState().auth.sshKeys.find(it => it.uuid === uuid);
-        dispatch(dialogActions.OPEN_DIALOG({ id: SSH_KEY_ATTRIBUTES_DIALOG, data: { sshKey } }));
-    };
-
-export const openSshKeyRemoveDialog = (uuid: string) =>
-    (dispatch: Dispatch, getState: () => RootState) => {
-        dispatch(dialogActions.OPEN_DIALOG({
-            id: SSH_KEY_REMOVE_DIALOG,
-            data: {
-                title: 'Remove public key',
-                text: 'Are you sure you want to remove this public key?',
-                confirmButtonLabel: 'Remove',
-                uuid
-            }
-        }));
-    };
-
-export const removeSshKey = (uuid: string) =>
-    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
-        await services.authorizedKeysService.delete(uuid);
-        dispatch(authActions.REMOVE_SSH_KEY(uuid));
-        dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Public Key has been successfully removed.', hideDuration: 2000 }));
-    };
-
-export const createSshKey = (data: SshKeyCreateFormDialogData) =>
-    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const userUuid = getState().auth.user!.uuid;
-        const { name, publicKey } = data;
-        dispatch(startSubmit(SSH_KEY_CREATE_FORM_NAME));
-        try {
-            const newSshKey = await services.authorizedKeysService.create({
-                name,
-                publicKey,
-                keyType: KeyType.SSH,
-                authorizedUserUuid: userUuid
-            });
-            dispatch(authActions.ADD_SSH_KEY(newSshKey));
-            dispatch(dialogActions.CLOSE_DIALOG({ id: SSH_KEY_CREATE_FORM_NAME }));
-            dispatch(reset(SSH_KEY_CREATE_FORM_NAME));
-            dispatch(snackbarActions.OPEN_SNACKBAR({
-                message: "Public key has been successfully created.",
-                hideDuration: 2000
-            }));
-        } catch (e) {
-            const error = getAuthorizedKeysServiceError(e);
-            if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
-                dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' } as FormErrors));
-            } else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
-                dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' } as FormErrors));
-            }
-        }
-    };
-
-export const loadSshKeysPanel = () =>
-    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
-        try {
-            dispatch(setBreadcrumbs([{ label: 'SSH Keys'}]));
-            const response = await services.authorizedKeysService.list();
-            dispatch(authActions.SET_SSH_KEYS(response.items));
-        } catch (e) {
-            return;
-        }
-    };
-
-
 export type AuthAction = UnionOf<typeof authActions>;
index a8e4340af52ac35142d9db3c73dce1c78de5fa7a..1edcedee68b6e2296cee4028ce655b9b0736a6ff 100644 (file)
@@ -6,17 +6,20 @@ import { authActions, AuthAction } from "./auth-action";
 import { User } from "~/models/user";
 import { ServiceRepository } from "~/services/services";
 import { SshKeyResource } from '~/models/ssh-key';
+import { Session } from "~/models/session";
 
 export interface AuthState {
     user?: User;
     apiToken?: string;
     sshKeys: SshKeyResource[];
+    sessions: Session[];
 }
 
 const initialState: AuthState = {
     user: undefined,
     apiToken: undefined,
-    sshKeys: []
+    sshKeys: [],
+    sessions: []
 };
 
 export const authReducer = (services: ServiceRepository) => (state = initialState, action: AuthAction) => {
@@ -45,6 +48,19 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat
         REMOVE_SSH_KEY: (uuid: string) => {
             return { ...state, sshKeys: state.sshKeys.filter((sshKey) => sshKey.uuid !== uuid )};
         },
+        SET_SESSIONS: (sessions: Session[]) => {
+            return { ...state, sessions };
+        },
+        ADD_SESSION: (session: Session) => {
+            return { ...state, sessions: state.sessions.concat(session) };
+        },
+        REMOVE_SESSION: (clusterId: string) => {
+            return {
+                ...state,
+                sessions: state.sessions.filter(
+                    session => session.clusterId !== clusterId
+                )};
+        },
         default: () => state
     });
 };
index 50cfd88d326e8fe97a4610b6b27b6ab842a8a092..8e3929d9501a7ab84b7b16da9012bfb260841c15 100644 (file)
@@ -68,6 +68,8 @@ export const navigateToRepositories = push(Routes.REPOSITORIES);
 
 export const navigateToSshKeys= push(Routes.SSH_KEYS);
 
+export const navigateToSiteManager= push(Routes.SITE_MANAGER);
+
 export const navigateToKeepServices = push(Routes.KEEP_SERVICES);
 
-export const navigateToComputeNodes = push(Routes.COMPUTE_NODES);
\ No newline at end of file
+export const navigateToComputeNodes = push(Routes.COMPUTE_NODES);
index e3f96a9c07de620385640dd43445ca566c276f8b..fdef38c485384478403d841419be4b0b81d2dc4e 100644 (file)
@@ -39,7 +39,8 @@ import { sharedWithMePanelActions } from '~/store/shared-with-me-panel/shared-wi
 import { loadSharedWithMePanel } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
 import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
-import { loadSshKeysPanel } from '~/store/auth/auth-action';
+import { loadSshKeysPanel } from '~/store/auth/auth-action-ssh';
+import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
 import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
 import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
@@ -400,7 +401,7 @@ export const loadVirtualMachines = handleFirstTimeLoad(
         await dispatch(loadVirtualMachinesPanel());
         dispatch(setBreadcrumbs([{ label: 'Virtual Machines' }]));
     });
-    
+
 export const loadRepositories = handleFirstTimeLoad(
     async (dispatch: Dispatch<any>) => {
         await dispatch(loadRepositoriesPanel());
@@ -412,6 +413,11 @@ export const loadSshKeys = handleFirstTimeLoad(
         await dispatch(loadSshKeysPanel());
     });
 
+export const loadSiteManager = handleFirstTimeLoad(
+    async (dispatch: Dispatch<any>) => {
+        await dispatch(loadSiteManagerPanel());
+    });
+
 export const loadKeepServices = handleFirstTimeLoad(
     async (dispatch: Dispatch<any>) => {
         await dispatch(loadKeepServicesPanel());
diff --git a/src/validators/is-remote-host.tsx b/src/validators/is-remote-host.tsx
new file mode 100644 (file)
index 0000000..b5e2231
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+
+const ERROR_MESSAGE = 'Remote host is invalid';
+
+export const isRemoteHost = (value: string) => {
+    return value.match(/\w+\.\w+\.\w+/i) ? undefined : ERROR_MESSAGE;
+};
index c601df17416d8711be048d51144684703fa4fe8c..06f46219414317b94ebeb7d25a25810e750d8920 100644 (file)
@@ -5,6 +5,7 @@
 import { require } from './require';
 import { maxLength } from './max-length';
 import { isRsaKey } from './is-rsa-key';
+import { isRemoteHost } from "./is-remote-host";
 
 export const TAG_KEY_VALIDATION = [require, maxLength(255)];
 export const TAG_VALUE_VALIDATION = [require, maxLength(255)];
@@ -26,3 +27,5 @@ export const REPOSITORY_NAME_VALIDATION = [require, maxLength(255)];
 
 export const SSH_KEY_PUBLIC_VALIDATION = [require, isRsaKey, maxLength(1024)];
 export const SSH_KEY_NAME_VALIDATION = [require, maxLength(255)];
+
+export const SITE_MANAGER_REMOTE_HOST_VALIDATION = [require, isRemoteHost, maxLength(255)];
index 0ce0c43118549b9107a17f8e9c3bf515b53f50a3..c2885185eabac9432c357c0d50a021d569179059 100644 (file)
@@ -4,7 +4,7 @@
 
 import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
 import { AdvancedIcon, RemoveIcon, AttributesIcon } from "~/components/icon/icon";
-import { openSshKeyRemoveDialog, openSshKeyAttributesDialog } from '~/store/auth/auth-action';
+import { openSshKeyRemoveDialog, openSshKeyAttributesDialog } from '~/store/auth/auth-action-ssh';
 import { openAdvancedTabDialog } from '~/store/advanced-tab/advanced-tab';
 
 export const sshKeyActionSet: ContextMenuActionSet = [[{
index b7c9b1fbe6e19bba50db582618c1455c75813cf0..aed1cd245dd26b0f3a5ad647758c196e34238271 100644 (file)
@@ -7,7 +7,7 @@ import { InjectedFormProps } from 'redux-form';
 import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { FormDialog } from '~/components/form-dialog/form-dialog';
 import { SshKeyPublicField, SshKeyNameField } from '~/views-components/form-fields/ssh-key-form-fields';
-import { SshKeyCreateFormDialogData } from '~/store/auth/auth-action';
+import { SshKeyCreateFormDialogData } from '~/store/auth/auth-action-ssh';
 
 type DialogSshKeyProps = WithDialogProps<{}> & InjectedFormProps<SshKeyCreateFormDialogData>;
 
index e96524338dd626bd333b3f3d6afd93dc91e85335..6472c3ae57a5c8743db8c7bbc7da2dc466d6fe9d 100644 (file)
@@ -5,7 +5,11 @@
 import { compose } from "redux";
 import { reduxForm } from 'redux-form';
 import { withDialog } from "~/store/dialog/with-dialog";
-import { SSH_KEY_CREATE_FORM_NAME, createSshKey, SshKeyCreateFormDialogData } from '~/store/auth/auth-action';
+import {
+    SSH_KEY_CREATE_FORM_NAME,
+    createSshKey,
+    SshKeyCreateFormDialogData
+} from '~/store/auth/auth-action-ssh';
 import { DialogSshKeyCreate } from '~/views-components/dialog-create/dialog-ssh-key-create';
 
 export const CreateSshKeyDialog = compose(
@@ -16,4 +20,4 @@ export const CreateSshKeyDialog = compose(
             dispatch(createSshKey(data));
         }
     })
-)(DialogSshKeyCreate);
\ No newline at end of file
+)(DialogSshKeyCreate);
index f4232a129dd3c07b11d64d88f661eab40b79ab9c..b71c92cb27e730b34eb19b364433d3b372c1683c 100644 (file)
@@ -12,7 +12,12 @@ import { logout } from '~/store/auth/auth-action';
 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, navigateToKeepServices, navigateToComputeNodes } from '~/store/navigation/navigation-action';
+import {
+    navigateToSshKeys,
+    navigateToKeepServices,
+    navigateToComputeNodes,
+    navigateToSiteManager
+} from '~/store/navigation/navigation-action';
 import { openVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
 
 interface AccountMenuProps {
@@ -37,6 +42,7 @@ export const AccountMenu = connect(mapStateToProps)(
                 <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
                 <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
                 <MenuItem onClick={() => dispatch(navigateToSshKeys)}>Ssh Keys</MenuItem>
+                <MenuItem onClick={() => dispatch(navigateToSiteManager)}>Site Manager</MenuItem>
                 { user.isAdmin && <MenuItem onClick={() => dispatch(navigateToKeepServices)}>Keep Services</MenuItem> }
                 { user.isAdmin && <MenuItem onClick={() => dispatch(navigateToComputeNodes)}>Compute Nodes</MenuItem> }
                 <MenuItem>My account</MenuItem>
index 78b79a8ed46bf0f70737fa412178d421fa0562fb..8b8f9891264fba26f2039e20c1e3addce80cf009 100644 (file)
@@ -20,7 +20,8 @@ const isButtonVisible = ({ router }: RootState) => {
     const pathname = router.location ? router.location.pathname : '';
     return !Routes.matchWorkflowRoute(pathname) && !Routes.matchVirtualMachineRoute(pathname) &&
         !Routes.matchRepositoriesRoute(pathname) && !Routes.matchSshKeysRoute(pathname) &&
-        !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname);
+        !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) &&
+        !Routes.matchSiteManagerRoute(pathname);
 };
 
 export const MainContentBar = connect((state: RootState) => ({
index 9e276ade09e71e6b9e42c485b8b6e89be73c8d57..1a806511523b6e0bc3fabeb1322a72ba615e3fcf 100644 (file)
@@ -37,5 +37,5 @@ const RenameDialogFormFields = (props: WithDialogProps<RenameFileDialogData>) =>
         component={TextField}
         autoFocus={true}
     />
-    <WarningCollection text="Renaming a file will change content adress." />
+    <WarningCollection text="Renaming a file will change content address." />
 </>;
index ce896dcc767091eb022f352889f3eb84a2d2b47f..0c164dbd26061e26c81aed12342ab97a1f2120bf 100644 (file)
@@ -4,9 +4,9 @@
 
 import * as React from "react";
 import { compose } from 'redux';
-import { withStyles, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, WithStyles, Typography, Grid } from '@material-ui/core';
+import { withStyles, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, WithStyles, Grid } from '@material-ui/core';
 import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog";
-import { SSH_KEY_ATTRIBUTES_DIALOG } from '~/store/auth/auth-action';
+import { SSH_KEY_ATTRIBUTES_DIALOG } from '~/store/auth/auth-action-ssh';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { SshKeyResource } from "~/models/ssh-key";
 
@@ -66,4 +66,4 @@ export const AttributesSshKeyDialog = compose(
                     </Button>
                 </DialogActions>
             </Dialog>
-    );
\ No newline at end of file
+    );
index 77c6cfdea9574bfdb66c2e47962f0ebed3c685e7..11ec159501a41f85928e97c6bfafde2993b6df3d 100644 (file)
@@ -6,7 +6,7 @@ import * as React from "react";
 import { compose } from 'redux';
 import { withStyles, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, WithStyles } from '@material-ui/core';
 import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog";
-import { SSH_KEY_PUBLIC_KEY_DIALOG } from '~/store/auth/auth-action';
+import { SSH_KEY_PUBLIC_KEY_DIALOG } from '~/store/auth/auth-action-ssh';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { DefaultCodeSnippet } from '~/components/default-code-snippet/default-code-snippet';
 
@@ -52,4 +52,4 @@ export const PublicKeyDialog = compose(
                     </Button>
                 </DialogActions>
             </Dialog>
-    );
\ No newline at end of file
+    );
index 8077f21b0c7a156bdea265f4bf4f39b5c066f930..916e918c36a2475824d78a7663d40ed37e041cd5 100644 (file)
@@ -5,7 +5,7 @@ import { Dispatch, compose } from 'redux';
 import { connect } from "react-redux";
 import { ConfirmationDialog } from "~/components/confirmation-dialog/confirmation-dialog";
 import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
-import { SSH_KEY_REMOVE_DIALOG, removeSshKey } from '~/store/auth/auth-action';
+import { SSH_KEY_REMOVE_DIALOG, removeSshKey } from '~/store/auth/auth-action-ssh';
 
 const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
     onConfirm: () => {
@@ -17,4 +17,4 @@ const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) =>
 export const RemoveSshKeyDialog = compose(
     withDialog(SSH_KEY_REMOVE_DIALOG),
     connect(null, mapDispatchToProps)
-)(ConfirmationDialog);
\ No newline at end of file
+)(ConfirmationDialog);
diff --git a/src/views/site-manager-panel/site-manager-panel-root.tsx b/src/views/site-manager-panel/site-manager-panel-root.tsx
new file mode 100644 (file)
index 0000000..29969fc
--- /dev/null
@@ -0,0 +1,152 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import {
+    Card,
+    CardContent,
+    Grid,
+    StyleRulesCallback,
+    Table,
+    TableBody,
+    TableCell,
+    TableHead,
+    TableRow,
+    Typography,
+    WithStyles,
+    withStyles
+} from '@material-ui/core';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { Session } from "~/models/session";
+import Button from "@material-ui/core/Button";
+import { User } from "~/models/user";
+import { compose } from "redux";
+import { Field, InjectedFormProps, reduxForm, reset } from "redux-form";
+import { TextField } from "~/components/text-field/text-field";
+import { addSession } from "~/store/auth/auth-action-session";
+import { SITE_MANAGER_REMOTE_HOST_VALIDATION } from "~/validators/validators";
+
+type CssRules = 'root' | 'link' | 'buttonContainer' | 'table' | 'tableRow' | 'status' | 'remoteSiteInfo' | 'buttonAdd';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    root: {
+       width: '100%',
+       overflow: 'auto'
+    },
+    link: {
+        color: theme.palette.primary.main,
+        textDecoration: 'none',
+        margin: '0px 4px'
+    },
+    buttonContainer: {
+        textAlign: 'right'
+    },
+    table: {
+        marginTop: theme.spacing.unit
+    },
+    tableRow: {
+        '& td, th': {
+            whiteSpace: 'nowrap'
+        }
+    },
+    status: {
+        width: 100,
+        padding: 5,
+        fontWeight: 'bold',
+        textAlign: 'center',
+        borderRadius: 4
+    },
+    remoteSiteInfo: {
+        marginTop: 20
+    },
+    buttonAdd: {
+        marginLeft: 10,
+        marginTop: theme.spacing.unit * 3
+    }
+});
+
+export interface SiteManagerPanelRootActionProps {
+}
+
+export interface SiteManagerPanelRootDataProps {
+    sessions: Session[];
+    user: User;
+}
+
+type SiteManagerPanelRootProps = SiteManagerPanelRootDataProps & SiteManagerPanelRootActionProps & WithStyles<CssRules> & InjectedFormProps;
+const SITE_MANAGER_FORM_NAME = 'siteManagerForm';
+
+export const SiteManagerPanelRoot = compose(
+    reduxForm<{remoteHost: string}>({
+        form: SITE_MANAGER_FORM_NAME,
+        onSubmit: (data, dispatch) => {
+            dispatch(addSession(data.remoteHost));
+            dispatch(reset(SITE_MANAGER_FORM_NAME));
+        }
+    }),
+    withStyles(styles))
+    (({ classes, sessions, handleSubmit }: SiteManagerPanelRootProps) =>
+        <Card className={classes.root}>
+            <CardContent>
+                <Grid container direction="row">
+                    <Grid item xs={12}>
+                        <Typography variant='body1' paragraph={true} >
+                            You can log in to multiple Arvados sites here, then use the multi-site search page to search collections and projects on all sites at once.
+                        </Typography>
+                    </Grid>
+                </Grid>
+                <Grid item xs={12}>
+                    {sessions.length > 0 && <Table className={classes.table}>
+                        <TableHead>
+                            <TableRow className={classes.tableRow}>
+                                <TableCell>Cluster ID</TableCell>
+                                <TableCell>Username</TableCell>
+                                <TableCell>Email</TableCell>
+                                <TableCell>Status</TableCell>
+                            </TableRow>
+                        </TableHead>
+                        <TableBody>
+                            {sessions.map((session, index) =>
+                                <TableRow key={index} className={classes.tableRow}>
+                                    <TableCell>{session.clusterId}</TableCell>
+                                    <TableCell>{session.username}</TableCell>
+                                    <TableCell>{session.email}</TableCell>
+                                    <TableCell>
+                                        <div className={classes.status} style={{
+                                            color: session.loggedIn ? '#fff' : '#000',
+                                            backgroundColor: session.loggedIn ? '#009966' : '#FFC414'
+                                        }}>
+                                            {session.loggedIn ? "Logged in" : "Logged out"}
+                                        </div>
+                                    </TableCell>
+                                </TableRow>)}
+                        </TableBody>
+                    </Table>}
+                </Grid>
+                <form onSubmit={handleSubmit}>
+                    <Grid container direction="row">
+                        <Grid item xs={12}>
+                            <Typography variant='body1' paragraph={true} className={classes.remoteSiteInfo}>
+                                To add a remote Arvados site, paste the remote site's host here (see "ARVADOS_API_HOST" on the "current token" page).
+                            </Typography>
+                        </Grid>
+                        <Grid item xs={8}>
+                            <Field
+                                name='remoteHost'
+                                validate={SITE_MANAGER_REMOTE_HOST_VALIDATION}
+                                component={TextField}
+                                placeholder="zzzz.arvadosapi.com"
+                                margin="normal"
+                                label="New cluster"/>
+                        </Grid>
+                        <Grid item xs={3}>
+                            <Button type="submit" variant="contained" color="primary"
+                                className={classes.buttonAdd}>
+                                {"ADD"}</Button>
+                        </Grid>
+                    </Grid>
+                </form>
+            </CardContent>
+        </Card>
+    );
diff --git a/src/views/site-manager-panel/site-manager-panel.tsx b/src/views/site-manager-panel/site-manager-panel.tsx
new file mode 100644 (file)
index 0000000..d7fd398
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { RootState } from '~/store/store';
+import { Dispatch } from 'redux';
+import { connect } from 'react-redux';
+import {
+    SiteManagerPanelRoot, SiteManagerPanelRootActionProps,
+    SiteManagerPanelRootDataProps
+} from "~/views/site-manager-panel/site-manager-panel-root";
+
+const mapStateToProps = (state: RootState): SiteManagerPanelRootDataProps => {
+    return {
+        sessions: state.auth.sessions,
+        user: state.auth.user!!
+    };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): SiteManagerPanelRootActionProps => ({
+});
+
+export const SiteManagerPanel = connect(mapStateToProps, mapDispatchToProps)(SiteManagerPanelRoot);
index 4e800296d076fb3f368ac9d98959d3d00520a18b..6575a9cc179aad9c8318303dfcc5faade6766379 100644 (file)
@@ -5,7 +5,7 @@
 import { RootState } from '~/store/store';
 import { Dispatch } from 'redux';
 import { connect } from 'react-redux';
-import { openSshKeyCreateDialog, openPublicKeyDialog } from '~/store/auth/auth-action';
+import { openSshKeyCreateDialog, openPublicKeyDialog } from '~/store/auth/auth-action-ssh';
 import { openSshKeyContextMenu } from '~/store/context-menu/context-menu-actions';
 import { SshKeyPanelRoot, SshKeyPanelRootDataProps, SshKeyPanelRootActionProps } from '~/views/ssh-key-panel/ssh-key-panel-root';
 
@@ -28,4 +28,4 @@ const mapDispatchToProps = (dispatch: Dispatch): SshKeyPanelRootActionProps => (
     }
 });
 
-export const SshKeyPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);
\ No newline at end of file
+export const SshKeyPanel = connect(mapStateToProps, mapDispatchToProps)(SshKeyPanelRoot);
index 92c2438b49f92c3d16bcf741713d76e6972d8643..af2325bffde022e105d6f0db3b1f7d94242775fd 100644 (file)
@@ -45,6 +45,7 @@ import SplitterLayout from 'react-splitter-layout';
 import { WorkflowPanel } from '~/views/workflow-panel/workflow-panel';
 import { SearchResultsPanel } from '~/views/search-results-panel/search-results-panel';
 import { SshKeyPanel } from '~/views/ssh-key-panel/ssh-key-panel';
+import { SiteManagerPanel } from "~/views/site-manager-panel/site-manager-panel";
 import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog';
 import { AdvancedTabDialog } from '~/views-components/advanced-tab-dialog/advanced-tab-dialog';
 import { ProcessInputDialog } from '~/views-components/process-input-dialog/process-input-dialog';
@@ -139,6 +140,7 @@ export const WorkbenchPanel =
                                 <Route path={Routes.VIRTUAL_MACHINES} component={VirtualMachinePanel} />
                                 <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
                                 <Route path={Routes.SSH_KEYS} component={SshKeyPanel} />
+                                <Route path={Routes.SITE_MANAGER} component={SiteManagerPanel} />
                                 <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
                                 <Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />
                             </Switch>
@@ -190,4 +192,4 @@ export const WorkbenchPanel =
             <UpdateProjectDialog />
             <VirtualMachineAttributesDialog />
         </Grid>
-    );
\ No newline at end of file
+    );