Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed up the links and wiki due to fabric profile layout changes for #…
  • Loading branch information
jstrachan committed Sep 12, 2013
1 parent c2be210 commit c6bbdf7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
Expand Up @@ -44,7 +44,7 @@ <h2 class="inline">Profile: {{row.id}}</h2>
<ul class="unstyled">
<li ng-repeat="profile in row.parentIds">
<i class="red clickable icon-remove" title="Remove parent {{profile}}" ng-click="removeParentProfile(profile)"></i>
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profile}}{{hash}}">{{profile}}</a>
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profilePath(profile)}}{{hash}}">{{profile}}</a>
</li>
<li>
<i class="clickable icon-edit" ng-click="showChangeParentsDialog()" title="Change parent profiles"></i>
Expand All @@ -56,7 +56,7 @@ <h2 class="inline">Profile: {{row.id}}</h2>
<dd>
<ul class="unstyled">
<li ng-repeat="profile in row.childIds">
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profile}}{{hash}}">{{profile}}</a>
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profilePath(profile)}}{{hash}}">{{profile}}</a>
</li>
</ul>
</dd>
Expand Down
Expand Up @@ -37,7 +37,7 @@ <h2 class="inline">Profile: {{row.id}}</h2>
<ul class="unstyled">
<li ng-repeat="profile in row.parentIds">
<i class="red clickable icon-remove" title="Remove parent {{profile}}" ng-click="removeParentProfile(profile)"></i>
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profile}}{{hash}}">{{profile}}</a>
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profilePath(profile)}}{{hash}}">{{profile}}</a>
</li>
<li>
<i class="clickable icon-edit" ng-click="showChangeParentsDialog()" title="Change parent profiles"></i>
Expand All @@ -49,7 +49,7 @@ <h2 class="inline">Profile: {{row.id}}</h2>
<dd>
<ul class="unstyled">
<li ng-repeat="profile in row.childIds">
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profile}}{{hash}}">{{profile}}</a>
<a href="#/wiki/branch/{{versionId}}/view/fabric/profiles/{{profilePath(profile)}}{{hash}}">{{profile}}</a>
</li>
</ul>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/fabric/html/profiles.html
Expand Up @@ -5,7 +5,7 @@
<fieldset>
<div class="btn-group inline-block">
<a href="" title="Create new Profile" class="btn" ng-click="createProfileDialog = true"><i class="icon-plus"></i></a>
<a ng-href="#/wiki/branch/{{version.id}}/view/{{selected[0].id}}" class="btn" ng-disabled="selected.length == 0" ng-show="hasFabricWiki()"
<a ng-href="#/wiki/branch/{{version.id}}/view/{{profilePath(selected[0].id)}}" class="btn" ng-disabled="selected.length == 0" ng-show="hasFabricWiki()"
title="View, edit or create configuration files for the profiles in this version"><i class="icon-edit"></i></a>
<a href="" title="Delete selected Profiles" class="btn" ng-disabled="selected.length == 0 || selectedHasContainers()" ng-click="deleteProfileDialog = true"><i class="icon-minus"></i></a>
</div>
Expand Down
9 changes: 7 additions & 2 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
Expand Up @@ -23,16 +23,21 @@ module Fabric {
var answer = null;
if (pageId.has(fabricTopLevel) && pageId !== fabricTopLevel) {
var profileId = pageId.remove(fabricTopLevel);
if (!profileId.has("/") && (!Fabric.useDirectoriesInGit || profileId.endsWith(profileSuffix))) {
if ((Fabric.useDirectoriesInGit || !profileId.has("/")) && (!Fabric.useDirectoriesInGit || profileId.endsWith(profileSuffix))) {
if (Fabric.useDirectoriesInGit) {
profileId = Core.trimTrailing(profileId, profileSuffix);
profileId = profileId.replace(/\//g, "-");
}
answer = profileId;
}
}
return answer;
}

export function profilePath(profileId) {
return profileId.replace(/-/g, "/") + profileSuffix;
}

export function initScope($scope, workspace) {
$scope.hasFabricWiki = () => {
return Git.isGitMBeanFabric(workspace);
Expand All @@ -41,7 +46,7 @@ module Fabric {

export function gotoProfile(workspace, jolokia, localStorage, $location, versionId, profile) {
if (Wiki.isWikiEnabled(workspace, jolokia, localStorage)) {
$location.url("/wiki/branch/" + versionId + "/view/fabric/profiles/" + profile.id);
$location.url("/wiki/branch/" + versionId + "/view/fabric/profiles/" + Fabric.profilePath(profile.id));
} else {
$location.url("/fabric/profile/" + versionId + "/" + profile.id);
}
Expand Down
4 changes: 3 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/profile.ts
Expand Up @@ -28,6 +28,8 @@ module Fabric {
$scope.newThingName = '';
$scope.selectedParents = [];

$scope.profilePath = Fabric.profilePath;

$scope.$watch('versionId', (newValue, oldValue) => {
Core.unregister(jolokia, $scope);
if (angular.isDefined($scope.versionId) && angular.isDefined($scope.profileId)) {
Expand Down Expand Up @@ -213,7 +215,7 @@ module Fabric {
var version = $scope.row.version;
$scope.configFolderLink = null;
if ($scope.hasFabricWiki() && id && version) {
$scope.configFolderLink = "#/wiki/branch/" + version + "/view/fabric/profiles/" + id;
$scope.configFolderLink = "#/wiki/branch/" + version + "/view/fabric/profiles/" + Fabric.profilePath(id);
}
Core.$apply($scope);
}
Expand Down
1 change: 1 addition & 0 deletions hawtio-web/src/test/specs/SpecRunner.html
Expand Up @@ -100,6 +100,7 @@


<!-- include spec files here... -->
<script type="text/javascript" src="spec/FabricSpec.js"></script>
<script type="text/javascript" src="spec/DozerSpec.js"></script>
<script type="text/javascript" src="spec/CamelSpec.js"></script>
<script type="text/javascript" src="spec/FormsSpec.js"></script>
Expand Down
14 changes: 14 additions & 0 deletions hawtio-web/src/test/specs/spec/FabricSpec.js
@@ -0,0 +1,14 @@
describe("Fabric", function () {

angular.forEach({
"dummy": null,
"fabric/profiles/foo.profile": "foo",
"fabric/profiles/example/camel/fabric.profile": "example-camel-fabric"
}, function(expected, path) {
it("converting wiki path " + path + " to correct profile ID", function () {
var result = Fabric. pagePathToProfileId(path);
expect(result).toEqual(expected);
});
});

});

0 comments on commit c6bbdf7

Please sign in to comment.