Skip to content

Commit 7e0413f

Browse files
committed
Add analytics link to publisher UI
1 parent 078e7b8 commit 7e0413f

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/Base/Header/navbar/GlobalNavLink.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const styles = (theme) => ({
9898
*/
9999
function GlobalNavLinks(props) {
100100
const {
101-
classes, active, title, children, to, type, icon,
101+
classes, active, title, children, to, type, icon, isExternalLink,
102102
} = props;
103103
const theme = useTheme();
104104
let tooltipTitle = title;
@@ -110,8 +110,8 @@ function GlobalNavLinks(props) {
110110
return (
111111
<Link
112112
underline='none'
113-
component={RouterLink}
114-
to={to}
113+
component={!isExternalLink && RouterLink}
114+
to={!isExternalLink && to}
115115
>
116116
<Tooltip
117117
classes={{ arrow: classes.arrow, tooltip: classes.tooltip }}

features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/Base/Header/navbar/GlobalNavLinks.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import React from 'react';
1919
import PropTypes from 'prop-types';
2020
import Box from '@material-ui/core/Box';
21+
import LaunchIcon from '@material-ui/icons/Launch';
22+
import { useTheme } from '@material-ui/styles';
2123
import { FormattedMessage } from 'react-intl';
2224
import AuthManager from 'AppData/AuthManager';
2325
import ScopesIcon from '@material-ui/icons/VpnKey';
@@ -29,6 +31,11 @@ const useStyles = makeStyles((theme) => ({
2931
scopeIcon: {
3032
color: theme.palette.background.paper,
3133
},
34+
externalLinkIcon: {
35+
marginLeft: theme.spacing(1),
36+
marginTop: theme.spacing(0.5),
37+
marginBottom: theme.spacing(-1),
38+
},
3239
}));
3340

3441

@@ -42,6 +49,9 @@ function GlobalNavLinks(props) {
4249
const publisherUser = !AuthManager.isNotPublisher();
4350
const classes = useStyles();
4451
const { selected } = props;
52+
const theme = useTheme();
53+
const analyticsMenuEnabled = theme.custom.leftMenuAnalytics.enable;
54+
const analyticsMenuLink = theme.custom.leftMenuAnalytics.link;
4555
return (
4656
<Box mt={10}>
4757
<GlobalNavLink
@@ -89,6 +99,25 @@ function GlobalNavLinks(props) {
8999
>
90100
<FormattedMessage id='Base.Header.navbar.GlobalNavBar.scopes' defaultMessage='Scopes' />
91101
</GlobalNavLink>
102+
{analyticsMenuEnabled && (
103+
<a href={analyticsMenuLink} target='_blank' rel='noreferrer'>
104+
<GlobalNavLink
105+
isExternalLink
106+
type='analytics'
107+
title='Analytics'
108+
>
109+
<div style={{ flexDirection: 'row', display: 'flex' }}>
110+
<FormattedMessage
111+
id='Base.Header.navbar.GlobalNavBar.analytics'
112+
defaultMessage='Analytics'
113+
/>
114+
<div className={classes.externalLinkIcon}>
115+
<LaunchIcon style={{ fontSize: 15 }} />
116+
</div>
117+
</div>
118+
</GlobalNavLink>
119+
</a>
120+
)}
92121
</Box>
93122
);
94123
}

features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/components/Shared/CustomIcon.jsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,45 @@ export default function CustomIcon(props) {
313313

314314
</svg>
315315
);
316+
} else if (icon === 'analytics') {
317+
return (
318+
<svg
319+
width={width}
320+
height={height}
321+
className={className}
322+
stroke={strokeColor}
323+
viewBox='0 0 18 18'
324+
version='1.1'
325+
xmlns='http://www.w3.org/2000/svg'
326+
>
327+
<g id='API' stroke='none' strokeWidth='1' fill='none' fillRule='evenodd' opacity='1'>
328+
<g
329+
id='API-UI-kit'
330+
transform='translate(-74.000000, -2031.000000)'
331+
fill={strokeColor}
332+
fillRule='nonzero'
333+
>
334+
<g id='Icon/Feedback' transform='translate(74.000000, 2031.000000)'>
335+
<path
336+
d={'M8.66176471,2.55 L8.66176471,9.38823529 L15.5,9.38823529 L15.5,10.0481286'
337+
+ ' L15.499,10.05 L15.5,10.05 C15.5,14.1921356 12.1421356,17.55 8,17.55'
338+
+ ' C3.85786438,17.55 0.5,14.1921356 0.5,10.05 C0.5,5.98908272'
339+
+ ' 3.72747441,2.68198248 7.75726895,2.55385357 L8,2.55 L8,2.554 L8.00903915,2.55'
340+
+ ' L8.66176471,2.55 Z M7.33796089,3.90859481 C4.23810015,4.23892283'
341+
+ ' 1.82352941,6.86248481 1.82352941,10.05 C1.82352941,13.4611705 4.58882949,16.2264706'
342+
+ ' 8,16.2264706 C11.1875152,16.2264706 13.8110772,13.8118998 14.1414052,10.7120391'
343+
+ ' L7.33823529,10.7117647 L7.33796089,3.90859481 Z M10.0010048,0.558320951'
344+
+ ' C13.895699,1.01522273 16.9853252,4.10513282 17.4417922,7.99996001 L10,8'
345+
+ ' L10.0002117,1 L10.001,0.999320951 L10.0010048,0.558320951 Z M11.356084,2.40639903'
346+
+ ' L11.3542172,6.64487537 L15.5937793,6.64441498 C14.8896237,4.67352548'
347+
+ ' 13.3269046,3.11069949 11.356084,2.40639903 Z'}
348+
id='Combined-Shape'
349+
/>
350+
</g>
351+
</g>
352+
</g>
353+
</svg>
354+
);
316355
}
317356
return null;
318357
}

features/apimgt/org.wso2.carbon.apimgt.publisher.feature/src/main/resources/publisher/source/src/app/data/defaultTheme.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ export default {
127127
leftMenuIconSize: 20,
128128
leftMenuIconMainSize: 52,
129129
leftMenuTextStyle: 'capitalize',
130+
leftMenuAnalytics: {
131+
enable: true,
132+
link: 'http://analytics.choreo.dev/setup',
133+
},
130134
resourceChipColors: { // https://github.com/swagger-api/swagger-ui/blob/master/src/style/_variables.scss#L45-L52
131135
get: '#61affe',
132136
post: '#49cc90',

0 commit comments

Comments
 (0)