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}>
{renderIcon(item)}
</Grid>
<Grid item>
- <Typography color="primary" style={{ width: '450px' }}>
+ <Typography color="primary" style={{ width: 'auto' }}>
{item.name}
</Typography>
</Grid>
})(renderUsername);
// Compute Node Resources
-const renderNodeDate = (date?: string) =>
- <Typography noWrap>{formatDate(date) || '(none)'}</Typography>;
+const renderNodeDate = (date: string) =>
+ <Typography noWrap>{formatDate(date)}</Typography>;
-const renderNodeData = (property?: string) =>
- <Typography noWrap>{property || '(none)'}</Typography>;
+const renderNodeData = (data: string) => {
+ return <Typography noWrap>{data}</Typography>;
+};
-const renderNodeInfo = (item: { info: NodeInfo }) =>
- <Typography>
- {JSON.stringify(item.info, null, 4)}
- </Typography>;
+const renderNodeInfo = (data: string) => {
+ return <Typography>{JSON.stringify(data, null, 4)}</Typography>;
+};
-export const ResourceNodeInfo = connect(
- (state: RootState, props: { uuid: string }) => {
- const resource = getResource<NodeResource>(props.uuid)(state.resources);
- return resource || { info: {} };
- })(renderNodeInfo);
+export const ComputeNodeInfo = withResourceData('info', renderNodeInfo);
-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 ComputeNodeUuid = withResourceData('uuid', renderNodeData);
-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 ComputeNodeDomain = withResourceData('domain', renderNodeData);
-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 ComputeNodeFirstPingAt = withResourceData('firstPingAt', renderNodeDate);
-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 ComputeNodeHostname = withResourceData('hostname', renderNodeData);
-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 ComputeNodeIpAddress = withResourceData('ipAddress', renderNodeData);
-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 ComputeNodeJobUuid = withResourceData('jobUuid', renderNodeData);
+
+export const ComputeNodeLastPingAt = withResourceData('lastPingAt', renderNodeDate);
// Links Resources
const renderLinkName = (item: { name: string }) =>