-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
23 changed files
with
762 additions
and
385 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...ns/lens/public/datatable_visualization/components/__snapshots__/table_basic.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiSwitch, EuiFormRow } from '@elastic/eui'; | ||
import { VisualizationDimensionEditorProps } from '../../types'; | ||
import { DatatableVisualizationState } from '../visualization'; | ||
|
||
export function TableDimensionEditor( | ||
props: VisualizationDimensionEditorProps<DatatableVisualizationState> | ||
) { | ||
const { state, setState, accessor } = props; | ||
const column = state.columns.find((c) => c.columnId === accessor); | ||
|
||
const visibleColumnsCount = state.columns.filter((c) => !c.hidden).length; | ||
|
||
if (!column) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<EuiFormRow | ||
label={i18n.translate('xpack.lens.table.columnVisibilityLabel', { | ||
defaultMessage: 'Column hidden in table', | ||
})} | ||
display="columnCompressedSwitch" | ||
> | ||
<EuiSwitch | ||
compressed | ||
label={i18n.translate('xpack.lens.table.columnVisibilityLabel', { | ||
defaultMessage: 'Column hidden in table', | ||
})} | ||
showLabel={false} | ||
data-test-subj="lns-table-column-hidden" | ||
checked={Boolean(column?.hidden)} | ||
disabled={!column.hidden && visibleColumnsCount <= 1} | ||
onChange={() => { | ||
const newState = { | ||
...state, | ||
columns: state.columns.map((currentColumn) => { | ||
if (currentColumn.columnId === accessor) { | ||
return { | ||
...currentColumn, | ||
hidden: !column.hidden, | ||
}; | ||
} else { | ||
return currentColumn; | ||
} | ||
}), | ||
}; | ||
setState(newState); | ||
}} | ||
/> | ||
</EuiFormRow> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.