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:
parent
b9c485d0af
commit
aed5760ba0
@ -75,7 +75,9 @@ export function syncWeblinks() {
|
|||||||
uid: weblinkData.id,
|
uid: weblinkData.id,
|
||||||
name: weblinkData.name,
|
name: weblinkData.name,
|
||||||
source: "local",
|
source: "local",
|
||||||
labels: {}
|
labels: {
|
||||||
|
triggerOnRunAfterOnClickDetailIcon: "true",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
spec: {
|
spec: {
|
||||||
url: weblinkData.url
|
url: weblinkData.url
|
||||||
|
|||||||
@ -261,6 +261,7 @@ export function catalogEntityFromCluster(cluster: Cluster) {
|
|||||||
name: cluster.name,
|
name: cluster.name,
|
||||||
source: "local",
|
source: "local",
|
||||||
labels: {
|
labels: {
|
||||||
|
triggerOnRunAfterOnClickDetailIcon: "true",
|
||||||
...cluster.labels,
|
...cluster.labels,
|
||||||
},
|
},
|
||||||
distro: cluster.distribution,
|
distro: cluster.distribution,
|
||||||
|
|||||||
@ -108,5 +108,46 @@ describe("<CatalogEntityDetails />", () => {
|
|||||||
expect(onRun).toHaveBeenCalledTimes(0);
|
expect(onRun).toHaveBeenCalledTimes(0);
|
||||||
expect(onClickDetailIcon).toHaveBeenCalledTimes(1);
|
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 {
|
} else {
|
||||||
item.onRun(catalogEntityRunContext);
|
item.onRun(catalogEntityRunContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof item.entity.onClickDetailIcon === "function" && Boolean(item.entity.metadata?.labels?.triggerOnRunAfterOnClickDetailIcon)) {
|
||||||
|
item.onRun(catalogEntityRunContext);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
size={128}
|
size={128}
|
||||||
data-testid="detail-panel-hot-bar-icon"
|
data-testid="detail-panel-hot-bar-icon"
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import { MenuItem } from "../menu";
|
|||||||
import { ConfirmDialog } from "../confirm-dialog";
|
import { ConfirmDialog } from "../confirm-dialog";
|
||||||
import { HotbarStore } from "../../../common/hotbar-store";
|
import { HotbarStore } from "../../../common/hotbar-store";
|
||||||
import { Icon } from "../icon";
|
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 {
|
export interface CatalogEntityDrawerMenuProps<T extends CatalogEntity> extends MenuActionsProps {
|
||||||
item: CatalogEntityItem<T> | null | undefined;
|
item: CatalogEntityItem<T> | null | undefined;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user