Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14512_admin_links
authorJanicki Artur <artur.janicki@contractors.roche.com>
Wed, 12 Dec 2018 09:55:10 +0000 (10:55 +0100)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Wed, 12 Dec 2018 09:55:10 +0000 (10:55 +0100)
refs #2
14512

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

32 files changed:
src/components/icon/icon.tsx
src/models/link.ts
src/routes/route-change-handlers.ts
src/routes/routes.ts
src/services/ancestors-service/ancestors-service.ts
src/services/workflow-service/workflow-service.ts
src/store/auth/auth-action.ts
src/store/collection-panel/collection-panel-action.ts
src/store/navigation/navigation-action.ts
src/store/process-panel/process-panel-actions.ts
src/store/processes/process-update-actions.ts
src/store/run-process-panel/run-process-panel-actions.ts
src/store/run-process-panel/run-process-panel-reducer.ts
src/store/users/users-actions.ts
src/store/virtual-machines/virtual-machines-actions.ts
src/validators/validators.tsx
src/views-components/dialog-update/dialog-process-update.tsx
src/views-components/form-fields/process-form-fields.tsx
src/views-components/main-app-bar/account-menu.tsx
src/views-components/main-app-bar/admin-menu.tsx [new file with mode: 0644]
src/views-components/main-app-bar/main-app-bar.tsx
src/views-components/main-content-bar/main-content-bar.tsx
src/views/collection-panel/collection-panel.tsx
src/views/process-panel/process-information-card.tsx
src/views/process-panel/process-panel-root.tsx
src/views/process-panel/process-panel.tsx
src/views/repositories-panel/repositories-panel.tsx
src/views/run-process-panel/run-process-second-step.tsx
src/views/run-process-panel/workflow-preset-select.tsx [new file with mode: 0644]
src/views/virtual-machine-panel/virtual-machine-admin-panel.tsx [new file with mode: 0644]
src/views/virtual-machine-panel/virtual-machine-user-panel.tsx [moved from src/views/virtual-machine-panel/virtual-machine-panel.tsx with 53% similarity]
src/views/workbench/workbench.tsx

index 8049686f3d749c56db2bab6a55b99d63c975a65e..c077f7a675ceaf10662c20e885160050fd5d10a9 100644 (file)
@@ -7,6 +7,7 @@ import Add from '@material-ui/icons/Add';
 import ArrowBack from '@material-ui/icons/ArrowBack';
 import ArrowDropDown from '@material-ui/icons/ArrowDropDown';
 import BubbleChart from '@material-ui/icons/BubbleChart';
+import Build from '@material-ui/icons/Build';
 import Cached from '@material-ui/icons/Cached';
 import ChevronLeft from '@material-ui/icons/ChevronLeft';
 import CloudUpload from '@material-ui/icons/CloudUpload';
@@ -55,6 +56,7 @@ export type IconType = React.SFC<{ className?: string, style?: object }>;
 
 export const AddIcon: IconType = (props) => <Add {...props} />;
 export const AddFavoriteIcon: IconType = (props) => <StarBorder {...props} />;
+export const AdminMenuIcon: IconType = (props) => <Build {...props} />;
 export const AdvancedIcon: IconType = (props) => <SettingsApplications {...props} />;
 export const AttributesIcon: IconType = (props) => <ListAlt {...props} />;
 export const BackIcon: IconType = (props) => <ArrowBack {...props} />;
index acaf13955d2ad2e9f0b2138894939568709ab7df..d931f7f21898b394b2b2efb73349838e533532a8 100644 (file)
@@ -20,4 +20,5 @@ export enum LinkClass {
     STAR = 'star',
     TAG = 'tag',
     PERMISSION = 'permission',
+    PRESET = 'preset',
 }
\ No newline at end of file
index 34b488def282b3224a22183766a3f91708eadaf8..c4b0fc7d5d5486f8be4fc30896a5296407c90ed2 100644 (file)
@@ -26,9 +26,11 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const searchResultsMatch = Routes.matchSearchResultsRoute(pathname);
     const sharedWithMeMatch = Routes.matchSharedWithMeRoute(pathname);
     const runProcessMatch = Routes.matchRunProcessRoute(pathname);
-    const virtualMachineMatch = Routes.matchVirtualMachineRoute(pathname);
+    const virtualMachineUserMatch = Routes.matchUserVirtualMachineRoute(pathname);
+    const virtualMachineAdminMatch = Routes.matchAdminVirtualMachineRoute(pathname);
     const workflowMatch = Routes.matchWorkflowRoute(pathname);
-    const sshKeysMatch = Routes.matchSshKeysRoute(pathname);
+    const sshKeysUserMatch = Routes.matchSshKeysUserRoute(pathname);
+    const sshKeysAdminMatch = Routes.matchSshKeysAdminRoute(pathname);
     const keepServicesMatch = Routes.matchKeepServicesRoute(pathname);
     const computeNodesMatch = Routes.matchComputeNodesRoute(pathname);
     const apiClientAuthorizationsMatch = Routes.matchApiClientAuthorizationsRoute(pathname);
