import { toggleIsActive, toggleIsAdmin } from '~/store/users/users-actions';
import { LinkResource } from '~/models/link';
import { navigateTo } from '~/store/navigation/navigation-action';
-import { Link } from 'react-router-dom';
-import { NodeResource } from '../../models/node';
-import { NodeInfo } from '~/models/node';
+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}>
return resource || { username: '' };
})(renderUsername);
-// Compute Node Resources
-const renderNodeDate = (date?: string) =>
- <Typography noWrap>{formatDate(date) || '(none)'}</Typography>;
+// Common methods
+const renderCommonData = (data: string) =>
+ <Typography noWrap>{data}</Typography>;
-const renderNodeData = (property?: string) =>
- <Typography noWrap>{property || '(none)'}</Typography>;
+const renderCommonDate = (date: string) =>
+ <Typography noWrap>{formatDate(date)}</Typography>;
-const renderNodeInfo = (item: { info: NodeInfo }) =>
- <Typography>
- {JSON.stringify(item.info, null, 4)}
- </Typography>;
+export const CommonUuid = withResourceData('uuid', renderCommonData);
-export const ResourceNodeInfo = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return resource || { info: {} };
- })(renderNodeInfo);
+// Api Client Authorizations
+export const TokenApiClientId = withResourceData('apiClientId', renderCommonData);
-export const ResourceNodeDomain = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return { property: resource ? resource.domain : '' };
- })((props: { property: string }) => renderNodeData(props.property));
+export const TokenApiToken = withResourceData('apiToken', renderCommonData);
-export const ResourceNodeFirstPingAt = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return { date: resource ? resource.firstPingAt : '' };
- })((props: { date: string }) => renderNodeDate(props.date));
+export const TokenCreatedByIpAddress = withResourceData('createdByIpAddress', renderCommonDate);
-export const ResourceNodeHostname = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return { property: resource ? resource.hostname : '' };
- })((props: { property: string }) => renderNodeData(props.property));
+export const TokenDefaultOwnerUuid = withResourceData('defaultOwnerUuid', renderCommonData);
-export const ResourceNodeIpAddress = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return { property: resource ? resource.ipAddress : '' };
- })((props: { property: string }) => renderNodeData(props.property));
+export const TokenExpiresAt = withResourceData('expiresAt', renderCommonDate);
-export const ResourceNodeJobUuid = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return { property: resource ? resource.jobUuid : '' };
- })((props: { property: string }) => renderNodeData(props.property));
+export const TokenLastUsedAt = withResourceData('lastUsedAt', renderCommonDate);
-export const ResourceNodeLastPingAt = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return { date: resource ? resource.lastPingAt : '' };
- })((props: { date: string }) => renderNodeDate(props.date));
+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 = withResourceData('info', renderNodeInfo);
+
+export const ComputeNodeDomain = withResourceData('domain', renderCommonData);
+
+export const ComputeNodeFirstPingAt = withResourceData('firstPingAt', renderCommonDate);
+
+export const ComputeNodeHostname = withResourceData('hostname', renderCommonData);
+
+export const ComputeNodeIpAddress = withResourceData('ipAddress', renderCommonData);
+
+export const ComputeNodeJobUuid = withResourceData('jobUuid', renderCommonData);
+
+export const ComputeNodeLastPingAt = withResourceData('lastPingAt', renderCommonDate);
// Links Resources
const renderLinkName = (item: { name: string }) =>