Skip to content

Commit 9f15b0a

Browse files
author
OpenShift Bot
authored
Merge pull request #1508 from jeff-phillips-18/tour
Merged by openshift-bot
2 parents 513de5a + 660bb1f commit 9f15b0a

File tree

5 files changed

+113
-24
lines changed

5 files changed

+113
-24
lines changed

app/scripts/controllers/landingPage.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,32 @@
33
angular.module('openshiftConsole')
44
.controller('LandingPageController',
55
function($scope,
6+
$rootScope,
67
AuthService,
78
Catalog,
89
Constants,
910
Navigate,
1011
NotificationsService,
11-
RecentlyViewedServiceItems) {
12+
RecentlyViewedServiceItems,
13+
GuidedTourService,
14+
$timeout,
15+
$routeParams,
16+
$location) {
17+
var tourConfig = _.get(Constants, 'GUIDED_TOURS.landing_page_tour');
18+
var tourEnabled = tourConfig && tourConfig.enabled && tourConfig.steps;
19+
1220
$scope.saasOfferings = Constants.SAAS_OFFERINGS;
1321

1422
$scope.viewMembership = function(project) {
1523
Navigate.toProjectMembership(project.metadata.name);
1624
};
1725

26+
if (tourEnabled) {
27+
$scope.startGuidedTour = function (onDone) {
28+
GuidedTourService.startTour(tourConfig.steps, onDone);
29+
};
30+
}
31+
1832
// Currently this is the only page showing notifications, clear any that came previous pages.
1933
// Once all pages show notifications this should be removed.
2034
NotificationsService.clearNotifications();
@@ -39,6 +53,7 @@ angular.module('openshiftConsole')
3953
var includeTemplates = !_.get(Constants, 'ENABLE_TECH_PREVIEW_FEATURE.template_service_broker');
4054
Catalog.getCatalogItems(includeTemplates).then(function(items) {
4155
$scope.catalogItems = items;
56+
dataLoaded();
4257
});
4358
});
4459

@@ -47,4 +62,33 @@ angular.module('openshiftConsole')
4762
// add the item to recently-viewed. No-op if the dialog is not open.
4863
addTemplateToRecentlyViewed();
4964
});
65+
66+
function dataLoaded() {
67+
if (!tourEnabled) {
68+
return;
69+
}
70+
71+
if ($routeParams.startTour) {
72+
$timeout(function() {
73+
$scope.startGuidedTour(resetRouteParams);
74+
}, 500);
75+
} else if (_.get(tourConfig, 'auto_launch')) {
76+
// Check if this is the first time this user has visited the home page, if so launch the tour
77+
var viewedHomePageKey = "openshift/viewedHomePage/" + $rootScope.user.metadata.name;
78+
if (localStorage.getItem(viewedHomePageKey) !== 'true') {
79+
$timeout(function() {
80+
localStorage.setItem(viewedHomePageKey, 'true');
81+
$scope.startGuidedTour();
82+
}, 500);
83+
}
84+
}
85+
}
86+
87+
function resetRouteParams() {
88+
// Reset the route params in the next digest cycle
89+
$timeout(function() {
90+
$location.replace();
91+
$location.search('startTour', null);
92+
});
93+
}
5094
});

app/scripts/extensions/nav/helpDropdown.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,38 @@ angular.module('openshiftConsole')
66
.run(function(extensionRegistry) {
77
extensionRegistry
88
.add('nav-help-dropdown', function() {
9-
return [
9+
var options = [];
10+
options.push(
1011
{
1112
type: 'dom',
1213
node: '<li><a target="_blank" href="{{\'default\' | helpLink}}">Documentation</a></li>'
13-
},
14+
}
15+
);
16+
17+
if (_.get(window, 'OPENSHIFT_CONSTANTS.ENABLE_TECH_PREVIEW_FEATURE.service_catalog_landing_page')) {
18+
var tourConfig = _.get(window, 'OPENSHIFT_CONSTANTS.GUIDED_TOURS.landing_page_tour');
19+
if (tourConfig && tourConfig.enabled && tourConfig.steps) {
20+
options.push(
21+
{
22+
type: 'dom',
23+
node: '<li><a href="./?startTour=true">Tour Home Page</a></li>'
24+
}
25+
);
26+
}
27+
}
28+
29+
options.push(
1430
{
1531
type: 'dom',
1632
node: '<li><a href="command-line">Command Line Tools</a></li>'
17-
},
33+
}
34+
);
35+
options.push(
1836
{
1937
type: 'dom',
2038
node: '<li><a href="about">About</a></li>'
2139
}
22-
];
23-
});
40+
);
41+
return options;
42+
})
2443
});

app/views/landing-page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<services-view catalog-items="catalogItems" base-project-url="project"></services-view>
2323
</landingbody>
2424
<landingside>
25-
<projects-summary base-project-url="project" projects-url="projects" view-edit-membership="viewMembership" catalog-items="catalogItems"></projects-summary>
25+
<projects-summary base-project-url="project" projects-url="projects" start-tour="startGuidedTour" view-edit-membership="viewMembership" catalog-items="catalogItems"></projects-summary>
2626
</landingside>
2727
</landing-page>
2828
</div><!-- /middle-content -->

