refs #14565-login-as-someone-proper-uuid
[arvados-workbench2.git] / src / views-components / data-explorer / renderers.tsx
index b74e8af19ed3c0d3dc32b903669d7c275ec4afcd..0637676c03836bf8b389a4f81dcf24dfd763f028 100644 (file)
@@ -25,7 +25,7 @@ import { UserResource } from '~/models/user';
 import { toggleIsActive, toggleIsAdmin } from '~/store/users/users-actions';
 import { LinkResource } from '~/models/link';
 import { navigateTo } from '~/store/navigation/navigation-action';
-import { withResource, getDataFromResource } from './with-resources';
+import { withResource, getDataFromResource, withResourceData } from '~/views-components/data-explorer/with-resources';
 
 const renderName = (item: { name: string; uuid: string, kind: string }) =>
     <Grid container alignItems="center" wrap="nowrap" spacing={16}>
@@ -191,33 +191,52 @@ export const ResourceUsername = connect(
         return resource || { username: '' };
     })(renderUsername);
 
-// Compute Node Resources
-const renderNodeDate = (date: string) =>
+// Common methods
+const renderCommonData = (data: string) =>
+    <Typography noWrap>{data}</Typography>;
+
+const renderCommonDate = (date: string) =>
     <Typography noWrap>{formatDate(date)}</Typography>;
 
-const renderNodeData = (data: string) => {
-    return <Typography noWrap>{data}</Typography>;
-};
+export const CommonUuid = withResourceData('uuid', renderCommonData);
+
+// Api Client Authorizations
+export const TokenApiClientId = withResourceData('apiClientId', renderCommonData);
+
+export const TokenApiToken = withResourceData('apiToken', renderCommonData);
+
+export const TokenCreatedByIpAddress = withResourceData('createdByIpAddress', renderCommonDate);
+
+export const TokenDefaultOwnerUuid = withResourceData('defaultOwnerUuid', renderCommonData);
 
+export const TokenExpiresAt = withResourceData('expiresAt', renderCommonDate);
+
+export const TokenLastUsedAt = withResourceData('lastUsedAt', renderCommonDate);
+
+export const TokenLastUsedByIpAddress = withResourceData('lastUsedByIpAddress', renderCommonData);
+
+export const TokenScopes = withResourceData('scopes', renderCommonData);
+
+export const TokenUserId = withResourceData('userId', renderCommonData);
+
+// Compute Node Resources
 const renderNodeInfo = (data: string) => {
     return <Typography>{JSON.stringify(data, null, 4)}</Typography>;
 };
 
-export const ComputeNodeInfo = withResource(({ resource }) => renderNodeInfo(getDataFromResource('info', resource)));
-
-export const ComputeNodeUuid = withResource(({ resource }) => renderNodeData(getDataFromResource('uuid', resource)));
+export const ComputeNodeInfo = withResourceData('info', renderNodeInfo);
 
-export const ComputeNodeDomain = withResource(({ resource }) => renderNodeData(getDataFromResource('domain', resource)));
+export const ComputeNodeDomain = withResourceData('domain', renderCommonData);
 
-export const ComputeNodeFirstPingAt = withResource(({ resource }) => renderNodeDate(getDataFromResource('firstPingAt', resource)));
+export const ComputeNodeFirstPingAt = withResourceData('firstPingAt', renderCommonDate);
 
-export const ComputeNodeHostname = withResource(({ resource }) => renderNodeData(getDataFromResource('hostname', resource)));
+export const ComputeNodeHostname = withResourceData('hostname', renderCommonData);
 
-export const ComputeNodeIpAddress = withResource(({ resource }) => renderNodeData(getDataFromResource('ipAddress', resource)));
+export const ComputeNodeIpAddress = withResourceData('ipAddress', renderCommonData);
 
-export const ComputeNodeJobUuid = withResource(({ resource }) => renderNodeData(getDataFromResource('jobUuid', resource)));
+export const ComputeNodeJobUuid = withResourceData('jobUuid', renderCommonData);
 
-export const ComputeNodeLastPingAt = withResource(({ resource }) => renderNodeDate(getDataFromResource('lastPingAt', resource)));
+export const ComputeNodeLastPingAt = withResourceData('lastPingAt', renderCommonDate);
 
 // Links Resources
 const renderLinkName = (item: { name: string }) =>