aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/nav/links-mixin.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/nav/links-mixin.jsx')
-rw-r--r--server/sonar-web/src/main/js/apps/nav/links-mixin.jsx16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/nav/links-mixin.jsx b/server/sonar-web/src/main/js/apps/nav/links-mixin.jsx
new file mode 100644
index 00000000000..e807c5a26d0
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/nav/links-mixin.jsx
@@ -0,0 +1,16 @@
+import React from 'react';
+
+export default {
+ activeLink(url) {
+ return window.location.pathname.indexOf(window.baseUrl + url) === 0 ? 'active' : null;
+ },
+
+ renderLink(url, title, highlightUrl = url) {
+ let fullUrl = window.baseUrl + url;
+ return (
+ <li key={highlightUrl} className={this.activeLink(highlightUrl)}>
+ <a href={fullUrl}>{title}</a>
+ </li>
+ );
+ }
+};