mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Add route, clusterRoute, and payloadValidatedClusterRoute helper functions to improve types with backend routes - Turn on the following new lints: - react/jsx-first-prop-new-line - react/jsx-wrap-multilines - react/jsx-one-expression-per-line - react/jsx-max-props-per-line - react/jsx-indent - react/jsx-indent-props Signed-off-by: Sebastian Malton <sebastian@malton.name>
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import "./add-remove-buttons.scss";
|
|
|
|
import React from "react";
|
|
import { cssNames } from "../../utils";
|
|
import { Button } from "../button";
|
|
import { Icon } from "../icon";
|
|
|
|
export interface AddRemoveButtonsProps extends React.HTMLAttributes<any> {
|
|
onAdd?: () => void;
|
|
onRemove?: () => void;
|
|
addTooltip?: React.ReactNode;
|
|
removeTooltip?: React.ReactNode;
|
|
}
|
|
|
|
export class AddRemoveButtons extends React.PureComponent<AddRemoveButtonsProps> {
|
|
renderButtons() {
|
|
const { onRemove, onAdd, addTooltip, removeTooltip } = this.props;
|
|
|
|
return [
|
|
{
|
|
onClick: onRemove,
|
|
className: "remove-button",
|
|
icon: "remove",
|
|
tooltip: removeTooltip,
|
|
},
|
|
{
|
|
onClick: onAdd,
|
|
className: "add-button",
|
|
icon: "add",
|
|
tooltip: addTooltip,
|
|
},
|
|
]
|
|
.filter(button => button.onClick)
|
|
.map(({ icon, ...props }) => (
|
|
<Button
|
|
key={icon}
|
|
big
|
|
round
|
|
primary
|
|
{...props}
|
|
>
|
|
<Icon material={icon} />
|
|
</Button>
|
|
));
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className={cssNames("AddRemoveButtons flex gaps", this.props.className)}>
|
|
{this.renderButtons()}
|
|
</div>
|
|
);
|
|
}
|
|
}
|