Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/upgrade xbk libraries #27

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<PackageVersion Include="GraphQL" Version="7.8.0" />
<PackageVersion Include="GraphQL.Client" Version="6.0.2" />
<PackageVersion Include="GraphQL.Client.Serializer.Newtonsoft" Version="6.0.2" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.3.2" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.3.2" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="29.3.2" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="29.3.2" />
<PackageVersion Include="Kentico.Xperience.Core" Version="29.3.2" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Core" Version="29.5.3" />
<PackageVersion Include="Moq.AutoMock" Version="3.5.0" />
<PackageVersion Include="ShopifySharp" Version="6.17.0" />
<PackageVersion Include="ShopifySharp.Extensions.DependencyInjection" Version="1.6.0" />
Expand Down
2 changes: 1 addition & 1 deletion examples/DancingGoat-Shopify/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"kentico.xperience.dbmanager": {
"version": "28.2.1",
"version": "29.5.3",
"commands": [
"kentico-xperience-dbmanager"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task<ViewViewComponentResult> InvokeAsync(WebPageRelatedItem articl
{
var languageName = currentLanguageRetriever.Get();

var articlesSection = await articlesSectionRepository.GetArticlesSection(articlesSectionItem.WebPageGuid, languageName);
var articlesSection = await articlesSectionRepository.GetArticlesSection(articlesSectionItem.WebPageGuid, languageName, HttpContext.RequestAborted);
if (articlesSection == null)
{
return View("~/Components/ViewComponents/Articles/Default.cshtml", ArticlesSectionViewModel.GetViewModel(null, Enumerable.Empty<ArticleViewModel>(), string.Empty));
Expand All @@ -55,11 +55,11 @@ public async Task<ViewViewComponentResult> InvokeAsync(WebPageRelatedItem articl
var models = new List<ArticleViewModel>();
foreach (var article in articlePages)
{
var model = await ArticleViewModel.GetViewModel(article, urlRetriever, languageName);
var model = await ArticleViewModel.GetViewModel(article, urlRetriever, languageName, HttpContext.RequestAborted);
models.Add(model);
}

var url = (await urlRetriever.Retrieve(articlesSection, languageName)).RelativePath;
var url = (await urlRetriever.Retrieve(articlesSection, languageName, HttpContext.RequestAborted)).RelativePath;

var viewModel = ArticlesSectionViewModel.GetViewModel(articlesSection, models, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
}
else
{
<a href="#" class="ourcoffee-tile-link">
<h2 class="ourcoffee-tile-text center-text">@Model.Name</h2>
<span class="cafe-overlay"> </span>
@if (!string.IsNullOrEmpty(Model.PhotoPath))
{
<img src="@Url.Content(Model.PhotoPath)" alt="@Model.PhotoShortDescription" title="@Model.Name" class="ourcoffee-tile-image" loading="lazy" />
}
</a>
<h2 class="ourcoffee-tile-text center-text">@Model.Name</h2>
<span class="cafe-overlay"> </span>
@if (!string.IsNullOrEmpty(Model.PhotoPath))
{
<img src="@Url.Content(Model.PhotoPath)" alt="@Model.PhotoShortDescription" title="@Model.Name" class="ourcoffee-tile-image" loading="lazy" />
}
}
</div>
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Threading;

using CMS.Websites;

using DancingGoat.Models;

using Kentico.Content.Web.Mvc.Routing;

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewComponents;

Expand All @@ -13,9 +18,37 @@ namespace DancingGoat.ViewComponents
/// </summary>
public class CafeCardSectionViewComponent : ViewComponent
{
public ViewViewComponentResult Invoke(IEnumerable<CafeViewModel> cafes)
private readonly ContactsPageRepository contactsPageRepository;
private readonly IWebPageUrlRetriever webPageUrlRetriever;
private readonly IPreferredLanguageRetriever currentLanguageRetriever;


public CafeCardSectionViewComponent(IPreferredLanguageRetriever currentLanguageRetriever, ContactsPageRepository contactsPageRepository, IWebPageUrlRetriever webPageUrlRetriever)
{
this.currentLanguageRetriever = currentLanguageRetriever;
this.contactsPageRepository = contactsPageRepository;
this.webPageUrlRetriever = webPageUrlRetriever;
}


public async Task<ViewViewComponentResult> InvokeAsync(IEnumerable<CafeViewModel> cafes)
{
return View("~/Components/ViewComponents/CafeCardSection/Default.cshtml", cafes.Take(3));
string languageName = currentLanguageRetriever.Get();
string contactsPagePath = await GetContactsPagePath(languageName, HttpContext.RequestAborted);
var model = new CafeCardSectionViewModel(cafes, contactsPagePath);

return View("~/Components/ViewComponents/CafeCardSection/Default.cshtml", model);
}


private async Task<string> GetContactsPagePath(string languageName, CancellationToken cancellationToken)
{
const string CONTACTS_PAGE_TREE_PATH = "/Contacts";

var contactsPage = await contactsPageRepository.GetContactsPage(CONTACTS_PAGE_TREE_PATH, languageName, cancellationToken);
var url = await webPageUrlRetriever.Retrieve(contactsPage, cancellationToken);

return url.RelativePath;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

using DancingGoat.Models;

namespace DancingGoat.ViewComponents
{
public record CafeCardSectionViewModel(IEnumerable<CafeViewModel> Cafes, string ContactsPagePath)
{
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
@using DancingGoat.Models
@model IEnumerable<CafeViewModel>
@using DancingGoat.ViewComponents
@model CafeCardSectionViewModel

<div class="row cafe-cards">
<div class="title-wrapper">
<h1 class="title-tab">@HtmlLocalizer["Taste our coffee"]</h1>
</div>
<div class="row row--with-cols-padding">
@foreach (var cafe in Model)
@foreach (var cafe in Model.Cafes)
{
<div class="col-md-4">
<vc:cafe cafe="@cafe" />
<a href="@Model.ContactsPagePath" class="ourcoffee-tile-link">
<vc:cafe cafe="@cafe" />
</a>
</div>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public async Task<IViewComponentResult> InvokeAsync()
{
ConsentShortText = (await consent.GetConsentTextAsync(currentLanguage)).ShortText,
ReturnPageUrl = webPageDataContextRetriever.TryRetrieve(out var currentWebPageContext)
? (await urlRetriever.Retrieve(currentWebPageContext.WebPage.WebPageItemID, currentLanguage)).RelativePath
? (await urlRetriever.Retrieve(currentWebPageContext.WebPage.WebPageItemID, currentLanguage, cancellationToken: HttpContext.RequestAborted)).RelativePath
: (HttpContext.Request.PathBase + HttpContext.Request.Path).Value
};

var contact = ContactManagementContext.CurrentContact;
if ((contact != null) && consentAgreementService.IsAgreed(contact, consent))
{
consentModel.IsConsentAgreed = true;
consentModel.PrivacyPageUrl = Url.Content((await urlRetriever.Retrieve(PrivacyPageConstants.PRIVACY_PAGE_TREE_PATH, websiteChannelContext.WebsiteChannelName, currentLanguage)).RelativePath);
consentModel.PrivacyPageUrl = Url.Content((await urlRetriever.Retrieve(PrivacyPageConstants.PRIVACY_PAGE_TREE_PATH, websiteChannelContext.WebsiteChannelName, currentLanguage, cancellationToken: HttpContext.RequestAborted)).RelativePath);
}

return View("~/Components/ViewComponents/TrackingConsent/Default.cshtml", consentModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Kentico.Content.Web.Mvc
@addTagHelper *, XbyKUpdate
@addTagHelper *, DancingGoat
@inject IHtmlLocalizer<SharedResources> HtmlLocalizer
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,22 @@ public async Task<ActionResult> Index(CancellationToken cancellationToken)
private async Task<ContactsIndexViewModel> GetIndexViewModel(ContactsPage contactsPage, CancellationToken cancellationToken)
{
var languageName = currentLanguageRetriever.Get();
var cafes = await cafeRepository.GetCompanyCafes(4, languageName, cancellationToken);
var cafes = (await cafeRepository.GetCafes(0, languageName, cancellationToken)).ToList();
var companyCafes = cafes.Where(c => c.CafeIsCompanyCafe).OrderBy(c => c.CafeName);
var partnerCafes = cafes.Where(c => !c.CafeIsCompanyCafe).OrderBy(c => c.CafeCity);
var contact = await contactRepository.GetContact(languageName, HttpContext.RequestAborted);

return new ContactsIndexViewModel
{
CompanyContact = ContactViewModel.GetViewModel(contact),
CompanyCafes = GetCompanyCafesModel(cafes),
CompanyCafes = GetCafesModel(companyCafes),
PartnerCafes = GetCafesModel(partnerCafes),
WebPage = contactsPage
};
}


private List<CafeViewModel> GetCompanyCafesModel(IEnumerable<Cafe> cafes)
private List<CafeViewModel> GetCafesModel(IEnumerable<Cafe> cafes)
{
return cafes.Select(cafe => CafeViewModel.GetViewModel(cafe)).ToList();
}
Expand Down
Binary file modified examples/DancingGoat-Shopify/Data/Template.zip
Binary file not shown.
186 changes: 93 additions & 93 deletions examples/DancingGoat-Shopify/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
module.exports = function (grunt) {

grunt.initConfig({
clean: {
formBuilder: ['wwwroot/Content/Bundles/Public/formComponents.css', 'wwwroot/Content/Bundles/Public/formComponents.min.css', 'wwwroot/Content/Bundles/Admin/formComponents.css', 'wwwroot/Content/Bundles/Admin/formComponents.min.css',
'wwwroot/Content/Bundles/Public/formComponents.js', 'wwwroot/Content/Bundles/Public/formComponents.min.js'],
pageBuilder: ['wwwroot/Content/Bundles/Public/pageComponents.css', 'wwwroot/Content/Bundles/Public/pageComponents.min.css', 'wwwroot/Content/Bundles/Admin/pageComponents.css', 'wwwroot/Content/Bundles/Admin/pageComponents.min.css',
'wwwroot/Content/Bundles/Public/pageComponents.js', 'wwwroot/Content/Bundles/Public/pageComponents.min.js', 'wwwroot/Content/Bundles/Admin/pageComponents.js', 'wwwroot/Content/Bundles/Admin/pageComponents.min.js']
},

concat: {
formBuilder: {
files: {
// Styles - live site
'wwwroot/Content/Bundles/Public/formComponents.css': ['wwwroot/FormBuilder/Public/**/*.css'],
// Styles - admin
'wwwroot/Content/Bundles/Admin/formComponents.css': ['wwwroot/FormBuilder/Admin/**/*.css'],
// Scripts - live site and admin
'wwwroot/Content/Bundles/Public/formComponents.js': ['wwwroot/FormBuilder/Public/**/*.js']
}
},
pageBuilder: {
files: {
// Styles - live site
'wwwroot/Content/Bundles/Public/pageComponents.css': ['wwwroot/PageBuilder/Public/**/*.css'],
// Styles - admin
'wwwroot/Content/Bundles/Admin/pageComponents.css': ['wwwroot/PageBuilder/Admin/**/*.css'],
// Scripts - live site
'wwwroot/Content/Bundles/Public/pageComponents.js': ['wwwroot/PageBuilder/Public/**/*.js'],
// Scripts - admin
'wwwroot/Content/Bundles/Admin/pageComponents.js': ['wwwroot/PageBuilder/Admin/**/*.js']
}
}
},

cssmin: {
formBuilder: {
files: {
'wwwroot/Content/Bundles/Public/formComponents.min.css': 'wwwroot/Content/Bundles/Public/formComponents.css',
'wwwroot/Content/Bundles/Admin/formComponents.min.css': 'wwwroot/Content/Bundles/Admin/formComponents.css'
}
},
pageBuilder: {
files: {
'wwwroot/Content/Bundles/Public/pageComponents.min.css': ['wwwroot/Content/Bundles/Public/pageComponents.css'],
'wwwroot/Content/Bundles/Admin/pageComponents.min.css': ['wwwroot/Content/Bundles/Admin/pageComponents.css']
}
}
},

terser: {
formBuilder: {
files: {
'wwwroot/Content/Bundles/Public/formComponents.min.js': ['wwwroot/Content/Bundles/Public/formComponents.js']
}
},
pageBuilder: {
files: {
'wwwroot/Content/Bundles/Public/pageComponents.min.js': ['wwwroot/Content/Bundles/Public/pageComponents.js'],
'wwwroot/Content/Bundles/Admin/pageComponents.min.js': ['wwwroot/Content/Bundles/Admin/pageComponents.js']
}
}
},

less: {
development: {
files: {
'wwwroot/Content/Styles/Site.css': 'wwwroot/Content/Styles/Site.less',
'wwwroot/Content/Styles/Landing-page.css': 'wwwroot/Content/Styles/Landing-page.less'
}
}
},
watch: {
styles: {
files: ['wwwroot/Content/Styles/**/*.less'],
tasks: ['less'],
options: {
nospawn: true
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-terser');

grunt.registerTask('formBuilder', ['clean:formBuilder', 'concat:formBuilder', 'cssmin:formBuilder', 'terser:formBuilder']);
grunt.registerTask('pageBuilder', ['clean:pageBuilder', 'concat:pageBuilder', 'cssmin:pageBuilder', 'terser:pageBuilder']);
grunt.registerTask('default', ['less']);
module.exports = function (grunt) {
grunt.initConfig({
clean: {
formBuilder: ['wwwroot/Content/Bundles/Public/formComponents.css', 'wwwroot/Content/Bundles/Public/formComponents.min.css', 'wwwroot/Content/Bundles/Admin/formComponents.css', 'wwwroot/Content/Bundles/Admin/formComponents.min.css',
'wwwroot/Content/Bundles/Public/formComponents.js', 'wwwroot/Content/Bundles/Public/formComponents.min.js'],
pageBuilder: ['wwwroot/Content/Bundles/Public/pageComponents.css', 'wwwroot/Content/Bundles/Public/pageComponents.min.css', 'wwwroot/Content/Bundles/Admin/pageComponents.css', 'wwwroot/Content/Bundles/Admin/pageComponents.min.css',
'wwwroot/Content/Bundles/Public/pageComponents.js', 'wwwroot/Content/Bundles/Public/pageComponents.min.js', 'wwwroot/Content/Bundles/Admin/pageComponents.js', 'wwwroot/Content/Bundles/Admin/pageComponents.min.js']
},
concat: {
formBuilder: {
files: {
// Styles - live site
'wwwroot/Content/Bundles/Public/formComponents.css': ['wwwroot/FormBuilder/Public/**/*.css'],
// Styles - admin
'wwwroot/Content/Bundles/Admin/formComponents.css': ['wwwroot/FormBuilder/Admin/**/*.css'],
// Scripts - live site and admin
'wwwroot/Content/Bundles/Public/formComponents.js': ['wwwroot/FormBuilder/Public/**/*.js']
}
},
pageBuilder: {
files: {
// Styles - live site
'wwwroot/Content/Bundles/Public/pageComponents.css': ['wwwroot/PageBuilder/Public/**/*.css'],
// Styles - admin
'wwwroot/Content/Bundles/Admin/pageComponents.css': ['wwwroot/PageBuilder/Admin/**/*.css'],
// Scripts - live site
'wwwroot/Content/Bundles/Public/pageComponents.js': ['wwwroot/PageBuilder/Public/**/*.js'],
// Scripts - admin
'wwwroot/Content/Bundles/Admin/pageComponents.js': ['wwwroot/PageBuilder/Admin/**/*.js']
}
}
},
cssmin: {
formBuilder: {
files: {
'wwwroot/Content/Bundles/Public/formComponents.min.css': 'wwwroot/Content/Bundles/Public/formComponents.css',
'wwwroot/Content/Bundles/Admin/formComponents.min.css': 'wwwroot/Content/Bundles/Admin/formComponents.css'
}
},
pageBuilder: {
files: {
'wwwroot/Content/Bundles/Public/pageComponents.min.css': ['wwwroot/Content/Bundles/Public/pageComponents.css'],
'wwwroot/Content/Bundles/Admin/pageComponents.min.css': ['wwwroot/Content/Bundles/Admin/pageComponents.css']
}
}
},
terser: {
formBuilder: {
files: {
'wwwroot/Content/Bundles/Public/formComponents.min.js': ['wwwroot/Content/Bundles/Public/formComponents.js']
}
},
pageBuilder: {
files: {
'wwwroot/Content/Bundles/Public/pageComponents.min.js': ['wwwroot/Content/Bundles/Public/pageComponents.js'],
'wwwroot/Content/Bundles/Admin/pageComponents.min.js': ['wwwroot/Content/Bundles/Admin/pageComponents.js']
}
}
},
less: {
development: {
files: {
'wwwroot/Content/Styles/Site.css': 'wwwroot/Content/Styles/Site.less',
'wwwroot/Content/Styles/Landing-page.css': 'wwwroot/Content/Styles/Landing-page.less'
}
}
},
watch: {
styles: {
files: ['wwwroot/Content/Styles/**/*.less'],
tasks: ['less'],
options: {
nospawn: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-terser');
grunt.registerTask('formBuilder', ['clean:formBuilder', 'concat:formBuilder', 'cssmin:formBuilder', 'terser:formBuilder']);
grunt.registerTask('pageBuilder', ['clean:pageBuilder', 'concat:pageBuilder', 'cssmin:pageBuilder', 'terser:pageBuilder']);
grunt.registerTask('default', ['less']);
};
Loading