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

New sample training checklist new version of pnp js used. #5225

Merged
merged 3 commits into from
Sep 29, 2024
Merged
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
38 changes: 38 additions & 0 deletions samples/react-training-checklist/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "SPFx 1.20.0",
"image": "docker.io/m365pnp/spfx:1.20.0",
"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"
}
33 changes: 33 additions & 0 deletions samples/react-training-checklist/.devcontainer/spfx-startup.sh
Original file line number Diff line number Diff line change
@@ -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**********"
352 changes: 352 additions & 0 deletions samples/react-training-checklist/.eslintrc.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions samples/react-training-checklist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Build generated files
dist
lib
release
solution
temp
*.sppkg
.heft

# Coverage directory used by tools like istanbul
coverage

# OSX
.DS_Store

# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj

# Resx Generated Code
*.resx.ts

# Styles Generated Code
*.scss.ts
16 changes: 16 additions & 0 deletions samples/react-training-checklist/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!dist
config

gulpfile.js

release
src
temp

tsconfig.json
tslint.json

*.log

.yo-rc.json
.vscode
21 changes: 21 additions & 0 deletions samples/react-training-checklist/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": true,
"isCreatingSolution": true,
"nodeVersion": "18.17.1",
"sdksVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.24.0"
},
"version": "1.20.0-beta.0",
"libraryName": "trainning-checklist-web-part",
"libraryId": "f9745724-d01a-4022-bbf5-cc4b89981c67",
"environment": "spo",
"packageManager": "npm",
"solutionName": "trainning-checklist-web-part",
"solutionShortDescription": "trainning-checklist-web-part description",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "webpart"
}
}
115 changes: 115 additions & 0 deletions samples/react-training-checklist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Training Checklist

Sample web part to display a training checklist in a SharePoint page.
PnPjs is used to interact with SharePoint lists.

![sample](./assets/trainingchecklist.png)

## Compatibility

| :warning: Important |
|:---------------------------|
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |

