Updated readme, sample manifest. Added container.

This commit is contained in:
Hugo Bernier 2024-03-16 14:16:54 -04:00
parent 38dbd37b63
commit 542ec5b431
4 changed files with 81 additions and 61 deletions

View File

@ -0,0 +1,38 @@
{
"name": "SPFx 1.18.2",
"image": "docker.io/m365pnp/spfx:1.18.2",
"customizations": {
"vscode": {
"extensions": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint"
]
}
},
"forwardPorts": [
4321,
35729,
5432
],
"portsAttributes": {
"4321": {
"protocol": "https",
"label": "Manifest",
"onAutoForward": "silent",
"requireLocalPort": true
},
"5432": {
"protocol": "https",
"label": "Workbench",
"onAutoForward": "silent"
},
"35729": {
"protocol": "https",
"label": "LiveReload",
"onAutoForward": "silent",
"requireLocalPort": true
}
},
"postCreateCommand": "bash .devcontainer/spfx-startup.sh",
"remoteUser": "node"
}

View File

@ -0,0 +1,33 @@
echo
echo -e "\e[1;94mInstalling Node dependencies\e[0m"
npm install
## commands to create dev certificate and copy it to the root folder of the project
echo
echo -e "\e[1;94mGenerating dev certificate\e[0m"
gulp trust-dev-cert
# Convert the generated PEM certificate to a CER certificate
openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer
# Copy the PEM ecrtificate for non-Windows hosts
cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem
## add *.cer to .gitignore to prevent certificates from being saved in repo
if ! grep -Fxq '*.cer' ./.gitignore
then
echo "# .CER Certificates" >> .gitignore
echo "*.cer" >> .gitignore
fi
## add *.pem to .gitignore to prevent certificates from being saved in repo
if ! grep -Fxq '*.pem' ./.gitignore
then
echo "# .PEM Certificates" >> .gitignore
echo "*.pem" >> .gitignore
fi
echo
echo -e "\e[1;92mReady!\e[0m"
echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********"

View File

@ -1,4 +1,4 @@
# connected-web-parts
# Connected Web Parts
## Summary
@ -30,10 +30,6 @@ This sample is optimally compatible with the following environment configuration
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
## Used SharePoint Framework Version
![version](https://img.shields.io/badge/version-1.18.2-green.svg)
## Applies to
* [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
@ -41,17 +37,7 @@ This sample is optimally compatible with the following environment configuration
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
## Contributors
<!--
We use this section to recognize and promote your contributions. Please provide one author per line -- even if you worked together on it.
We'll only use the info you provided here. Make sure to include your full name, not just your GitHub username.
Provide a link to your GitHub profile to help others find more cool things you have done. The only link we'll accept is a link to your GitHub profile.
If you want to provide links to your social media, blog, and employer name, make sure to update your GitHub profile.
-->
* [Guido Zambarda](https://github.com/guidozam)
@ -61,14 +47,6 @@ Version|Date|Comments
-------|----|--------
|1.0|March 16, 2024|Initial release|
## Prerequisites
<!--
Any special pre-requisites? Include any lists, permissions, offerings to the demo gods, or whatever else needs to be done for this web part to work.
Please describe the steps to configure the pre-requisites. Feel free to add screen shots, but make sure that there is a text description of the steps to perform.
-->
## Minimal path to awesome
* Clone this repository (or [download this solution as a .ZIP file](https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-connected-web-parts) then unzip it)
@ -105,6 +83,7 @@ public getPropertyDefinitions(): ReadonlyArray<IDynamicDataPropertyDefinition> {
];
}
```
This define the properties that the provider web part exposes to the consumer web part.
The other method that the provider web part must implement is the following:
@ -123,6 +102,7 @@ public getPropertyValue(propertyId: string): string | IPreferences {
throw new Error(strings.BadPropertyId);
}
```
This method returns the value of the property identified by the `propertyId` parameter.
In the provider web part the properties are updated by the user through the UI, and the consumer web part is automatically updated with the new values, to enable the automatic update the provider web part must call the `notifyPropertyChanged` method every time a property is updated, for example the following code is called every time the first name is updated:
@ -153,41 +133,12 @@ firstName: DynamicProperty<string>;
The last step to display the value of the connected property in the consumer web part control is to use the property as the following:
```typescript
```typescript
const firstNameValue = this.props.firstName?.tryGetValue();
```
<!--
RESERVED FOR REPO MAINTAINERS
We'll add the video from the community call recording here
## Video
[![YouTube video title](./assets/video-thumbnail.jpg)](https://www.youtube.com/watch?v=XXXXX "YouTube video title")
-->
## Help
<!--
You can just search and replace this page with the following values:
Search for:
react-connected-web-parts
Replace with your sample folder name. E.g.: react-my-cool-sample
Search for:
@YOURGITHUBUSERNAME
Replace with your GitHub username, prefixed with an "@". If you have more than one author, use %20 to separate them, making sure to prefix everyone's username individually with an "@".
Example:
@hugoabernier
Or:
@hugoabernier%20@VesaJuvonen%20@PopWarner
-->
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
@ -207,4 +158,4 @@ Finally, if you have an idea for improvement, [make a suggestion](https://github
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-webparts/samples/react-connected-web-parts" />
<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-webparts/samples/react-connected-web-parts" />

View File

@ -2,7 +2,7 @@
{
"name": "pnp-sp-dev-spfx-web-parts-react-connected-web-parts",
"source": "pnp",
"title": "React Connected web parts",
"title": "Connected web parts",
"shortDescription": "This samples showcase how to connect two web parts together.",
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-connected-web-parts",
"longDescription": [
@ -50,10 +50,8 @@
"authors": [
{
"gitHubAccount": "guidozam",
"company": "PiaSys",
"pictureUrl": "https://github.com/guidozam.png",
"name": "Guido Zambarda",
"twitter": "iamguidozam"
"name": "Guido Zambarda"
}
],
"references": [
@ -65,17 +63,17 @@
{
"name": "Integrate web part properties with SharePoint",
"description": "Learn how to integrate web part properties with SharePoint.",
"url": "https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/integrate-web-part-properties-with-sharepoint"
"url": "https://learn.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/integrate-web-part-properties-with-sharepoint"
},
{
"name": "Make your SharePoint client-side web part configurable",
"description": "Learn how to make your SharePoint client-side web part configurable.",
"url": "https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/basics/integrate-with-property-pane"
"url": "https://learn.microsoft.com/sharepoint/dev/spfx/web-parts/basics/integrate-with-property-pane"
},
{
"name": "Connect SharePoint Framework components using dynamic data",
"description": "Learn how to connect SharePoint Framework components using dynamic data.",
"url": "https://learn.microsoft.com/en-us/sharepoint/dev/spfx/dynamic-data"
"url": "https://learn.microsoft.com/sharepoint/dev/spfx/dynamic-data"
}
]
}