From ade60a5be7d85040ea7c1ed3ff657af136b5448f Mon Sep 17 00:00:00 2001 From: PathToSharePoint Date: Fri, 18 Mar 2022 22:48:18 -0700 Subject: [PATCH 1/4] v0.4.0 --- README.md | 1 + package-lock.json | 2 +- package.json | 2 +- .../cherryPickedContent/CherryPickedContentWebPart.ts | 9 ++++++--- .../components/CherryPickedContent.tsx | 11 +++-------- .../components/CherryPickedMemo.tsx | 9 +++++++++ 6 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 src/webparts/cherryPickedContent/components/CherryPickedMemo.tsx diff --git a/README.md b/README.md index d62b01967..ba8082498 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ React-Cherry-Picked-Content | [Christophe Humbert](https://github.com/PathToShar Version|Date|Comments -------|----|-------- +0.4.0|March 18, 2022|Update to library REST query 0.3.0|March 9, 2022|4 samples added 0.2.0|March 6, 2022|Refactoring 0.1.0|February 21, 2022|Initial draft diff --git a/package-lock.json b/package-lock.json index 3e3a38797..2caf3f36c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-cherry-picked-content", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 22c412627..8a208bf22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-cherry-picked-content", - "version": "0.3.0", + "version": "0.4.0", "private": true, "main": "lib/index.js", "scripts": { diff --git a/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts b/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts index e29ca3922..6cc12a5cb 100644 --- a/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts +++ b/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts @@ -103,10 +103,10 @@ export default class CherryPickedContentWebPart extends BaseClientSideWebPart { // Validate approved location const filesLocation = this.approvedLibraries.filter(loc => loc.key == library)[0]; - const filesQuery = window.location.origin + filesLocation.siteRelativeURL + "/_api/web/lists/getbytitle('" + filesLocation.library + "')/files?$select=Name"; + const filesQuery = window.location.origin + filesLocation.siteRelativeURL + "/_api/web/lists/getbytitle('" + filesLocation.library + "')/Items?$select=FileLeafRef"; return this.context.spHttpClient.get(filesQuery, SPHttpClient.configurations.v1) - .then((response: SPHttpClientResponse) => response.json()) + .then((response: SPHttpClientResponse) => { console.log(); return response.json(); }) .then(data => data.value); } @@ -119,7 +119,10 @@ export default class CherryPickedContentWebPart extends BaseClientSideWebPart { // store items - this.libraryItemsList = files.map(file => file.Name).sort().map(name => { return { key: name, text: name }; }); + this.libraryItemsList = files.map(file => file.FileLeafRef) + .filter(rf => rf.match(/\.(htm?l|txt)$/i)) + .sort() + .map(name => ({ key: name, text: name })); this.itemsDropdownDisabled = false; }) .then(() => this.context.propertyPane.refresh()); diff --git a/src/webparts/cherryPickedContent/components/CherryPickedContent.tsx b/src/webparts/cherryPickedContent/components/CherryPickedContent.tsx index be1f768ec..bfa29ae34 100644 --- a/src/webparts/cherryPickedContent/components/CherryPickedContent.tsx +++ b/src/webparts/cherryPickedContent/components/CherryPickedContent.tsx @@ -5,12 +5,7 @@ import { escape } from '@microsoft/sp-lodash-subset'; import { SPHttpClient, SPHttpClientResponse } from '@microsoft/sp-http'; import PortalIframe from './PortalIframe'; - -const CherryPickedDiv = ({ htmlFragment }) => -
{ if (ref) { ref.innerHTML = ""; ref.appendChild(document.createRange().createContextualFragment(htmlFragment)); } }}> -
; - -const MemoDiv = React.memo(CherryPickedDiv); +import CherryPickedMemo from './CherryPickedMemo'; const CherryPickedContent: React.FunctionComponent = (props) => { @@ -70,13 +65,13 @@ const CherryPickedContent: React.FunctionComponent = else if (props.isolated) { return ( - + ); } else { return ( - + ); } }; diff --git a/src/webparts/cherryPickedContent/components/CherryPickedMemo.tsx b/src/webparts/cherryPickedContent/components/CherryPickedMemo.tsx new file mode 100644 index 000000000..5063ae8cf --- /dev/null +++ b/src/webparts/cherryPickedContent/components/CherryPickedMemo.tsx @@ -0,0 +1,9 @@ +import * as React from 'react'; + +const CherryPickedDiv = ({ htmlFragment }) => +
{ if (ref) { ref.innerHTML = ""; ref.appendChild(document.createRange().createContextualFragment(htmlFragment)); } }}> +
; + +const CherryPickedMemo = React.memo(CherryPickedDiv); + +export default CherryPickedMemo; \ No newline at end of file From e49c9ef2225578c41227c82d380cfed69d7c7353 Mon Sep 17 00:00:00 2001 From: Christophe Humbert <40323257+PathToSharePoint@users.noreply.github.com> Date: Fri, 8 Apr 2022 17:16:29 -0700 Subject: [PATCH 2/4] Update CherryPickedContentWebPart.ts --- .../cherryPickedContent/CherryPickedContentWebPart.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts b/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts index 6cc12a5cb..220254ea4 100644 --- a/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts +++ b/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts @@ -147,7 +147,10 @@ export default class CherryPickedContentWebPart extends BaseClientSideWebPart { if (files.length) { // store items - this.libraryItemsList = files.map(file => { return { key: file.Name, text: file.Name }; }); + this.libraryItemsList = files.map(file => file.FileLeafRef) + .filter(rf => rf.match(/\.(htm?l|txt)$/i)) + .sort() + .map(name => ({ key: name, text: name })); // enable item selector this.itemsDropdownDisabled = false; // refresh the item selector control by repainting the property pane From c3a97b9696f78764e95482ed61776c779e4b2ea9 Mon Sep 17 00:00:00 2001 From: Christophe Humbert <40323257+PathToSharePoint@users.noreply.github.com> Date: Fri, 8 Apr 2022 17:17:34 -0700 Subject: [PATCH 3/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8a208bf22..2acfd3b92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-cherry-picked-content", - "version": "0.4.0", + "version": "0.4.1", "private": true, "main": "lib/index.js", "scripts": { From 6570d7f8c3838c9f2454edec83f708f8a8c350a5 Mon Sep 17 00:00:00 2001 From: PathToSharePoint Date: Sat, 9 Apr 2022 08:11:01 -0700 Subject: [PATCH 4/4] v0.4.1 --- package-lock.json | 2 +- package.json | 2 +- .../cherryPickedContent/CherryPickedContentWebPart.ts | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2caf3f36c..ff4d297d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-cherry-picked-content", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8a208bf22..2acfd3b92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-cherry-picked-content", - "version": "0.4.0", + "version": "0.4.1", "private": true, "main": "lib/index.js", "scripts": { diff --git a/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts b/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts index 6cc12a5cb..9b938ad40 100644 --- a/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts +++ b/src/webparts/cherryPickedContent/CherryPickedContentWebPart.ts @@ -106,7 +106,7 @@ export default class CherryPickedContentWebPart extends BaseClientSideWebPart { console.log(); return response.json(); }) + .then((response: SPHttpClientResponse) => response.json()) .then(data => data.value); } @@ -147,7 +147,10 @@ export default class CherryPickedContentWebPart extends BaseClientSideWebPart { if (files.length) { // store items - this.libraryItemsList = files.map(file => { return { key: file.Name, text: file.Name }; }); + this.libraryItemsList = files.map(file => file.FileLeafRef) + .filter(rf => rf.match(/\.(htm?l|txt)$/i)) + .sort() + .map(name => ({ key: name, text: name })); // enable item selector this.itemsDropdownDisabled = false; // refresh the item selector control by repainting the property pane