Skip to content

Commit

Permalink
Rename CellButtons to CellActions
Browse files Browse the repository at this point in the history
- to be more specific and intentional about what we're referring to
  • Loading branch information
cee-chen committed Feb 2, 2022
1 parent d794a70 commit 123f45b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions src/components/datagrid/body/data_grid_cell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ describe('EuiDataGridCell', () => {
);
component.setState({ enableInteractions: true });

const getCellButtons = () => component.find('EuiDataGridCellButtons');
expect(getCellButtons()).toHaveLength(1);
const getCellActions = () => component.find('EuiDataGridCellActions');
expect(getCellActions()).toHaveLength(1);

// Should handle opening the popover
(getCellButtons().prop('onExpandClick') as Function)();
(getCellActions().prop('onExpandClick') as Function)();
expect(mockPopoverContext.openCellPopover).toHaveBeenCalled();

// Should handle closing the popover
component.setProps({
isExpandable: true,
popoverContext: { ...mockPopoverContext, popoverIsOpen: true },
});
(getCellButtons().prop('onExpandClick') as Function)();
(getCellActions().prop('onExpandClick') as Function)();
expect(mockPopoverContext.closeCellPopover).toHaveBeenCalledTimes(1);
(getCellButtons().prop('closePopover') as Function)();
(getCellActions().prop('closePopover') as Function)();
expect(mockPopoverContext.closeCellPopover).toHaveBeenCalledTimes(2);
});

Expand Down
18 changes: 9 additions & 9 deletions src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import {
EuiDataGridCellValueProps,
} from '../data_grid_types';
import {
EuiDataGridCellButtons,
EuiDataGridCellPopoverButtons,
} from './data_grid_cell_buttons';
EuiDataGridCellActions,
EuiDataGridCellPopoverActions,
} from './data_grid_cell_actions';
import { IS_JEST_ENVIRONMENT } from '../../../test';

const EuiDataGridCellContent: FunctionComponent<
Expand Down Expand Up @@ -465,7 +465,7 @@ export class EuiDataGridCell extends Component<
isDetails={true}
/>
</PopoverContent>
<EuiDataGridCellPopoverButtons
<EuiDataGridCellPopoverActions
rowIndex={rowIndex}
colIndex={colIndex}
column={column}
Expand Down Expand Up @@ -495,8 +495,8 @@ export class EuiDataGridCell extends Component<
const { rowIndex, visibleRowIndex, colIndex } = rest;

const popoverIsOpen = this.isPopoverOpen();
const hasCellButtons = isExpandable || column?.cellActions;
const showCellButtons =
const hasCellActions = isExpandable || column?.cellActions;
const showCellActions =
this.state.isFocused ||
this.state.isEntered ||
this.state.enableInteractions ||
Expand Down Expand Up @@ -626,14 +626,14 @@ export class EuiDataGridCell extends Component<
</EuiFocusTrap>
);

