Skip to content

Commit 38078ec

Browse files
authored
Merge pull request #2766 from headlamp-k8s/endpoints-fix
frontend: Quick fix for a case when no endpoints are available for the resource
2 parents 34d353d + 8e8d5c1 commit 38078ec

File tree

10 files changed

+242
-53
lines changed

10 files changed

+242
-53
lines changed

frontend/.storybook/baseMocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { NODE_DUMMY_DATA } from '../src/components/node/storyHelper';
77
*
88
*/
99
export const baseMocks = [
10+
http.get('http://localhost:4466/wsMultiplexer', () => HttpResponse.error()),
1011
http.get('https://api.iconify.design/mdi.json', () => HttpResponse.json({})),
1112
http.post('http://localhost:4466/apis/authorization.k8s.io/v1/selfsubjectaccessreviews', () =>
1213
HttpResponse.json({ status: { allowed: true, reason: '', code: 200 } })

frontend/src/components/gateway/ClassDetails.stories.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ export default {
2020
parameters: {
2121
msw: {
2222
handlers: {
23+
story: [],
2324
storyBase: [
2425
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses', () =>
25-
HttpResponse.error()
26+
HttpResponse.json({})
27+
),
28+
http.get(
29+
'http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gatewayclasses',
30+
() => HttpResponse.error()
2631
),
2732
http.get('http://localhost:4466/api/v1/namespaces/default/events', () =>
2833
HttpResponse.json({
@@ -31,6 +36,10 @@ export default {
3136
metadata: {},
3237
})
3338
),
39+
http.get(
40+
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses/default-gateway-class',
41+
() => HttpResponse.json(DEFAULT_GATEWAY_CLASS)
42+
),
3443
],
3544
},
3645
},
@@ -45,15 +54,3 @@ export const Basic = Template.bind({});
4554
Basic.args = {
4655
gatewayJson: DEFAULT_GATEWAY_CLASS,
4756
};
48-
Basic.parameters = {
49-
msw: {
50-
handlers: {
51-
story: [
52-
http.get(
53-
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses/default-gateway-class',
54-
() => HttpResponse.json(DEFAULT_GATEWAY_CLASS)
55-
),
56-
],
57-
},
58-
},
59-
};

frontend/src/components/gateway/ClassList.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ export default {
2020
parameters: {
2121
msw: {
2222
handlers: {
23+
storyBase: [],
2324
story: [
25+
http.get(
26+
'http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gatewayclasses',
27+
() => HttpResponse.error()
28+
),
2429
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gatewayclasses', () =>
2530
HttpResponse.json({
2631
kind: 'GatewayClassList',

frontend/src/components/gateway/GRPCRouteDetails.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export default {
2020
parameters: {
2121
msw: {
2222
handlers: {
23-
baseStory: [
23+
story: [],
24+
storyBase: [
2425
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/grpcroutes', () =>
2526
HttpResponse.json({})
2627
),

frontend/src/components/gateway/GatewayDetails.stories.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ export default {
2020
parameters: {
2121
msw: {
2222
handlers: {
23-
baseStory: [
23+
story: [],
24+
storyBase: [
2425
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways', () =>
2526
HttpResponse.json({})
2627
),
27-
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways', () =>
28+
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gateways', () =>
2829
HttpResponse.error()
2930
),
3031
http.get('http://localhost:4466/api/v1/namespaces/default/events', () =>
@@ -38,6 +39,10 @@ export default {
3839
'http://localhost:4466/apis/authorization.k8s.io/v1/selfsubjectaccessreviews',
3940
() => HttpResponse.json({ status: { allowed: true, reason: '', code: 200 } })
4041
),
42+
http.get(
43+
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways/default-gateway',
44+
() => HttpResponse.json(DEFAULT_GATEWAY)
45+
),
4146
],
4247
},
4348
},
@@ -52,15 +57,3 @@ export const Basic = Template.bind({});
5257
Basic.args = {
5358
gatewayJson: DEFAULT_GATEWAY,
5459
};
55-
Basic.parameters = {
56-
msw: {
57-
handlers: {
58-
story: [
59-
http.get(
60-
'http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways/default-gateway',
61-
() => HttpResponse.json(DEFAULT_GATEWAY)
62-
),
63-
],
64-
},
65-
},
66-
};

frontend/src/components/gateway/GatewayList.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default {
2929
items: [DEFAULT_GATEWAY],
3030
})
3131
),
32-
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/gateways', () =>
32+
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1beta1/gateways', () =>
3333
HttpResponse.error()
3434
),
3535
],

frontend/src/components/gateway/HTTPRouteDetails.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export default {
2020
parameters: {
2121
msw: {
2222
handlers: {
23-
baseStory: [
23+
story: [],
24+
storyBase: [
2425
http.get('http://localhost:4466/apis/gateway.networking.k8s.io/v1/httproutes', () =>
2526
HttpResponse.json({})
2627
),

frontend/src/components/gateway/__snapshots__/ClassDetails.Basic.stories.storyshot

Lines changed: 209 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,20 @@
4040
>
4141
<div
4242
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
43-
/>
43+
>
44+
<div
45+
class="MuiBox-root css-70qvj9"
46+
>
47+
<h1
48+
class="MuiTypography-root MuiTypography-h1 MuiTypography-noWrap css-yeaech-MuiTypography-root"
49+
>
50+
GatewayClass: default-gateway-class
51+
</h1>
52+
<div
53+
class="MuiBox-root css-ldp2l3"
54+
/>
55+
</div>
56+
</div>
4457
<div
4558
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
4659
>
@@ -55,10 +68,35 @@
5568
/>
5669
<div
5770
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
58-
/>
71+
>
72+
<button
73+
aria-label="Edit"
74+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
75+
data-mui-internal-clone-element="true"
76+
tabindex="0"
77+
type="button"
78+
>
79+
<span
80+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
81+
/>
82+
</button>
83+
</div>
5984
<div
6085
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
61-
/>
86+
>
87+
<button
88+
aria-label="Delete"
89+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
90+
data-mui-internal-clone-element="true"
91+
tabindex="0"
92+
type="button"
93+
>
94+
<span
95+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
96+
/>
97+
</button>
98+
<div />
99+
</div>
62100
</div>
63101
</div>
64102
</div>
@@ -71,28 +109,177 @@
71109
class="MuiBox-root css-p0cik4"
72110
>
73111
<div
74-
class="MuiBox-root css-5cned0"
112+
class="MuiBox-root css-j1fy4m"
75113
>
76-
<span
77-
class="MuiCircularProgress-root MuiCircularProgress-indeterminate MuiCircularProgress-colorPrimary css-wdedfu-MuiCircularProgress-root"
78-
role="progressbar"
79-
style="width: 40px; height: 40px;"
80-
title="Loading resource data"
114+
<div
115+
aria-busy="false"
116+
aria-live="polite"
117+
class="MuiBox-root css-1txv3mw"
81118
>
82-
<svg
83-
class="MuiCircularProgress-svg css-1idz92c-MuiCircularProgress-svg"
84-
viewBox="22 22 44 44"
119+
<div
120+
class="MuiBox-root css-0"
85121
>
86-
<circle
87-
class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate css-176wh8e-MuiCircularProgress-circle"
88-
cx="44"
89-
cy="44"
90-
fill="none"
91-
r="20.2"
92-
stroke-width="3.6"
93-
/>
94-
</svg>
95-
</span>
122+
<dl
123+
class="MuiGrid-root MuiGrid-container css-uximdg-MuiGrid-root"
124+
>
125+
<dt
126+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-trrd7p-MuiGrid-root"
127+
>
128+
Name
129+
</dt>
130+
<dd
131+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
132+
>
133+
<span
134+
class="MuiTypography-root MuiTypography-body1 css-1qti38g-MuiTypography-root"
135+
>
136+
default-gateway-class
137+
</span>
138+
</dd>
139+
<dt
140+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-trrd7p-MuiGrid-root"
141+
>
142+
Namespace
143+
</dt>
144+
<dd
145+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
146+
>
147+
<a
148+
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineHover css-srrjpp-MuiTypography-root-MuiLink-root"
149+
href="/"
150+
>
151+
default
152+
</a>
153+
</dd>
154+
<dt
155+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-trrd7p-MuiGrid-root"
156+
>
157+
Creation
158+
</dt>
159+
<dd
160+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
161+
>
162+
<span
163+
class="MuiTypography-root MuiTypography-body1 css-1qti38g-MuiTypography-root"
164+
>
165+
2023-07-19T09:48:42.000Z
166+
</span>
167+
</dd>
168+
<dt
169+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-16fae59-MuiGrid-root"
170+
>
171+
Controller Name
172+
</dt>
173+
<dd
174+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-1xrovmc-MuiGrid-root"
175+
>
176+
<span
177+
class="MuiTypography-root MuiTypography-body1 css-1qti38g-MuiTypography-root"
178+
>
179+
test
180+
</span>
181+
</dd>
182+
</dl>
183+
</div>
184+
</div>
185+
</div>
186+
</div>
187+
</div>
188+
<div
189+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 css-49904w-MuiGrid-root"
190+
>
191+
<div
192+
class="MuiBox-root css-p0cik4"
193+
>
194+
<div
195+
class="MuiBox-root css-j1fy4m"
196+
>
197+
<div
198+
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 css-1qm9nul-MuiGrid-root"
199+
>
200+
<div
201+
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
202+
>
203+
<div
204+
class="MuiBox-root css-70qvj9"
205+
>
206+
<h2
207+
class="MuiTypography-root MuiTypography-h2 MuiTypography-noWrap css-m5vcfd-MuiTypography-root"
208+
>
209+
Conditions
210+
</h2>
211+
<div
212+
class="MuiBox-root css-ldp2l3"
213+
/>
214+
</div>
215+
</div>
216+
</div>
217+
<div
218+
class="MuiBox-root css-1txv3mw"
219+
>
220+
<div
221+
class="MuiPaper-root MuiPaper-outlined MuiPaper-rounded css-172kgz0-MuiPaper-root"
222+
>
223+
<div
224+
class="MuiBox-root css-19midj6"
225+
>
226+
<p
227+
class="MuiTypography-root MuiTypography-body1 MuiTypography-alignCenter css-18lkse1-MuiTypography-root"
228+
>
229+
No data to be shown.
230+
</p>
231+
</div>
232+
</div>
233+
</div>
234+
</div>
235+
</div>
236+
</div>
237+
<div
238+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 css-49904w-MuiGrid-root"
239+
>
240+
<div
241+
class="MuiBox-root css-p0cik4"
242+
>
243+
<div
244+
class="MuiBox-root css-j1fy4m"
245+
>
246+
<div
247+
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 css-1qm9nul-MuiGrid-root"
248+
>
249+
<div
250+
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
251+
>
252+
<div
253+
class="MuiBox-root css-70qvj9"
254+
>
255+
<h2
256+
class="MuiTypography-root MuiTypography-h2 MuiTypography-noWrap css-m5vcfd-MuiTypography-root"
257+
>
258+
Events
259+
</h2>
260+
<div
261+
class="MuiBox-root css-ldp2l3"
262+
/>
263+
</div>
264+
</div>
265+
</div>
266+
<div
267+
class="MuiBox-root css-1txv3mw"
268+
>
269+
<div
270+
class="MuiPaper-root MuiPaper-outlined MuiPaper-rounded css-172kgz0-MuiPaper-root"
271+
>
272+
<div
273+
class="MuiBox-root css-19midj6"
274+
>
275+
<p
276+
class="MuiTypography-root MuiTypography-body1 MuiTypography-alignCenter css-18lkse1-MuiTypography-root"
277+
>
278+
No data to be shown.
279+
</p>
280+
</div>
281+
</div>
282+
</div>
96283
</div>
97284
</div>
98285
</div>

0 commit comments

Comments
 (0)