Skip to content

Commit d5ab41d

Browse files
authored
[ACM-10020] Enable search details page in global search context (stolostron#3478)
* [ACM-10020] Enable search details page in global search context Signed-off-by: zlayne <zlayne@redhat.com> * fix lint errors Signed-off-by: zlayne <zlayne@redhat.com> * update tests snapshot Signed-off-by: zlayne <zlayne@redhat.com> --------- Signed-off-by: zlayne <zlayne@redhat.com>
1 parent 0955dd6 commit d5ab41d

File tree

4 files changed

+567
-77
lines changed

4 files changed

+567
-77
lines changed

frontend/src/routes/Home/Search/Search.tsx

-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
11
/* Copyright Contributors to the Open Cluster Management project */
22
import { Redirect, Route, Switch } from 'react-router-dom'
33
import { NavigationPath } from '../../../NavigationPath'
4-
import { useRecoilValue, useSharedAtoms } from '../../../shared-recoil'
54
import DetailsPage from './Details/DetailsPage'
65
import SearchPage from './SearchPage'
76

87
export default function Search() {
9-
const { isGlobalHubState, settingsState } = useSharedAtoms()
10-
const isGlobalHub = useRecoilValue(isGlobalHubState)
11-
const settings = useRecoilValue(settingsState)
12-
13-
if (isGlobalHub && settings.globalSearchFeatureFlag === 'enabled') {
14-
// Details page is not supported in Global search in 2.9
15-
return (
16-
<Switch>
17-
<Route exact path={NavigationPath.search} component={SearchPage} />
18-
<Route path="*">
19-
<Redirect to={NavigationPath.search} />
20-
</Route>
21-
</Switch>
22-
)
23-
}
24-
258
return (
269
<Switch>
2710
<Route exact path={NavigationPath.resources} component={DetailsPage} />

frontend/src/routes/Home/Search/__snapshots__/searchDefinitions.test.tsx.snap

+230-3
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,237 @@ exports[`Correctly returns CreateExternalLink from consoleURL 1`] = `
109109
</a>
110110
`;
111111

112-
exports[`Correctly returns GlobalHub CreateDetailsLink - Default 1`] = `
112+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed cluster Application resource 1`] = `
113113
<body>
114114
<div>
115-
testPodName
115+
<a
116+
aria-disabled="false"
117+
class="pf-c-button pf-m-link pf-m-inline"
118+
data-ouia-component-id="OUIA-Generated-Button-link-3"
119+
data-ouia-component-type="PF4/Button"
120+
data-ouia-safe="true"
121+
href="undefined/multicloud/applications/details/testClusterNamespace/testClusterName/overview?apiVersion=application.app.k8s.io&cluster=leaf-cluster"
122+
target="_blank"
123+
>
124+
testClusterName
125+
<span
126+
class="pf-c-button__icon pf-m-end"
127+
>
128+
<svg
129+
aria-hidden="true"
130+
fill="currentColor"
131+
height="1em"
132+
role="img"
133+
style="vertical-align: -0.125em;"
134+
viewBox="0 0 512 512"
135+
width="1em"
136+
>
137+
<path
138+
d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"
139+
/>
140+
</svg>
141+
</span>
142+
</a>
143+
</div>
144+
</body>
145+
`;
146+
147+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed cluster Cluster resource 1`] = `
148+
<body>
149+
<div>
150+
<a
151+
aria-disabled="false"
152+
class="pf-c-button pf-m-link pf-m-inline"
153+
data-ouia-component-id="OUIA-Generated-Button-link-2"
154+
data-ouia-component-type="PF4/Button"
155+
data-ouia-safe="true"
156+
href="undefined/multicloud/infrastructure/clusters/details/testClusterName/testClusterName/overview?cluster%3Dundefined%26kind%3DCluster%26namespace%3DtestClusterNamespace%26name%3DtestClusterName"
157+
target="_blank"
158+
>
159+
testClusterName
160+
<span
161+
class="pf-c-button__icon pf-m-end"
162+
>
163+
<svg
164+
aria-hidden="true"
165+
fill="currentColor"
166+
height="1em"
167+
role="img"
168+
style="vertical-align: -0.125em;"
169+
viewBox="0 0 512 512"
170+
width="1em"
171+
>
172+
<path
173+
d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"
174+
/>
175+
</svg>
176+
</span>
177+
</a>
178+
</div>
179+
</body>
180+
`;
181+
182+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed cluster Policy resource 1`] = `
183+
<body>
184+
<div>
185+
<a
186+
href="/multicloud/governance/policies/details/default/global-policy"
187+
>
188+
global-policy
189+
</a>
190+
</div>
191+
</body>
192+
`;
193+
194+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed cluster PolicyReport resource 1`] = `
195+
<body>
196+
<div>
197+
<a
198+
aria-disabled="false"
199+
class="pf-c-button pf-m-link pf-m-inline"
200+
data-ouia-component-id="OUIA-Generated-Button-link-5"
201+
data-ouia-component-type="PF4/Button"
202+
data-ouia-safe="true"
203+
href="undefined/multicloud/infrastructure/clusters/details/testClusterNamespace/testClusterNamespace/overview?showClusterIssues%3Dtrue"
204+
target="_blank"
205+
>
206+
leaf-cluster-policyreport
207+
<span
208+
class="pf-c-button__icon pf-m-end"
209+
>
210+
<svg
211+
aria-hidden="true"
212+
fill="currentColor"
213+
height="1em"
214+
role="img"
215+
style="vertical-align: -0.125em;"
216+
viewBox="0 0 512 512"
217+
width="1em"
218+
>
219+
<path
220+
d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"
221+
/>
222+
</svg>
223+
</span>
224+
</a>
225+
</div>
226+
</body>
227+
`;
228+
229+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed cluster default resource 1`] = `
230+
<body>
231+
<div>
232+
<a
233+
aria-disabled="false"
234+
class="pf-c-button pf-m-link pf-m-inline"
235+
data-ouia-component-id="OUIA-Generated-Button-link-1"
236+
data-ouia-component-type="PF4/Button"
237+
data-ouia-safe="true"
238+
href="https://leaf-hub.com/multicloud/home/search/resources?cluster%3DtestCluster%26kind%3DPod%26namespace%3DtestPodNamespace%26name%3DtestPodName"
239+
target="_blank"
240+
>
241+
testPodName
242+
<span
243+
class="pf-c-button__icon pf-m-end"
244+
>
245+
<svg
246+
aria-hidden="true"
247+
fill="currentColor"
248+
height="1em"
249+
role="img"
250+
style="vertical-align: -0.125em;"
251+
viewBox="0 0 512 512"
252+
width="1em"
253+
>
254+
<path
255+
d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"
256+
/>
257+
</svg>
258+
</span>
259+
</a>
260+
</div>
261+
</body>
262+
`;
263+
264+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed hub Application resource 1`] = `
265+
<body>
266+
<div>
267+
<a
268+
href="/multicloud/applications/details/testClusterNamespace/testClusterName/overview?apiVersion=application.app.k8s.io"
269+
>
270+
testClusterName
271+
</a>
272+
</div>
273+
</body>
274+
`;
275+
276+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed hub Cluster resource 1`] = `
277+
<body>
278+
<div>
279+
<a
280+
href="/multicloud/infrastructure/clusters/details/testClusterName/testClusterName/overview"
281+
>
282+
testClusterName
283+
</a>
284+
</div>
285+
</body>
286+
`;
287+
288+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed hub Policy resource 1`] = `
289+
<body>
290+
<div>
291+
<a
292+
aria-disabled="false"
293+
class="pf-c-button pf-m-link pf-m-inline"
294+
data-ouia-component-id="OUIA-Generated-Button-link-4"
295+
data-ouia-component-type="PF4/Button"
296+
data-ouia-safe="true"
297+
href="undefined/multicloud/governance/policies/details/default/hub-a-policy-test"
298+
target="_blank"
299+
>
300+
hub-a-policy-test
301+
<span
302+
class="pf-c-button__icon pf-m-end"
303+
>
304+
<svg
305+
aria-hidden="true"
306+
fill="currentColor"
307+
height="1em"
308+
role="img"
309+
style="vertical-align: -0.125em;"
310+
viewBox="0 0 512 512"
311+
width="1em"
312+
>
313+
<path
314+
d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"
315+
/>
316+
</svg>
317+
</span>
318+
</a>
319+
</div>
320+
</body>
321+
`;
322+
323+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed hub PolicyReport resource 1`] = `
324+
<body>
325+
<div>
326+
<a
327+
href="/multicloud/infrastructure/clusters/details/testClusterNamespace/testClusterNamespace/overview?showClusterIssues%3Dtrue"
328+
>
329+
local-cluster-policyreport
330+
</a>
331+
</div>
332+
</body>
333+
`;
334+
335+
exports[`Correctly returns CreateGlobalSearchDetailsLink managed hub default resource 1`] = `
336+
<body>
337+
<div>
338+
<a
339+
href="/multicloud/home/search/resources?cluster%3DtestCluster%26kind%3DPod%26namespace%3DtestPodNamespace%26name%3DtestPodName"
340+
>
341+
testPodName
342+
</a>
116343
</div>
117344
</body>
118345
`;
@@ -2113,7 +2340,7 @@ exports[`Correctly returns policyreport policies 1`] = `
21132340
exports[`Correctly returns resource with managedHub column: SearchDefinitions-global-node 1`] = `
21142341
Array [
21152342
Object {
2116-
"cell": <CreateDetailsLink
2343+
"cell": <CreateGlobalSearchDetailsLink
21172344
item={
21182345
Object {
21192346
"apiversion": "v1",

0 commit comments

Comments
 (0)