@@ -58,11 +60,15 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
         store.dispatch(WorkbenchActions.loadWorkflow);
     } else if (searchResultsMatch) {
         store.dispatch(WorkbenchActions.loadSearchResults);
-    } else if (virtualMachineMatch) {
+    } else if (virtualMachineUserMatch) {
         store.dispatch(WorkbenchActions.loadVirtualMachines);
-    } else if(repositoryMatch) {
+    } else if (virtualMachineAdminMatch) {
+        store.dispatch(WorkbenchActions.loadVirtualMachines);
+    } else if (repositoryMatch) {
         store.dispatch(WorkbenchActions.loadRepositories);
-    } else if (sshKeysMatch) {
+    } else if (sshKeysUserMatch) {
+        store.dispatch(WorkbenchActions.loadSshKeys);
+    } else if (sshKeysAdminMatch) {
         store.dispatch(WorkbenchActions.loadSshKeys);
     } else if (keepServicesMatch) {
         store.dispatch(WorkbenchActions.loadKeepServices);
index 8286e10ea23551a59daffb6258dfe3e97a276b55..05f6663fe3c2bbb8021423249e5e045263ab3be7 100644 (file)
@@ -19,10 +19,12 @@ export const Routes = {
     REPOSITORIES: '/repositories',
     SHARED_WITH_ME: '/shared-with-me',
     RUN_PROCESS: '/run-process',
-    VIRTUAL_MACHINES: '/virtual-machines',
+    VIRTUAL_MACHINES_ADMIN: '/virtual-machines-admin',
+    VIRTUAL_MACHINES_USER: '/virtual-machines-user',
     WORKFLOWS: '/workflows',
     SEARCH_RESULTS: '/search-results',
-    SSH_KEYS: `/ssh-keys`,
+    SSH_KEYS_ADMIN: `/ssh-keys-admin`,
+    SSH_KEYS_USER: `/ssh-keys-user`,
     MY_ACCOUNT: '/my-account',
     KEEP_SERVICES: `/keep-services`,
     COMPUTE_NODES: `/nodes`,
@@ -86,14 +88,20 @@ export const matchWorkflowRoute = (route: string) =>
 export const matchSearchResultsRoute = (route: string) =>
     matchPath<ResourceRouteParams>(route, { path: Routes.SEARCH_RESULTS });
 
-export const matchVirtualMachineRoute = (route: string) =>
-    matchPath<ResourceRouteParams>(route, { path: Routes.VIRTUAL_MACHINES });
+export const matchUserVirtualMachineRoute = (route: string) =>
+    matchPath<ResourceRouteParams>(route, { path: Routes.VIRTUAL_MACHINES_USER });
+
+export const matchAdminVirtualMachineRoute = (route: string) =>
+    matchPath<ResourceRouteParams>(route, { path: Routes.VIRTUAL_MACHINES_ADMIN });
 
 export const matchRepositoriesRoute = (route: string) =>
     matchPath<ResourceRouteParams>(route, { path: Routes.REPOSITORIES });
 
-export const matchSshKeysRoute = (route: string) =>
-    matchPath(route, { path: Routes.SSH_KEYS });
+export const matchSshKeysUserRoute = (route: string) =>
+    matchPath(route, { path: Routes.SSH_KEYS_USER });
+
+export const matchSshKeysAdminRoute = (route: string) =>
+    matchPath(route, { path: Routes.SSH_KEYS_ADMIN });
 
 export const matchMyAccountRoute = (route: string) =>
     matchPath(route, { path: Routes.MY_ACCOUNT });
index 44e4eef5c944b271eba16c558b43a4d700c4f886..23e7729f7d0324f019de00f529c3dcd4d8022bb9 100644 (file)
@@ -6,7 +6,7 @@ import { GroupsService } from "~/services/groups-service/groups-service";
 import { UserService } from '../user-service/user-service';
 import { GroupResource } from '~/models/group';
 import { UserResource } from '~/models/user';
-import { extractUuidObjectType, ResourceObjectType, TrashableResource } from "~/models/resource";
+import { extractUuidObjectType, ResourceObjectType } from "~/models/resource";
 
 export class AncestorService {
     constructor(
@@ -14,16 +14,25 @@ export class AncestorService {
         private userService: UserService
     ) { }
 
-    async ancestors(uuid: string, rootUuid: string): Promise<Array<UserResource | GroupResource>> {
-        const service = this.getService(extractUuidObjectType(uuid));
+    async ancestors(startUuid: string, endUuid: string): Promise<Array<UserResource | GroupResource>> {
+        return this._ancestors(startUuid, endUuid);
+    }
+
+    private async _ancestors(startUuid: string, endUuid: string, previousUuid = ''): Promise<Array<UserResource | GroupResource>> {
+
+        if (startUuid === previousUuid) {
+            return [];
+        }
+
+        const service = this.getService(extractUuidObjectType(startUuid));
         if (service) {
             try {
-                const resource = await service.get(uuid);
-                if (uuid === rootUuid) {
+                const resource = await service.get(startUuid);
+                if (startUuid === endUuid) {
                     return [resource];
                 } else {
                     return [
-                        ...await this.ancestors(resource.ownerUuid, rootUuid),
+                        ...await this._ancestors(resource.ownerUuid, endUuid, startUuid),
                         resource
                     ];
                 }
index 57ad5fa40fc61394f084dcd8ca778ea7d82aa4b0..de9a1186e345ae406de1da2f1b981a444eb5585f 100644 (file)
@@ -6,9 +6,44 @@ import { AxiosInstance } from "axios";
 import { CommonResourceService } from "~/services/common-service/common-resource-service";
 import { WorkflowResource } from '~/models/workflow';
 import { ApiActions } from '~/services/api/api-actions';
+import { LinkService } from '~/services/link-service/link-service';
+import { FilterBuilder } from '~/services/api/filter-builder';
+import { LinkClass } from '~/models/link';
+import { OrderBuilder } from '~/services/api/order-builder';
 
 export class WorkflowService extends CommonResourceService<WorkflowResource> {
+
+    private linksService = new LinkService(this.serverApi, this.actions);
+
     constructor(serverApi: AxiosInstance, actions: ApiActions) {
         super(serverApi, "workflows", actions);
     }
+
+    async presets(workflowUuid: string) {
+
+        const { items: presetLinks } = await this.linksService.list({
+
+            filters: new FilterBuilder()
+                .addEqual('tailUuid', workflowUuid)
+                .addEqual('linkClass', LinkClass.PRESET)
+                .getFilters()
+
+        });
+
+        const presetUuids = presetLinks.map(link => link.headUuid);
+
+        return this.list({
+
+            filters: new FilterBuilder()
+                .addIn('uuid', presetUuids)
+                .getFilters(),
+
+            order: new OrderBuilder<WorkflowResource>()
+                .addAsc('name')
+                .getOrder(),
+
+        });
+
+    }
+
 }
index 1e2620e48c790838e87d76ee0ab45317170e3a5f..d72a3ece7a829270e902b6c9790b59feda51a22d 100644 (file)
@@ -14,6 +14,7 @@ import { ServiceRepository } from "~/services/services";
 import { getAuthorizedKeysServiceError, AuthorizedKeysServiceError } from '~/services/authorized-keys-service/authorized-keys-service';
 import { KeyType, SshKeyResource } from '~/models/ssh-key';
 import { User } from "~/models/user";
+import * as Routes from '~/routes/routes';
 
 export const authActions = unionize({
     SAVE_API_TOKEN: ofType<string>(),
@@ -153,9 +154,13 @@ export const createSshKey = (data: SshKeyCreateFormDialogData) =>
 export const loadSshKeysPanel = () =>
     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
         try {
-            dispatch(setBreadcrumbs([{ label: 'SSH Keys'}]));
+            const userUuid = getState().auth.user!.uuid;
+            const { router } = getState();
+            const pathname = router.location ? router.location.pathname : '';
+            dispatch(setBreadcrumbs([{ label: 'SSH Keys' }]));
             const response = await services.authorizedKeysService.list();
-            dispatch(authActions.SET_SSH_KEYS(response.items));
+            const userSshKeys = response.items.find(it => it.ownerUuid === userUuid);
+            return Routes.matchSshKeysAdminRoute(pathname) ? dispatch(authActions.SET_SSH_KEYS(response.items)) : dispatch(authActions.SET_SSH_KEYS([userSshKeys!]));
         } catch (e) {
             return;
         }
index 265b5cf8310f3a752ba16302852241ea90fd879b..3b3e34c2b063765a02e2a1b9808ece9ab9aeb75c 100644 (file)
@@ -13,6 +13,8 @@ import { TagProperty } from "~/models/tag";
 import { snackbarActions } from "../snackbar/snackbar-actions";
 import { resourcesActions } from "~/store/resources/resources-actions";
 import { unionize, ofType, UnionOf } from '~/common/unionize';
+import { SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { navigateTo } from '~/store/navigation/navigation-action';
 
 export const collectionPanelActions = unionize({
     SET_COLLECTION: ofType<CollectionResource>(),
@@ -53,6 +55,16 @@ export const createCollectionTag = (data: TagProperty) =>
         }
     };
 
+export const navigateToProcess = (uuid: string) =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            await services.containerRequestService.get(uuid);
+            dispatch<any>(navigateTo(uuid));
+        } catch {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'This process does not exists!', hideDuration: 2000, kind: SnackbarKind.ERROR }));
+        }
+    };
+
 export const deleteCollectionTag = (key: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const item = getState().collectionPanel.item;
index 0221fa9cc7c9b4a209393d6c6300cd4925608151..cbd983a68fe4bce3f6676068f44b59ccc3786b29 100644 (file)
@@ -62,11 +62,15 @@ export const navigateToRunProcess = push(Routes.RUN_PROCESS);
 
 export const navigateToSearchResults = push(Routes.SEARCH_RESULTS);
 
-export const navigateToVirtualMachines = push(Routes.VIRTUAL_MACHINES);
+export const navigateToUserVirtualMachines = push(Routes.VIRTUAL_MACHINES_USER);
+
+export const navigateToAdminVirtualMachines = push(Routes.VIRTUAL_MACHINES_ADMIN);
 
 export const navigateToRepositories = push(Routes.REPOSITORIES);
 
-export const navigateToSshKeys= push(Routes.SSH_KEYS);
+export const navigateToSshKeysAdmin= push(Routes.SSH_KEYS_ADMIN);
+
+export const navigateToSshKeysUser= push(Routes.SSH_KEYS_USER);
 
 export const navigateToMyAccount = push(Routes.MY_ACCOUNT);
 
index 832d4d5118749088ca39fae276d0f7cb9e8faa44..2aa914af2ae505c8faaf08ff75b54c50fe17224c 100644 (file)
@@ -6,6 +6,11 @@ import { unionize, ofType, UnionOf } from "~/common/unionize";
 import { loadProcess } from '~/store/processes/processes-actions';
 import { Dispatch } from 'redux';
 import { ProcessStatus } from '~/store/processes/process';
+import { RootState } from '~/store/store';
+import { ServiceRepository } from "~/services/services";
+import { navigateToCollection } from '~/store/navigation/navigation-action';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { SnackbarKind } from '../snackbar/snackbar-actions';
 
 export const procesPanelActions = unionize({
     SET_PROCESS_PANEL_FILTERS: ofType<string[]>(),
@@ -22,6 +27,16 @@ export const loadProcessPanel = (uuid: string) =>
         dispatch(initProcessPanelFilters);
     };
 
+export const navigateToOutput = (uuid: string) =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            await services.collectionService.get(uuid);
+            dispatch<any>(navigateToCollection(uuid));
+        } catch {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'This collection does not exists!', hideDuration: 2000, kind: SnackbarKind.ERROR }));
+        }
+    };
+
 export const initProcessPanelFilters = procesPanelActions.SET_PROCESS_PANEL_FILTERS([
     ProcessStatus.QUEUED,
     ProcessStatus.COMPLETED,
index 372e18829d222745fe487adc395d979fb83557ce..1d6d95bb80cc2a9344efb162297b0bf95fd69c30 100644 (file)
@@ -15,6 +15,7 @@ import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 export interface ProcessUpdateFormDialogData {
     uuid: string;
     name: string;
+    description?: string;
 }
 
 export const PROCESS_UPDATE_FORM_NAME = 'processUpdateFormName';
@@ -34,7 +35,7 @@ export const updateProcess = (resource: ProcessUpdateFormDialogData) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(startSubmit(PROCESS_UPDATE_FORM_NAME));
         try {
-            const updatedProcess = await services.containerRequestService.update(resource.uuid, { name: resource.name });
+            const updatedProcess = await services.containerRequestService.update(resource.uuid, { name: resource.name, description: resource.description });
             dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_UPDATE_FORM_NAME }));
             return updatedProcess;
index f1d2d2fd55aab72f72e03907f9e2460157cb4720..0cbd9cd6823abd18e284e95c9ecc1177b2febb69 100644 (file)
@@ -6,8 +6,8 @@ import { Dispatch } from 'redux';
 import { unionize, ofType, UnionOf } from "~/common/unionize";
 import { ServiceRepository } from "~/services/services";
 import { RootState } from '~/store/store';
-import { WorkflowResource } from '~/models/workflow';
-import { getFormValues } from 'redux-form';
+import { WorkflowResource, getWorkflowInputs, parseWorkflowDefinition } from '~/models/workflow';
+import { getFormValues, initialize } from 'redux-form';
 import { RUN_PROCESS_BASIC_FORM, RunProcessBasicFormData } from '~/views/run-process-panel/run-process-basic-form';
 import { RUN_PROCESS_INPUTS_FORM } from '~/views/run-process-panel/run-process-inputs-form';
 import { WorkflowInputsData } from '~/models/workflow';
@@ -25,6 +25,8 @@ export const runProcessPanelActions = unionize({
     SET_STEP_CHANGED: ofType<boolean>(),
     SET_WORKFLOWS: ofType<WorkflowResource[]>(),
     SET_SELECTED_WORKFLOW: ofType<WorkflowResource>(),
+    SET_WORKFLOW_PRESETS: ofType<WorkflowResource[]>(),
+    SELECT_WORKFLOW_PRESET: ofType<WorkflowResource>(),
     SEARCH_WORKFLOWS: ofType<string>(),
     RESET_RUN_PROCESS_PANEL: ofType<{}>(),
 });
@@ -76,14 +78,33 @@ export const setWorkflow = (workflow: WorkflowResource, isWorkflowChanged = true
         if (isStepChanged && isWorkflowChanged) {
             dispatch(runProcessPanelActions.SET_STEP_CHANGED(false));
             dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow));
+            dispatch<any>(loadPresets(workflow.uuid));
         }
         if (!isWorkflowChanged) {
             dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow));
+            dispatch<any>(loadPresets(workflow.uuid));
         }
     };
 
