import { PermissionLevel } from 'models/permission';
import { openPermissionEditContextMenu } from 'store/context-menu/context-menu-actions';
import { getUserUuid } from 'common/getuser';
+import { VirtualMachinesResource } from 'models/virtual-machines';
const renderName = (dispatch: Dispatch, item: GroupContentsResource) => {
color="primary"
checked={props.isActive}
disabled={!!props.disabled}
- onClick={() => props.toggleIsActive(props.uuid)} />;
+ onClick={(e) => {
+ e.stopPropagation();
+ props.toggleIsActive(props.uuid)
+ }} />;
} else {
return <Typography />;
}
permissionLinkUuid: string,
visible: boolean,
canManage: boolean,
- setMemberIsHidden: (memberLinkUuid: string, permissionLinkUuid: string, hide: boolean) => void
+ setMemberIsHidden: (memberLinkUuid: string, permissionLinkUuid: string, hide: boolean) => void
}) => {
if (props.memberLinkUuid) {
return <Checkbox
color="primary"
checked={props.visible}
disabled={!props.canManage}
- onClick={() => props.setMemberIsHidden(props.memberLinkUuid, props.permissionLinkUuid, !props.visible)} />;
+ onClick={(e) => {
+ e.stopPropagation();
+ props.setMemberIsHidden(props.memberLinkUuid, props.permissionLinkUuid, !props.visible);
+ }} />;
} else {
return <Typography />;
}
<Checkbox
color="primary"
checked={props.isAdmin}
- onClick={() => props.toggleIsAdmin(props.uuid)} />;
+ onClick={(e) => {
+ e.stopPropagation();
+ props.toggleIsAdmin(props.uuid);
+ }} />;
export const ResourceIsAdmin = connect(
(state: RootState, props: { uuid: string }) => {
}, { toggleIsAdmin }
)(renderIsAdmin);
-const renderUsername = (item: { username: string }) =>
- <Typography noWrap>{item.username}</Typography>;
+const renderUsername = (item: { username: string, uuid: string }) =>
+ <Typography noWrap>{item.username || item.uuid}</Typography>;
export const ResourceUsername = connect(
(state: RootState, props: { uuid: string }) => {
const resource = getResource<UserResource>(props.uuid)(state.resources);
- return resource || { username: '' };
+ return resource || { username: '', uuid: props.uuid };
})(renderUsername);
+// Virtual machine resource
+
+const renderHostname = (item: { hostname: string }) =>
+ <Typography noWrap>{item.hostname}</Typography>;
+
+export const VirtualMachineHostname = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<VirtualMachinesResource>(props.uuid)(state.resources);
+ return resource || { hostname: '' };
+ })(renderHostname);
+
+const renderVirtualMachineLogin = (login: {user: string}) =>
+ <Typography noWrap>{login.user}</Typography>
+
+export const VirtualMachineLogin = connect(
+ (state: RootState, props: { linkUuid: string }) => {
+ const permission = getResource<LinkResource>(props.linkUuid)(state.resources);
+ const user = getResource<UserResource>(permission?.tailUuid || '')(state.resources);
+
+ return {user: user?.username || permission?.tailUuid || ''};
+ })(renderVirtualMachineLogin);
+
// Common methods
const renderCommonData = (data: string) =>
<Typography noWrap>{data}</Typography>;
export const ResourceCluster = (props: { uuid: string }) => {
const CLUSTER_ID_LENGTH = 5;
const pos = props.uuid.length > CLUSTER_ID_LENGTH ? props.uuid.indexOf('-') : 5;
- const clusterId = pos >= CLUSTER_ID_LENGTH ? props.uuid.substr(0, pos) : '';
+ const clusterId = pos >= CLUSTER_ID_LENGTH ? props.uuid.substring(0, pos) : '';
const ci = pos >= CLUSTER_ID_LENGTH ? (((((
(props.uuid.charCodeAt(0) * props.uuid.charCodeAt(1))
+ props.uuid.charCodeAt(2))