1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Allow port-forwards to be restarted with the same local port (#4097)

* allow port-forwards to be restarted with the same local port

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* address review comment

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2021-10-21 12:32:34 -04:00 committed by GitHub
parent 0dab7b8073
commit c0c0b3ae11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,7 +49,6 @@ const dialogState = observable.object({
@observer @observer
export class PortForwardDialog extends Component<Props> { export class PortForwardDialog extends Component<Props> {
@observable ready = false;
@observable currentPort = 0; @observable currentPort = 0;
@observable desiredPort = 0; @observable desiredPort = 0;
@ -81,16 +80,13 @@ export class PortForwardDialog extends Component<Props> {
this.currentPort = +portForward.forwardPort; this.currentPort = +portForward.forwardPort;
this.desiredPort = this.currentPort; this.desiredPort = this.currentPort;
this.ready = this.currentPort ? false : true;
}; };
onClose = () => { onClose = () => {
this.ready = false;
}; };
changePort = (value: string) => { changePort = (value: string) => {
this.desiredPort = Number(value); this.desiredPort = Number(value);
this.ready = Boolean(this.desiredPort == 0 || this.currentPort !== this.desiredPort);
}; };
startPortForward = async () => { startPortForward = async () => {
@ -170,7 +166,6 @@ export class PortForwardDialog extends Component<Props> {
contentClass="flex gaps column" contentClass="flex gaps column"
next={this.startPortForward} next={this.startPortForward}
nextLabel={this.currentPort === 0 ? "Start" : "Restart"} nextLabel={this.currentPort === 0 ? "Start" : "Restart"}
disabledNext={!this.ready}
> >
{this.renderContents()} {this.renderContents()}
</WizardStep> </WizardStep>