From 5d38fc0d4f7eeda5a4a85a577acc69451bc31c42 Mon Sep 17 00:00:00 2001 From: Hugo Bernier Date: Sun, 27 Mar 2022 03:13:25 -0400 Subject: [PATCH] Added remote container and sample.json --- .../.devcontainer/devcontainer.json | 39 ++++++++ .../.devcontainer/spfx-startup.sh | 33 +++++++ samples/react-lists-hide/.gitignore | 4 + samples/react-lists-hide/README.md | 98 +++---------------- samples/react-lists-hide/assets/sample.json | 56 +++++++++++ templates/README-template.md | 27 ++--- templates/sample-template.json | 1 + 7 files changed, 162 insertions(+), 96 deletions(-) create mode 100644 samples/react-lists-hide/.devcontainer/devcontainer.json create mode 100644 samples/react-lists-hide/.devcontainer/spfx-startup.sh create mode 100644 samples/react-lists-hide/assets/sample.json diff --git a/samples/react-lists-hide/.devcontainer/devcontainer.json b/samples/react-lists-hide/.devcontainer/devcontainer.json new file mode 100644 index 000000000..3e7ba6ebb --- /dev/null +++ b/samples/react-lists-hide/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +// For more information on how to run this SPFx project in a VS Code Remote Container, please visit https://aka.ms/spfx-devcontainer +{ + "name": "SPFx 1.13.1", + "image": "docker.io/m365pnp/spfx:1.13.1", + // Set *default* container specific settings.json values on container create. + "settings": {}, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "editorconfig.editorconfig", + "dbaeumer.vscode-eslint" + ], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 4321, + 35729 + ], + "portsAttributes": { + "4321": { + "protocol": "https", + "label": "Manifest", + "onAutoForward": "silent", + "requireLocalPort": true + }, + // Not needed for SPFx>= 1.12.1 + // "5432": { + // "protocol": "https", + // "label": "Workbench", + // "onAutoForward": "silent" + // }, + "35729": { + "protocol": "https", + "label": "LiveReload", + "onAutoForward": "silent", + "requireLocalPort": true + } + }, + "postCreateCommand": "bash .devcontainer/spfx-startup.sh", + "remoteUser": "node" +} \ No newline at end of file diff --git a/samples/react-lists-hide/.devcontainer/spfx-startup.sh b/samples/react-lists-hide/.devcontainer/spfx-startup.sh new file mode 100644 index 000000000..456d6aea8 --- /dev/null +++ b/samples/react-lists-hide/.devcontainer/spfx-startup.sh @@ -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**********" \ No newline at end of file diff --git a/samples/react-lists-hide/.gitignore b/samples/react-lists-hide/.gitignore index d5ab57b0f..636a3337f 100644 --- a/samples/react-lists-hide/.gitignore +++ b/samples/react-lists-hide/.gitignore @@ -31,3 +31,7 @@ obj # Styles Generated Code *.scss.ts +# .CER Certificates +*.cer +# .PEM Certificates +*.pem diff --git a/samples/react-lists-hide/README.md b/samples/react-lists-hide/README.md index 4a4c92a30..98f01f1ce 100644 --- a/samples/react-lists-hide/README.md +++ b/samples/react-lists-hide/README.md @@ -2,7 +2,7 @@ ## Summary -SPFx Webpart to Hide/UnHide lists in a Site Collection's Site Contents Page. +SPFx Web part to Hide/UnHide lists in a Site Collection's Site Contents Page. ![HideLists WebPart](./assets/ListHideWebPart.jpg) @@ -12,13 +12,13 @@ For example: we may have created a PowerApps form and need to hide master lists So that once the list is hidden, users cannot access the list directly from Site Contents or without knowing list name or list URL. -There are multiple ways to do this by using PowerShell Scripts, Rest Api & MS Flows. +There are multiple ways to do this by using PowerShell Scripts, Rest API & MS Flows. -Here same functionality is achieved using SPFx Webpart, which we can just be added to a Site Collection and it will list out the lists and libraries in the site and Site Admin can Hide/Unhide lists with a simple button click. +Here same functionality is achieved using SPFx web part, which we can just be added to a Site Collection and it will list out the lists and libraries in the site and Site Admin can Hide/Unhide lists with a simple button click. -This Webpart will be accessible only to users with Site Collection Admin access. +This web part will be accessible only to users with Site Collection Admin access. -PnP Js library to get relevant SharePoint lists and libraries from current Site Collection and use "Hidden" property of lists to hide/Unhide. +PnP JS library to get relevant SharePoint lists and libraries from current Site Collection and use "Hidden" property of lists to hide/Unhide. ![HideLists WebPart GIF](./assets/listHidewp.gif) @@ -31,41 +31,8 @@ PnP Js library to get relevant SharePoint lists and libraries from current Site ![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1") ![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 @@ -74,12 +41,7 @@ Don't worry if you're unsure about the compatibility matrix above. We'll verify > Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram) ## Solution - + Solution|Author(s) --------|--------- @@ -93,64 +55,30 @@ Version|Date|Comments ## Prerequisites -Enusre to have Site Collection Admin access to use this WebPart. +Ensure to have Site Collection Admin access to use this web part. - -## Minimal Path to Awesome +## 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-lists-hide) then unzip it) * From your command line, change your current directory to the directory containing this sample (`react-lists-hide`, located under `samples`) * in the command line run: * `npm install` - * **Update your SharePoint Site Url in serve.json** + * **Update your SharePoint Site URL in `serve.json`** * `gulp serve` > This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit https://aka.ms/spfx-devcontainer for further instructions. -> + + ## Features * List Out available Lists and Libraries based on template in current Site Collection * Hide/Unhide Lists on button click - - - ## 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. diff --git a/samples/react-lists-hide/assets/sample.json b/samples/react-lists-hide/assets/sample.json new file mode 100644 index 000000000..951e3a854 --- /dev/null +++ b/samples/react-lists-hide/assets/sample.json @@ -0,0 +1,56 @@ +[ + { + "name": "pnp-sp-dev-spfx-web-parts-react-hide-lists", + "source": "pnp", + "title": "Hide Lists", + "shortDescription": "SPFx Web part to Hide/UnHide lists in a Site Collection's Site Contents Page.", + "url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-hide-lists", + "downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-hide-lists", + "longDescription": [ + "SPFx Web part to Hide/UnHide lists in a Site Collection's Site Contents Page." + ], + "creationDateTime": "2022-02-27", + "updateDateTime": "2022-02-27", + "products": [ + "SharePoint" + ], + "metadata": [ + { + "key": "CLIENT-SIDE-DEV", + "value": "React" + }, + { + "key": "SPFX-VERSION", + "value": "1.14" + } + ], + "thumbnails": [ + { + "type": "image", + "order": 100, + "url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-hide-lists/assets/ListHideWebPart.jpg", + "alt": "Web Part Preview" + }, + { + "type": "image", + "order": 101, + "url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-hide-lists/assets/listHidewp.gif", + "alt": "Web Part Preview" + } + ], + "authors": [ + { + "gitHubAccount": "SandeepDev365", + "pictureUrl": "https://github.com/SandeepDev365.png", + "name": "Sandeep Unnikrishnan" + } + ], + "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/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part" + } + ] + } +] \ No newline at end of file diff --git a/templates/README-template.md b/templates/README-template.md index 05470c41c..c6dd7bc2a 100644 --- a/templates/README-template.md +++ b/templates/README-template.md @@ -2,12 +2,20 @@ ## Summary @@ -33,7 +41,7 @@ You can add as many screen shots as you'd like to help users understand your web ## Compatibility ![SPFx 1.14](https://img.shields.io/badge/SPFx-1.14-green.svg) -![Node.js v14 | v12](https://img.shields.io/badge/Node.js-v14%20%7C%20v12-green.svg) +![Node.js v14 | v12](https://img.shields.io/badge/Node.js-v14%20%7C%20v12-green.svg) ![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg) ![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower") ![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1") @@ -42,7 +50,7 @@ You can add as many screen shots as you'd like to help users understand your web ![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg) If using SPFx 1.12.1, update the SPFx and Node.js tags accordingly: ![SPFx 1.12.1](https://img.shields.io/badge/SPFx-1.12.1-green.svg) @@ -127,7 +135,7 @@ Please describe the steps to configure the pre-requisites. Feel free to add scre --> -## Minimal Path to Awesome +## Minimal path to awesome