mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add triggerOnRunAfterOnClickDetailIcon
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
5 files changed
+50
-2
No files matched your search
@@ -75,7 +75,9 @@ export function syncWeblinks() {
|
||||
uid: weblinkData.id,
|
||||
name: weblinkData.name,
|
||||
source: "local",
|
||||
labels: {}
|
||||
labels: {
|
||||
triggerOnRunAfterOnClickDetailIcon: "true",
|
||||
}
|
||||
},
|
||||
spec: {
|
||||
url: weblinkData.url
|
||||
|
||||
@@ -261,6 +261,7 @@ export function catalogEntityFromCluster(cluster: Cluster) {
|
||||
name: cluster.name,
|
||||
source: "local",
|
||||
labels: {
|
||||
triggerOnRunAfterOnClickDetailIcon: "true",
|
||||
...cluster.labels,
|
||||
},
|
||||
distro: cluster.distribution,
|
||||
|
||||
@@ -108,5 +108,46 @@ describe("<CatalogEntityDetails />", () => {
|
||||
expect(onRun).toHaveBeenCalledTimes(0);
|
||||
expect(onClickDetailIcon).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
|
||||
it("prioritize onClickDetailIcon over onRun, but always trigger onRun if triggerOnRunAfterOnClickDetailIcon='true'", () => {
|
||||
const onRun = jest.fn();
|
||||
const onClickDetailIcon = jest.fn();
|
||||
|
||||
const item = new CatalogEntityItem({
|
||||
enabled: true,
|
||||
apiVersion: "",
|
||||
kind: "",
|
||||
metadata: {
|
||||
uid: "",
|
||||
name: "",
|
||||
labels: {
|
||||
triggerOnRunAfterOnClickDetailIcon: "true",
|
||||
},
|
||||
},
|
||||
status: {
|
||||
phase: "",
|
||||
},
|
||||
spec: { },
|
||||
getId: () => "",
|
||||
getName: () => "",
|
||||
onContextMenuOpen: () => {},
|
||||
onSettingsOpen: () => {},
|
||||
onRun,
|
||||
onClickDetailIcon,
|
||||
});
|
||||
|
||||
render(
|
||||
<CatalogEntityDetails
|
||||
item={item}
|
||||
hideDetails={() => {}}
|
||||
/>
|
||||
);
|
||||
|
||||
userEvent.click(screen.getByTestId("detail-panel-hot-bar-icon"));
|
||||
|
||||
expect(onClickDetailIcon).toHaveBeenCalledTimes(1);
|
||||
expect(onRun).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -74,6 +74,10 @@ export class CatalogEntityDetails<T extends CatalogEntity> extends Component<Pro
|
||||
} else {
|
||||
item.onRun(catalogEntityRunContext);
|
||||
}
|
||||
|
||||
if (typeof item.entity.onClickDetailIcon === "function" && Boolean(item.entity.metadata?.labels?.triggerOnRunAfterOnClickDetailIcon)) {
|
||||
item.onRun(catalogEntityRunContext);
|
||||
}
|
||||
}}
|
||||
size={128}
|
||||
data-testid="detail-panel-hot-bar-icon"
|
||||
|
||||
@@ -30,7 +30,7 @@ import { MenuItem } from "../menu";
|
||||
import { ConfirmDialog } from "../confirm-dialog";
|
||||
import { HotbarStore } from "../../../common/hotbar-store";
|
||||
import { Icon } from "../icon";
|
||||
import type { CatalogEntityItem } from "./catalog-entity.store";
|
||||
import type { CatalogEntityItem } from "./catalog-entity-item";
|
||||
|
||||
export interface CatalogEntityDrawerMenuProps<T extends CatalogEntity> extends MenuActionsProps {
|
||||
item: CatalogEntityItem<T> | null | undefined;
|
||||
|
||||
Reference in new issue
Block a user