+const loadPresets = (workflowUuid: string) =>
+    async (dispatch: Dispatch<any>, _: () => RootState, { workflowService }: ServiceRepository) => {
+        const { items } = await workflowService.presets(workflowUuid);
+        dispatch(runProcessPanelActions.SET_WORKFLOW_PRESETS(items));
+    };
+
+export const selectPreset = (preset: WorkflowResource) =>
+    (dispatch: Dispatch<any>) => {
+        dispatch(runProcessPanelActions.SELECT_WORKFLOW_PRESET(preset));
+        const inputs = getWorkflowInputs(parseWorkflowDefinition(preset)) || [];
+        const values = inputs.reduce((values, input) => ({
+            ...values,
+            [input.id]: input.default,
+        }), {});
+        dispatch(initialize(RUN_PROCESS_INPUTS_FORM, values));
+    };
+
 export const goToStep = (step: number) =>
-    (dispatch: Dispatch, getState: () => RootState) => {
+    (dispatch: Dispatch) => {
         if (step === 1) {
             dispatch(runProcessPanelActions.SET_STEP_CHANGED(true));
         }
index cb272dec7e8c31727ed5ca4bc74d1f718450149f..12c8988bdaccdaba37043631c0f38b49df8c174a 100644 (file)
@@ -12,6 +12,8 @@ interface RunProcessPanel {
     workflows: WorkflowResource[];
     searchWorkflows: WorkflowResource[];
     selectedWorkflow: WorkflowResource | undefined;
+    presets?: WorkflowResource[];
+    selectedPreset?: WorkflowResource;
     inputs: CommandInputParameter[];
 }
 
@@ -33,8 +35,18 @@ export const runProcessPanelReducer = (state = initialState, action: RunProcessP
         SET_SELECTED_WORKFLOW: selectedWorkflow => ({
             ...state,
             selectedWorkflow,
+            presets: undefined,
+            selectedPreset: selectedWorkflow,
             inputs: getWorkflowInputs(parseWorkflowDefinition(selectedWorkflow)) || [],
         }),
+        SET_WORKFLOW_PRESETS: presets => ({
+            ...state,
+            presets,
+        }),
+        SELECT_WORKFLOW_PRESET: selectedPreset => ({
+            ...state,
+            selectedPreset,
+        }),
         SET_WORKFLOWS: workflows => ({ ...state, workflows, searchWorkflows: workflows }),
         SEARCH_WORKFLOWS: term => {
             const termRegex = new RegExp(term, 'i');
index 64c3646a36ae70be55af9470d1ad14ab43eee719..585a3663bcdf5fabf7b34fe295f0d30981f08fd0 100644 (file)
@@ -7,16 +7,15 @@ import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-act
 import { RootState } from '~/store/store';
 import { ServiceRepository } from "~/services/services";
 import { dialogActions } from '~/store/dialog/dialog-actions';
-import { startSubmit, reset, stopSubmit } from "redux-form";
-import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
+import { startSubmit, reset } from "redux-form";
 import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
 import { UserResource } from "~/models/user";
 import { getResource } from '~/store/resources/resources';
-import { navigateToProject } from "~/store/navigation/navigation-action";
+import { navigateToProject, navigateToUsers, navigateToRootProject } from "~/store/navigation/navigation-action";
 
 export const USERS_PANEL_ID = 'usersPanel';
 export const USER_ATTRIBUTES_DIALOG = 'userAttributesDialog';
-export const USER_CREATE_FORM_NAME = 'repositoryCreateFormName';
+export const USER_CREATE_FORM_NAME = 'userCreateFormName';
 
 export interface UserCreateFormDialogData {
     email: string;
@@ -59,7 +58,18 @@ export const createUser = (user: UserCreateFormDialogData) =>
             dispatch(userBindedActions.REQUEST_ITEMS());
             return newUser;
         } catch (e) {
-            return ;
+            return;
+        }
+    };
+
+export const openUserPanel = () =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const user = getState().auth.user;
+        if (user && user.isAdmin) {
+            dispatch<any>(navigateToUsers);
+        } else {
+            dispatch<any>(navigateToRootProject);
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: "You don't have permissions to view this page", hideDuration: 2000 }));
         }
     };
 
index 0aaa9050d7276cd4eef159b53166d5a34032182b..1e9825c1cdcbaf917e120b60af685342d6283ddc 100644 (file)
@@ -5,7 +5,7 @@
 import { Dispatch } from "redux";
 import { RootState } from '~/store/store';
 import { ServiceRepository } from "~/services/services";
