|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import { css, cx } from '@emotion/css'; |
|
|
|
|
import { cx } from '@emotion/css'; |
|
|
|
|
import React from 'react'; |
|
|
|
|
import SVG from 'react-inlinesvg'; |
|
|
|
|
|
|
|
|
@ -13,8 +13,6 @@ import { TableColumn } from './SearchResultsTable'; |
|
|
|
|
|
|
|
|
|
const TYPE_COLUMN_WIDTH = 250; |
|
|
|
|
const DATASOURCE_COLUMN_WIDTH = 200; |
|
|
|
|
const LOCATION_COLUMN_WIDTH = 200; |
|
|
|
|
const TAGS_COLUMN_WIDTH = 300; |
|
|
|
|
|
|
|
|
|
export const generateColumns = ( |
|
|
|
|
response: QueryResponse, |
|
|
|
@ -76,9 +74,14 @@ export const generateColumns = ( |
|
|
|
|
width = Math.max(availableWidth * 0.2, 300); |
|
|
|
|
columns.push({ |
|
|
|
|
Cell: (p) => { |
|
|
|
|
const name = access.name.values.get(p.row.index); |
|
|
|
|
let classNames = cx(p.cellStyle, styles.cellWrapper); |
|
|
|
|
let name = access.name.values.get(p.row.index); |
|
|
|
|
if (!name?.length) { |
|
|
|
|
name = 'Missing title'; // normal for panels
|
|
|
|
|
classNames += ' ' + styles.missingTitleText; |
|
|
|
|
} |
|
|
|
|
return ( |
|
|
|
|
<a {...p.cellProps} href={p.userProps.href} className={cx(p.cellStyle, styles.cellWrapper)}> |
|
|
|
|
<a {...p.cellProps} href={p.userProps.href} className={classNames} title={name}> |
|
|
|
|
{name} |
|
|
|
|
</a> |
|
|
|
|
); |
|
|
|
@ -110,22 +113,17 @@ export const generateColumns = ( |
|
|
|
|
availableWidth -= width; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
width = Math.max(availableWidth - TAGS_COLUMN_WIDTH, LOCATION_COLUMN_WIDTH); |
|
|
|
|
width = Math.max(availableWidth / 2.5, 200); |
|
|
|
|
columns.push(makeTagsColumn(access.tags, width, styles.tagList, onTagSelected)); |
|
|
|
|
availableWidth -= width; |
|
|
|
|
|
|
|
|
|
const meta = response.view.dataFrame.meta?.custom as SearchResultMeta; |
|
|
|
|
if (meta?.locationInfo) { |
|
|
|
|
if (meta?.locationInfo && availableWidth > 0) { |
|
|
|
|
columns.push({ |
|
|
|
|
Cell: (p) => { |
|
|
|
|
const parts = (access.location?.values.get(p.row.index) ?? '').split('/'); |
|
|
|
|
return ( |
|
|
|
|
<div |
|
|
|
|
{...p.cellProps} |
|
|
|
|
className={cx( |
|
|
|
|
p.cellStyle, |
|
|
|
|
css` |
|
|
|
|
padding-right: 10px; |
|
|
|
|
` |
|
|
|
|
)} |
|
|
|
|
> |
|
|
|
|
<div {...p.cellProps} className={cx(p.cellStyle, styles.locationCellStyle)}> |
|
|
|
|
{parts.map((p) => { |
|
|
|
|
const info = meta.locationInfo[p]; |
|
|
|
|
return info ? ( |
|
|
|
@ -142,13 +140,10 @@ export const generateColumns = ( |
|
|
|
|
id: `column-location`, |
|
|
|
|
field: access.location ?? access.url, |
|
|
|
|
Header: 'Location', |
|
|
|
|
width, |
|
|
|
|
width: availableWidth, |
|
|
|
|
}); |
|
|
|
|
availableWidth -= width; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
columns.push(makeTagsColumn(access.tags, availableWidth, styles.tagList, onTagSelected)); |
|
|
|
|
|
|
|
|
|
return columns; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|