+enum UserAccountStatus {
+ ACTIVE = 'Active',
+ INACTIVE = 'Inactive',
+ SETUP = 'Setup',
+ UNKNOWN = ''
+}
+
+const renderAccountStatus = (props: { status: UserAccountStatus }) =>
+ <Grid container alignItems="center" wrap="nowrap" spacing={8} data-cy="account-status">
+ <Grid item>
+ {(() => {
+ switch (props.status) {
+ case UserAccountStatus.ACTIVE:
+ return <ActiveIcon style={{ color: '#4caf50', verticalAlign: "middle" }} />;
+ case UserAccountStatus.SETUP:
+ return <SetupIcon style={{ color: '#2196f3', verticalAlign: "middle" }} />;
+ case UserAccountStatus.INACTIVE:
+ return <InactiveIcon style={{ color: '#9e9e9e', verticalAlign: "middle" }} />;
+ default:
+ return <></>;
+ }
+ })()}
+ </Grid>
+ <Grid item>
+ <Typography noWrap>
+ {props.status}
+ </Typography>
+ </Grid>
+ </Grid>;
+
+const getUserAccountStatus = (state: RootState, props: { uuid: string }) => {
+ const user = getResource<UserResource>(props.uuid)(state.resources);
+ // Get membership links for all users group
+ const allUsersGroupUuid = getBuiltinGroupUuid(state.auth.localCluster, BuiltinGroups.ALL);
+ const permissions = filterResources((resource: LinkResource) =>
+ resource.kind === ResourceKind.LINK &&
+ resource.linkClass === LinkClass.PERMISSION &&
+ resource.headUuid === allUsersGroupUuid &&
+ resource.tailUuid === props.uuid
+ )(state.resources);
+
+ if (user) {
+ return user.isActive ? { status: UserAccountStatus.ACTIVE } : permissions.length > 0 ? { status: UserAccountStatus.SETUP } : { status: UserAccountStatus.INACTIVE };
+ } else {
+ return { status: UserAccountStatus.UNKNOWN };
+ }
+}
+
+export const ResourceLinkTailAccountStatus = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const link = getResource<LinkResource>(props.uuid)(state.resources);
+ return link && link.tailKind === ResourceKind.USER ? getUserAccountStatus(state, { uuid: link.tailUuid }) : { status: UserAccountStatus.UNKNOWN };
+ })(renderAccountStatus);
+
+export const UserResourceAccountStatus = connect(getUserAccountStatus)(renderAccountStatus);
+
+const renderIsHidden = (props: {
+ memberLinkUuid: string,
+ permissionLinkUuid: string,
+ visible: boolean,
+ canManage: boolean,
+ setMemberIsHidden: (memberLinkUuid: string, permissionLinkUuid: string, hide: boolean) => void
+}) => {
+ if (props.memberLinkUuid) {