![SPFx 1.20.0-beta.0](https://img.shields.io/badge/SPFx-1.20.0-green.svg)
![Node.js >=18.17.1 <19.0.0](https://img.shields.io/badge/Node.js-v18%20%7C%20v19-green.svg)
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above")
![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)

## Applies to

* [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
* [Office 365 developer tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-developer-tenant)

## Contributors

* [Valeras Narbutas](https://github.com/ValerasNarbutas)

## Version history

Version|Date|Comments
-------|----|--------
1.0|September 12, 2024|Initial release

## Minimal Path to Awesome

* Clone this repo
* From your command line, change your current directory to the directory containing this sample (`react-training-checklist`, located under `samples`)
* in the command line run:
* `npm install`
* `gulp bundle --ship`
* `gulp package-solution --ship`
* from the _sharepoint/solution_ folder, deploy the `.sppkg` file to the App catalog in your tenant
* in the site where you want to test this solution
* add the app named _training_checklist_
* edit a page
* add _Training Checklist_ web part

## Prerequisites

> Any special pre-requisites?

PowerShell script to create the SharePoint list with the required columns:

```powershell
# Connect to SharePoint Online
Connect-PnPOnline -Url "https://macaw.sharepoint.com/sites/valerasn_dev" -Interactive

# Create the SharePoint list named "TrainingChecklist"
$list = New-PnPList -Title "TrainingChecklist" -Template GenericList -Url "Lists/TrainingChecklist" -OnQuickLaunch

# Add columns to the list

# Title column is automatically created, so no need to add it again.

# Description (Multiple lines of text)
Add-PnPField -List $list -DisplayName "Description" -InternalName "Description" -Type Note

# AssignedTo (Person or Group)
Add-PnPField -List $list -DisplayName "AssignedTo" -InternalName "AssignedTo" -Type User

# DueDate (Date and Time)
Add-PnPField -List $list -DisplayName "DueDate" -InternalName "DueDate" -Type DateTime

# Status (Choice field: Not Started, In Progress, Completed)
Add-PnPField -List $list -DisplayName "Status" -InternalName "Status" -Type Choice -Choices "Not Started", "In Progress", "Completed" #-DefaultValue "Not Started"

# CompletionDate (Date and Time)
Add-PnPField -List $list -DisplayName "CompletionDate" -InternalName "CompletionDate" -Type DateTime

# Progress (Number field, 0-100)
Add-PnPField -List $list -DisplayName "Progress" -InternalName "Progress" -Type Number #-Min 0 -Max 100 #-DefaultValue 0

# $view = Get-PnPView -List $list -Identity "All Items"
# Add the newly created fields to the default view
Set-PnPView -List $list -Identity "All Items" -Fields "Title", "Description", "AssignedTo", "DueDate", "Status", "CompletionDate", "Progress"

Write-Host "TrainingChecklist list created successfully with all specified columns."
```

## Help


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.

If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.

You can try looking at [issues related to this sample](https://github.com/pnp/sp-dev-fx-webparts/issues?q=label%3A%22sample%3A%20training%20checklist%22) to see if anybody else is having the same issues.

You can also try looking at [discussions related to this sample](https://github.com/pnp/sp-dev-fx-webparts/discussions?discussions_q=react-training-checklist) and see what the community is saying.


If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-training-checklist&template=bug-report.yml&sample=react-training-checklist&authors=@YOURGITHUBUSERNAME&title=react-training-checklist%20-%20).

For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-training-checklist&template=question.yml&sample=react-training-checklist&authors=@YOURGITHUBUSERNAME&title=react-training-checklist%20-%20).

Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-training-checklist&template=suggestion.yml&sample=react-training-checklist&authors=@YOURGITHUBUSERNAME&title=react-training-checklist%20-%20).

## Disclaimer

**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-training-checklist" />
51 changes: 51 additions & 0 deletions samples/react-training-checklist/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[
{
"name": "pnp-sp-dev-spfx-web-parts-react-training-checklist",
"source": "pnp",
"title": "Training Checklist",
"shortDescription": "YSample web part to display a training checklist in a SharePoint page.",
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-training-checklist",
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-training-checklist",
"longDescription": [
"YSample web part to display a training checklist in a SharePoint page."
],
"creationDateTime": "2024-09-12",
"updateDateTime": "2024-09-12",
"products": [
"SharePoint"
],
"metadata": [
{
"key": "CLIENT-SIDE-DEV",
"value": "React"
},
{
"key": "SPFX-VERSION",
"value": "1.20.0"
}
],
"thumbnails": [
{
"name": "trainingchecklist.png",
"type": "image",
"order": 100,
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-training-checklist/assets/trainingchecklist.png",
"alt": "Web Part Preview"
}
],
"authors": [
{
"gitHubAccount": "ValerasNarbutas",
"pictureUrl": "https://github.com/ValerasNarbutas.png",
"name": "Valeras Narbutas"
}
],
"references": [
{
"name": "Build your first SharePoint client-side web part",
"description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.",
"url": "https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part"
}
]
}
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions samples/react-training-checklist/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"trainning-checklist-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/trainningChecklist/TrainningChecklistWebPart.js",
"manifest": "./src/webparts/trainningChecklist/TrainningChecklistWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"TrainningChecklistWebPartStrings": "lib/webparts/trainningChecklist/loc/{locale}.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "trainning-checklist-web-part",
"accessKey": "<!-- ACCESS KEY -->"
}
40 changes: 40 additions & 0 deletions samples/react-training-checklist/config/package-solution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "trainning-checklist-web-part-client-side-solution",
"id": "f9745724-d01a-4022-bbf5-cc4b89981c67",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.20.0-beta.0"
},
"metadata": {
"shortDescription": {
"default": "Trainning checklist web part"
},
"longDescription": {
"default": "Trainning checklist web part to display a list of trainning items"
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "trainning-checklist-web-part Feature",
"description": "The feature that activates elements of the trainning-checklist-web-part solution.",
"id": "531af3dd-6259-43e7-b5ce-6d77d1995ead",
"version": "1.0.0.0"
}
]
},
"paths": {
"zippedPackage": "solution/trainning-checklist-web-part.sppkg"
}
}
3 changes: 3 additions & 0 deletions samples/react-training-checklist/config/sass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
}
6 changes: 6 additions & 0 deletions samples/react-training-checklist/config/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://macaw.sharepoint.com/sites/valerasn_dev/_layouts/workbench.aspx"
}
Loading
Loading