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:
parent
3d06f8a765
commit
098cabe0e0
@ -124,6 +124,7 @@ export interface CatalogEntityContextMenu {
|
||||
|
||||
export interface CatalogEntityAddMenu extends CatalogEntityContextMenu {
|
||||
icon: string | React.ComponentType;
|
||||
defaultAction?: boolean;
|
||||
}
|
||||
|
||||
export interface CatalogEntitySettingsMenu {
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user