Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/common/Resource/PortForward.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function PortForwardContent(props: PortForwardProps) {
return;
}
setLoading(true);
stopOrDeletePortForward(cluster, portForward.id, true)
stopOrDeletePortForward(cluster, portForward.id, true /* justStop */)
.then(() => {
portForward.status = PORT_FORWARD_STOP_STATUS;
setPortForward(portForward);
Expand All @@ -335,7 +335,7 @@ function PortForwardContent(props: PortForwardProps) {
return;
}
setLoading(true);
stopOrDeletePortForward(cluster, id, false).finally(() => {
stopOrDeletePortForward(cluster, id, false /* justStop */).finally(() => {
setLoading(false);
const portforwardInStorage = localStorage.getItem(PORT_FORWARDS_STORAGE_KEY);
const parsedPortForwards = JSON.parse(portforwardInStorage || '[]');
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/portforward/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default function PortForwardingList() {
if (option === PortForwardAction.Stop) {
setPortForwardInActionSafely({ ...portforward, loading: true });
// stop portforward
stopOrDeletePortForward(cluster, id, true).finally(() => {
stopOrDeletePortForward(cluster, id, true /* justStop */).finally(() => {
setPortForwardInActionSafely(null);
// Always refresh the backend-backed port-forward list so localStorage
// stays in sync even if the component unmounts before the request settles.
Expand All @@ -209,7 +209,7 @@ export default function PortForwardingList() {
if (option === PortForwardAction.Delete) {
setPortForwardInActionSafely({ ...portforward, loading: true });
// delete portforward
stopOrDeletePortForward(cluster, id, false).finally(() => {
stopOrDeletePortForward(cluster, id, false /* justStop */).finally(() => {
setPortForwardInActionSafely(null);

// remove portforward from storage too
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/lib/k8s/api/v1/portForward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,20 @@ export async function startPortForward(
});
}

// @todo: stopOrDelete true is confusing, rename this param to justStop?
/**
* Stops or deletes a portforward with the specified details.
*
* @param cluster - The cluster to portforward for.
* @param id - The id to portforward for.
* @param stopOrDelete - Whether to stop or delete the portforward. True for stop, false for delete.
* @param justStop - Whether to just stop the portforward (true) or delete it entirely (false).
*
* @returns The response from the API.
* @throws {Error} if the request fails.
*/
export async function stopOrDeletePortForward(
cluster: string,
id: string,
stopOrDelete: boolean = true
justStop: boolean = true
): Promise<string> {
const kubeconfig = await findKubeconfigByClusterName(cluster);
const headers = new Headers(addBackstageAuthHeaders(JSON_HEADERS));
Expand All @@ -151,7 +150,7 @@ export async function stopOrDeletePortForward(
headers: headers,
body: JSON.stringify({
id,
stopOrDelete,
stopOrDelete: justStop,
}),
cluster,
}).then(async response => {
Expand Down
Loading