X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/66088cabf30c5291ad8894e7009d9c9af466c158..ec491638051a00f89f613caecd7ed571ac7a2bfd:/services/workbench2/src/views-components/data-explorer/renderers.tsx diff --git a/services/workbench2/src/views-components/data-explorer/renderers.tsx b/services/workbench2/src/views-components/data-explorer/renderers.tsx index 257eacfb29..81e2b55aa9 100644 --- a/services/workbench2/src/views-components/data-explorer/renderers.tsx +++ b/services/workbench2/src/views-components/data-explorer/renderers.tsx @@ -36,7 +36,6 @@ import { ResourceStatus as WorkflowStatus } from "views/workflow-panel/workflow- import { getUuidPrefix, openRunProcess } from "store/workflow-panel/workflow-panel-actions"; import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions"; import { getUserFullname, getUserDisplayName, User, UserResource } from "models/user"; -import { toggleIsAdmin } from "store/users/users-actions"; import { LinkClass, LinkResource } from "models/link"; import { navigateTo, navigateToGroupDetails, navigateToUserProfile } from "store/navigation/navigation-action"; import { withResourceData } from "views-components/data-explorer/with-resources"; @@ -53,6 +52,18 @@ import { VirtualMachinesResource } from "models/virtual-machines"; import { CopyToClipboardSnackbar } from "components/copy-to-clipboard-snackbar/copy-to-clipboard-snackbar"; import { ProjectResource } from "models/project"; import { ProcessResource } from "models/process"; +import { ServiceRepository } from "services/services"; +import { loadUsersPanel } from "store/users/users-actions"; + +export const toggleIsAdmin = (uuid: string) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const { resources } = getState(); + const data = getResource(uuid)(resources); + const isAdmin = data!.isAdmin; + const newActivity = await services.userService.update(uuid, { isAdmin: !isAdmin }); + dispatch(loadUsersPanel()); + return newActivity; + }; const renderName = (dispatch: Dispatch, item: GroupContentsResource) => { const navFunc = "groupClass" in item && item.groupClass === GroupClass.ROLE ? navigateToGroupDetails : navigateTo; @@ -68,7 +79,10 @@ const renderName = (dispatch: Dispatch, item: GroupContentsResource) => { dispatch(navFunc(item.uuid))} + onClick={(ev) => { + ev.stopPropagation() + dispatch(navFunc(item.uuid)) + }} > {item.kind === ResourceKind.PROJECT || item.kind === ResourceKind.COLLECTION ? : null} {item.name} @@ -512,7 +526,7 @@ const getResourceDisplayName = (resource: Resource): string => { } }; -const renderResourceLink = (dispatch: Dispatch, item: Resource) => { +const renderResourceLink = (dispatch: Dispatch, item: Resource ) => { var displayName = getResourceDisplayName(item); return ( @@ -523,7 +537,9 @@ const renderResourceLink = (dispatch: Dispatch, item: Resource) => { onClick={() => { item.kind === ResourceKind.GROUP && (item as GroupResource).groupClass === "role" ? dispatch(navigateToGroupDetails(item.uuid)) - : dispatch(navigateTo(item.uuid)); + : item.kind === ResourceKind.USER + ? dispatch(navigateToUserProfile(item.uuid)) + : dispatch(navigateTo(item.uuid)); }} > {resourceLabel(item.kind, item && item.kind === ResourceKind.GROUP ? (item as GroupResource).groupClass || "" : "")}:{" "} @@ -914,6 +930,30 @@ const _resourceWithName = withStyles( ); }); +const _resourceWithNameLink = withStyles( + {}, + { withTheme: true } +)((props: { uuid: string; userFullname: string; dispatch: Dispatch; theme: ArvadosTheme }) => { + const { uuid, userFullname, dispatch, theme } = props; + if (!userFullname) { + dispatch(loadResource(uuid, false)); + } + + return ( + dispatch(navigateTo(uuid))} + > + {userFullname ? userFullname : uuid} + + ) +}); + + +export const ResourceOwnerWithNameLink = ownerFromResourceId(_resourceWithNameLink); + export const ResourceOwnerWithName = ownerFromResourceId(_resourceWithName); export const ResourceWithName = userFromID(_resourceWithName);