Skip to content

Commit 6bdeff1

Browse files
authored
Remove sort, move, and remove buttons from Context app's table header (#42026) (#42082)
Prior to #41259 we intentionally did not show the sort, move, and remove column buttons in the doc table in the Context app. Context doesn't pass in handlers for these actions and in the old angular directive we conditionally showed the buttons depending on whether those handlers were passed in. So in this PR I've simply mimicked that behavior in the new React component.
1 parent 7186619 commit 6bdeff1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/legacy/core_plugins/kibana/public/discover/doc_table/components/table_header/table_header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ interface Props {
2828
hideTimeColumn: boolean;
2929
indexPattern: IndexPatternEnhanced;
3030
isShortDots: boolean;
31-
onChangeSortOrder: (name: string, direction: 'asc' | 'desc') => void;
32-
onMoveColumn: (name: string, index: number) => void;
33-
onRemoveColumn: (name: string) => void;
31+
onChangeSortOrder?: (name: string, direction: 'asc' | 'desc') => void;
32+
onMoveColumn?: (name: string, index: number) => void;
33+
onRemoveColumn?: (name: string) => void;
3434
sortOrder: SortOrder;
3535
}
3636

src/legacy/core_plugins/kibana/public/discover/doc_table/components/table_header/table_header_column.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function TableHeaderColumn({
5656
const buttons = [
5757
// Sort Button
5858
{
59-
active: isSortable,
59+
active: isSortable && typeof onChangeSortOrder === 'function',
6060
ariaLabel:
6161
sortDirection === 'asc'
6262
? i18n.translate('kbn.docTable.tableHeader.sortByColumnDescendingAriaLabel', {
@@ -86,7 +86,7 @@ export function TableHeaderColumn({
8686
},
8787
// Remove Button
8888
{
89-
active: isRemoveable,
89+
active: isRemoveable && typeof onRemoveColumn === 'function',
9090
ariaLabel: i18n.translate('kbn.docTable.tableHeader.removeColumnButtonAriaLabel', {
9191
defaultMessage: 'Remove {columnName} column',
9292
values: { columnName: name },
@@ -100,7 +100,7 @@ export function TableHeaderColumn({
100100
},
101101
// Move Left Button
102102
{
103-
active: colLeftIdx >= 0,
103+
active: colLeftIdx >= 0 && typeof onMoveColumn === 'function',
104104
ariaLabel: i18n.translate('kbn.docTable.tableHeader.moveColumnLeftButtonAriaLabel', {
105105
defaultMessage: 'Move {columnName} column to the left',
106106
values: { columnName: name },
@@ -114,7 +114,7 @@ export function TableHeaderColumn({
114114
},
115115
// Move Right Button
116116
{
117-
active: colRightIdx >= 0,
117+
active: colRightIdx >= 0 && typeof onMoveColumn === 'function',
118118
ariaLabel: i18n.translate('kbn.docTable.tableHeader.moveColumnRightButtonAriaLabel', {
119119
defaultMessage: 'Move {columnName} column to the right',
120120
values: { columnName: name },

0 commit comments

Comments
 (0)