|
| 1 | +# Copy Page SPFx Application Customizer |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +This SPFx Application Customizer empowers content authors to **copy modern site pages** across sites with full control over: |
| 6 | + |
| 7 | +- **Publishing State**: Choose between `Published` or `Draft`. |
| 8 | +- **Promotion as News Post**: Optionally promote the page as a news post. |
| 9 | +- **Local Page Templates**: Save the page as a local template for reuse. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +- Copy modern site pages across SharePoint sites. |
| 20 | +- Control publishing state (`Published` or `Draft`). |
| 21 | +- Promote pages as news posts. |
| 22 | +- Save pages as local templates in the target site. |
| 23 | +- Fully integrated with SharePoint Framework (SPFx). |
| 24 | + |
| 25 | +## Used SharePoint Framework Version |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +## Applies to |
| 30 | + |
| 31 | +- [SharePoint Framework](https://aka.ms/spfx) |
| 32 | +- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) |
| 33 | + |
| 34 | +> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram) |
| 35 | +
|
| 36 | +## Prerequisites |
| 37 | + |
| 38 | +- The source and destination sites must use modern pages and have the **Site Pages** library. |
| 39 | +- User must have contribute permissions on the destination site. |
| 40 | + |
| 41 | +## Contributors |
| 42 | + |
| 43 | +- [Ahmad Jad Alhak](https://github.com/ahmad-jad-alhak) |
| 44 | + |
| 45 | +## Version history |
| 46 | + |
| 47 | +| Version | Date | Comments | |
| 48 | +|---------|----------------|----------------------------| |
| 49 | +| 1.0 | Initial release| Basic copy page and template | |
| 50 | + |
| 51 | +## Disclaimer |
| 52 | + |
| 53 | +**THIS CODE IS PROVIDED _AS IS_ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED.** |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## Minimal Path to Awesome |
| 58 | + |
| 59 | +```bash |
| 60 | +git clone https://github.com/ahmad-jad-alhak/React-Application-Copy-Page.git |
| 61 | +cd react-application-copy-page |
| 62 | +npm install |
| 63 | +gulp serve |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Deployment Instructions |
| 69 | + |
| 70 | +To deploy this SPFx Application Customizer, follow these steps: |
| 71 | + |
| 72 | +1. **Build the solution**: |
| 73 | + ```bash |
| 74 | + gulp build |
| 75 | + gulp bundle --ship |
| 76 | + gulp package-solution --ship |
| 77 | + ``` |
| 78 | + |
| 79 | +2. **Upload the package**: |
| 80 | + - Navigate to your SharePoint tenant's App Catalog. |
| 81 | + - Upload the `.sppkg` file generated in the `sharepoint/solution` folder. |
| 82 | + |
| 83 | +3. **Deploy the package**: |
| 84 | + - Select the uploaded package in the App Catalog. |
| 85 | + - Click **Deploy** to make the solution available across your tenant. |
| 86 | + |
| 87 | +4. **Enable the extension**: |
| 88 | + - Add the Application Customizer to your site using the following PowerShell command or manually via site settings: |
| 89 | + ```powershell |
| 90 | + Set-PnPWeb -WebPart -ClientSideComponentId <ComponentId> |
| 91 | + ``` |
| 92 | +
|
| 93 | +5. **Verify functionality**: |
| 94 | + - Navigate to a modern page in your site. |
| 95 | + - Ensure the copy page functionality is available and working as expected. |
| 96 | + ### Deployment via UI |
| 97 | +
|
| 98 | + To deploy this SPFx Application Customizer using the SharePoint UI: |
| 99 | +
|
| 100 | + 1. **Upload the package**: |
| 101 | + - Navigate to your SharePoint tenant's App Catalog. |
| 102 | + - Upload the `.sppkg` file generated in the `sharepoint/solution` folder. |
| 103 | +
|
| 104 | + 2. **Deploy the package**: |
| 105 | + - Select the uploaded package in the App Catalog. |
| 106 | + - Click **Deploy** to make the solution available across your tenant. |
| 107 | +
|
| 108 | + 3. **Enable the extension**: |
| 109 | + - Navigate to the site where you want to enable the extension. |
| 110 | + - Click the **Settings wheel** in the top-right corner of the site. |
| 111 | + - Select **Add an app**. |
| 112 | + - Locate the Application Customizer in the list of available apps and add it to your site. |
| 113 | +
|
| 114 | + 4. **Verify functionality**: |
| 115 | + - Navigate to a modern page in your site. |
| 116 | + - Ensure the copy page functionality is available and working as expected. |
| 117 | +
|
| 118 | +
|
| 119 | +## Features |
| 120 | +
|
| 121 | +
|
| 122 | +This SPFx Application Customizer demonstrates: |
| 123 | +
|
| 124 | +- Copying client-side pages across site collections |
| 125 | +- Toggling **Publish Page**: determines whether the page is immediately published or saved as draft |
| 126 | +- Toggling **Promote as news post**: marks the page for news rollups (uses `PromotedState`) |
| 127 | +- Support for all 4 SharePoint page promotion states: |
| 128 | + - Draft (not promoted) |
| 129 | + - Draft news (`PromotedState = 1`) |
| 130 | + - Published page |
| 131 | + - Published news (`PromotedState = 2`) |
| 132 | +- Optionally saving a page as a **local template** |
| 133 | +- |
| 134 | +- ### Explanation |
| 135 | +
|
| 136 | +- **NotPromoted (`0`)**: Default state for pages. The page remains unpromoted. |
| 137 | +- **PromoteOnPublish (`1`)**: The page is marked for promotion but will only be promoted when published. |
| 138 | +- **Promoted (`2`)**: The page is already promoted and treated as a news post. |
| 139 | +
|
| 140 | +## Feedback and Contributions |
| 141 | +
|
| 142 | +We welcome feedback and contributions! Feel free to submit issues or pull requests to improve this solution. |
| 143 | +
|
| 144 | +
|
| 145 | +## References |
| 146 | +
|
| 147 | +- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) |
| 148 | +- [SharePoint client-side pages API](https://pnp.github.io/pnpjs/sp/clientside-pages/) |
| 149 | +- [PnPjs Documentation](https://pnp.github.io/pnpjs/) |
| 150 | +- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) |
| 151 | +
|
| 152 | +<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-extensions/samples/react-application-copy-page" /> |
0 commit comments