Skip to content

Commit

Permalink
Merge pull request #2766 from headlamp-k8s/endpoints-fix
Browse files Browse the repository at this point in the history
frontend: Quick fix for a case when no endpoints are available for the resource
  • Loading branch information
joaquimrocha authored Jan 22, 2025
2 parents 34d353d + 8e8d5c1 commit 38078ec
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 53 deletions.
1 change: 1 addition & 0 deletions frontend/.storybook/baseMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NODE_DUMMY_DATA } from '../src/components/node/storyHelper';
*
*/
export const baseMocks = [
http.get('http://localhost:4466/wsMultiplexer', () => HttpResponse.error()),
http.get('https://api.iconify.design/mdi.json', () => HttpResponse.json({})),
http.post('http://localhost:4466/apis/authorization.k8s.io/v1/selfsubjectaccessreviews', () =>
HttpResponse.json({ status: { allowed: true, reason: '', code: 200 } })
Expand Down
23 changes: 10 additions & 13 deletions frontend/src/components/gateway/ClassDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ export default {
parameters: {
msw: {
handlers: {
story: [],
storyBase: [
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses', () =>
HttpResponse.error()
HttpResponse.json({})
),
http.get(
'http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gatewayclasses',
() => HttpResponse.error()
),
http.get('http://localhost:4466/api/v1/namespaces/default/events', () =>
HttpResponse.json({
Expand All @@ -31,6 +36,10 @@ export default {
metadata: {},
})
),
http.get(
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses/default-gateway-class',
() => HttpResponse.json(DEFAULT_GATEWAY_CLASS)
),
],
},
},
Expand All @@ -45,15 +54,3 @@ export const Basic = Template.bind({});
Basic.args = {
gatewayJson: DEFAULT_GATEWAY_CLASS,
};
Basic.parameters = {
msw: {
handlers: {
story: [
http.get(
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses/default-gateway-class',
() => HttpResponse.json(DEFAULT_GATEWAY_CLASS)
),
],
},
},
};
5 changes: 5 additions & 0 deletions frontend/src/components/gateway/ClassList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export default {
parameters: {
msw: {
handlers: {
storyBase: [],
story: [
http.get(
'http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gatewayclasses',
() => HttpResponse.error()
),
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses', () =>
HttpResponse.json({
kind: 'GatewayClassList',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/gateway/GRPCRouteDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default {
parameters: {
msw: {
handlers: {
baseStory: [
story: [],
storyBase: [
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/grpcroutes', () =>
HttpResponse.json({})
),
Expand Down
21 changes: 7 additions & 14 deletions frontend/src/components/gateway/GatewayDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ export default {
parameters: {
msw: {
handlers: {
baseStory: [
story: [],
storyBase: [
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways', () =>
HttpResponse.json({})
),
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways', () =>
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gateways', () =>
HttpResponse.error()
),
http.get('http://localhost:4466/api/v1/namespaces/default/events', () =>
Expand All @@ -38,6 +39,10 @@ export default {
'http://localhost:4466/apis/authorization.k8s.io/v1/selfsubjectaccessreviews',
() => HttpResponse.json({ status: { allowed: true, reason: '', code: 200 } })
),
http.get(
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways/default-gateway',
() => HttpResponse.json(DEFAULT_GATEWAY)
),
],
},
},
Expand All @@ -52,15 +57,3 @@ export const Basic = Template.bind({});
Basic.args = {
gatewayJson: DEFAULT_GATEWAY,
};
Basic.parameters = {
msw: {
handlers: {
story: [
http.get(
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways/default-gateway',
() => HttpResponse.json(DEFAULT_GATEWAY)
),
],
},
},
};
2 changes: 1 addition & 1 deletion frontend/src/components/gateway/GatewayList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
items: [DEFAULT_GATEWAY],
})
),
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways', () =>
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gateways', () =>
HttpResponse.error()
),
],
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/gateway/HTTPRouteDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default {
parameters: {
msw: {
handlers: {
baseStory: [
story: [],
storyBase: [
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/httproutes', () =>
HttpResponse.json({})
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,20 @@
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
/>
>
<div
class="MuiBox-root css-70qvj9"
>
<h1
class="MuiTypography-root MuiTypography-h1 MuiTypography-noWrap css-yeaech-MuiTypography-root"
>
GatewayClass: default-gateway-class
</h1>
<div
class="MuiBox-root css-ldp2l3"
/>
</div>
</div>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
>
Expand All @@ -55,10 +68,35 @@
/>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
/>
>
<button
aria-label="Edit"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
data-mui-internal-clone-element="true"
tabindex="0"
type="button"
>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
/>
>
<button
aria-label="Delete"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
data-mui-internal-clone-element="true"
tabindex="0"
type="button"
>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
<div />
</div>
</div>
</div>
</div>
Expand All @@ -71,28 +109,177 @@
class="MuiBox-root css-p0cik4"
>
<div
class="MuiBox-root css-5cned0"
class="MuiBox-root css-j1fy4m"
>
<span
class="MuiCircularProgress-root MuiCircularProgress-indeterminate MuiCircularProgress-colorPrimary css-wdedfu-MuiCircularProgress-root"
role="progressbar"
style="width: 40px; height: 40px;"
title="Loading resource data"
<div
aria-busy="false"
aria-live="polite"
class="MuiBox-root css-1txv3mw"
>
<svg
class="MuiCircularProgress-svg css-1idz92c-MuiCircularProgress-svg"
viewBox="22 22 44 44"
<div
class="MuiBox-root css-0"
>
<circle
class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate css-176wh8e-MuiCircularProgress-circle"
cx="44"
cy="44"
fill="none"
r="20.2"
stroke-width="3.6"
/>
</svg>
</span>
<dl
class="MuiGrid-root MuiGrid-container css-uximdg-MuiGrid-root"
>
<dt
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-trrd7p-MuiGrid-root"
>
Name
</dt>
<dd
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 css-1qti38g-MuiTypography-root"
>
default-gateway-class
</span>
</dd>
<dt
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-trrd7p-MuiGrid-root"
>
Namespace
</dt>
<dd
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineHover css-srrjpp-MuiTypography-root-MuiLink-root"
href="/"
>
default
</a>
</dd>
<dt
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-trrd7p-MuiGrid-root"
>
Creation
</dt>
<dd
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 css-1qti38g-MuiTypography-root"
>
2023-07-19T09:48:42.000Z
</span>
</dd>
<dt
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-16fae59-MuiGrid-root"
>
Controller Name
</dt>
<dd
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-1xrovmc-MuiGrid-root"
>
<span
class="MuiTypography-root MuiTypography-body1 css-1qti38g-MuiTypography-root"
>
test
</span>
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 css-49904w-MuiGrid-root"
>
<div
class="MuiBox-root css-p0cik4"
>
<div
class="MuiBox-root css-j1fy4m"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 css-1qm9nul-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
>
<div
class="MuiBox-root css-70qvj9"
>
<h2
class="MuiTypography-root MuiTypography-h2 MuiTypography-noWrap css-m5vcfd-MuiTypography-root"
>
Conditions
</h2>
<div
class="MuiBox-root css-ldp2l3"
/>
</div>
</div>
</div>
<div
class="MuiBox-root css-1txv3mw"
>
<div
class="MuiPaper-root MuiPaper-outlined MuiPaper-rounded css-172kgz0-MuiPaper-root"
>
<div
class="MuiBox-root css-19midj6"
>
<p
class="MuiTypography-root MuiTypography-body1 MuiTypography-alignCenter css-18lkse1-MuiTypography-root"
>
No data to be shown.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 css-49904w-MuiGrid-root"
>
<div
class="MuiBox-root css-p0cik4"
>
<div
class="MuiBox-root css-j1fy4m"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 css-1qm9nul-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
>
<div
class="MuiBox-root css-70qvj9"
>
<h2
class="MuiTypography-root MuiTypography-h2 MuiTypography-noWrap css-m5vcfd-MuiTypography-root"
>
Events
</h2>
<div
class="MuiBox-root css-ldp2l3"
/>
</div>
</div>
</div>
<div
class="MuiBox-root css-1txv3mw"
>
<div
class="MuiPaper-root MuiPaper-outlined MuiPaper-rounded css-172kgz0-MuiPaper-root"
>
<div
class="MuiBox-root css-19midj6"
>
<p
class="MuiTypography-root MuiTypography-body1 MuiTypography-alignCenter css-18lkse1-MuiTypography-root"
>
No data to be shown.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 38078ec

Please sign in to comment.