+export const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ownerUuid: string }) =>
+ <Grid container alignItems="center" wrap="nowrap" spacing={16}>
+ <Grid item>
+ {renderIcon(item)}
+ </Grid>
+ <Grid item>
+ <Typography color="primary" style={{ width: '100px' }}>
+ {item.name}
+ </Typography>
+ </Grid>
+ </Grid>;
+
+export const RosurceWorkflowName = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<WorkflowResource>(props.uuid)(state.resources);
+ return resource || { name: '', uuid: '', kind: '', ownerUuid: '' };
+ })(renderWorkflowName);
+
+const getPublicUuid = (uuidPrefix: string) => {
+ return `${uuidPrefix}-tpzed-anonymouspublic`;
+};
+
+// ToDo: share onClick
+export const resourceShare = (dispatch: Dispatch, uuidPrefix: string, ownerUuid?: string, uuid?: string) => {
+ const isPublic = ownerUuid === getPublicUuid(uuidPrefix);
+ return (
+ <div>
+ { isPublic && uuid &&
+ <Tooltip title="Share">
+ <IconButton onClick={() => dispatch<any>(openSharingDialog(uuid))}>
+ <ShareIcon />
+ </IconButton>
+ </Tooltip>
+ }
+ </div>
+ );
+};
+
+export const ResourceShare = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<WorkflowResource>(props.uuid)(state.resources);
+ const uuidPrefix = getUuidPrefix(state);
+ return {
+ uuid: resource ? resource.uuid : '',
+ ownerUuid: resource ? resource.ownerUuid : '',
+ uuidPrefix
+ };
+ })((props: { ownerUuid?: string, uuidPrefix: string, uuid?: string } & DispatchProp<any>) =>
+ resourceShare(props.dispatch, props.uuidPrefix, props.ownerUuid, props.uuid));
+
+export const renderWorkflowStatus = (uuidPrefix: string, ownerUuid?: string) => {
+ if (ownerUuid === getPublicUuid(uuidPrefix)) {
+ return renderStatus(ResourceStatus.PUBLIC);
+ } else {
+ return renderStatus(ResourceStatus.PRIVATE);
+ }
+};
+
+const renderStatus = (status: string) =>
+ <Typography noWrap style={{ width: '60px' }}>{status}</Typography>;
+
+export const ResourceWorkflowStatus = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<WorkflowResource>(props.uuid)(state.resources);
+ const uuidPrefix = getUuidPrefix(state);
+ return {
+ ownerUuid: resource ? resource.ownerUuid : '',
+ uuidPrefix
+ };
+ })((props: { ownerUuid?: string, uuidPrefix: string }) => renderWorkflowStatus(props.uuidPrefix, props.ownerUuid));
+
+export const ResourceLastModifiedDate = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
+ return { date: resource ? resource.modifiedAt : '' };
+ })((props: { date: string }) => renderDate(props.date));
+
+export const ResourceTrashDate = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<TrashableResource>(props.uuid)(state.resources);
+ return { date: resource ? resource.trashAt : '' };
+ })((props: { date: string }) => renderDate(props.date));
+
+export const ResourceDeleteDate = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<TrashableResource>(props.uuid)(state.resources);
+ return { date: resource ? resource.deleteAt : '' };
+ })((props: { date: string }) => renderDate(props.date));
+