if (hasCellButtons) {
if (showCellButtons) {
if (hasCellActions) {
if (showCellActions) {
innerContent = (
<div className={anchorClass} ref={this.popoverAnchorRef}>
<div className={expandClass}>
<EuiDataGridCellContent {...cellContentProps} />
</div>
<EuiDataGridCellButtons
<EuiDataGridCellActions
rowIndex={rowIndex}
colIndex={colIndex}
column={column}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import React from 'react';
import { shallow } from 'enzyme';

import {
EuiDataGridCellButtons,
EuiDataGridCellPopoverButtons,
} from './data_grid_cell_buttons';
EuiDataGridCellActions,
EuiDataGridCellPopoverActions,
} from './data_grid_cell_actions';

describe('EuiDataGridCellButtons', () => {
describe('EuiDataGridCellActions', () => {
const requiredProps = {
popoverIsOpen: false,
closePopover: jest.fn(),
Expand All @@ -24,7 +24,7 @@ describe('EuiDataGridCellButtons', () => {
};

it('renders an expand button', () => {
const component = shallow(<EuiDataGridCellButtons {...requiredProps} />);
const component = shallow(<EuiDataGridCellActions {...requiredProps} />);

expect(component).toMatchInlineSnapshot(`
<div
Expand All @@ -33,7 +33,7 @@ describe('EuiDataGridCellButtons', () => {
<EuiI18n
default="Click or hit enter to interact with cell content"
key="expand"
token="euiDataGridCellButtons.expandButtonTitle"
token="euiDataGridCellActions.expandButtonTitle"
>
<Component />
</EuiI18n>
Expand All @@ -57,7 +57,7 @@ describe('EuiDataGridCellButtons', () => {

it('renders column cell actions as `EuiButtonIcon`s', () => {
const component = shallow(
<EuiDataGridCellButtons
<EuiDataGridCellActions
{...requiredProps}
column={{ id: 'someId', cellActions: [() => <button />] }}
/>
Expand All @@ -79,7 +79,7 @@ describe('EuiDataGridCellButtons', () => {
<EuiI18n
default="Click or hit enter to interact with cell content"
key="expand"
token="euiDataGridCellButtons.expandButtonTitle"
token="euiDataGridCellActions.expandButtonTitle"
>
<Component />
</EuiI18n>
Expand All @@ -98,10 +98,10 @@ describe('EuiDataGridCellButtons', () => {
});
});

describe('EuiDataGridCellPopoverButtons', () => {
describe('EuiDataGridCellPopoverActions', () => {
it('renders column cell actions as `EuiButtonEmpty`s', () => {
const component = shallow(
<EuiDataGridCellPopoverButtons
<EuiDataGridCellPopoverActions
colIndex={0}
rowIndex={0}
column={{ id: 'someId', cellActions: [() => <button />] }}
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('EuiDataGridCellPopoverButtons', () => {

it('does not render anything if the column has no cell actions', () => {
const component = shallow(
<EuiDataGridCellPopoverButtons
<EuiDataGridCellPopoverActions
colIndex={0}
rowIndex={0}
column={{ id: 'noActions' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { EuiButtonEmpty, EuiButtonEmptyProps } from '../../button/button_empty';
import { EuiFlexGroup, EuiFlexItem } from '../../flex';
import { EuiPopoverFooter } from '../../popover';

export const EuiDataGridCellButtons = ({
export const EuiDataGridCellActions = ({
popoverIsOpen,
closePopover,
onExpandClick,
Expand All @@ -44,7 +44,7 @@ export const EuiDataGridCellButtons = ({
const expandButton = (
<EuiI18n
key={'expand'}
token="euiDataGridCellButtons.expandButtonTitle"
token="euiDataGridCellActions.expandButtonTitle"
default="Click or hit enter to interact with cell content"
>
{(expandButtonTitle: string) => (
Expand Down Expand Up @@ -74,11 +74,11 @@ export const EuiDataGridCellButtons = ({
? column.cellActions.map(
(Action: EuiDataGridColumnCellAction, idx: number) => {
// React is more permissible than the TS types indicate
const CellButtonElement = Action as JSXElementConstructor<
const ActionButtonElement = Action as JSXElementConstructor<
EuiDataGridColumnCellActionProps
>;
return (
<CellButtonElement
<ActionButtonElement
key={idx}
rowIndex={rowIndex}
colIndex={colIndex}
Expand All @@ -98,7 +98,7 @@ export const EuiDataGridCellButtons = ({
);
};

export const EuiDataGridCellPopoverButtons = ({
export const EuiDataGridCellPopoverActions = ({
rowIndex,
colIndex,
column,
Expand All @@ -114,12 +114,12 @@ export const EuiDataGridCellPopoverButtons = ({
<EuiFlexGroup gutterSize="s">
{column.cellActions.map(
(Action: EuiDataGridColumnCellAction, idx: number) => {
const CellButtonElement = Action as JSXElementConstructor<
const ActionButtonElement = Action as JSXElementConstructor<
EuiDataGridColumnCellActionProps
>;
return (
<EuiFlexItem key={idx}>
<CellButtonElement
<ActionButtonElement
rowIndex={rowIndex}
colIndex={colIndex}
columnId={column.id}
Expand Down

0 comments on commit 123f45b

Please sign in to comment.