Skip to content

Commit de2668a

Browse files
authored
Added section for promoted packages in the back-office. (#11947)
* Added section for promoted packages in the back-office. * Updates from PR review.
1 parent a34e278 commit de2668a

File tree

5 files changed

+92
-56
lines changed

5 files changed

+92
-56
lines changed

src/Umbraco.Web.UI.Client/src/common/resources/ourpackagerrepository.resource.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,21 @@ function ourPackageRepositoryResource($q, $http, umbDataFormatter, umbRequestHel
3636
$http.get(baseurl + "?pageIndex=0&pageSize=" + maxResults + "&category=" + category + "&order=Popular&version=" + Umbraco.Sys.ServerVariables.application.version),
3737
'Failed to query packages');
3838
},
39-
39+
40+
getPromoted: function (maxResults, category) {
41+
42+
if (maxResults === undefined) {
43+
maxResults = 20;
44+
}
45+
if (category === undefined) {
46+
category = "";
47+
}
48+
49+
return umbRequestHelper.resourcePromise(
50+
$http.get(baseurl + "?pageIndex=0&pageSize=" + maxResults + "&category=" + category + "&order=Popular&version=" + Umbraco.Sys.ServerVariables.application.version + "&onlyPromoted=true"),
51+
'Failed to query packages');
52+
},
53+
4054
search: function (pageIndex, pageSize, orderBy, category, query, canceler) {
4155

4256
var httpConfig = {};

src/Umbraco.Web.UI.Client/src/views/packages/views/repo.controller.js

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(function () {
22
"use strict";
33

4-
function PackagesRepoController($scope, $timeout, ourPackageRepositoryResource, $q, packageResource, localStorageService, localizationService) {
4+
function PackagesRepoController($scope, $timeout, ourPackageRepositoryResource, $q, localizationService) {
55

66
var vm = this;
77

@@ -24,6 +24,8 @@
2424
vm.closeLightbox = closeLightbox;
2525
vm.search = search;
2626
vm.installCompleted = false;
27+
vm.highlightedPackageCollections = [];
28+
vm.labels = {};
2729

2830
var defaultSort = "Latest";
2931
var currSort = defaultSort;
@@ -46,28 +48,38 @@
4648
function init() {
4749

4850
vm.loading = true;
49-
50-
$q.all([
51-
ourPackageRepositoryResource.getCategories()
52-
.then(function (cats) {
53-
vm.categories = cats.filter(function (cat) {
54-
return cat.name !== "Umbraco Pro";
51+
localizationService.localizeMany(["packager_packagesPopular", "packager_packagesPromoted"])
52+
.then(function (labels) {
53+
vm.labels.popularPackages = labels[0];
54+
vm.labels.promotedPackages = labels[1];
55+
56+
var popularPackages, promotedPackages;
57+
$q.all([
58+
ourPackageRepositoryResource.getCategories()
59+
.then(function (cats) {
60+
vm.categories = cats.filter(function (cat) {
61+
return cat.name !== "Umbraco Pro";
62+
});
63+
}),
64+
ourPackageRepositoryResource.getPopular(10)
65+
.then(function (pack) {
66+
popularPackages = { title: vm.labels.popularPackages, packages: pack.packages };
67+
}),
68+
ourPackageRepositoryResource.getPromoted(20)
69+
.then(function (pack) {
70+
promotedPackages = { title: vm.labels.promotedPackages, packages: pack.packages };
71+
}),
72+
ourPackageRepositoryResource.search(vm.pagination.pageNumber - 1, vm.pagination.pageSize, currSort)
73+
.then(function (pack) {
74+
vm.packages = pack.packages;
75+
vm.pagination.totalPages = Math.ceil(pack.total / vm.pagination.pageSize);
76+
})
77+
])
78+
.then(function () {
79+
vm.highlightedPackageCollections = [popularPackages, promotedPackages];
80+
vm.loading = false;
5581
});
56-
}),
57-
ourPackageRepositoryResource.getPopular(8)
58-
.then(function (pack) {
59-
vm.popular = pack.packages;
60-
}),
61-
ourPackageRepositoryResource.search(vm.pagination.pageNumber - 1, vm.pagination.pageSize, currSort)
62-
.then(function (pack) {
63-
vm.packages = pack.packages;
64-
vm.pagination.totalPages = Math.ceil(pack.total / vm.pagination.pageSize);
65-
})
66-
])
67-
.then(function () {
68-
vm.loading = false;
6982
});
70-
7183
}
7284

7385
function selectCategory(selectedCategory, categories) {
@@ -96,10 +108,15 @@
96108

97109
currSort = defaultSort;
98110

111+
var popularPackages, promotedPackages;
99112
$q.all([
100-
ourPackageRepositoryResource.getPopular(8, searchCategory)
113+
ourPackageRepositoryResource.getPopular(10, searchCategory)
114+
.then(function (pack) {
115+
popularPackages = { title: vm.labels.popularPackages, packages: pack.packages };
116+
}),
117+
ourPackageRepositoryResource.getPromoted(20, searchCategory)
101118
.then(function (pack) {
102-
vm.popular = pack.packages;
119+
promotedPackages = { title: vm.labels.promotedPackages, packages: pack.packages };
103120
}),
104121
ourPackageRepositoryResource.search(vm.pagination.pageNumber - 1, vm.pagination.pageSize, currSort, searchCategory, vm.searchQuery)
105122
.then(function (pack) {
@@ -109,6 +126,7 @@
109126
})
110127
])
111128
.then(function () {
129+
vm.highlightedPackageCollections = [popularPackages, promotedPackages];
112130
vm.loading = false;
113131
});
114132
}

src/Umbraco.Web.UI.Client/src/views/packages/views/repo.html

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,46 +36,48 @@
3636

3737
<div ng-show="vm.loading === false">
3838

39-
<div class="umb-packages-section" ng-if="vm.searchQuery == '' && vm.popular.length > 0">
40-
<h4><strong><localize key="packager_packagesPopular">Popular</localize></strong></h4>
41-
<div class="umb-packages">
42-
43-
<div class="umb-package" ng-repeat="package in vm.popular">
44-
<button type="button" class="umb-package-link" ng-click="vm.showPackageDetails(package)">
45-
46-
<div class="flex flex-column">
47-
<div class="umb-package-icon">
48-
<img ng-src="{{package.icon}}" alt="" />
49-
</div>
39+
<div ng-repeat="highlightedPackageCollection in vm.highlightedPackageCollections">
40+
<div class="umb-packages-section" ng-if="vm.searchQuery == '' && highlightedPackageCollection.packages.length > 0">
41+
<h4><strong>{{highlightedPackageCollection.title}}</strong></h4>
42+
<div class="umb-packages">
5043

51-
<div class="umb-package-info">
52-
<div class="umb-package-name">{{package.name}}</div>
53-
<div class="umb-package-description">{{package.excerpt | limitTo: 40}}<span ng-if="package.excerpt > (package.excerpt | limitTo: 40)">...</span></div>
44+
<div class="umb-package" ng-repeat="package in highlightedPackageCollection.packages">
45+
<button type="button" class="umb-package-link" ng-click="vm.showPackageDetails(package)">
5446

55-
<div class="umb-package-numbers">
56-
<small class="umb-package-downloads">
57-
<umb-icon icon="icon-download-alt"></umb-icon>
58-
<strong>{{package.downloads}}</strong>
59-
</small>
60-
<small class="umb-package-likes">
61-
<umb-icon icon="icon-hearts" class="icon-hearts"></umb-icon>
62-
<strong>{{package.likes}}</strong>
63-
</small>
47+
<div class="flex flex-column">
48+
<div class="umb-package-icon">
49+
<img ng-src="{{package.icon}}" alt="" />
6450
</div>
65-
<div class="umb-package-cloud">
66-
<div ng-if="package.certifiedToWorkOnUmbracoCloud">
67-
<umb-icon icon="icon-cloud" class="icon-cloud"></umb-icon>
68-
<span><localize key="packager_verifiedToWorkOnUmbracoCloud">Verified to work on Umbraco Cloud</localize></span>
51+
52+
<div class="umb-package-info">
53+
<div class="umb-package-name">{{package.name}}</div>
54+
<div class="umb-package-description">{{package.excerpt | limitTo: 40}}<span ng-if="package.excerpt > (package.excerpt | limitTo: 40)">...</span></div>
55+
56+
<div class="umb-package-numbers">
57+
<small class="umb-package-downloads">
58+
<umb-icon icon="icon-download-alt"></umb-icon>
59+
<strong>{{package.downloads}}</strong>
60+
</small>
61+
<small class="umb-package-likes">
62+
<umb-icon icon="icon-hearts" class="icon-hearts"></umb-icon>
63+
<strong>{{package.likes}}</strong>
64+
</small>
65+
</div>
66+
<div class="umb-package-cloud">
67+
<div ng-if="package.certifiedToWorkOnUmbracoCloud">
68+
<umb-icon icon="icon-cloud" class="icon-cloud"></umb-icon>
69+
<span><localize key="packager_verifiedToWorkOnUmbracoCloud">Verified to work on Umbraco Cloud</localize></span>
70+
</div>
6971
</div>
70-
</div>
7172

73+
</div>
7274
</div>
73-
</div>
7475

75-
</button>
76-
</div> <!-- end package -->
76+
</button>
77+
</div> <!-- end package -->
7778

78-
</div> <!-- end packages -->
79+
</div> <!-- end packages -->
80+
</div>
7981
</div>
8082

8183
<div class="umb-packages-section" ng-if="vm.packages.length > 0">

src/Umbraco.Web.UI/umbraco/config/lang/en.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
12921292
<key alias="packageNoResultsDescription">Please try searching for another package or browse through the categories
12931293
</key>
12941294
<key alias="packagesPopular">Popular</key>
1295+
<key alias="packagesPromoted">Promoted</key>
12951296
<key alias="packagesNew">New releases</key>
12961297
<key alias="packageHas">has</key>
12971298
<key alias="packageKarmaPoints">karma points</key>

src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
13101310
<key alias="packageNoResultsDescription">Please try searching for another package or browse through the categories
13111311
</key>
13121312
<key alias="packagesPopular">Popular</key>
1313+
<key alias="packagesPromoted">Promoted</key>
13131314
<key alias="packagesNew">New releases</key>
13141315
<key alias="packageHas">has</key>
13151316
<key alias="packageKarmaPoints">karma points</key>

0 commit comments

Comments
 (0)