Skip to content

Commit

Permalink
Ensure both Wiki and Configuration can't be active at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Sep 16, 2013
1 parent d90ed10 commit debb0b6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions hawtio-web/src/main/webapp/app/core/js/workspace.ts
Expand Up @@ -375,6 +375,19 @@ class Workspace {
});
}

private getStrippedPathName():String {
var pathName = Core.trimLeading((this.$location.path() || '/'), "#");
pathName = Core.trimLeading(pathName, "/");
return pathName;
}

public linkContains(...words:String[]):bool {
var pathName = this.getStrippedPathName();
return words.all((word) => {
return pathName.has(word);
});
}

/**
* Returns true if the given link is active. The link can omit the leading # or / if necessary.
* The query parameters of the URL are ignored in the comparison.
Expand All @@ -384,8 +397,7 @@ class Workspace {
*/
public isLinkActive(href:string):bool {
// lets trim the leading slash
var pathName = Core.trimLeading((this.$location.path() || '/'), "#");
pathName = Core.trimLeading(pathName, "/");
var pathName = this.getStrippedPathName();

var link = Core.trimLeading(href, "#");
link = Core.trimLeading(link, "/");
Expand All @@ -401,6 +413,7 @@ class Workspace {
}
}


/**
* Returns true if the tab query parameter is active or the URL starts with the given path
*/
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/fabricPlugin.ts
Expand Up @@ -69,7 +69,7 @@ module Fabric {
href: () => {
return "#/wiki/branch/" + Fabric.activeVersion($location) + "/view/fabric/profiles";
},
isActive: (workspace: Workspace) => workspace.isLinkActive("wiki")
isActive: (workspace: Workspace) => workspace.isLinkActive("wiki") && workspace.linkContains("fabric", "profiles")
});

helpRegistry.addDevDoc("fabric", 'app/fabric/doc/developer.md');
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/wiki/js/wikiPlugin.ts
Expand Up @@ -63,7 +63,7 @@ module Wiki {
title: "View and edit wiki pages",
isValid: (workspace:Workspace) => Wiki.isWikiEnabled(workspace, jolokia, localStorage),
href: () => "#/wiki/view",
isActive: (workspace:Workspace) => workspace.isLinkActive("/wiki")
isActive: (workspace:Workspace) => workspace.isLinkActive("/wiki") && !workspace.linkContains("fabric", "profiles")
});
});

Expand Down

0 comments on commit debb0b6

Please sign in to comment.