[ARVADOS-WORKBENCH2] created: 1.2.1-1062-g17d467b

Git user git at public.curoverse.com
Mon Dec 3 05:00:33 EST 2018


        at  17d467bf2fecc68a6d66beea293cf23a38f95a53 (commit)


commit 17d467bf2fecc68a6d66beea293cf23a38f95a53
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Mon Dec 3 11:00:11 2018 +0100

    add keep services panel with state and all dialogs for actions
    
    Feature #14503_keep_services_panel
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/index.tsx b/src/index.tsx
index 801a56a..79525a8 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -50,6 +50,7 @@ import HTML5Backend from 'react-dnd-html5-backend';
 import { initAdvanceFormProjectsTree } from '~/store/search-bar/search-bar-actions';
 import { repositoryActionSet } from '~/views-components/context-menu/action-sets/repository-action-set';
 import { sshKeyActionSet } from '~/views-components/context-menu/action-sets/ssh-key-action-set';
+import { keepServiceActionSet } from '~/views-components/context-menu/action-sets/keep-service-action-set';
 import { loadVocabulary } from '~/store/vocabulary/vocabulary-actions';
 
 console.log(`Starting arvados [${getBuildInfo()}]`);
@@ -69,6 +70,7 @@ addMenuActionSet(ContextMenuKind.PROCESS_RESOURCE, processResourceActionSet);
 addMenuActionSet(ContextMenuKind.TRASH, trashActionSet);
 addMenuActionSet(ContextMenuKind.REPOSITORY, repositoryActionSet);
 addMenuActionSet(ContextMenuKind.SSH_KEY, sshKeyActionSet);
+addMenuActionSet(ContextMenuKind.KEEP_SERVICE, keepServiceActionSet);
 
 fetchConfig()
     .then(({ config, apiHost }) => {
diff --git a/src/models/keep.ts b/src/models/keep-services.ts
similarity index 61%
rename from src/models/keep.ts
rename to src/models/keep-services.ts
index f6b5ef2..d99943c 100644
--- a/src/models/keep.ts
+++ b/src/models/keep-services.ts
@@ -1,12 +1,13 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { Resource } from "./resource";
-
-export interface KeepResource extends Resource {
-    serviceHost: string;
-    servicePort: number;
-    serviceSslFlag: boolean;
-    serviceType: string;
-}
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Resource } from '~/models/resource';
+
+export interface KeepServiceResource extends Resource {
+    serviceHost: string;
+    servicePort: number;
+    serviceSslFlag: boolean;
+    serviceType: string;
+    readOnly: boolean;
+}
\ No newline at end of file
diff --git a/src/models/resource.ts b/src/models/resource.ts
index 7e2127b..ee90174 100644
--- a/src/models/resource.ts
+++ b/src/models/resource.ts
@@ -30,6 +30,7 @@ export enum ResourceKind {
     PROJECT = "arvados#group",
     REPOSITORY = "arvados#repository",
     SSH_KEY = "arvados#authorizedKeys",
+    KEEP_SERVICE = "arvados#keepService",
     USER = "arvados#user",
     VIRTUAL_MACHINE = "arvados#virtualMachine",
     WORKFLOW = "arvados#workflow",
@@ -46,7 +47,8 @@ export enum ResourceObjectType {
     USER = 'tpzed',
     VIRTUAL_MACHINE = '2x53u',
     WORKFLOW = '7fd4e',
-    SSH_KEY = 'fngyi'
+    SSH_KEY = 'fngyi',
+    KEEP_SERVICE = 'bi6l4'
 }
 
 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
@@ -85,6 +87,8 @@ export const extractUuidKind = (uuid: string = '') => {
             return ResourceKind.REPOSITORY;
         case ResourceObjectType.SSH_KEY:
             return ResourceKind.SSH_KEY;
+        case ResourceObjectType.KEEP_SERVICE:
+            return ResourceKind.KEEP_SERVICE;
         default:
             return undefined;
     }
diff --git a/src/routes/route-change-handlers.ts b/src/routes/route-change-handlers.ts
index 22d0b7c..fdc4211 100644
--- a/src/routes/route-change-handlers.ts
+++ b/src/routes/route-change-handlers.ts
@@ -4,10 +4,18 @@
 
 import { History, Location } from 'history';
 import { RootStore } from '~/store/store';
-import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute } from './routes';
-import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadVirtualMachines } from '~/store/workbench/workbench-actions';
+import {
+    matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute,
+    matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute,
+    matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute,
+    matchKeepServicesRoute
+} from './routes';
+import {
+    loadSharedWithMe, loadRunProcess, loadWorkflow, loadSearchResults,
+    loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog,
+    loadSshKeys, loadRepositories, loadVirtualMachines, loadKeepServices
+} from '~/store/workbench/workbench-actions';
 import { navigateToRootProject } from '~/store/navigation/navigation-action';
