Skip to content

Commit ae7e5b0

Browse files
author
Jessica Wang
committed
CLOUDSTACK-1065: cloudstack UI - AWS Style Regions - set current region (whose end point matches current URL) to region button and region dropdown on top menu.
1 parent 918a7c7 commit ae7e5b0

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

ui/scripts/regions.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
data: regions ? regions : [
3030
{ id: -1, name: '(Default)' }
3131
],
32-
activeRegionID: cloudStack.context.users.regionid ?
33-
cloudStack.context.users.regionid : 1
32+
activeRegionID: cloudStack.context.users[0].regionid
3433
});
3534
}
3635
});

ui/scripts/ui-custom/regions.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,28 @@
2929
var data = args.data;
3030
var activeRegionID = args.activeRegionID;
3131

32+
var currentRegion;
3233
$(data).each(function() {
3334
var region = this;
3435
var regionName = region.name;
3536
var $li = $('<li>').append($('<span>').html(_s(region.name)));
3637

3738
$li.data('region-data', region);
38-
39+
40+
if(document.location.href == region.endpoint) {
41+
currentRegion = region;
42+
$li.addClass('active');
43+
}
44+
/*
3945
if (region.id == activeRegionID) {
4046
$li.addClass('active');
4147
}
42-
43-
$regionSwitcherButton.find('.title')
44-
.html(regionName)
45-
.attr('title', regionName);
46-
47-
$regionList.append($li);
48+
*/
49+
50+
$regionList.append($li);
4851
});
52+
53+
$regionSwitcherButton.find('.title').html(_s(currentRegion.name)).attr('title', _s(currentRegion.name));
4954
}
5055
}
5156
});

0 commit comments

Comments
 (0)