mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add ability to hide KubeObjectMenu Edit and Remove buttons in extensions (#5107)
This commit is contained in:
1 parent
e532b90b72
commit
dbdde19222
51 files changed
+1245
-765
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { CatalogEntityContextMenu } from "../api/catalog-entity";
|
||||
import withConfirmationInjectable from "../components/confirm-dialog/with-confirm.injectable";
|
||||
|
||||
export interface NormalizedCatalogEntityContextMenu {
|
||||
title: string;
|
||||
icon?: string;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export type NormalizeCatalogEntityContextMenu = (menuItem: CatalogEntityContextMenu) => NormalizedCatalogEntityContextMenu;
|
||||
|
||||
const normalizeCatalogEntityContextMenuInjectable = getInjectable({
|
||||
id: "normalize-catalog-entity-context-menu",
|
||||
instantiate: (di): NormalizeCatalogEntityContextMenu => {
|
||||
const withConfirmation = di.inject(withConfirmationInjectable);
|
||||
|
||||
return (menuItem) => {
|
||||
if (menuItem.confirm) {
|
||||
return {
|
||||
title: menuItem.title,
|
||||
icon: menuItem.icon,
|
||||
onClick: withConfirmation({
|
||||
message: menuItem.confirm.message,
|
||||
ok: menuItem.onClick,
|
||||
okButtonProps: {
|
||||
primary: false,
|
||||
accent: true,
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
return menuItem;
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default normalizeCatalogEntityContextMenuInjectable;
|
||||
Reference in new issue
Block a user