//
// SPDX-License-Identifier: AGPL-3.0
-export const FORMAT_DATE = (isoDate: string) => {
+export const formatDate = (isoDate: string) => {
const date = new Date(isoDate);
const text = date.toLocaleString();
return text === 'Invalid Date' ? "" : text;
};
-export const FORMAT_FILE_SIZE = (size?: number) => {
+export const formatFileSize = (size?: number) => {
if (typeof size === "number") {
for (const { base, unit } of FILE_SIZES) {
if (size >= base) {
import { ResourceKind } from "../models/resource";
-export const RESOURCE_LABEL = (type: string) => {
+export const resourceLabel = (type: string) => {
switch (type) {
case ResourceKind.Collection:
return "Data collection";
import * as React from 'react';
import { DetailsPanelResource } from '../../../views-components/details-panel/details-panel';
-import { IconType } from '../../icon/icon';
export default abstract class AbstractItem<T extends DetailsPanelResource = DetailsPanelResource> {
import Attribute from '../../attribute/attribute';
import AbstractItem from './abstract-item';
import { CollectionResource } from '../../../models/collection';
-import { FORMAT_DATE } from '../../../common/formatters';
-import { RESOURCE_LABEL } from '../../../common/labels';
+import { formatDate } from '../../../common/formatters';
+import { resourceLabel } from '../../../common/labels';
import { ResourceKind } from '../../../models/resource';
export default class CollectionItem extends AbstractItem<CollectionResource> {
buildDetails() {
return <div>
- <Attribute label='Type' value={RESOURCE_LABEL(ResourceKind.Collection)} />
+ <Attribute label='Type' value={resourceLabel(ResourceKind.Collection)} />
<Attribute label='Size' value='---' />
<Attribute label='Owner' value={this.item.ownerUuid} />
- <Attribute label='Last modified' value={FORMAT_DATE(this.item.modifiedAt)} />
- <Attribute label='Created at' value={FORMAT_DATE(this.item.createdAt)} />
+ <Attribute label='Last modified' value={formatDate(this.item.modifiedAt)} />
+ <Attribute label='Created at' value={formatDate(this.item.createdAt)} />
{/* Links but we dont have view */}
<Attribute label='Collection UUID' link={this.item.uuid} value={this.item.uuid} />
<Attribute label='Content address' link={this.item.portableDataHash} value={this.item.portableDataHash} />
import Attribute from '../../attribute/attribute';
import AbstractItem from './abstract-item';
import { ProcessResource } from '../../../models/process';
-import { FORMAT_DATE } from '../../../common/formatters';
+import { formatDate } from '../../../common/formatters';
import { ResourceKind } from '../../../models/resource';
-import { RESOURCE_LABEL } from '../../../common/labels';
+import { resourceLabel } from '../../../common/labels';
export default class ProcessItem extends AbstractItem<ProcessResource> {
buildDetails() {
return <div>
- <Attribute label='Type' value={RESOURCE_LABEL(ResourceKind.Process)} />
+ <Attribute label='Type' value={resourceLabel(ResourceKind.Process)} />
<Attribute label='Size' value='---' />
<Attribute label='Owner' value={this.item.ownerUuid} />
{/* Missing attr */}
<Attribute label='Status' value={this.item.state} />
- <Attribute label='Last modified' value={FORMAT_DATE(this.item.modifiedAt)} />
+ <Attribute label='Last modified' value={formatDate(this.item.modifiedAt)} />
{/* Missing attrs */}
- <Attribute label='Started at' value={FORMAT_DATE(this.item.createdAt)} />
- <Attribute label='Finished at' value={FORMAT_DATE(this.item.expiresAt)} />
+ <Attribute label='Started at' value={formatDate(this.item.createdAt)} />
+ <Attribute label='Finished at' value={formatDate(this.item.expiresAt)} />
{/* Links but we dont have view */}
<Attribute label='Outputs' link={this.item.outputPath} value={this.item.outputPath} />
import Attribute from '../../attribute/attribute';
import AbstractItem from './abstract-item';
import { ProjectResource } from '../../../models/project';
-import { FORMAT_DATE } from '../../../common/formatters';
+import { formatDate } from '../../../common/formatters';
import { ResourceKind } from '../../../models/resource';
-import { RESOURCE_LABEL } from '../../../common/labels';
+import { resourceLabel } from '../../../common/labels';
export default class ProjectItem extends AbstractItem<ProjectResource> {
buildDetails() {
return <div>
- <Attribute label='Type' value={RESOURCE_LABEL(ResourceKind.Project)} />
+ <Attribute label='Type' value={resourceLabel(ResourceKind.Project)} />
{/* Missing attr */}
<Attribute label='Size' value='---' />
<Attribute label='Owner' value={this.item.ownerUuid} />
- <Attribute label='Last modified' value={FORMAT_DATE(this.item.modifiedAt)} />
- <Attribute label='Created at' value={FORMAT_DATE(this.item.createdAt)} />
+ <Attribute label='Last modified' value={formatDate(this.item.modifiedAt)} />
+ <Attribute label='Created at' value={formatDate(this.item.createdAt)} />
{/* Missing attr */}
<Attribute label='File size' value='1.4 GB' />
<Attribute label='Description' value={this.item.description} />
import { Middleware } from "redux";
import actions from "../data-explorer/data-explorer-action";
-import { PROJECT_PANEL_ID, ProjectPanelFilter, COLUMNS, ProjectPanelColumnNames } from "../../views/project-panel/project-panel";
+import { PROJECT_PANEL_ID, ProjectPanelFilter, columns, ProjectPanelColumnNames } from "../../views/project-panel/project-panel";
import { groupsService } from "../../services/services";
import { RootState } from "../store";
import { getDataExplorer } from "../data-explorer/data-explorer-reducer";
import { SortDirection } from "../../components/data-table/data-column";
export const projectPanelMiddleware: Middleware = store => next => {
- next(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns: COLUMNS }));
+ next(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns }));
return action => {
import * as React from 'react';
import { ProjectPanelItem } from './project-panel-item';
import { Grid, Typography, Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
-import { FORMAT_DATE, FORMAT_FILE_SIZE } from '../../common/formatters';
+import { formatDate, formatFileSize } from '../../common/formatters';
import DataExplorer from "../../views-components/data-explorer/data-explorer";
import { DispatchProp, connect } from 'react-redux';
import { DataColumns } from '../../components/data-table/data-table';
import { ContainerRequestState } from '../../models/container-request';
import { SortDirection } from '../../components/data-table/data-column';
import { ResourceKind } from '../../models/resource';
-import { RESOURCE_LABEL } from '../../common/labels';
+import { resourceLabel } from '../../common/labels';
import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon } from '../../components/icon/icon';
import { ArvadosTheme } from '../../common/custom-theme';
}
};
-const RENDER_DATE = (date: string) => {
- return <Typography noWrap>{FORMAT_DATE(date)}</Typography>;
+const renderDate = (date: string) => {
+ return <Typography noWrap>{formatDate(date)}</Typography>;
};
-const RENDER_FILE_SIZE = (fileSize?: number) =>
+const renderFileSize = (fileSize?: number) =>
<Typography noWrap>
- {FORMAT_FILE_SIZE(fileSize)}
+ {formatFileSize(fileSize)}
</Typography>;
-const RENDER_OWNER = (owner: string) =>
+const renderOwner = (owner: string) =>
<Typography noWrap color="primary" >
{owner}
</Typography>;
-const RENDER_TYPE = (type: string) =>
+const renderType = (type: string) =>
<Typography noWrap>
- {RESOURCE_LABEL(type)}
+ {resourceLabel(type)}
</Typography>;
-const RENDER_STATUS = (item: ProjectPanelItem) =>
+const renderStatus = (item: ProjectPanelItem) =>
<Typography noWrap align="center" >
{item.status || "-"}
</Typography>;
}
-export const COLUMNS: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
+export const columns: DataColumns<ProjectPanelItem, ProjectPanelFilter> = [
{
name: ProjectPanelColumnNames.NAME,
selected: true,
type: ContainerRequestState.Uncommitted
}
],
- render: RENDER_STATUS,
+ render: renderStatus,
width: "75px"
},
{
selected: true,
filters: [
{
- name: RESOURCE_LABEL(ResourceKind.Collection),
+ name: resourceLabel(ResourceKind.Collection),
selected: true,
type: ResourceKind.Collection
},
{
- name: RESOURCE_LABEL(ResourceKind.Process),
+ name: resourceLabel(ResourceKind.Process),
selected: true,
type: ResourceKind.Process
},
{
- name: RESOURCE_LABEL(ResourceKind.Project),
+ name: resourceLabel(ResourceKind.Project),
selected: true,
type: ResourceKind.Project
}
],
- render: item => RENDER_TYPE(item.kind),
+ render: item => renderType(item.kind),
width: "125px"
},
{
name: ProjectPanelColumnNames.OWNER,
selected: true,
- render: item => RENDER_OWNER(item.owner),
+ render: item => renderOwner(item.owner),
width: "200px"
},
{
name: ProjectPanelColumnNames.FILE_SIZE,
selected: true,
- render: item => RENDER_FILE_SIZE(item.fileSize),
+ render: item => renderFileSize(item.fileSize),
width: "50px"
},
{
name: ProjectPanelColumnNames.LAST_MODIFIED,
selected: true,
sortDirection: SortDirection.None,
- render: item => RENDER_DATE(item.lastModified),
+ render: item => renderDate(item.lastModified),
width: "150px"
}
];