Skip to content

Commit

Permalink
custom kebab children, custom table data
Browse files Browse the repository at this point in the history
  • Loading branch information
priley86 committed May 7, 2019
1 parent a6a8954 commit 482c381
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/public/components/deployment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const DeploymentTableRow = (o) => {
};
};

const DeploymentTableRows = componentProps =>
const DeploymentTableRows = ({componentProps}) =>
_.map(componentProps.data, obj => obj && obj.metadata && DeploymentTableRow(obj));

const DeploymentTableHeader = props => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/public/components/factory/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ export const Table = connect(stateToProps, {sortList: UIActions.sortList})(
}

render() {
const {Rows, label, mock, onSelect, selectedResourcesForKind, 'aria-label': ariaLabel, virtualize} = this.props;
const {Rows, label, mock, onSelect, selectedResourcesForKind, 'aria-label': ariaLabel, virtualize, customData} = this.props;
const {sortBy, columns} = this.state;
const componentProps: any = _.pick(this.props, ['data', 'filters', 'selected', 'match', 'kindObj']);
const rows = Rows(componentProps, selectedResourcesForKind);
const rows = Rows({componentProps, selectedResourcesForKind, customData});

let children = null;
if (rows){
Expand Down Expand Up @@ -436,6 +436,7 @@ export type TableInnerProps = {
onSelect?: (event: React.MouseEvent, isSelected: boolean, rowIndex: number, rowData: IRowData, extraData: IExtraData) => void;
staticFilters?: any[];
virtualize?: boolean;
customData?: any;
};

export type TableInnerState = {
Expand Down
8 changes: 6 additions & 2 deletions frontend/public/components/utils/kebab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ export class Kebab extends React.Component<KebabProps, KebabState> {

render() {
const { isOpen } = this.state;
const { options, isDisabled, position, id } = this.props;
const { options, isDisabled, position, id, children } = this.props;

const items = [];
let items = [];
if (options && options.length){
options.forEach((option) => {
items.push(
Expand All @@ -141,6 +141,9 @@ export class Kebab extends React.Component<KebabProps, KebabState> {
</DropdownItem>
);
});
} else {
//default to children if no options are passed, allowing custom jsx for items
items = children;
}

return (
Expand All @@ -167,6 +170,7 @@ export type KebabProps = {
isDisabled?: boolean;
options: KebabOption[];
position?: OneOf<typeof DropdownPosition, keyof typeof DropdownPosition>;
children?: React.ReactNode[];
};

export type KebabState = {
Expand Down

0 comments on commit 482c381

Please sign in to comment.