Transformations: Organise fields transformer fixes & detailing (#23812)

* Transformers: Organise fields transformer detailing

* Table header cell - fix text overflowing columns
This commit is contained in:
Dominik Prokop
2020-04-23 16:21:54 +02:00
committed by GitHub
parent ebdbb0c96d
commit e0dbd87a5a
3 changed files with 22 additions and 4 deletions
@@ -181,7 +181,7 @@ function renderHeaderCell(column: any, tableStyles: TableStyles, field?: Field)
return ( return (
<div className={tableStyles.headerCell} {...headerProps}> <div className={tableStyles.headerCell} {...headerProps}>
{column.canSort && ( {column.canSort && (
<div {...column.getSortByToggleProps()}> <div {...column.getSortByToggleProps()} className={tableStyles.headerCellLabel} title={column.render('Header')}>
{column.render('Header')} {column.render('Header')}
{column.isSorted && (column.isSortedDesc ? <Icon name="angle-down" /> : <Icon name="angle-up" />)} {column.isSorted && (column.isSortedDesc ? <Icon name="angle-down" /> : <Icon name="angle-up" />)}
</div> </div>
@@ -10,6 +10,7 @@ export interface TableStyles {
table: string; table: string;
thead: string; thead: string;
headerCell: string; headerCell: string;
headerCellLabel: string;
tableCell: string; tableCell: string;
tableCellWrapper: string; tableCellWrapper: string;
tableCellLink: string; tableCellLink: string;
@@ -53,7 +54,6 @@ export const getTableStyles = stylesFactory(
headerCell: css` headerCell: css`
padding: ${padding}px 10px; padding: ${padding}px 10px;
cursor: pointer; cursor: pointer;
white-space: nowrap;
color: ${colors.textBlue}; color: ${colors.textBlue};
border-right: 1px solid ${theme.colors.panelBg}; border-right: 1px solid ${theme.colors.panelBg};
@@ -61,6 +61,11 @@ export const getTableStyles = stylesFactory(
border-right: none; border-right: none;
} }
`, `,
headerCellLabel: css`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`,
row: css` row: css`
label: row; label: row;
border-bottom: 1px solid ${borderColor}; border-bottom: 1px solid ${borderColor};
@@ -80,6 +80,7 @@ const OrganizeFieldsTransformerEditor: React.FC<OrganizeFieldsTransformerEditorP
return ( return (
<DraggableFieldName <DraggableFieldName
fieldName={fieldName} fieldName={fieldName}
renamedFieldName={renameByName[fieldName]}
index={index} index={index}
onToggleVisibility={onToggleVisibility} onToggleVisibility={onToggleVisibility}
onRenameField={onRenameField} onRenameField={onRenameField}
@@ -96,8 +97,11 @@ const OrganizeFieldsTransformerEditor: React.FC<OrganizeFieldsTransformerEditorP
); );
}; };
OrganizeFieldsTransformerEditor.displayName = 'OrganizeFieldsTransformerEditor';
interface DraggableFieldProps { interface DraggableFieldProps {
fieldName: string; fieldName: string;
renamedFieldName?: string;
index: number; index: number;
visible: boolean; visible: boolean;
onToggleVisibility: (fieldName: string, isVisible: boolean) => void; onToggleVisibility: (fieldName: string, isVisible: boolean) => void;
@@ -106,6 +110,7 @@ interface DraggableFieldProps {
const DraggableFieldName: React.FC<DraggableFieldProps> = ({ const DraggableFieldName: React.FC<DraggableFieldProps> = ({
fieldName, fieldName,
renamedFieldName,
index, index,
visible, visible,
onToggleVisibility, onToggleVisibility,
@@ -133,12 +138,15 @@ const DraggableFieldName: React.FC<DraggableFieldProps> = ({
surface="header" surface="header"
onClick={() => onToggleVisibility(fieldName, visible)} onClick={() => onToggleVisibility(fieldName, visible)}
/> />
<span className={styles.name}>{fieldName}</span> <span className={styles.name} title={fieldName}>
{fieldName}
</span>
</div> </div>
<Input <Input
className="flex-grow-1" className="flex-grow-1"
defaultValue={renamedFieldName || ''}
placeholder={`Rename ${fieldName}`} placeholder={`Rename ${fieldName}`}
onChange={event => onRenameField(fieldName, event.currentTarget.value)} onBlur={event => onRenameField(fieldName, event.currentTarget.value)}
/> />
</div> </div>
</div> </div>
@@ -147,6 +155,8 @@ const DraggableFieldName: React.FC<DraggableFieldProps> = ({
); );
}; };
DraggableFieldName.displayName = 'DraggableFieldName';
const getFieldNameStyles = stylesFactory((theme: GrafanaTheme) => ({ const getFieldNameStyles = stylesFactory((theme: GrafanaTheme) => ({
toggle: css` toggle: css`
margin: 0 8px; margin: 0 8px;
@@ -161,6 +171,9 @@ const getFieldNameStyles = stylesFactory((theme: GrafanaTheme) => ({
} }
`, `,
name: css` name: css`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: ${theme.typography.size.sm}; font-size: ${theme.typography.size.sm};
font-weight: ${theme.typography.weight.semibold}; font-weight: ${theme.typography.weight.semibold};
`, `,