-import { loadSharedWithMe, loadRunProcess, loadWorkflow, loadSearchResults } from '~//store/workbench/workbench-actions';
 
 export const addRouteChangeHandlers = (history: History, store: RootStore) => {
     const handler = handleLocationChange(store);
@@ -23,13 +31,14 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const trashMatch = matchTrashRoute(pathname);
     const processMatch = matchProcessRoute(pathname);
     const processLogMatch = matchProcessLogRoute(pathname);
-    const repositoryMatch = matchRepositoriesRoute(pathname); 
+    const repositoryMatch = matchRepositoriesRoute(pathname);
     const searchResultsMatch = matchSearchResultsRoute(pathname);
     const sharedWithMeMatch = matchSharedWithMeRoute(pathname);
     const runProcessMatch = matchRunProcessRoute(pathname);
     const virtualMachineMatch = matchVirtualMachineRoute(pathname);
     const workflowMatch = matchWorkflowRoute(pathname);
     const sshKeysMatch = matchSshKeysRoute(pathname);
+    const keepServicesMatch = matchKeepServicesRoute(pathname);
 
     if (projectMatch) {
         store.dispatch(loadProject(projectMatch.params.id));
@@ -59,5 +68,7 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
         store.dispatch(loadRepositories);
     } else if (sshKeysMatch) {
         store.dispatch(loadSshKeys);
+    } else if (keepServicesMatch) {
+        store.dispatch(loadKeepServices);
     }
 };
diff --git a/src/routes/routes.ts b/src/routes/routes.ts
index 71cdfda..5cd3e55 100644
--- a/src/routes/routes.ts
+++ b/src/routes/routes.ts
@@ -22,7 +22,8 @@ export const Routes = {
     VIRTUAL_MACHINES: '/virtual-machines',
     WORKFLOWS: '/workflows',
     SEARCH_RESULTS: '/search-results',
-    SSH_KEYS: `/ssh-keys`
+    SSH_KEYS: `/ssh-keys`,
+    KEEP_SERVICES: `/keep-services`
 };
 
 export const getResourceUrl = (uuid: string) => {
@@ -88,3 +89,6 @@ export const matchRepositoriesRoute = (route: string) =>
     
 export const matchSshKeysRoute = (route: string) =>
     matchPath(route, { path: Routes.SSH_KEYS });
+
+export const matchKeepServicesRoute = (route: string) =>
+    matchPath(route, { path: Routes.KEEP_SERVICES });
diff --git a/src/services/keep-service/keep-service.ts b/src/services/keep-service/keep-service.ts
index 17ee522..5a89ba5 100644
--- a/src/services/keep-service/keep-service.ts
+++ b/src/services/keep-service/keep-service.ts
@@ -4,11 +4,11 @@
 
 import { CommonResourceService } from "~/services/common-service/common-resource-service";
 import { AxiosInstance } from "axios";
-import { KeepResource } from "~/models/keep";
+import { KeepServiceResource } from "~/models/keep-services";
 import { ApiActions } from "~/services/api/api-actions";
 
-export class KeepService extends CommonResourceService<KeepResource> {
+export class KeepService extends CommonResourceService<KeepServiceResource> {
     constructor(serverApi: AxiosInstance, actions: ApiActions) {
         super(serverApi, "keep_services", actions);
     }
-}
+}
\ No newline at end of file
diff --git a/src/store/advanced-tab/advanced-tab.ts b/src/store/advanced-tab/advanced-tab.ts
index b3c5164..c48011d 100644
--- a/src/store/advanced-tab/advanced-tab.ts
+++ b/src/store/advanced-tab/advanced-tab.ts
@@ -16,6 +16,7 @@ import { ServiceRepository } from '~/services/services';
 import { FilterBuilder } from '~/services/api/filter-builder';
 import { RepositoryResource } from '~/models/repositories';
 import { SshKeyResource } from '~/models/ssh-key';
+import { KeepServiceResource } from '~/models/keep-services';
 
 export const ADVANCED_TAB_DIALOG = 'advancedTabDialog';
 
@@ -58,8 +59,13 @@ enum SshKeyData {
     CREATED_AT = 'created_at'
 }
 
-type AdvanceResourceKind = CollectionData | ProcessData | ProjectData | RepositoryData | SshKeyData;
-type AdvanceResourcePrefix = GroupContentsResourcePrefix | 'repositories' | 'authorized_keys';
+enum KeepServiceData {
+    KEEP_SERVICE = 'keep_services',
+    CREATED_AT = 'created_at'
+}
+
+type AdvanceResourceKind = CollectionData | ProcessData | ProjectData | RepositoryData | SshKeyData | KeepServiceData;
+type AdvanceResourcePrefix = GroupContentsResourcePrefix | 'repositories' | 'authorized_keys' | 'keep_services';
 
 export const openAdvancedTabDialog = (uuid: string, index?: number) =>
     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
@@ -90,6 +96,11 @@ export const openAdvancedTabDialog = (uuid: string, index?: number) =>
                 const advanceDataSshKey: AdvancedTabDialogData = advancedTabData(uuid, '', '', sshKeyApiResponse, dataSshKey, SshKeyData.SSH_KEY, 'authorized_keys', SshKeyData.CREATED_AT, dataSshKey.createdAt);
                 dispatch<any>(initAdvancedTabDialog(advanceDataSshKey));
                 break;
+            case ResourceKind.KEEP_SERVICE:
+                const dataKeepService = getState().keepServices[index!];
+                const advanceDataKeepService: AdvancedTabDialogData = advancedTabData(uuid, '', '', keepServiceApiResponse, dataKeepService, KeepServiceData.KEEP_SERVICE, 'keep_services', KeepServiceData.CREATED_AT, dataKeepService.createdAt);
+                dispatch<any>(initAdvancedTabDialog(advanceDataKeepService));
+                break;
             default:
                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Could not open advanced tab for this resource.", hideDuration: 2000, kind: SnackbarKind.ERROR }));
         }
