From: Janicki Artur Date: Mon, 3 Dec 2018 12:05:41 +0000 (+0100) Subject: Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14503_keep_service... X-Git-Tag: 1.4.0~99^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/785a62a8934dc439cbd201d9011775ccbcbb2c24?hp=756f931c1faeb27a00625093697ff95358e0afc4 Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14503_keep_services_panel refs #2 14503 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- diff --git a/src/index.tsx b/src/index.tsx index 801a56a1..79525a8a 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 f6b5ef2a..d99943c6 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 7e2127b2..ee901749 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 22d0b7c7..fdc4211f 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 71cdfdac..5cd3e559 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/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts index edc6e24f..69e3a79d 100644 --- a/src/services/auth-service/auth-service.ts +++ b/src/services/auth-service/auth-service.ts @@ -52,7 +52,7 @@ export class AuthService { } public getIsAdmin(): boolean { - return !!localStorage.getItem(USER_IS_ADMIN); + return localStorage.getItem(USER_IS_ADMIN) === 'true'; } public getUser(): User | undefined { diff --git a/src/services/keep-service/keep-service.ts b/src/services/keep-service/keep-service.ts index 17ee522e..5a89ba57 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 { +export class KeepService extends CommonResourceService { 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 b3c5164c..c48011d2 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, 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(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(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, @@ -292,5 +303,25 @@ const sshKeyApiResponse = (apiResponse: SshKeyResource) => { "name": ${stringify(name)}, "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 5631a5e8..2c533d66 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) => - event.nativeEvent.detail === 0; + +export const isKeyboardClick = (event: React.MouseEvent) => event.nativeEvent.detail === 0; + export const openContextMenu = (event: React.MouseEvent, resource: ContextMenuResource) => (dispatch: Dispatch) => { event.preventDefault(); @@ -86,6 +88,18 @@ export const openSshKeyContextMenu = (event: React.MouseEvent, inde })); }; +export const openKeepServiceContextMenu = (event: React.MouseEvent, index: number, keepService: KeepServiceResource) => + (dispatch: Dispatch) => { + dispatch(openContextMenu(event, { + name: '', + uuid: keepService.uuid, + ownerUuid: keepService.ownerUuid, + kind: ResourceKind.KEEP_SERVICE, + menuKind: ContextMenuKind.KEEP_SERVICE, + index + })); + }; + export const openRootProjectContextMenu = (event: React.MouseEvent, projectUuid: string) => (dispatch: Dispatch, getState: () => RootState) => { const res = getResource(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 00000000..1de6802e --- /dev/null +++ b/src/store/keep-services/keep-services-actions.ts @@ -0,0 +1,71 @@ +// 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'; +import { navigateToRootProject } from '~/store/navigation/navigation-action'; + +export const keepServicesActions = unionize({ + SET_KEEP_SERVICES: ofType(), + REMOVE_KEEP_SERVICE: ofType() +}); + +export type KeepServicesActions = UnionOf; + +export const KEEP_SERVICE_REMOVE_DIALOG = 'keepServiceRemoveDialog'; +export const KEEP_SERVICE_ATTRIBUTES_DIALOG = 'keepServiceAttributesDialog'; + +export const loadKeepServicesPanel = () => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const user = getState().auth.user; + if(user && user.isAdmin) { + try { + dispatch(setBreadcrumbs([{ label: 'Keep Services' }])); + const response = await services.keepService.list(); + dispatch(keepServicesActions.SET_KEEP_SERVICES(response.items)); + } catch (e) { + return; + } + } else { + dispatch(navigateToRootProject); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "You don't have permissions to view this page", hideDuration: 2000 })); + } + }; + +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 + } + })); + }; + +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 00000000..043c010a --- /dev/null +++ b/src/store/keep-services/keep-services-reducer.ts @@ -0,0 +1,17 @@ +// 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), + 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 2bfd8b99..d452710c 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 4ab0918e..f8bdcc24 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 12dbe7b1..667f1c80 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) => { + await dispatch(loadKeepServicesPanel()); + }); + const finishLoadingProject = (project: GroupContentsResource | string) => async (dispatch: Dispatch) => { 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 00000000..5d27e4e9 --- /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(openKeepServiceAttributesDialog(index!)); + } +}, { + name: "Advanced", + icon: AdvancedIcon, + execute: (dispatch, { uuid, index }) => { + dispatch(openAdvancedTabDialog(uuid, index)); + } +}, { + name: "Remove", + icon: RemoveIcon, + execute: (dispatch, { uuid }) => { + dispatch(openKeepServiceRemoveDialog(uuid)); + } +}]]; diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx index af5aaa92..211881ca 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 00000000..113d191b --- /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 = (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 & WithStyles) => + + Attributes + + {data.keepService && + UUID + {data.keepService.uuid} + Read only + {JSON.stringify(data.keepService.readOnly)} + Service host + {data.keepService.serviceHost} + Service port + {data.keepService.servicePort} + Service SSL flag + {JSON.stringify(data.keepService.serviceSslFlag)} + Service type + {data.keepService.serviceType} + Owner uuid + {data.keepService.ownerUuid} + Created at + {data.keepService.createdAt} + Modified at + {data.keepService.modifiedAt} + Modified by user uuid + {data.keepService.modifiedByUserUuid} + Modified by client uuid + {data.keepService.modifiedByClientUuid} + } + + + + + + ); \ 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 00000000..7e398509 --- /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) => ({ + onConfirm: () => { + props.closeDialog(); + dispatch(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 ca88021c..075aa69a 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)( dispatch(openRepositoriesPanel())}>Repositories dispatch(openCurrentTokenDialog)}>Current token dispatch(navigateToSshKeys)}>Ssh Keys + { user.isAdmin && dispatch(navigateToKeepServices)}>Keep Services } My account dispatch(logout())}>Logout 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 6b84bde2..66d7cabc 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 00000000..57193d35 --- /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 = (theme: ArvadosTheme) => ({ + root: { + width: '100%', + overflow: 'auto' + }, + tableRow: { + '& td, th': { + whiteSpace: 'nowrap' + } + } +}); + +export interface KeepServicePanelRootActionProps { + openRowOptions: (event: React.MouseEvent, index: number, keepService: KeepServiceResource) => void; +} + +export interface KeepServicePanelRootDataProps { + keepServices: KeepServiceResource[]; + hasKeepSerices: boolean; +} + +type KeepServicePanelRootProps = KeepServicePanelRootActionProps & KeepServicePanelRootDataProps & WithStyles; + +export const KeepServicePanelRoot = withStyles(styles)( + ({ classes, hasKeepSerices, keepServices, openRowOptions }: KeepServicePanelRootProps) => + + + {hasKeepSerices && + + + + + UUID + Read only + Service host + Service port + Service SSL flag + Service type + + + + + {keepServices.map((keepService, index) => + + {keepService.uuid} + + + + {keepService.serviceHost} + {keepService.servicePort} + + + + {keepService.serviceType} + + + openRowOptions(event, index, keepService)}> + + + + + )} + +
+
+
} +
+
+); \ 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 00000000..2c6323b0 --- /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(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 3914f646..dd4f802c 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 = + @@ -140,6 +144,7 @@ export const WorkbenchPanel = + @@ -161,6 +166,7 @@ export const WorkbenchPanel = +