Skip to content

Commit

Permalink
Remove sort, move, and remove buttons from Context app's table header (
Browse files Browse the repository at this point in the history
…elastic#42026)

Prior to elastic#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.
  • Loading branch information
Bargs committed Jul 26, 2019
1 parent 00db7ea commit 74ce0e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ interface Props {
hideTimeColumn: boolean;
indexPattern: IndexPatternEnhanced;
isShortDots: boolean;
onChangeSortOrder: (name: string, direction: 'asc' | 'desc') => void;
onMoveColumn: (name: string, index: number) => void;
onRemoveColumn: (name: string) => void;
onChangeSortOrder?: (name: string, direction: 'asc' | 'desc') => void;
onMoveColumn?: (name: string, index: number) => void;
onRemoveColumn?: (name: string) => void;
sortOrder: SortOrder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function TableHeaderColumn({
const buttons = [
// Sort Button
{
active: isSortable,
active: isSortable && typeof onChangeSortOrder === 'function',
ariaLabel:
sortDirection === 'asc'
? i18n.translate('kbn.docTable.tableHeader.sortByColumnDescendingAriaLabel', {
Expand Down Expand Up @@ -86,7 +86,7 @@ export function TableHeaderColumn({
},
// Remove Button
{
active: isRemoveable,
active: isRemoveable && typeof onRemoveColumn === 'function',
ariaLabel: i18n.translate('kbn.docTable.tableHeader.removeColumnButtonAriaLabel', {
defaultMessage: 'Remove {columnName} column',
values: { columnName: name },
Expand All @@ -100,7 +100,7 @@ export function TableHeaderColumn({
},
// Move Left Button
{
active: colLeftIdx >= 0,
active: colLeftIdx >= 0 && typeof onMoveColumn === 'function',
ariaLabel: i18n.translate('kbn.docTable.tableHeader.moveColumnLeftButtonAriaLabel', {
defaultMessage: 'Move {columnName} column to the left',
values: { columnName: name },
Expand All @@ -114,7 +114,7 @@ export function TableHeaderColumn({
},
// Move Right Button
{
active: colRightIdx >= 0,
active: colRightIdx >= 0 && typeof onMoveColumn === 'function',
ariaLabel: i18n.translate('kbn.docTable.tableHeader.moveColumnRightButtonAriaLabel', {
defaultMessage: 'Move {columnName} column to the right',
values: { columnName: name },
Expand Down

0 comments on commit 74ce0e7

Please sign in to comment.