1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add defaultAction prop to AddButton items

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-08-04 11:36:26 +03:00
parent 3d06f8a765
commit 098cabe0e0
2 changed files with 5 additions and 3 deletions

View File

@ -124,6 +124,7 @@ export interface CatalogEntityContextMenu {
export interface CatalogEntityAddMenu extends CatalogEntityContextMenu {
icon: string | React.ComponentType;
defaultAction?: boolean;
}
export interface CatalogEntitySettingsMenu {

View File

@ -73,9 +73,10 @@ export class CatalogAddButton extends React.Component<CatalogAddButtonProps> {
@boundMethod
onButtonClick() {
if (this.menuItems.length == 1) {
this.menuItems[0].onClick();
}
const defaultAction = this.menuItems.find(item => item.defaultAction)?.onClick;
const clickAction = defaultAction || this.menuItems.length == 1 ? this.menuItems[0].onClick : null;
clickAction?.();
}
render() {