mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add a query param for filtering port forwards by clusterId
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
406f595011
commit
536e9bbd31
@ -189,9 +189,10 @@ export class PortForwardRoute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async routeAllPortForwards(request: LensApiRequest) {
|
static async routeAllPortForwards(request: LensApiRequest) {
|
||||||
const { response } = request;
|
const { query, response } = request;
|
||||||
|
const clusterId = query.get("clusterId");
|
||||||
|
|
||||||
const portForwards: PortForwardArgs[] = PortForward.portForwards.map(f => (
|
let portForwards: PortForwardArgs[] = PortForward.portForwards.map(f => (
|
||||||
{
|
{
|
||||||
clusterId: f.clusterId,
|
clusterId: f.clusterId,
|
||||||
kind: f.kind,
|
kind: f.kind,
|
||||||
@ -203,6 +204,12 @@ export class PortForwardRoute {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (clusterId) {
|
||||||
|
// filter out any not for this cluster
|
||||||
|
portForwards = portForwards.filter(pf => pf.clusterId == clusterId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
respondJson(response, { portForwards });
|
respondJson(response, { portForwards });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,10 +60,8 @@ export class PortForwardStore extends ItemStore<PortForwardItem> {
|
|||||||
|
|
||||||
loadAll() {
|
loadAll() {
|
||||||
return this.loadItems(async () => {
|
return this.loadItems(async () => {
|
||||||
let portForwards = await getPortForwards();
|
const portForwards = await getPortForwards(getHostedClusterId());
|
||||||
|
|
||||||
// filter out any not for this cluster
|
|
||||||
portForwards = portForwards.filter(pf => pf.clusterId == getHostedClusterId());
|
|
||||||
this.storage.set(portForwards);
|
this.storage.set(portForwards);
|
||||||
|
|
||||||
this.reset();
|
this.reset();
|
||||||
@ -166,9 +164,10 @@ export async function removePortForward(portForward: ForwardedPort) {
|
|||||||
portForwardStore.reset();
|
portForwardStore.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPortForwards(): Promise<ForwardedPort[]> {
|
export async function getPortForwards(clusterId?: string): Promise<ForwardedPort[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiBase.get<PortForwardsResult>(`/pods/port-forwards`);
|
const query = clusterId ? `?clusterId=${clusterId}` : "";
|
||||||
|
const response = await apiBase.get<PortForwardsResult>(`/pods/port-forwards${query}`);
|
||||||
|
|
||||||
return response.portForwards;
|
return response.portForwards;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user