From a17b76ac75f506f5da6fe8adf9c36632b60d4226 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 26 Sep 2020 14:56:02 +0200 Subject: refactor to use app-rooted js imports --- frontend/common/table.component.js | 128 ------------------------------------- 1 file changed, 128 deletions(-) delete mode 100644 frontend/common/table.component.js (limited to 'frontend/common/table.component.js') diff --git a/frontend/common/table.component.js b/frontend/common/table.component.js deleted file mode 100644 index 8a74a79..0000000 --- a/frontend/common/table.component.js +++ /dev/null @@ -1,128 +0,0 @@ -import React from 'react' - -import { formatName } from '../util' - -const __HR__ = '__HR__' - -export function TableObject({ tag, object, order, summary }) { - if (!object) return null - if (object === 'loading') { - return
{tag}{': Loading'}
- } - if (object.err) { - return
{tag}{' Error: '}{object.err}
- } - let objects = Object.keys(object) - if (order) { - const grouped = objects.reduce((a, b) => { - const index = order.indexOf(b) - if (index !== -1) { - a.order.push([index, b]) - } else { - a.alpha.push(b) - } - return a - }, { order: [], alpha: [] }) - objects = grouped.order - .sort((a, b) => a[0] - b[0]) - .map(([i, s]) => s) - if (!summary) { - objects = objects - // .concat([__HR__]) - .concat(grouped.alpha.sort()) - } - } else { - objects = objects.sort() - } - return ( -
- {tag &&

{tag}

} - - - {objects.map((key, i) => ( - - ))} - -
-
- ) -} - -export function TableArray({ tag, list }) { - if (!list) return null - return ( -
- {tag &&

{tag}

} - - - {list.map((value, i) => ( - - - - ))} - -
-
- ) -} - -export function TableTuples({ tag, list }) { - if (!list) return null - return ( -
- {tag &&

{tag}

} - - - {list.map(([key, ...values], i) => ( - - - {values.map((value, j) => ( - - ))} - - ))} - -
{formatName(key)}
-
- ) -} - -export function TableRow({ name, value }) { - if (name === __HR__) { - return ( - - -
- - - ) - } - return ( - - {formatName(name)} - - - ) -} - -export function TableCell({ value }) { - if (value && typeof value === 'object') { - if (value._raw) { - value = value.value - } else if (value.length) { - value = - } else { - value = - } - } - if (typeof value === 'boolean') { - return {value ? : } - } - return ( - {value} - ) -} - -export const Pill = ({ color, type }) => ( -
{type}
-) \ No newline at end of file -- cgit v1.2.3-70-g09d2