// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
-import { Grid, Typography, withStyles, Tooltip, IconButton } from '@material-ui/core';
+import { Grid, Typography, withStyles, Tooltip, IconButton, Checkbox } from '@material-ui/core';
import { FavoriteStar } from '../favorite-star/favorite-star';
import { ResourceKind, TrashableResource } from '~/models/resource';
import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, WorkflowIcon, ShareIcon } from '~/components/icon/icon';
import { getUuidPrefix, openRunProcess } from '~/store/workflow-panel/workflow-panel-actions';
import { getResourceData } from "~/store/resources-data/resources-data";
import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions';
+import { UserResource } from '~/models/user';
-export const renderName = (item: { name: string; uuid: string, kind: string }) =>
+const renderName = (item: { name: string; uuid: string, kind: string }) =>
<Grid container alignItems="center" wrap="nowrap" spacing={16}>
<Grid item>
{renderIcon(item)}
return resource || { name: '', uuid: '', kind: '' };
})(renderName);
-export const renderIcon = (item: { kind: string }) => {
+const renderIcon = (item: { kind: string }) => {
switch (item.kind) {
case ResourceKind.PROJECT:
return <ProjectIcon />;
}
};
-export const renderDate = (date?: string) => {
+const renderDate = (date?: string) => {
return <Typography noWrap style={{ minWidth: '100px' }}>{formatDate(date)}</Typography>;
};
-export const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ownerUuid: string }) =>
+const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ownerUuid: string }) =>
<Grid container alignItems="center" wrap="nowrap" spacing={16}>
<Grid item>
{renderIcon(item)}
return `${uuidPrefix}-tpzed-anonymouspublic`;
};
-export const resourceShare = (dispatch: Dispatch, uuidPrefix: string, ownerUuid?: string, uuid?: string) => {
+const resourceShare = (dispatch: Dispatch, uuidPrefix: string, ownerUuid?: string, uuid?: string) => {
const isPublic = ownerUuid === getPublicUuid(uuidPrefix);
return (
<div>
})((props: { ownerUuid?: string, uuidPrefix: string, uuid?: string } & DispatchProp<any>) =>
resourceShare(props.dispatch, props.uuidPrefix, props.ownerUuid, props.uuid));
-export const resourceRunProcess = (dispatch: Dispatch, uuid: string) => {
+const renderFirstName = (item: { firstName: string }) => {
+ return <Typography noWrap>{item.firstName}</Typography>;
+};
+
+export const ResourceFirstName = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<UserResource>(props.uuid)(state.resources);
+ return resource || { firstName: '' };
+ })(renderFirstName);
+
+const renderLastName = (item: { lastName: string }) =>
+ <Typography noWrap>{item.lastName}</Typography>;
+
+export const ResourceLastName = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<UserResource>(props.uuid)(state.resources);
+ return resource || { lastName: '' };
+ })(renderLastName);
+
+const renderUuid = (item: { uuid: string }) =>
+ <Typography noWrap>{item.uuid}</Typography>;
+
+export const ResourceUuid = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<UserResource>(props.uuid)(state.resources);
+ return resource || { uuid: '' };
+ })(renderUuid);
+
+const renderEmail = (item: { email: string }) =>
+ <Typography noWrap>{item.email}</Typography>;
+
+export const ResourceEmail = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<UserResource>(props.uuid)(state.resources);
+ return resource || { email: '' };
+ })(renderEmail);
+
+const renderIsActive = (item: { isActive: boolean }) =>
+ <Checkbox
+ disableRipple
+ color="primary"
+ checked={item.isActive} />;
+
+export const ResourceIsActive = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<UserResource>(props.uuid)(state.resources);
+ return resource || { isActive: false };
+ })(renderIsActive);
+
+const renderIsAdmin = (item: { isAdmin: boolean }) =>
+ <Checkbox
+ disableRipple
+ color="primary"
+ checked={item.isAdmin} />;
+
+export const ResourceIsAdmin = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<UserResource>(props.uuid)(state.resources);
+ return resource || { isAdmin: false };
+ })(renderIsAdmin);
+
+const renderUsername = (item: { username: string }) =>
+ <Typography noWrap>{item.username}</Typography>;
+
+export const ResourceUsername = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<UserResource>(props.uuid)(state.resources);
+ return resource || { username: '' };
+ })(renderUsername);
+
+const resourceRunProcess = (dispatch: Dispatch, uuid: string) => {
return (
<div>
{uuid &&
})((props: { uuid: string } & DispatchProp<any>) =>
resourceRunProcess(props.dispatch, props.uuid));
-export const renderWorkflowStatus = (uuidPrefix: string, ownerUuid?: string) => {
+const renderWorkflowStatus = (uuidPrefix: string, ownerUuid?: string) => {
if (ownerUuid === getPublicUuid(uuidPrefix)) {
return renderStatus(ResourceStatus.PUBLIC);
} else {
return { fileSize: resource ? resource.fileSize : 0 };
})((props: { fileSize?: number }) => renderFileSize(props.fileSize));
-export const renderOwner = (owner: string) =>
+const renderOwner = (owner: string) =>
<Typography noWrap color="primary" >
{owner}
</Typography>;
return { owner: resource ? resource.ownerUuid : '' };
})((props: { owner: string }) => renderOwner(props.owner));
-export const renderType = (type: string) =>
+const renderType = (type: string) =>
<Typography noWrap>
{resourceLabel(type)}
</Typography>;