-import { navigateToVirtualMachines } from "../navigation/navigation-action";
+import { navigateToUserVirtualMachines, navigateToAdminVirtualMachines, navigateToRootProject } from "~/store/navigation/navigation-action";
 import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-action';
 import { formatDate } from "~/common/formatters";
 import { unionize, ofType, UnionOf } from "~/common/unionize";
@@ -28,9 +28,20 @@ export const VIRTUAL_MACHINES_PANEL = 'virtualMachinesPanel';
 export const VIRTUAL_MACHINE_ATTRIBUTES_DIALOG = 'virtualMachineAttributesDialog';
 export const VIRTUAL_MACHINE_REMOVE_DIALOG = 'virtualMachineRemoveDialog';
 
-export const openVirtualMachines = () =>
+export const openUserVirtualMachines = () =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        dispatch<any>(navigateToVirtualMachines);
+        dispatch<any>(navigateToUserVirtualMachines);
+    };
+
+export const openAdminVirtualMachines = () =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const user = getState().auth.user;
+        if (user && user.isAdmin) {
+            dispatch<any>(navigateToAdminVirtualMachines);
+        } else {
+            dispatch<any>(navigateToRootProject);
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: "You don't have permissions to view this page", hideDuration: 2000 }));
+        }
     };
 
 export const openVirtualMachineAttributes = (uuid: string) =>
@@ -45,7 +56,16 @@ const loadRequestedDate = () =>
         dispatch(virtualMachinesActions.SET_REQUESTED_DATE(date));
     };
 
-export const loadVirtualMachinesData = () =>
+export const loadVirtualMachinesAdminData = () =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch<any>(loadRequestedDate());
+        const virtualMachines = await services.virtualMachineService.list();
+        dispatch(virtualMachinesActions.SET_VIRTUAL_MACHINES(virtualMachines));
+        const getAllLogins = await services.virtualMachineService.getAllLogins();
+        dispatch(virtualMachinesActions.SET_LOGINS(getAllLogins));
+    };
+
+export const loadVirtualMachinesUserData = () =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch<any>(loadRequestedDate());
         const virtualMachines = await services.virtualMachineService.list();
@@ -57,8 +77,6 @@ export const loadVirtualMachinesData = () =>
         });
         dispatch(virtualMachinesActions.SET_VIRTUAL_MACHINES(virtualMachines));
         dispatch(virtualMachinesActions.SET_LINKS(links));
-        const getAllLogins = await services.virtualMachineService.getAllLogins();
-        dispatch(virtualMachinesActions.SET_LOGINS(getAllLogins));
     };
 
 export const saveRequestedDate = () =>
@@ -86,7 +104,7 @@ export const removeVirtualMachine = (uuid: string) =>
         dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
         await services.virtualMachineService.delete(uuid);
         dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
-        dispatch<any>(loadVirtualMachinesData());
+        dispatch<any>(loadVirtualMachinesAdminData());
     };
 
 const virtualMachinesBindedActions = bindDataExplorerActions(VIRTUAL_MACHINES_PANEL);
index 30fa36bfeb9ece62a3ee3a46f19764bf9487a357..9bc76419ff03fd713311a25c60b7dc0a4d0822ba 100644 (file)
@@ -21,6 +21,7 @@ export const COPY_FILE_VALIDATION = [require];
 export const MOVE_TO_VALIDATION = [require];
 
 export const PROCESS_NAME_VALIDATION = [require, maxLength(255)];
+export const PROCESS_DESCRIPTION_VALIDATION = [maxLength(255)];
 
 export const REPOSITORY_NAME_VALIDATION = [require, maxLength(255)];
 
index d5bbce69e783b36873924e792bb4fac44b56952a..8880330c789bf65c3e06d9394ce92e3b181272a9 100644 (file)
@@ -7,7 +7,7 @@ import { InjectedFormProps } from 'redux-form';
 import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { ProcessUpdateFormDialogData } from '~/store/processes/process-update-actions';
 import { FormDialog } from '~/components/form-dialog/form-dialog';
-import { ProcessNameField } from '~/views-components/form-fields/process-form-fields';
+import { ProcessNameField, ProcessDescriptionField } from '~/views-components/form-fields/process-form-fields';
 
 type DialogProcessProps = WithDialogProps<{}> & InjectedFormProps<ProcessUpdateFormDialogData>;
 
@@ -21,4 +21,5 @@ export const DialogProcessUpdate = (props: DialogProcessProps) =>
 
 const ProcessEditFields = () => <span>
     <ProcessNameField />
+    <ProcessDescriptionField />
 </span>;
index 8f55e08456258fa3a0f87f259cfd8afa66e8c5d5..bdae05315d5d8e5b3fac53a8acbda257de03a7d8 100644 (file)
@@ -5,7 +5,7 @@
 import * as React from "react";
 import { Field } from "redux-form";
 import { TextField } from "~/components/text-field/text-field";
-import { PROCESS_NAME_VALIDATION } from "~/validators/validators";
+import { PROCESS_NAME_VALIDATION, PROCESS_DESCRIPTION_VALIDATION } from "~/validators/validators";
 
 export const ProcessNameField = () =>
     <Field
@@ -13,3 +13,10 @@ export const ProcessNameField = () =>
         component={TextField}
         validate={PROCESS_NAME_VALIDATION}
         label="Process Name" />;
+
+export const ProcessDescriptionField = () =>
+    <Field
+        name='description'
+        component={TextField}
+        validate={PROCESS_DESCRIPTION_VALIDATION}
+        label="Process Description" />;
index f765a608611e0056956baede2413ba20e2c3aba6..1609aafa0849a277432f343dbe39e788de788bf7 100644 (file)
@@ -12,8 +12,8 @@ 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 * as NavigationAction from '~/store/navigation/navigation-action';
-import { openVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
+import { navigateToSshKeysUser, navigateToMyAccount } from '~/store/navigation/navigation-action';
+import { openUserVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
 
 interface AccountMenuProps {
     user?: User;
@@ -33,16 +33,11 @@ export const AccountMenu = connect(mapStateToProps)(
                 <MenuItem>
                     {getUserFullname(user)}
                 </MenuItem>
-                <MenuItem onClick={() => dispatch(openVirtualMachines())}>Virtual Machines</MenuItem>
-                <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
+                <MenuItem onClick={() => dispatch(openUserVirtualMachines())}>Virtual Machines</MenuItem>
+                {!user.isAdmin && <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>}
                 <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
-                <MenuItem onClick={() => dispatch(NavigationAction.navigateToSshKeys)}>Ssh Keys</MenuItem>
-                <MenuItem onClick={() => dispatch(NavigationAction.navigateToUsers)}>Users</MenuItem>
-                { user.isAdmin && <MenuItem onClick={() => dispatch(NavigationAction.navigateToApiClientAuthorizations)}>Api Tokens</MenuItem> }
-                { user.isAdmin && <MenuItem onClick={() => dispatch(NavigationAction.navigateToKeepServices)}>Keep Services</MenuItem> }
-                { user.isAdmin && <MenuItem onClick={() => dispatch(NavigationAction.navigateToComputeNodes)}>Compute Nodes</MenuItem> }
-                { user.isAdmin && <MenuItem onClick={() => dispatch(NavigationAction.navigateToLinks)}>Links</MenuItem> }
-                <MenuItem onClick={() => dispatch(NavigationAction.navigateToMyAccount)}>My account</MenuItem>
+                <MenuItem onClick={() => dispatch(navigateToSshKeysUser)}>Ssh Keys</MenuItem>
+                <MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>
                 <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
             </DropdownMenu>
             : null);
diff --git a/src/views-components/main-app-bar/admin-menu.tsx b/src/views-components/main-app-bar/admin-menu.tsx
new file mode 100644 (file)
index 0000000..88aafba
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { MenuItem } from "@material-ui/core";
+import { User } from "~/models/user";
+import { DropdownMenu } from "~/components/dropdown-menu/dropdown-menu";
+import { AdminMenuIcon } from "~/components/icon/icon";
+import { DispatchProp, connect } from 'react-redux';
+import { logout } from '~/store/auth/auth-action';
+import { RootState } from "~/store/store";
+import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
+import * as NavigationAction from '~/store/navigation/navigation-action';
+import { openAdminVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
+import { openUserPanel } from "~/store/users/users-actions";
+
+interface AdminMenuProps {
+    user?: User;
+}
+
+const mapStateToProps = (state: RootState): AdminMenuProps => ({
+    user: state.auth.user
+});
+
+export const AdminMenu = connect(mapStateToProps)(
+    ({ user, dispatch }: AdminMenuProps & DispatchProp<any>) =>
+        user
+            ? <DropdownMenu
+                icon={<AdminMenuIcon />}
+                id="admin-menu"
+                title="Admin Panel">
+                <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
+                <MenuItem onClick={() => dispatch(openAdminVirtualMachines())}>Virtual Machines</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToSshKeysAdmin)}>Ssh Keys</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToApiClientAuthorizations)}>Api Tokens</MenuItem>
+                <MenuItem onClick={() => dispatch(openUserPanel())}>Users</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToComputeNodes)}>Compute Nodes</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToKeepServices)}>Keep Services</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToLinks)}>Links</MenuItem>
+                <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
+            </DropdownMenu>
+            : null);
index b936fb14d3fbc05412bc76178efbf466fa5dc496..8a7e9f2000f0af954275b3ac6717ff6479550ce1 100644 (file)
@@ -11,8 +11,9 @@ import { SearchBar } from "~/views-components/search-bar/search-bar";
 import { Routes } from '~/routes/routes';
 import { NotificationsMenu } from "~/views-components/main-app-bar/notifications-menu";
 import { AccountMenu } from "~/views-components/main-app-bar/account-menu";