dist/scripts/scripts.js

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4652,25 +4652,43 @@ _.set(this, "selectedTab.networking", !0), b(this);
46524652
}
46534653
}
46544654
};
4655-
}), angular.module("openshiftConsole").controller("LandingPageController", [ "$scope", "AuthService", "Catalog", "Constants", "Navigate", "NotificationsService", "RecentlyViewedServiceItems", function(a, b, c, d, e, f, g) {
4656-
a.saasOfferings = d.SAAS_OFFERINGS, a.viewMembership = function(a) {
4657-
e.toProjectMembership(a.metadata.name);
4658-
}, f.clearNotifications();
4659-
var h = function() {
4655+
}), angular.module("openshiftConsole").controller("LandingPageController", [ "$scope", "$rootScope", "AuthService", "Catalog", "Constants", "Navigate", "NotificationsService", "RecentlyViewedServiceItems", "GuidedTourService", "$timeout", "$routeParams", "$location", function(a, b, c, d, e, f, g, h, i, j, k, l) {
4656+
function m() {
4657+
if (p) if (k.startTour) j(function() {
4658+
a.startGuidedTour(n);
4659+
}, 500); else if (_.get(o, "auto_launch")) {
4660+
var c = "openshift/viewedHomePage/" + b.user.metadata.name;
4661+
"true" !== localStorage.getItem(c) && j(function() {
4662+
localStorage.setItem(c, "true"), a.startGuidedTour();
4663+
}, 500);
4664+
}
4665+
}
4666+
function n() {
4667+
j(function() {
4668+
l.replace(), l.search("startTour", null);
4669+
});
4670+
}
4671+
var o = _.get(e, "GUIDED_TOURS.landing_page_tour"), p = o && o.enabled && o.steps;
4672+
a.saasOfferings = e.SAAS_OFFERINGS, a.viewMembership = function(a) {
4673+
f.toProjectMembership(a.metadata.name);
4674+
}, p && (a.startGuidedTour = function(a) {
4675+
i.startTour(o.steps, a);
4676+
}), g.clearNotifications();
4677+
var q = function() {
46604678
var b = _.get(a, "template.metadata.uid");
4661-
b && g.addItem(b);
4679+
b && h.addItem(b);
46624680
};
46634681
a.templateSelected = function(b) {
46644682
a.template = b;
46654683
}, a.templateDialogClosed = function() {
4666-
h(), a.template = null;
4667-
}, b.withUser().then(function() {
4668-
var b = !_.get(d, "ENABLE_TECH_PREVIEW_FEATURE.template_service_broker");
4669-
c.getCatalogItems(b).then(function(b) {
4670-
a.catalogItems = b;
4684+
q(), a.template = null;
4685+
}, c.withUser().then(function() {
4686+
var b = !_.get(e, "ENABLE_TECH_PREVIEW_FEATURE.template_service_broker");
4687+
d.getCatalogItems(b).then(function(b) {
4688+
a.catalogItems = b, m();
46714689
});
46724690
}), a.$on("$destroy", function() {
4673-
h();
4691+
q();
46744692
});
46754693
} ]), angular.module("openshiftConsole").controller("ProjectsController", [ "$scope", "$filter", "$location", "$route", "$timeout", "AlertMessageService", "AuthService", "DataService", "KeywordService", "Logger", "ProjectsService", function(a, b, c, d, e, f, g, h, i, j, k) {
46764694
var l, m, n = [], o = [];
@@ -15612,16 +15630,24 @@ url:l
1561215630
} ]), hawtioPluginLoader.addModule(a);
1561315631
}(), angular.module("openshiftConsole").run([ "extensionRegistry", function(a) {
1561415632
a.add("nav-help-dropdown", function() {
15615-
return [ {
15633+
var a = [];
15634+
if (a.push({
1561615635
type:"dom",
1561715636
node:'<li><a target="_blank" href="{{\'default\' | helpLink}}">Documentation</a></li>'
15618-
}, {
15637+
}), _.get(window, "OPENSHIFT_CONSTANTS.ENABLE_TECH_PREVIEW_FEATURE.service_catalog_landing_page")) {
15638+
var b = _.get(window, "OPENSHIFT_CONSTANTS.GUIDED_TOURS.landing_page_tour");
15639+
b && b.enabled && b.steps && a.push({
15640+
type:"dom",
15641+
node:'<li><a href="./?startTour=true">Tour Home Page</a></li>'
15642+
});
15643+
}
15644+
return a.push({
1561915645
type:"dom",
1562015646
node:'<li><a href="command-line">Command Line Tools</a></li>'
15621-
}, {
15647+
}), a.push({
1562215648
type:"dom",
1562315649
node:'<li><a href="about">About</a></li>'
15624-
} ];
15650+
}), a;
1562515651
});
1562615652
} ]), angular.module("openshiftConsole").run([ "extensionRegistry", function(a) {
1562715653
a.add("nav-user-dropdown", function() {

dist/scripts/templates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10421,7 +10421,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1042110421
"<services-view catalog-items=\"catalogItems\" base-project-url=\"project\"></services-view>\n" +
1042210422
"</landingbody>\n" +
1042310423
"<landingside>\n" +
10424-
"<projects-summary base-project-url=\"project\" projects-url=\"projects\" view-edit-membership=\"viewMembership\" catalog-items=\"catalogItems\"></projects-summary>\n" +
10424+
"<projects-summary base-project-url=\"project\" projects-url=\"projects\" start-tour=\"startGuidedTour\" view-edit-membership=\"viewMembership\" catalog-items=\"catalogItems\"></projects-summary>\n" +
1042510425
"</landingside>\n" +
1042610426
"</landing-page>\n" +
1042710427
"</div>\n" +

0 commit comments

Comments
 (0)