mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
address review comments, plus added toolbar/menu to port-forward details Drawer
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
47ac36c904
commit
01faec3a05
@ -27,7 +27,7 @@ export const portForwardsRoute: RouteProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface PortForwardsRouteParams {
|
export interface PortForwardsRouteParams {
|
||||||
forwardport: string;
|
forwardport?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const portForwardsURL = buildURL<PortForwardsRouteParams>(portForwardsRoute.path);
|
export const portForwardsURL = buildURL<PortForwardsRouteParams>(portForwardsRoute.path);
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import { Drawer, DrawerItem } from "../drawer";
|
|||||||
import { cssNames } from "../../utils";
|
import { cssNames } from "../../utils";
|
||||||
import { podsApi, serviceApi } from "../../../common/k8s-api/endpoints";
|
import { podsApi, serviceApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { getDetailsUrl } from "../kube-detail-params";
|
import { getDetailsUrl } from "../kube-detail-params";
|
||||||
|
import { PortForwardMenu } from "./port-forward-menu";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
portForward: PortForwardItem;
|
portForward: PortForwardItem;
|
||||||
@ -36,19 +37,36 @@ interface Props {
|
|||||||
|
|
||||||
export class PortForwardDetails extends React.Component<Props> {
|
export class PortForwardDetails extends React.Component<Props> {
|
||||||
|
|
||||||
renderContent() {
|
renderResourceName() {
|
||||||
const { portForward } = this.props;
|
const { portForward } = this.props;
|
||||||
|
const name = portForward.getName();
|
||||||
const api = {
|
const api = {
|
||||||
"service": serviceApi,
|
"service": serviceApi,
|
||||||
"pod": podsApi
|
"pod": podsApi
|
||||||
}[portForward.kind];
|
}[portForward.kind];
|
||||||
|
|
||||||
|
if (!api) {
|
||||||
|
return (
|
||||||
|
<span>{name}</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link to={getDetailsUrl(api.getUrl({ name, namespace: portForward.getNs() }))}>
|
||||||
|
{name}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderContent() {
|
||||||
|
const { portForward } = this.props;
|
||||||
|
|
||||||
|
if (!portForward) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<DrawerItem name="Resource Name">
|
<DrawerItem name="Resource Name">
|
||||||
<Link to={getDetailsUrl(api.getUrl({ name: portForward.getName(), namespace: portForward.getNs() }))}>
|
{this.renderResourceName()}
|
||||||
{portForward.getName()}
|
|
||||||
</Link>
|
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
<DrawerItem name="Namespace">
|
<DrawerItem name="Namespace">
|
||||||
{portForward.getNs()}
|
{portForward.getNs()}
|
||||||
@ -71,15 +89,16 @@ export class PortForwardDetails extends React.Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { hideDetails, portForward } = this.props;
|
const { hideDetails, portForward } = this.props;
|
||||||
const title = "Port Forward";
|
const toolbar = <PortForwardMenu portForward={portForward} toolbar hideDetails={hideDetails}/>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
className="PortForwardDetails"
|
className="PortForwardDetails"
|
||||||
usePortal={true}
|
usePortal={true}
|
||||||
open={!!portForward}
|
open={!!portForward}
|
||||||
title={title}
|
title="Port Forward"
|
||||||
onClose={hideDetails}
|
onClose={hideDetails}
|
||||||
|
toolbar={toolbar}
|
||||||
>
|
>
|
||||||
{this.renderContent()}
|
{this.renderContent()}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user