-import { HelpMenu } from './help-menu';
+import { HelpMenu } from '~/views-components/main-app-bar/help-menu';
 import { ReactNode } from "react";
+import { AdminMenu } from "~/views-components/main-app-bar/admin-menu";
 
 type CssRules = 'toolbar' | 'link';
 
@@ -65,6 +66,7 @@ export const MainAppBar = withStyles(styles)(
                             ? <>
                                 <NotificationsMenu />
                                 <AccountMenu />
+                                {props.user.isAdmin && <AdminMenu />}
                                 <HelpMenu />
                             </>
                             : <HelpMenu />}
index 03362178075c75be95fb7fcbbf6e51fc90d80cea..3806b5245a75b0e58acfe4d6c4aba4247acdb434 100644 (file)
@@ -18,11 +18,12 @@ interface MainContentBarProps {
 
 const isButtonVisible = ({ router }: RootState) => {
     const pathname = router.location ? router.location.pathname : '';
-    return !Routes.matchWorkflowRoute(pathname) && !Routes.matchVirtualMachineRoute(pathname) &&
-        !Routes.matchRepositoriesRoute(pathname) && !Routes.matchSshKeysRoute(pathname) &&
+    return !Routes.matchWorkflowRoute(pathname) && !Routes.matchUserVirtualMachineRoute(pathname) &&
+        !Routes.matchAdminVirtualMachineRoute(pathname) && !Routes.matchRepositoriesRoute(pathname) &&
+        !Routes.matchSshKeysAdminRoute(pathname) && !Routes.matchSshKeysUserRoute(pathname) &&
         !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) &&
-        !Routes.matchApiClientAuthorizationsRoute(pathname) && !Routes.matchUsersRoute(pathname) && 
-        !Routes.matchLinksRoute(pathname);
+        !Routes.matchApiClientAuthorizationsRoute(pathname) && !Routes.matchUsersRoute(pathname) &&
+        !Routes.matchMyAccountRoute(pathname) && !Routes.matchLinksRoute(pathname);
 };
 
 export const MainContentBar = connect((state: RootState) => ({
index 26ee18875424f152dc6bb458a44917915c0fafef..119b9e994605061d61962f4e94801614815d4283 100644 (file)
@@ -17,7 +17,7 @@ import { CollectionResource } from '~/models/collection';
 import { CollectionPanelFiles } from '~/views-components/collection-panel-files/collection-panel-files';
 import * as CopyToClipboard from 'react-copy-to-clipboard';
 import { CollectionTagForm } from './collection-tag-form';
-import { deleteCollectionTag } from '~/store/collection-panel/collection-panel-action';
+import { deleteCollectionTag, navigateToProcess } from '~/store/collection-panel/collection-panel-action';
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 import { getResource } from '~/store/resources/resources';
 import { openContextMenu } from '~/store/context-menu/context-menu-actions';
@@ -26,7 +26,7 @@ import { formatFileSize } from "~/common/formatters";
 import { getResourceData } from "~/store/resources-data/resources-data";
 import { ResourceData } from "~/store/resources-data/resources-data-reducer";
 
-type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value';
+type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value' | 'link';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     card: {
@@ -52,6 +52,13 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     value: {
         textTransform: 'none',
         fontSize: '0.875rem'
+    },
+    link: {
+        fontSize: '0.875rem',
+        color: theme.palette.primary.main,
+        '&:hover': {
+            cursor: 'pointer'
+        }
     }
 });
 
@@ -63,7 +70,6 @@ interface CollectionPanelDataProps {
 type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
     & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
 
-
 export const CollectionPanel = withStyles(styles)(
     connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
         const item = getResource(props.match.params.id)(state.resources);
@@ -72,7 +78,7 @@ export const CollectionPanel = withStyles(styles)(
     })(
         class extends React.Component<CollectionPanelProps> {
             render() {
-                const { classes, item, data } = this.props;
+                const { classes, item, data, dispatch } = this.props;
                 return item
                     ? <>
                         <Card className={classes.card}>
@@ -107,6 +113,9 @@ export const CollectionPanel = withStyles(styles)(
                                             label='Content size' value={data && formatFileSize(data.fileSize)} />
                                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
                                             label='Owner' value={item && item.ownerUuid} />
+                                        <span onClick={() => dispatch<any>(navigateToProcess(item.properties.container_request))}>
+                                            <DetailsAttribute classLabel={classes.link} label='Link to process' />
+                                        </span>
                                     </Grid>
                                 </Grid>
                             </CardContent>
index e5d15e729d6d32b26f07e934d7a2fbb854c87b5d..7f3e025f8dc7e97a7f1b7616a09d9013949260b1 100644 (file)
@@ -11,7 +11,7 @@ import { ArvadosTheme } from '~/common/custom-theme';
 import { MoreOptionsIcon, ProcessIcon } from '~/components/icon/icon';
 import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
 import { Process } from '~/store/processes/process';
-import { getProcessStatus, getProcessStatusColor } from '../../store/processes/process';
+import { getProcessStatus, getProcessStatusColor } from '~/store/processes/process';
 import { formatDate } from '~/common/formatters';
 
 
@@ -69,12 +69,13 @@ export interface ProcessInformationCardDataProps {
     process: Process;
     onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
     openProcessInputDialog: (uuid: string) => void;
+    navigateToOutput: (uuid: string) => void;
 }
 
 type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules, true>;
 
 export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
-    ({ classes, process, onContextMenu, theme, openProcessInputDialog }: ProcessInformationCardProps) =>
+    ({ classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput }: ProcessInformationCardProps) =>
         <Card className={classes.card}>
             <CardHeader
                 classes={{
@@ -120,7 +121,9 @@ export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
                             label='Workflow' value='???' />
                     </Grid>
                     <Grid item xs={6}>
-                        <DetailsAttribute classLabel={classes.link} label='Outputs' />
+                        <span onClick={() => navigateToOutput(process.containerRequest.outputUuid!)}>
+                            <DetailsAttribute classLabel={classes.link} label='Outputs' />
+                        </span>
                         <span onClick={() => openProcessInputDialog(process.containerRequest.uuid)}>
                             <DetailsAttribute classLabel={classes.link} label='Inputs' />
                         </span>
index 52c0f4515145120caf1d6f95038323d4f5fdb307..73f71e5e0a139b0fbbe007213b0f1d6705070868 100644 (file)
@@ -23,6 +23,7 @@ export interface ProcessPanelRootActionProps {
     onContextMenu: (event: React.MouseEvent<HTMLElement>, process: Process) => void;
     onToggle: (status: string) => void;
     openProcessInputDialog: (uuid: string) => void;
+    navigateToOutput: (uuid: string) => void;
 }
 
 export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps;
@@ -34,7 +35,8 @@ export const ProcessPanelRoot = ({ process, ...props }: ProcessPanelRootProps) =
                 <ProcessInformationCard
                     process={process}
                     onContextMenu={event => props.onContextMenu(event, process)}
-                    openProcessInputDialog={props.openProcessInputDialog} />
+                    openProcessInputDialog={props.openProcessInputDialog}
+                    navigateToOutput={props.navigateToOutput} />
             </Grid>
             <Grid item sm={12} md={5}>
                 <SubprocessesCard
index 8108cd1ef4d0b19a51fc7c530e6880e61b529334..5672469677a3d29c5150a39f955ae71078d8c022 100644 (file)
@@ -11,7 +11,7 @@ import { matchProcessRoute } from '~/routes/routes';
 import { ProcessPanelRootDataProps, ProcessPanelRootActionProps, ProcessPanelRoot } from './process-panel-root';
 import { ProcessPanel as ProcessPanelState} from '~/store/process-panel/process-panel';
 import { groupBy } from 'lodash';
-import { toggleProcessPanelFilter } from '~/store/process-panel/process-panel-actions';
+import { toggleProcessPanelFilter, navigateToOutput } from '~/store/process-panel/process-panel-actions';
 import { openProcessInputDialog } from '~/store/processes/process-input-actions';
 
 const mapStateToProps = ({ router, resources, processPanel }: RootState): ProcessPanelRootDataProps => {
@@ -34,7 +34,8 @@ const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps =>
     onToggle: status => {
         dispatch<any>(toggleProcessPanelFilter(status));
     },
-    openProcessInputDialog: (uuid) => dispatch<any>(openProcessInputDialog(uuid))
+    openProcessInputDialog: (uuid) => dispatch<any>(openProcessInputDialog(uuid)),
+    navigateToOutput: (uuid) => dispatch<any>(navigateToOutput(uuid))
 });
 
 export const ProcessPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessPanelRoot);
index c7016f6298848355be16a206b7c4ce66ac9a029e..62e91b5f1de5e4923abecd46b4494eff377f85ca 100644 (file)
@@ -103,7 +103,7 @@ export const RepositoriesPanel = compose(
                                 <Grid item xs={8}>
                                     <Typography variant="body2">
                                         When you are using an Arvados virtual machine, you should clone the https:// URLs. This will authenticate automatically using your API token. <br />
-                                        In order to clone git repositories using SSH, <Link to={Routes.SSH_KEYS} className={classes.link}>add an SSH key to your account</Link> and clone the git@ URLs.
+                                        In order to clone git repositories using SSH, <Link to={Routes.SSH_KEYS_USER} className={classes.link}>add an SSH key to your account</Link> and clone the git@ URLs.
                                     </Typography>
                                 </Grid>
                                 <Grid item xs={4} className={classes.button}>
index 0b8563822e4906be2dc62147cee5a0f7139f1bcf..a7e4a87f172661f1359b3e0aa6b5f751aafca102 100644 (file)
@@ -6,24 +6,39 @@ import * as React from 'react';
 import { Grid, Button } from '@material-ui/core';
 import { RunProcessBasicForm, RUN_PROCESS_BASIC_FORM } from './run-process-basic-form';
 import { RunProcessInputsForm } from '~/views/run-process-panel/run-process-inputs-form';
-import { CommandInputParameter } from '~/models/workflow';
+import { CommandInputParameter, WorkflowResource } from '~/models/workflow';
 import { connect } from 'react-redux';
 import { RootState } from '~/store/store';
 import { isValid } from 'redux-form';
 import { RUN_PROCESS_INPUTS_FORM } from './run-process-inputs-form';
 import { RunProcessAdvancedForm } from './run-process-advanced-form';
 import { createSelector, createStructuredSelector } from 'reselect';
+import { WorkflowPresetSelect } from '~/views/run-process-panel/workflow-preset-select';
+import { selectPreset } from '~/store/run-process-panel/run-process-panel-actions';
 
 export interface RunProcessSecondStepFormDataProps {
     inputs: CommandInputParameter[];
+    workflow?: WorkflowResource;
+    presets?: WorkflowResource[];
+    selectedPreset?: WorkflowResource;
     valid: boolean;
 }
 
 export interface RunProcessSecondStepFormActionProps {
     goBack: () => void;
     runProcess: () => void;
+    onPresetChange: (preset: WorkflowResource) => void;
 }
 
+const selectedWorkflowSelector = (state: RootState) =>
+    state.runProcessPanel.selectedWorkflow;
+
+const presetsSelector = (state: RootState) =>
+    state.runProcessPanel.presets;
+
+const selectedPresetSelector = (state: RootState) =>
+    state.runProcessPanel.selectedPreset;
+
 const inputsSelector = (state: RootState) =>
     state.runProcessPanel.inputs;
 
@@ -33,13 +48,24 @@ const validSelector = (state: RootState) =>
 const mapStateToProps = createStructuredSelector({
     inputs: inputsSelector,
     valid: validSelector,
+    workflow: selectedWorkflowSelector,
+    presets: presetsSelector,
+    selectedPreset: selectedPresetSelector,
 });
 
 export type RunProcessSecondStepFormProps = RunProcessSecondStepFormDataProps & RunProcessSecondStepFormActionProps;
-export const RunProcessSecondStepForm = connect(mapStateToProps)(
-    ({ inputs, valid, goBack, runProcess }: RunProcessSecondStepFormProps) =>
+export const RunProcessSecondStepForm = connect(mapStateToProps, { onPresetChange: selectPreset })(
+    ({ inputs, workflow, selectedPreset, presets, onPresetChange, valid, goBack, runProcess }: RunProcessSecondStepFormProps) =>
         <Grid container spacing={16}>
             <Grid item xs={12}>
+                <Grid container spacing={32}>
+                    <Grid item xs={12} md={6}>
+                        {workflow && selectedPreset && presets &&
+                            < WorkflowPresetSelect
+                                {...{ workflow, selectedPreset, presets, onChange: onPresetChange }} />
+                        }
+                    </Grid>
+                </Grid>
                 <RunProcessBasicForm />
                 <RunProcessInputsForm inputs={inputs} />
                 <RunProcessAdvancedForm />
diff --git a/src/views/run-process-panel/workflow-preset-select.tsx b/src/views/run-process-panel/workflow-preset-select.tsx
new file mode 100644 (file)
index 0000000..2e30356
--- /dev/null
@@ -0,0 +1,68 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { Select, FormControl, InputLabel, MenuItem, Tooltip, withStyles, WithStyles } from '@material-ui/core';
+import { WorkflowResource } from '~/models/workflow';
+import { DetailsIcon } from '~/components/icon/icon';
+
+export interface WorkflowPresetSelectProps {
+    workflow: WorkflowResource;
+    selectedPreset: WorkflowResource;
+    presets: WorkflowResource[];
+    onChange: (preset: WorkflowResource) => void;
+}
+
+type CssRules = 'root' | 'icon';
+
+export const WorkflowPresetSelect = withStyles<CssRules>(theme => ({
+    root: {
+        display: 'flex',
+    },
+    icon: {
+        color: theme.palette.text.hint,
+        marginTop: 18,
+        marginLeft: 8,
+    },
+}))(
+    class extends React.Component<WorkflowPresetSelectProps & WithStyles<CssRules>> {
+
+        render() {
+
+            const { selectedPreset, workflow, presets, classes } = this.props;
+
+            return (
+                <div className={classes.root}>
+                    <FormControl fullWidth>
+                        <InputLabel>Preset</InputLabel>
+                        <Select
+                            value={selectedPreset.uuid}
+                            onChange={this.handleChange}>
+                            <MenuItem value={workflow.uuid}>
+                                <em>Default</em>
+                            </MenuItem>
+                            {presets.map(
+                                ({ uuid, name }) => <MenuItem key={uuid} value={uuid}>{name}</MenuItem>
+                            )}
+                        </Select>
+                    </FormControl>
+                    <Tooltip title='List of already defined set of inputs to run a workflow'>
+                        <DetailsIcon className={classes.icon} />
+                    </Tooltip>
+                </div >
+            );
+        }
+
+        handleChange = ({ target }: React.ChangeEvent<HTMLSelectElement>) => {
+
+            const { workflow, presets, onChange } = this.props;
+
+            const selectedPreset = [workflow, ...presets]
+                .find(({ uuid }) => uuid === target.value);
+
+            if (selectedPreset) {
+                onChange(selectedPreset);
+            }
+        }
+    });
diff --git a/src/views/virtual-machine-panel/virtual-machine-admin-panel.tsx b/src/views/virtual-machine-panel/virtual-machine-admin-panel.tsx
new file mode 100644 (file)
index 0000000..dda2889
--- /dev/null
@@ -0,0 +1,112 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { Grid, Card, CardContent, TableBody, TableCell, TableHead, TableRow, Table, Tooltip, IconButton } from '@material-ui/core';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { compose, Dispatch } from 'redux';
+import { loadVirtualMachinesAdminData } from '~/store/virtual-machines/virtual-machines-actions';
+import { RootState } from '~/store/store';
+import { ListResults } from '~/services/common-service/common-service';
+import { MoreOptionsIcon } from '~/components/icon/icon';
+import { VirtualMachineLogins, VirtualMachinesResource } from '~/models/virtual-machines';
+import { openVirtualMachinesContextMenu } from '~/store/context-menu/context-menu-actions';
+
+type CssRules = 'moreOptionsButton' | 'moreOptions';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    moreOptionsButton: {
+        padding: 0
+    },
+    moreOptions: {
+        textAlign: 'right',
+        '&:last-child': {
+            paddingRight: 0
+        }
+    },
+});
+
+const mapStateToProps = ({ virtualMachines }: RootState) => {
+    return {
+        logins: virtualMachines.logins,
+        ...virtualMachines
+    };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): Pick<VirtualMachinesPanelActionProps, 'loadVirtualMachinesData' | 'onOptionsMenuOpen'> => ({
+    loadVirtualMachinesData: () => dispatch<any>(loadVirtualMachinesAdminData()),
+    onOptionsMenuOpen: (event, virtualMachine) => {
+        dispatch<any>(openVirtualMachinesContextMenu(event, virtualMachine));
+    },
+});
+
+interface VirtualMachinesPanelDataProps {
+    virtualMachines: ListResults<any>;
+    logins: VirtualMachineLogins;
+}
+
+interface VirtualMachinesPanelActionProps {
+    loadVirtualMachinesData: () => string;
+    onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>, virtualMachine: VirtualMachinesResource) => void;
+}
+
+type VirtualMachineProps = VirtualMachinesPanelActionProps & VirtualMachinesPanelDataProps & WithStyles<CssRules>;
+
+export const VirtualMachineAdminPanel = compose(
+    withStyles(styles),
+    connect(mapStateToProps, mapDispatchToProps))(
+        class extends React.Component<VirtualMachineProps> {
+            componentDidMount() {
+                this.props.loadVirtualMachinesData();
+            }
+
+            render() {
+                const { virtualMachines } = this.props;
+                return (
+                    <Grid container spacing={16}>
+                        {virtualMachines.itemsAvailable > 0 && <CardContentWithVirtualMachines {...this.props} />}
+                    </Grid>
+                );
+            }
+        }
+    );
+
+const CardContentWithVirtualMachines = (props: VirtualMachineProps) =>
+    <Grid item xs={12}>
+        <Card>
+            <CardContent>
+                {virtualMachinesTable(props)}
+            </CardContent>
+        </Card>
+    </Grid>;
+
+const virtualMachinesTable = (props: VirtualMachineProps) =>
+    <Table>
+        <TableHead>
+            <TableRow>
+                <TableCell>Uuid</TableCell>
+                <TableCell>Host name</TableCell>
+                <TableCell>Logins</TableCell>
+                <TableCell />
+            </TableRow>
+        </TableHead>
+        <TableBody>
+            {props.logins.items.length > 0 && props.virtualMachines.items.map((it, index) =>
+                <TableRow key={index}>
+                    <TableCell>{it.uuid}</TableCell>
+                    <TableCell>{it.hostname}</TableCell>
+                    <TableCell>["{props.logins.items[0].username}"]</TableCell>
+                    <TableCell className={props.classes.moreOptions}>
+                        <Tooltip title="More options" disableFocusListener>
+                            <IconButton onClick={event => props.onOptionsMenuOpen(event, it)} className={props.classes.moreOptionsButton}>
+                                <MoreOptionsIcon />
+                            </IconButton>
+                        </Tooltip>
+                    </TableCell>
+                </TableRow>
+            )}
+        </TableBody>
+    </Table>;
similarity index 53%
rename from src/views/virtual-machine-panel/virtual-machine-panel.tsx
rename to src/views/virtual-machine-panel/virtual-machine-user-panel.tsx
index d5d345551c41a680a26c6b62247f2109980567ce..fbb1f23f51cb33069167cb763ea76833eed6e4bf 100644 (file)
@@ -4,21 +4,19 @@
 
 import * as React from 'react';
 import { connect } from 'react-redux';
-import { Grid, Typography, Button, Card, CardContent, TableBody, TableCell, TableHead, TableRow, Table, Tooltip, IconButton } from '@material-ui/core';
+import { Grid, Typography, Button, Card, CardContent, TableBody, TableCell, TableHead, TableRow, Table, Tooltip } from '@material-ui/core';
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { DefaultCodeSnippet } from '~/components/default-code-snippet/default-code-snippet';
 import { Link } from 'react-router-dom';
 import { compose, Dispatch } from 'redux';
-import { saveRequestedDate, loadVirtualMachinesData } from '~/store/virtual-machines/virtual-machines-actions';
+import { saveRequestedDate, loadVirtualMachinesUserData } from '~/store/virtual-machines/virtual-machines-actions';
 import { RootState } from '~/store/store';
 import { ListResults } from '~/services/common-service/common-service';
-import { HelpIcon, MoreOptionsIcon } from '~/components/icon/icon';
-import { VirtualMachineLogins, VirtualMachinesResource } from '~/models/virtual-machines';
+import { HelpIcon } from '~/components/icon/icon';
 import { Routes } from '~/routes/routes';
-import { openVirtualMachinesContextMenu } from '~/store/context-menu/context-menu-actions';
 
-type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon' | 'moreOptionsButton' | 'moreOptions';
+type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     button: {
@@ -56,52 +54,35 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     icon: {
         textAlign: "right",
         marginTop: theme.spacing.unit
-    },
-    moreOptionsButton: {
-        padding: 0
-    },
-    moreOptions: {
-        textAlign: 'right',
-        '&:last-child': {
-            paddingRight: 0
-        }
-    },
+    }
 });
 
-const mapStateToProps = ({ virtualMachines, auth }: RootState) => {
+const mapStateToProps = ({ virtualMachines }: RootState) => {
     return {
         requestedDate: virtualMachines.date,
-        isAdmin: auth.user!.isAdmin,
-        logins: virtualMachines.logins,
         ...virtualMachines
     };
 };
 
-const mapDispatchToProps = (dispatch: Dispatch): Pick<VirtualMachinesPanelActionProps, 'loadVirtualMachinesData' | 'saveRequestedDate' | 'onOptionsMenuOpen'> => ({
+const mapDispatchToProps = (dispatch: Dispatch): Pick<VirtualMachinesPanelActionProps, 'loadVirtualMachinesData' | 'saveRequestedDate'> => ({
     saveRequestedDate: () => dispatch<any>(saveRequestedDate()),
-    loadVirtualMachinesData: () => dispatch<any>(loadVirtualMachinesData()),
-    onOptionsMenuOpen: (event, virtualMachine) => {
-        dispatch<any>(openVirtualMachinesContextMenu(event, virtualMachine));
-    },
+    loadVirtualMachinesData: () => dispatch<any>(loadVirtualMachinesUserData()),
 });
 
 interface VirtualMachinesPanelDataProps {
     requestedDate: string;
     virtualMachines: ListResults<any>;
-    logins: VirtualMachineLogins;
     links: ListResults<any>;
-    isAdmin: boolean;
 }
 
 interface VirtualMachinesPanelActionProps {
     saveRequestedDate: () => void;
     loadVirtualMachinesData: () => string;
-    onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>, virtualMachine: VirtualMachinesResource) => void;
 }
 
 type VirtualMachineProps = VirtualMachinesPanelActionProps & VirtualMachinesPanelDataProps & WithStyles<CssRules>;
 
-export const VirtualMachinePanel = compose(
+export const VirtualMachineUserPanel = compose(
     withStyles(styles),
     connect(mapStateToProps, mapDispatchToProps))(
         class extends React.Component<VirtualMachineProps> {
@@ -110,19 +91,19 @@ export const VirtualMachinePanel = compose(
             }
 
             render() {
-                const { virtualMachines, links, isAdmin } = this.props;
+                const { virtualMachines, links } = this.props;
                 return (
                     <Grid container spacing={16}>
-                        {!isAdmin && virtualMachines.itemsAvailable > 0 && <CardContentWithNoVirtualMachines {...this.props} />}
+                        {virtualMachines.itemsAvailable === 0 && <CardContentWithoutVirtualMachines {...this.props} />}
                         {virtualMachines.itemsAvailable > 0 && links.itemsAvailable > 0 && <CardContentWithVirtualMachines {...this.props} />}
-                        {!isAdmin && <CardSSHSection {...this.props} />}
+                        {<CardSSHSection {...this.props} />}
                     </Grid>
                 );
             }
         }
     );
 
-const CardContentWithNoVirtualMachines = (props: VirtualMachineProps) =>
+const CardContentWithoutVirtualMachines = (props: VirtualMachineProps) =>
     <Grid item xs={12}>
         <Card>
             <CardContent className={props.classes.cardWithoutMachines}>
@@ -132,13 +113,7 @@ const CardContentWithNoVirtualMachines = (props: VirtualMachineProps) =>
                     </Typography>
                 </Grid>
                 <Grid item xs={6} className={props.classes.rightAlign}>
-                    <Button variant="contained" color="primary" className={props.classes.button} onClick={props.saveRequestedDate}>
-                        SEND REQUEST FOR SHELL ACCESS
-                    </Button>
-                    {props.requestedDate &&
-                        <Typography variant="body1">
-                            A request for shell access was sent on {props.requestedDate}
-                        </Typography>}
+                    {virtualMachineSendRequest(props)}
                 </Grid>
             </CardContent>
         </Card>
@@ -148,32 +123,36 @@ const CardContentWithVirtualMachines = (props: VirtualMachineProps) =>
     <Grid item xs={12}>
         <Card>
             <CardContent>
-                {props.isAdmin ? <span>{adminVirtualMachinesTable(props)}</span>
-                    : <span>
-                        <div className={props.classes.rightAlign}>
-                            <Button variant="contained" color="primary" className={props.classes.button} onClick={props.saveRequestedDate}>
-                                SEND REQUEST FOR SHELL ACCESS
-                                </Button>
-                            {props.requestedDate &&
-                                <Typography variant="body1">
-                                    A request for shell access was sent on {props.requestedDate}
-                                </Typography>}
-                        </div>
-                        <div className={props.classes.icon}>
-                            <a href="https://doc.arvados.org/user/getting_started/vm-login-with-webshell.html" target="_blank" className={props.classes.linkIcon}>
-                                <Tooltip title="Access VM using webshell">
-                                    <HelpIcon />
-                                </Tooltip>
-                            </a>
-                        </div>
-                        {userVirtualMachinesTable(props)}
-                    </span>
-                }
+                <span>
+                    <div className={props.classes.rightAlign}>
+                        {virtualMachineSendRequest(props)}
+                    </div>
+                    <div className={props.classes.icon}>
+                        <a href="https://doc.arvados.org/user/getting_started/vm-login-with-webshell.html" target="_blank" className={props.classes.linkIcon}>
+                            <Tooltip title="Access VM using webshell">
+                                <HelpIcon />
+                            </Tooltip>
+                        </a>
+                    </div>
+                    {virtualMachinesTable(props)}
+                </span>
+
             </CardContent>
         </Card>
     </Grid>;
 
-const userVirtualMachinesTable = (props: VirtualMachineProps) =>
+const virtualMachineSendRequest = (props: VirtualMachineProps) =>
+    <span>
+        <Button variant="contained" color="primary" className={props.classes.button} onClick={props.saveRequestedDate}>
+            SEND REQUEST FOR SHELL ACCESS
+        </Button>
+        {props.requestedDate &&
+            <Typography variant="body1">
+                A request for shell access was sent on {props.requestedDate}
+            </Typography>}
+    </span>;
+
+const virtualMachinesTable = (props: VirtualMachineProps) =>
     <Table>
         <TableHead>
             <TableRow>
@@ -199,34 +178,6 @@ const userVirtualMachinesTable = (props: VirtualMachineProps) =>
         </TableBody>
     </Table>;
 
-const adminVirtualMachinesTable = (props: VirtualMachineProps) =>
-    <Table>
-        <TableHead>
-            <TableRow>
-                <TableCell>Uuid</TableCell>
-                <TableCell>Host name</TableCell>
-                <TableCell>Logins</TableCell>
-                <TableCell />
-            </TableRow>
-        </TableHead>
-        <TableBody>
-            {props.logins.items.length > 0 && props.virtualMachines.items.map((it, index) =>
-                <TableRow key={index}>
-                    <TableCell>{it.uuid}</TableCell>
-                    <TableCell>{it.hostname}</TableCell>
-                    <TableCell>["{props.logins.items[0].username}"]</TableCell>
-                    <TableCell className={props.classes.moreOptions}>
-                        <Tooltip title="More options" disableFocusListener>
-                            <IconButton onClick={event => props.onOptionsMenuOpen(event, it)} className={props.classes.moreOptionsButton}>
-                                <MoreOptionsIcon />
-                            </IconButton>
-                        </Tooltip>
-                    </TableCell>
-                </TableRow>
-            )}
-        </TableBody>
-    </Table>;
-
 const getUsername = (links: ListResults<any>) => {
     return links.items[0].properties.username;
 };
@@ -236,7 +187,7 @@ const CardSSHSection = (props: VirtualMachineProps) =>
         <Card>
             <CardContent>
                 <Typography variant="body2">
-                    In order to access virtual machines using SSH, <Link to={Routes.SSH_KEYS} className={props.classes.link}>add an SSH key to your account</Link> and add a section like this to your SSH configuration file ( ~/.ssh/config):
+                    In order to access virtual machines using SSH, <Link to={Routes.SSH_KEYS_USER} className={props.classes.link}>add an SSH key to your account</Link> and add a section like this to your SSH configuration file ( ~/.ssh/config):
                 </Typography>
                 <DefaultCodeSnippet
                     className={props.classes.codeSnippet}
index 8181cdf9c47d714b30a18777c1a5999faf6236dc..025540e22ed89c6bab5ecd1a9dee6ddc11281a94 100644 (file)
@@ -49,7 +49,8 @@ import { MyAccountPanel } from '~/views/my-account-panel/my-account-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';
-import { VirtualMachinePanel } from '~/views/virtual-machine-panel/virtual-machine-panel';
+import { VirtualMachineUserPanel } from '~/views/virtual-machine-panel/virtual-machine-user-panel';
+import { VirtualMachineAdminPanel } from '~/views/virtual-machine-panel/virtual-machine-admin-panel';
 import { ProjectPropertiesDialog } from '~/views-components/project-properties-dialog/project-properties-dialog';
 import { RepositoriesPanel } from '~/views/repositories-panel/repositories-panel';
 import { KeepServicePanel } from '~/views/keep-service-panel/keep-service-panel';
@@ -147,9 +148,11 @@ 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.VIRTUAL_MACHINES_USER} component={VirtualMachineUserPanel} />
+                                <Route path={Routes.VIRTUAL_MACHINES_ADMIN} component={VirtualMachineAdminPanel} />
                                 <Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
-                                <Route path={Routes.SSH_KEYS} component={SshKeyPanel} />
+                                <Route path={Routes.SSH_KEYS_USER} component={SshKeyPanel} />
+                                <Route path={Routes.SSH_KEYS_ADMIN} component={SshKeyPanel} />
                                 <Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
                                 <Route path={Routes.USERS} component={UserPanel} />
                                 <Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />