Skip to content

Commit 9f9b576

Browse files
Katia Arestikaresti
authored andcommitted
[#653] Swagger and Metrics links
1 parent 50b8803 commit 9f9b576

File tree

4 files changed

+58
-17
lines changed

4 files changed

+58
-17
lines changed

cypress/e2e/1_cluster-welcome.cy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ describe('Welcome page', () => {
4949
// Show sidebar
5050
clickSideBar();
5151
//Checks if navigation menu is visible
52+
cy.contains('Operations').should('be.visible');
5253
cy.contains('Data Container').should('be.visible');
5354
cy.contains('Global Statistics').should('be.visible');
5455
cy.contains('Cluster Membership').should('be.visible');
5556
cy.contains('Access Management').should('be.visible');
5657
cy.contains('Connected Clients').should('be.visible');
58+
cy.contains('DevOps Tools').should('be.visible');
59+
cy.contains('Swagger Ui').should('be.visible');
60+
cy.contains('Metrics endpoint').should('be.visible');
5761

5862
//Clicks the side menu Data Container
5963
cy.get('[itemid="data_container"]').click();

src/app/AppLayout/AppLayout.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
MenuToggle,
1818
MenuToggleElement,
1919
Nav,
20+
NavGroup,
2021
NavItem,
2122
NavList,
2223
Page,
@@ -264,21 +265,34 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
264265
const Navigation = (
265266
<Nav id="nav-primary-simple">
266267
<NavList id="nav-list-simple">
267-
{filteredRoutes.map(
268-
(route, idx) =>
269-
displayNavMenu(route) && (
270-
<NavItem key={`${route.label}-${idx}`} id={`${route.label}-${idx}`}>
271-
<NavLink
272-
itemID={route.id}
273-
caseSensitive={true}
274-
to={route.path + location.search}
275-
className={isCurrentActiveNavItem(route) ? 'pf-m-current' : ''}
276-
>
277-
{route.label}
278-
</NavLink>
279-
</NavItem>
280-
)
281-
)}
268+
<NavGroup title="Operations">
269+
{filteredRoutes.map(
270+
(route, idx) =>
271+
displayNavMenu(route) && (
272+
<NavItem key={`${route.label}-${idx}`} id={`${route.label}-${idx}`}>
273+
<NavLink
274+
itemID={route.id}
275+
caseSensitive={true}
276+
to={route.path + location.search}
277+
className={isCurrentActiveNavItem(route) ? 'pf-m-current' : ''}
278+
>
279+
{route.label}
280+
</NavLink>
281+
</NavItem>
282+
)
283+
)}
284+
</NavGroup>
285+
<NavGroup title="DevOps Tools">
286+
<NavItem icon={<ExternalLinkAltIcon />} onClick={() => window.open(ConsoleServices.swaggerUi(), '_blank')}>
287+
{t('layout.swagger-ui')}
288+
</NavItem>
289+
<NavItem
290+
icon={<ExternalLinkAltIcon />}
291+
onClick={() => window.open(ConsoleServices.metricsEndpoint(), '_blank')}
292+
>
293+
{t('layout.metrics')}
294+
</NavItem>
295+
</NavGroup>
282296
</NavList>
283297
</Nav>
284298
);

src/app/assets/languages/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
"documentation-name": "Documentation",
3939
"close-browser-message": "Close the browser or open an incognito window to log again.",
4040
"dark-theme": "Dark theme",
41-
"logout": "Logout"
41+
"logout": "Logout",
42+
"swagger-ui": "Swagger Ui",
43+
"metrics": "Metrics endpoint"
4244
},
4345
"welcome-page": {
4446
"welcome-title": "Welcome to {{brandname}} Server",
@@ -57,7 +59,8 @@
5759
"learn-more": " Get started",
5860
"develop": "Code applications for different use cases.",
5961
"tutorials": " Run quick tutorials",
60-
"go-to-console": "Open the console"
62+
"go-to-console": "Open the console",
63+
"open-swagger-ui": "Open Swagger UI"
6164
},
6265
"login-form": {
6366
"login-main": "Log in to {{brandname}}.",

src/services/ConsoleServices.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ export class ConsoleServices {
5555
}
5656
}
5757

58+
public static metricsEndpoint(): string {
59+
return ConsoleServices.getEndpoint('/metrics');
60+
}
61+
62+
public static swaggerUi(): string {
63+
return ConsoleServices.getEndpoint('/swagger-ui');
64+
}
65+
66+
private static getEndpoint(endpoint: string): string {
67+
if (ConsoleServices.isDevMode()) {
68+
if (!process.env.INFINISPAN_SERVER_URL) {
69+
return 'http://localhost:11222' + endpoint;
70+
} else {
71+
return process.env.INFINISPAN_SERVER_URL + endpoint;
72+
}
73+
} else {
74+
return window.location.origin.toString() + endpoint;
75+
}
76+
}
77+
5878
public static landing(): string {
5979
if (ConsoleServices.isDevMode()) {
6080
return 'http://localhost:9000/console/';

0 commit comments

Comments
 (0)