@@ -110,7 +121,7 @@ const getDataForAdvancedTab = (uuid: string) =>
 
 const initAdvancedTabDialog = (data: AdvancedTabDialogData) => dialogActions.OPEN_DIALOG({ id: ADVANCED_TAB_DIALOG, data });
 
-const advancedTabData = (uuid: string, metadata: any, user: any, apiResponseKind: any, data: any, resourceKind: AdvanceResourceKind, 
+const advancedTabData = (uuid: string, metadata: any, user: any, apiResponseKind: any, data: any, resourceKind: AdvanceResourceKind,
     resourcePrefix: AdvanceResourcePrefix, resourceKindProperty: AdvanceResourceKind, property: any) => {
     return {
         uuid,
@@ -293,4 +304,24 @@ const sshKeyApiResponse = (apiResponse: SshKeyResource) => {
 "created_at": "${createdAt}",
 "expires_at": "${expiresAt}"`;
     return response;
+};
+
+const keepServiceApiResponse = (apiResponse: KeepServiceResource) => {
+    const {
+        uuid, readOnly, serviceHost, servicePort, serviceSslFlag, serviceType,
+        ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid
+    } = apiResponse;
+    const response = `"uuid": "${uuid}",
+"owner_uuid": "${ownerUuid}",
+"modified_by_client_uuid": ${stringify(modifiedByClientUuid)},
+"modified_by_user_uuid": ${stringify(modifiedByUserUuid)},
+"modified_at": ${stringify(modifiedAt)},
+"service_host": "${serviceHost}",
+"service_port": "${servicePort}",
+"service_ssl_flag": "${stringify(serviceSslFlag)}",
+"service_type": "${serviceType}",
+"created_at": "${createdAt}",
+"read_only": "${stringify(readOnly)}"`;
+
+    return response;
 };
\ No newline at end of file
diff --git a/src/store/context-menu/context-menu-actions.ts b/src/store/context-menu/context-menu-actions.ts
index 5631a5e..f26a97d 100644
--- a/src/store/context-menu/context-menu-actions.ts
+++ b/src/store/context-menu/context-menu-actions.ts
@@ -15,6 +15,7 @@ import { extractUuidKind, ResourceKind } from '~/models/resource';
 import { Process } from '~/store/processes/process';
 import { RepositoryResource } from '~/models/repositories';
 import { SshKeyResource } from '~/models/ssh-key';
+import { KeepServiceResource } from '../../models/keep-services';
 
 export const contextMenuActions = unionize({
     OPEN_CONTEXT_MENU: ofType<{ position: ContextMenuPosition, resource: ContextMenuResource }>(),
@@ -33,8 +34,9 @@ export type ContextMenuResource = {
     isTrashed?: boolean;
     index?: number
 };
-export const isKeyboardClick = (event: React.MouseEvent<HTMLElement>) =>
-    event.nativeEvent.detail === 0;
+
+export const isKeyboardClick = (event: React.MouseEvent<HTMLElement>) => event.nativeEvent.detail === 0;
+
 export const openContextMenu = (event: React.MouseEvent<HTMLElement>, resource: ContextMenuResource) =>
     (dispatch: Dispatch) => {
         event.preventDefault();
@@ -86,6 +88,18 @@ export const openSshKeyContextMenu = (event: React.MouseEvent<HTMLElement>, inde
         }));
     };
 
+export const openKeepServiceContextMenu = (event: React.MouseEvent<HTMLElement>, index: number, keepService: KeepServiceResource) =>
+    (dispatch: Dispatch) => {
+        dispatch<any>(openContextMenu(event, {
+            name: '',
+            uuid: keepService.uuid,
+            ownerUuid: keepService.ownerUuid,
+            kind: ResourceKind.KEEP_SERVICE,
+            menuKind: ContextMenuKind.KEEP_SERVICE,
+            index
+        }));
+    };
+
 export const openRootProjectContextMenu = (event: React.MouseEvent<HTMLElement>, projectUuid: string) =>
     (dispatch: Dispatch, getState: () => RootState) => {
         const res = getResource<UserResource>(projectUuid)(getState().resources);
diff --git a/src/store/keep-services/keep-services-actions.ts b/src/store/keep-services/keep-services-actions.ts
new file mode 100644
index 0000000..bf7c45e
--- /dev/null
+++ b/src/store/keep-services/keep-services-actions.ts
@@ -0,0 +1,67 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from "redux";
+import { unionize, ofType, UnionOf } from "~/common/unionize";
+import { RootState } from '~/store/store';
+import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
+import { ServiceRepository } from "~/services/services";
+import { KeepServiceResource } from '~/models/keep-services';
+import { dialogActions } from '~/store/dialog/dialog-actions';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+
+export const keepServicesActions = unionize({
+    SET_KEEP_SERVICES: ofType<KeepServiceResource[]>(),
+    REMOVE_KEEP_SERVICE: ofType<string>(),
+    RESET_KEEP_SERVICES: ofType<{}>()
+});
+
+export type KeepServicesActions = UnionOf<typeof keepServicesActions>;
+
+export const KEEP_SERVICE_REMOVE_DIALOG = 'keepServiceRemoveDialog';
+export const KEEP_SERVICE_ATTRIBUTES_DIALOG = 'keepServiceAttributesDialog';
+
+// ToDo: access denied for loading keepService and reset data and redirect
+export const loadKeepServicesPanel = () =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            dispatch(setBreadcrumbs([{ label: 'Keep Services' }]));
+            const response = await services.keepService.list();
+            dispatch(keepServicesActions.SET_KEEP_SERVICES(response.items));
+        } catch (e) {
+            return;
+        }
+    };
+
+export const openKeepServiceAttributesDialog = (index: number) =>
+    (dispatch: Dispatch, getState: () => RootState) => {
+        const keepService = getState().keepServices[index];
+        dispatch(dialogActions.OPEN_DIALOG({ id: KEEP_SERVICE_ATTRIBUTES_DIALOG, data: { keepService } }));
+    };
+
+export const openKeepServiceRemoveDialog = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState) => {
+        dispatch(dialogActions.OPEN_DIALOG({
+            id: KEEP_SERVICE_REMOVE_DIALOG,
+            data: {
+                title: 'Remove keep service',
+                text: 'Are you sure you want to remove this keep service?',
+                confirmButtonLabel: 'Remove',
+                uuid
+            }
+        }));
+    };
+
+// ToDo: access denied for removing keepService and reset data and redirect
+export const removeKeepService = (uuid: string) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
+        try {
+            await services.keepService.delete(uuid);
+            dispatch(keepServicesActions.REMOVE_KEEP_SERVICE(uuid));
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Keep service has been successfully removed.', hideDuration: 2000 }));
+        } catch (e) {
+            return;
+        }
+    };
\ No newline at end of file
diff --git a/src/store/keep-services/keep-services-reducer.ts b/src/store/keep-services/keep-services-reducer.ts
new file mode 100644
index 0000000..53ef678
--- /dev/null
+++ b/src/store/keep-services/keep-services-reducer.ts
@@ -0,0 +1,18 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { keepServicesActions, KeepServicesActions } from '~/store/keep-services/keep-services-actions';
+import { KeepServiceResource } from '~/models/keep-services';
+
+export type KeepSericesState = KeepServiceResource[];
+
+const initialState: KeepSericesState = [];
+
+export const keepServicesReducer = (state: KeepSericesState = initialState, action: KeepServicesActions): KeepSericesState =>
+    keepServicesActions.match(action, {
+        SET_KEEP_SERVICES: items => items,
+        REMOVE_KEEP_SERVICE: (uuid: string) => state.filter((keepService) => keepService.uuid !== uuid),
+        RESET_KEEP_SERVICES: () => [],
+        default: () => state
+    });
\ No newline at end of file
diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts
index 2bfd8b9..d452710 100644
--- a/src/store/navigation/navigation-action.ts
+++ b/src/store/navigation/navigation-action.ts
@@ -67,3 +67,5 @@ export const navigateToVirtualMachines = push(Routes.VIRTUAL_MACHINES);
 export const navigateToRepositories = push(Routes.REPOSITORIES);
 
 export const navigateToSshKeys= push(Routes.SSH_KEYS);
+
+export const navigateToKeepServices = push(Routes.KEEP_SERVICES);
\ No newline at end of file
diff --git a/src/store/store.ts b/src/store/store.ts
index 4ab0918..f8bdcc2 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -45,6 +45,7 @@ import { SearchResultsMiddlewareService } from './search-results-panel/search-re
 import { resourcesDataReducer } from "~/store/resources-data/resources-data-reducer";
 import { virtualMachinesReducer } from "~/store/virtual-machines/virtual-machines-reducer";
 import { repositoriesReducer } from '~/store/repositories/repositories-reducer';
+import { keepServicesReducer } from '~/store/keep-services/keep-services-reducer';
 
 const composeEnhancers =
     (process.env.NODE_ENV === 'development' &&
@@ -115,5 +116,6 @@ const createRootReducer = (services: ServiceRepository) => combineReducers({
     appInfo: appInfoReducer,
     searchBar: searchBarReducer,
     virtualMachines: virtualMachinesReducer,
-    repositories: repositoriesReducer
+    repositories: repositoriesReducer,
+    keepServices: keepServicesReducer
 });
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index 12dbe7b..667f1c8 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -56,6 +56,7 @@ import { searchResultsPanelActions, loadSearchResultsPanel } from '~/store/searc
 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
 import { loadVirtualMachinesPanel } from '~/store/virtual-machines/virtual-machines-actions';
 import { loadRepositoriesPanel } from '~/store/repositories/repositories-actions';
+import { loadKeepServicesPanel } from '~/store/keep-services/keep-services-actions';
 
 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
 
@@ -410,6 +411,11 @@ export const loadSshKeys = handleFirstTimeLoad(
         await dispatch(loadSshKeysPanel());
     });
 
+export const loadKeepServices = handleFirstTimeLoad(
+    async (dispatch: Dispatch<any>) => {
+        await dispatch(loadKeepServicesPanel());
+    });
+
 const finishLoadingProject = (project: GroupContentsResource | string) =>
     async (dispatch: Dispatch<any>) => {
         const uuid = typeof project === 'string' ? project : project.uuid;
diff --git a/src/views-components/context-menu/action-sets/keep-service-action-set.ts b/src/views-components/context-menu/action-sets/keep-service-action-set.ts
new file mode 100644
index 0000000..5d27e4e
--- /dev/null
+++ b/src/views-components/context-menu/action-sets/keep-service-action-set.ts
@@ -0,0 +1,28 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { openKeepServiceAttributesDialog, openKeepServiceRemoveDialog } from '~/store/keep-services/keep-services-actions';
+import { openAdvancedTabDialog } from '~/store/advanced-tab/advanced-tab';
+import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
+import { AdvancedIcon, RemoveIcon, AttributesIcon } from "~/components/icon/icon";
+
+export const keepServiceActionSet: ContextMenuActionSet = [[{
+    name: "Attributes",
+    icon: AttributesIcon,
+    execute: (dispatch, { index }) => {
+        dispatch<any>(openKeepServiceAttributesDialog(index!));
+    }
+}, {
+    name: "Advanced",
+    icon: AdvancedIcon,
+    execute: (dispatch, { uuid, index }) => {
+        dispatch<any>(openAdvancedTabDialog(uuid, index));
+    }
+}, {
+    name: "Remove",
+    icon: RemoveIcon,
+    execute: (dispatch, { uuid }) => {
+        dispatch<any>(openKeepServiceRemoveDialog(uuid));
+    }
+}]];
diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index af5aaa9..211881c 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -70,5 +70,6 @@ export enum ContextMenuKind {
     PROCESS_RESOURCE = 'ProcessResource',
     PROCESS_LOGS = "ProcessLogs",
     REPOSITORY = "Repository",
-    SSH_KEY = "SshKey"
+    SSH_KEY = "SshKey",
+    KEEP_SERVICE = "KeepService"
 }
diff --git a/src/views-components/keep-services-dialog/attributes-dialog.tsx b/src/views-components/keep-services-dialog/attributes-dialog.tsx
new file mode 100644
index 0000000..113d191
--- /dev/null
+++ b/src/views-components/keep-services-dialog/attributes-dialog.tsx
@@ -0,0 +1,73 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { compose } from 'redux';
+import {
+    withStyles, Dialog, DialogTitle, DialogContent, DialogActions,
+    Button, StyleRulesCallback, WithStyles, Grid
+} from '@material-ui/core';
+import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog";
+import { KEEP_SERVICE_ATTRIBUTES_DIALOG } from '~/store/keep-services/keep-services-actions';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { KeepServiceResource } from '~/models/keep-services';
+
+type CssRules = 'root';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    root: {
+        fontSize: '0.875rem',
+        '& div:nth-child(odd)': {
+            textAlign: 'right',
+            color: theme.palette.grey["500"]
+        }
+    }
+});
+
+interface AttributesKeepServiceDialogDataProps {
+    keepService: KeepServiceResource;
+}
+
+export const AttributesKeepServiceDialog = compose(
+    withDialog(KEEP_SERVICE_ATTRIBUTES_DIALOG),
+    withStyles(styles))(
+        ({ open, closeDialog, data, classes }: WithDialogProps<AttributesKeepServiceDialogDataProps> & WithStyles<CssRules>) =>
+            <Dialog open={open} onClose={closeDialog} fullWidth maxWidth='sm'>
+                <DialogTitle>Attributes</DialogTitle>
+                <DialogContent>
+                    {data.keepService && <Grid container direction="row" spacing={16} className={classes.root}>
+                        <Grid item xs={5}>UUID</Grid>
+                        <Grid item xs={7}>{data.keepService.uuid}</Grid>
+                        <Grid item xs={5}>Read only</Grid>
+                        <Grid item xs={7}>{JSON.stringify(data.keepService.readOnly)}</Grid>
+                        <Grid item xs={5}>Service host</Grid>
+                        <Grid item xs={7}>{data.keepService.serviceHost}</Grid>
+                        <Grid item xs={5}>Service port</Grid>
+                        <Grid item xs={7}>{data.keepService.servicePort}</Grid>
+                        <Grid item xs={5}>Service SSL flag</Grid>
+                        <Grid item xs={7}>{JSON.stringify(data.keepService.serviceSslFlag)}</Grid>
+                        <Grid item xs={5}>Service type</Grid>
+                        <Grid item xs={7}>{data.keepService.serviceType}</Grid>
+                        <Grid item xs={5}>Owner uuid</Grid>
+                        <Grid item xs={7}>{data.keepService.ownerUuid}</Grid>
+                        <Grid item xs={5}>Created at</Grid>
+                        <Grid item xs={7}>{data.keepService.createdAt}</Grid>
+                        <Grid item xs={5}>Modified at</Grid>
+                        <Grid item xs={7}>{data.keepService.modifiedAt}</Grid>
+                        <Grid item xs={5}>Modified by user uuid</Grid>
+                        <Grid item xs={7}>{data.keepService.modifiedByUserUuid}</Grid>
+                        <Grid item xs={5}>Modified by client uuid</Grid>
+                        <Grid item xs={7}>{data.keepService.modifiedByClientUuid}</Grid>
+                    </Grid>}
+                </DialogContent>
+                <DialogActions>
+                    <Button
+                        variant='flat'
+                        color='primary'
+                        onClick={closeDialog}>
+                        Close
+                    </Button>
+                </DialogActions>
+            </Dialog>
+    );
\ No newline at end of file
diff --git a/src/views-components/keep-services-dialog/remove-dialog.tsx b/src/views-components/keep-services-dialog/remove-dialog.tsx
new file mode 100644
index 0000000..7e39850
--- /dev/null
+++ b/src/views-components/keep-services-dialog/remove-dialog.tsx
@@ -0,0 +1,20 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+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 { KEEP_SERVICE_REMOVE_DIALOG, removeKeepService } from '~/store/keep-services/keep-services-actions';
+
+const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
+    onConfirm: () => {
+        props.closeDialog();
+        dispatch<any>(removeKeepService(props.data.uuid));
+    }
+});
+
+export const RemoveKeepServiceDialog = compose(
+    withDialog(KEEP_SERVICE_REMOVE_DIALOG),
+    connect(null, mapDispatchToProps)
+)(ConfirmationDialog);
\ No newline at end of file
diff --git a/src/views-components/main-app-bar/account-menu.tsx b/src/views-components/main-app-bar/account-menu.tsx
index ca88021..075aa69 100644
--- a/src/views-components/main-app-bar/account-menu.tsx
+++ b/src/views-components/main-app-bar/account-menu.tsx
@@ -12,7 +12,7 @@ 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 } from '~/store/navigation/navigation-action';
+import { navigateToSshKeys, navigateToKeepServices } from '~/store/navigation/navigation-action';
 import { openVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
 
 interface AccountMenuProps {
@@ -37,6 +37,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>
+                { user.isAdmin && <MenuItem onClick={() => dispatch(navigateToKeepServices)}>Keep Services</MenuItem> }
                 <MenuItem>My account</MenuItem>
                 <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
             </DropdownMenu>
diff --git a/src/views-components/main-content-bar/main-content-bar.tsx b/src/views-components/main-content-bar/main-content-bar.tsx
index 6b84bde..66d7cab 100644
--- a/src/views-components/main-content-bar/main-content-bar.tsx
+++ b/src/views-components/main-content-bar/main-content-bar.tsx
@@ -8,7 +8,7 @@ import { DetailsIcon } from "~/components/icon/icon";
 import { Breadcrumbs } from "~/views-components/breadcrumbs/breadcrumbs";
 import { connect } from 'react-redux';
 import { RootState } from '~/store/store';
-import { matchWorkflowRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute } from '~/routes/routes';
+import { matchWorkflowRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute, matchKeepServicesRoute } from '~/routes/routes';
 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
 
 interface MainContentBarProps {
@@ -16,32 +16,14 @@ interface MainContentBarProps {
     buttonVisible: boolean;
 }
 
-const isWorkflowPath = ({ router }: RootState) => {
+const isButtonVisible = ({ router }: RootState) => {
     const pathname = router.location ? router.location.pathname : '';
-    const match = matchWorkflowRoute(pathname);
-    return !!match;
-};
-
-const isVirtualMachinePath = ({ router }: RootState) => {
-    const pathname = router.location ? router.location.pathname : '';
-    const match = matchVirtualMachineRoute(pathname);
-    return !!match;
-};
-
-const isRepositoriesPath = ({ router }: RootState) => {
-    const pathname = router.location ? router.location.pathname : '';
-    const match = matchRepositoriesRoute(pathname);
-    return !!match;
-};
-
-const isSshKeysPath = ({ router }: RootState) => {
-    const pathname = router.location ? router.location.pathname : '';
-    const match = matchSshKeysRoute(pathname);
-    return !!match;
+    return !matchWorkflowRoute(pathname) && !matchVirtualMachineRoute(pathname) &&
+        !matchRepositoriesRoute(pathname) && !matchSshKeysRoute(pathname) && !matchKeepServicesRoute(pathname);
 };
 
 export const MainContentBar = connect((state: RootState) => ({
-    buttonVisible: !isWorkflowPath(state) && !isSshKeysPath(state) && !isRepositoriesPath(state) && !isVirtualMachinePath(state)
+    buttonVisible: isButtonVisible(state)
 }), {
         onDetailsPanelToggle: toggleDetailsPanel
     })((props: MainContentBarProps) =>
diff --git a/src/views/keep-service-panel/keep-service-panel-root.tsx b/src/views/keep-service-panel/keep-service-panel-root.tsx
new file mode 100644
index 0000000..57193d3
--- /dev/null
+++ b/src/views/keep-service-panel/keep-service-panel-root.tsx
@@ -0,0 +1,87 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { StyleRulesCallback, WithStyles, withStyles, Card, CardContent, Button, Typography, Grid, Table, TableHead, TableRow, TableCell, TableBody, Tooltip, IconButton, Checkbox } from '@material-ui/core';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { MoreOptionsIcon } from '~/components/icon/icon';
+import { KeepServiceResource } from '~/models/keep-services';
+
+type CssRules = 'root' | 'tableRow';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    root: {
+        width: '100%',
+        overflow: 'auto'
+    },
+    tableRow: {
+        '& td, th': {
+            whiteSpace: 'nowrap'
+        }
+    }
+});
+
+export interface KeepServicePanelRootActionProps {
+    openRowOptions: (event: React.MouseEvent<HTMLElement>, index: number, keepService: KeepServiceResource) => void;
+}
+
+export interface KeepServicePanelRootDataProps {
+    keepServices: KeepServiceResource[];
+    hasKeepSerices: boolean;
+}
+
+type KeepServicePanelRootProps = KeepServicePanelRootActionProps & KeepServicePanelRootDataProps & WithStyles<CssRules>;
+
+export const KeepServicePanelRoot = withStyles(styles)(
+    ({ classes, hasKeepSerices, keepServices, openRowOptions }: KeepServicePanelRootProps) => 
+        <Card className={classes.root}>
+            <CardContent>
+                {hasKeepSerices && <Grid container direction="row">
+                    <Grid item xs={12}>
+                        <Table>
+                            <TableHead>
+                                <TableRow className={classes.tableRow}>
+                                    <TableCell>UUID</TableCell>
+                                    <TableCell>Read only</TableCell>
+                                    <TableCell>Service host</TableCell>
+                                    <TableCell>Service port</TableCell>
+                                    <TableCell>Service SSL flag</TableCell>
+                                    <TableCell>Service type</TableCell>
+                                    <TableCell />
+                                </TableRow>
+                            </TableHead>
+                            <TableBody>
+                                {keepServices.map((keepService, index) =>
+                                    <TableRow key={index} className={classes.tableRow}>
+                                        <TableCell>{keepService.uuid}</TableCell>
+                                        <TableCell>
+                                            <Checkbox
+                                                disableRipple
+                                                color="primary"
+                                                checked={keepService.readOnly} />
+                                        </TableCell>
+                                        <TableCell>{keepService.serviceHost}</TableCell>
+                                        <TableCell>{keepService.servicePort}</TableCell>
+                                        <TableCell>
+                                            <Checkbox
+                                                disableRipple
+                                                color="primary"
+                                                checked={keepService.serviceSslFlag} />
+                                        </TableCell>
+                                        <TableCell>{keepService.serviceType}</TableCell>
+                                        <TableCell>
+                                            <Tooltip title="More options" disableFocusListener>
+                                                <IconButton onClick={event => openRowOptions(event, index, keepService)}>
+                                                    <MoreOptionsIcon />
+                                                </IconButton>
+                                            </Tooltip>
+                                        </TableCell>
+                                    </TableRow>)}
+                            </TableBody>
+                        </Table>
+                    </Grid>
+                </Grid>}
+            </CardContent>
+        </Card>
+);
\ No newline at end of file
diff --git a/src/views/keep-service-panel/keep-service-panel.tsx b/src/views/keep-service-panel/keep-service-panel.tsx
new file mode 100644
index 0000000..2c6323b
--- /dev/null
+++ b/src/views/keep-service-panel/keep-service-panel.tsx
@@ -0,0 +1,29 @@
+// 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 { } from '~/store/keep-services/keep-services-actions';
+import { 
+    KeepServicePanelRoot, 
+    KeepServicePanelRootDataProps, 
+    KeepServicePanelRootActionProps 
+} from '~/views/keep-service-panel/keep-service-panel-root';
+import { openKeepServiceContextMenu } from '~/store/context-menu/context-menu-actions';
+
+const mapStateToProps = (state: RootState): KeepServicePanelRootDataProps => {
+    return {
+        keepServices: state.keepServices,
+        hasKeepSerices: state.keepServices.length > 0
+    };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): KeepServicePanelRootActionProps => ({
+    openRowOptions: (event, index, keepService) => {
+        dispatch<any>(openKeepServiceContextMenu(event, index, keepService));
+    }
+});
+
+export const KeepServicePanel = connect(mapStateToProps, mapDispatchToProps)(KeepServicePanelRoot);
\ No newline at end of file
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 3914f64..dd4f802 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -51,13 +51,16 @@ import { ProcessInputDialog } from '~/views-components/process-input-dialog/proc
 import { VirtualMachinePanel } from '~/views/virtual-machine-panel/virtual-machine-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';
 import { RepositoriesSampleGitDialog } from '~/views-components/repositories-sample-git-dialog/repositories-sample-git-dialog';
 import { RepositoryAttributesDialog } from '~/views-components/repository-attributes-dialog/repository-attributes-dialog';
 import { CreateRepositoryDialog } from '~/views-components/dialog-forms/create-repository-dialog';
 import { RemoveRepositoryDialog } from '~/views-components/repository-remove-dialog/repository-remove-dialog';
 import { CreateSshKeyDialog } from '~/views-components/dialog-forms/create-ssh-key-dialog';
 import { PublicKeyDialog } from '~/views-components/ssh-keys-dialog/public-key-dialog';
+import { RemoveKeepServiceDialog } from '~/views-components/keep-services-dialog/remove-dialog';
 import { RemoveSshKeyDialog } from '~/views-components/ssh-keys-dialog/remove-dialog';
+import { AttributesKeepServiceDialog } from '~/views-components/keep-services-dialog/attributes-dialog';
 import { AttributesSshKeyDialog } from '~/views-components/ssh-keys-dialog/attributes-dialog';
 
 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
@@ -131,6 +134,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.KEEP_SERVICES} component={KeepServicePanel} />
                             </Switch>
                         </Grid>
                     </Grid>
@@ -140,6 +144,7 @@ export const WorkbenchPanel =
                 <DetailsPanel />
             </Grid>
             <AdvancedTabDialog />
+            <AttributesKeepServiceDialog />
             <AttributesSshKeyDialog />
             <ChangeWorkflowDialog />
             <ContextMenu />
@@ -161,6 +166,7 @@ export const WorkbenchPanel =
             <ProcessCommandDialog />
             <ProcessInputDialog />
             <ProjectPropertiesDialog />
+            <RemoveKeepServiceDialog />
             <RemoveProcessDialog />
             <RemoveRepositoryDialog />
             <RemoveSshKeyDialog />

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list