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

MS Feature 386904 Support: Page Header divs are removed and settings are now part of the PageTitle-WebPart #1506

Merged
merged 4 commits into from
Aug 16, 2024

Conversation

czullu
Copy link

@czullu czullu commented Aug 15, 2024

create from Blank Page in UI creates new format of Page-HTML because of MS Feature 386904.
All the settings from the Header DIV's have been moved to the WebPart-Settings of PageTitle WebPart.
The Manifest or settings of the PageTitle-WebPart do not reflect that it now should support fullbleed.
To dedect new Page-Format i go by the assumption that the PageTitle-WebPart needs to be placed in the first section which needs to be OneColumnFullWith.

With the code change i'm able to load and save a Page created from Blank-Page again:

                    var pages = await pnpContext.Web.GetPagesAsync("TestPageNew.aspx");
                    var testPage = pages.First();
                    await testPage.SaveAsync();

or create a new Page with same format like this:

                    var page = await pnpContext.Web.NewPageAsync();
                    page.AddSection(CanvasSectionTemplate.OneColumnFullWidth, 1);
                    page.AddSection(CanvasSectionTemplate.OneColumn, 2);
                    var availableComponents = await page.AvailablePageComponentsAsync();
                    var pageTitleWebPartComponent = availableComponents.FirstOrDefault(p => p.Id == page.DefaultWebPartToWebPartId(DefaultWebPart.PageTitle));
                    page.AddControl(page.NewWebPart(pageTitleWebPartComponent), page.Sections[0].Columns[0]);

                    var HeroWebPartComponent = availableComponents.FirstOrDefault(p => p.Id == page.DefaultWebPartToWebPartId(DefaultWebPart.Hero));
                    page.AddControl(page.NewWebPart(HeroWebPartComponent), page.Sections[1].Columns[0]);

                    await page.SaveAsync("TestFromCode.aspx");

Christian Zuellig added 3 commits August 14, 2024 17:44
…the Configuration of PageTitle-WebPart in a and we do not need to set a default Title on the page anymore.
@czullu
Copy link
Author

czullu commented Aug 15, 2024

To solve issue pnp/pnpframework#1043 it needs a fix in createPage as well.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 76.31579% with 9 lines in your changes missing coverage. Please review.

Project coverage is 81.91%. Comparing base (63545f3) to head (ef2b461).
Report is 2061 commits behind head on dev.

Files Patch % Lines
...k/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs 78.26% 3 Missing and 2 partials ⚠️
...Core/Model/SharePoint/Pages/Internal/PageHeader.cs 50.00% 3 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1506      +/-   ##
==========================================
- Coverage   82.42%   81.91%   -0.51%     
==========================================
  Files         416      627     +211     
  Lines       28590    44073   +15483     
  Branches        0     4623    +4623     
==========================================
+ Hits        23565    36104   +12539     
- Misses       5025     6614    +1589     
- Partials        0     1355    +1355     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@czullu
Copy link
Author

czullu commented Aug 15, 2024

This Version will break Export in pnp.framework as we have a new Header Type which is not reflected in PnP-Schema.

The changes needed in pnp.framework are:
in: ObjectClientSidePages.cs - Line:385 to 389

                    case ClientSidePageHeaderType.Default:
                        {
                            //Message ID: MC791596 / Roadmap ID: 386904
                            if (clientSidePage.Sections.Any() && clientSidePage.Sections.First().Type == CanvasSectionType.OneColumnFullWidth && clientSidePage.Sections.First().Controls.Any(c => c.Type == WebPartType.PageTitle))
                            {
                                page.SetPageTitleWebPartPageHeader();
                            }
                            else
                            {
                                page.SetDefaultPageHeader();
                            }
                            break;
                        }

and in ClientSidePageContentsHelper.cs start Lin 120 (before var extractHeader

                        //All Headersettings are in the PageTitle WebPart. PageTitle-WP in first section as OneColumnFullWith (Message ID: MC791596 / Roadmap ID: 386904)
                        //need to fallback to default as we otherwise need to change xml schema
                        var headerType = ClientSidePageHeaderType.Default;
                        if(pageToExtract.PageHeader.Type != PnPCore.PageHeaderType.PageTitleWebPart)
                        {
                            headerType = (ClientSidePageHeaderType)Enum.Parse(typeof(ClientSidePageHeaderType), pageToExtract.PageHeader.Type.ToString());
                        }

and then inside var extractedHeader = new ClientSidePageHeader() set the Type to headerType

Tested that way and Export/Provision does work. Can do Pull-request for pnp.framework once this pullrequest is in nightly

jansenbe pushed a commit that referenced this pull request Aug 16, 2024
@jansenbe jansenbe merged commit 5f3beae into pnp:dev Aug 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants