From df2648f8f48a4a16ef94951f6fad14b63105a48e Mon Sep 17 00:00:00 2001 From: Mikael Svenson Date: Tue, 7 Aug 2018 16:27:46 +0200 Subject: [PATCH] Improvements to react-search-refiner web part (#589) * Added weburl/siteurl tokens Added getUrlField helper method Changed property pane settings headers/grouping Updated ouifr version to v5.118.0 Updated handlebar helper to v0.8.4 Updated readme * Added webpack-bundle-analyzer * Fixed ouifr static references to limit bundle size --- samples/react-search-refiners/README.md | 3 + samples/react-search-refiners/gulpfile.js | 14 ++ .../react-search-refiners/package-lock.json | 202 ++++++++++++++++-- samples/react-search-refiners/package.json | 37 ++-- .../TemplateService/BaseTemplateService.ts | 32 ++- .../components/TextDialog/TextDialog.tsx | 6 +- .../SearchResultsWebPart.manifest.json | 6 +- .../searchResults/SearchResultsWebPart.ts | 20 +- .../components/FilterPanel/FilterPanel.tsx | 2 +- .../Layouts/ISearchResultsTemplateContext.ts | 2 + .../ISearchResultsContainerProps.ts | 6 + .../SearchResultsContainer.tsx | 4 +- 12 files changed, 271 insertions(+), 63 deletions(-) diff --git a/samples/react-search-refiners/README.md b/samples/react-search-refiners/README.md index 0b991cfe2..de350b1f1 100644 --- a/samples/react-search-refiners/README.md +++ b/samples/react-search-refiners/README.md @@ -120,8 +120,11 @@ Setting | Description `{{getDate "}}"` | Format the date with moment.ts according to the current language. `{{getPreviewSrc item}}` | Determine the image thumbnail URL if applicable. `{{getUrl item}}` | Get the item URL. For a document, it means the URL to the Office Online instance or the direct URL (to download it). +`{{getUrlField managed_propertyOWSURLH "URL/Title"}}` | Return the URL or Title part of a URL field managed property. `{{getCountMessage totalRows }}` | Display a friendly message displaying the result and the entered keywords. `{{}}` | Any valid search managed property returned in the results set. These are typically managed properties set in the *"Selected properties"* setting in the property pane. You don't need to prefix them with `item.` if you are in the "each" loop. +`{{webUrl}}` | The current web relative url. Use `{{../webUrl}}` inside a loop. +`{{siteUrl}}` | The current site relative url. Use `{{../siteUrl}}` inside a loop. Also the [Handlebars helpers](https://github.com/helpers/handlebars-helpers) (188 helpers) are also available. You can also define your own in the *BaseTemplateService.ts* file. diff --git a/samples/react-search-refiners/gulpfile.js b/samples/react-search-refiners/gulpfile.js index f1cc1fdae..a95b94df6 100644 --- a/samples/react-search-refiners/gulpfile.js +++ b/samples/react-search-refiners/gulpfile.js @@ -1,7 +1,9 @@ 'use strict'; const gulp = require('gulp'); +const path = require('path'); const build = require('@microsoft/sp-build-web'); +const bundleAnalyzer = require('webpack-bundle-analyzer'); /******************************************************************************************** * Adds an alias for handlebars in order to avoid errors while gulping the project @@ -27,9 +29,21 @@ build.configureWebpack.mergeConfig({ generatedConfiguration.node = { fs: 'empty' } + + const lastDirName = path.basename(__dirname); + const dropPath = path.join(__dirname, 'temp', 'stats'); + generatedConfiguration.plugins.push(new bundleAnalyzer.BundleAnalyzerPlugin({ + openAnalyzer: false, + analyzerMode: 'static', + reportFilename: path.join(dropPath, `${lastDirName}.stats.html`), + generateStatsFile: true, + statsFilename: path.join(dropPath, `${lastDirName}.stats.json`), + logLevel: 'error' + })); return generatedConfiguration; } }); + build.initialize(gulp); diff --git a/samples/react-search-refiners/package-lock.json b/samples/react-search-refiners/package-lock.json index ced9a2789..aa4f82a95 100644 --- a/samples/react-search-refiners/package-lock.json +++ b/samples/react-search-refiners/package-lock.json @@ -2169,9 +2169,9 @@ } }, "@types/fabric": { - "version": "1.5.37", - "resolved": "https://registry.npmjs.org/@types/fabric/-/fabric-1.5.37.tgz", - "integrity": "sha512-SBgayDbEmiZ8VYDNqHd3vdqx0qjuCjt9X1B8fZ1aJRtHjGFxj6CRE+v/l7nnKEtJNfb4g/4HVNwD694/1hQMqg==" + "version": "1.5.40", + "resolved": "https://registry.npmjs.org/@types/fabric/-/fabric-1.5.40.tgz", + "integrity": "sha512-fs+hmCkRw9SRrwu61MuVD6ZeBzY9XVKzi42mLDgKpysQ5pILX+p7JL2XZlBhi0ygii1lxZjU1e/LgVarIflfQg==" }, "@types/finalhandler": { "version": "0.0.31", @@ -2234,9 +2234,9 @@ } }, "@types/handlebars": { - "version": "4.0.38", - "resolved": "https://registry.npmjs.org/@types/handlebars/-/handlebars-4.0.38.tgz", - "integrity": "sha512-oMzU0D7jDp+H2go/i0XqBHfr+HEhYD/e1TvkhHi3yrhQm/7JFR8FJMdvoH76X8G1FBpgc6Pwi+QslCJBeJ1N9g==" + "version": "4.0.39", + "resolved": "https://registry.npmjs.org/@types/handlebars/-/handlebars-4.0.39.tgz", + "integrity": "sha512-vjaS7Q0dVqFp85QhyPSZqDKnTTCemcSHNHFvDdalO1s0Ifz5KuE64jQD5xoUkfdWwF4WpqdJEl7LsWH8rzhKJA==" }, "@types/karma": { "version": "0.13.33", @@ -3295,6 +3295,12 @@ "integrity": "sha1-NhIfhFwFeBct5Bmpfb6x0W7DRUI=", "dev": true }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -3881,6 +3887,25 @@ "callsite": "1.0.0" } }, + "bfj-node4": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/bfj-node4/-/bfj-node4-5.3.1.tgz", + "integrity": "sha512-SOmOsowQWfXc7ybFARsK3C4MCOWzERaOMV/Fl3Tgjs+5dJWyzo3oa127jL44eMbQiAN17J7SvAs2TRxEScTUmg==", + "dev": true, + "requires": { + "bluebird": "3.5.1", + "check-types": "7.4.0", + "tryer": "1.0.1" + }, + "dependencies": { + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", + "dev": true + } + } + }, "big.js": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", @@ -4351,6 +4376,12 @@ "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", "dev": true }, + "check-types": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/check-types/-/check-types-7.4.0.tgz", + "integrity": "sha512-YbulWHdfP99UfZ73NcUDlNJhEIDgm9Doq9GhpyXbF+7Aegi3CVV7qqMCKTTqJxlvEvnQBp9IA+dxsGN6xK/nSg==", + "dev": true + }, "chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -5630,6 +5661,12 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", "dev": true }, + "ejs": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz", + "integrity": "sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==", + "dev": true + }, "electron-to-chromium": { "version": "1.3.50", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.50.tgz", @@ -6547,6 +6584,12 @@ "minimatch": "3.0.4" } }, + "filesize": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz", + "integrity": "sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==", + "dev": true + }, "fill-range": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", @@ -9172,6 +9215,24 @@ "glogg": "1.0.1" } }, + "gzip-size": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-4.1.0.tgz", + "integrity": "sha1-iuCWJX6r59acRb4rZ8RIEk/7UXw=", + "dev": true, + "requires": { + "duplexer": "0.1.1", + "pify": "3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, "handlebars": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", @@ -9184,9 +9245,9 @@ } }, "handlebars-helpers": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/handlebars-helpers/-/handlebars-helpers-0.8.2.tgz", - "integrity": "sha1-jg232KkYSyVXIyEyFqpmh0KgpN0=", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/handlebars-helpers/-/handlebars-helpers-0.8.4.tgz", + "integrity": "sha1-+YgLeujYkOYxoxRvAZBQAFxU7RI=", "requires": { "arr-filter": "1.1.2", "arr-flatten": "1.1.0", @@ -13673,17 +13734,49 @@ "integrity": "sha512-VwGbHIT89e+9XdGcb2gdPgKgYQGjRG5peyPNO982znlCSB/UIM9g7gF6JmHpaMHb8xvEScY7UGJ8GRz6GQVBRg==" }, "office-ui-fabric-react": { - "version": "5.21.0", - "resolved": "https://registry.npmjs.org/office-ui-fabric-react/-/office-ui-fabric-react-5.21.0.tgz", - "integrity": "sha512-9IBLK6JUWYvdCumKywjkSP7mf/MqTRorP1qXtb2c+w2fQJH4NkdBjanO0zr37c5VPwlqc0KvPf51E9t1NU7oTg==", + "version": "5.118.0", + "resolved": "https://registry.npmjs.org/office-ui-fabric-react/-/office-ui-fabric-react-5.118.0.tgz", + "integrity": "sha512-foDTN918nHDoBrotjviSJWrmR+eGJj6nWkNT8pGcyQIrrw09/TIeihAmNbMmsu8RewLltDlvC2SiSkny6N0iLw==", "requires": { "@microsoft/load-themed-styles": "1.7.53", - "@uifabric/icons": "5.7.1", + "@uifabric/icons": "5.8.0", "@uifabric/merge-styles": "5.17.1", - "@uifabric/styling": "5.31.0", - "@uifabric/utilities": "5.27.0", + "@uifabric/styling": "5.31.2", + "@uifabric/utilities": "5.34.1", "prop-types": "15.6.2", "tslib": "1.8.1" + }, + "dependencies": { + "@uifabric/icons": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@uifabric/icons/-/icons-5.8.0.tgz", + "integrity": "sha512-EUhKxYlIPJshg4fQvCNTYSk0p7RhzEWeEAJBV4sao1SKmN0/pZBnkLbDqWjU5VUfdwZZYiIdaLRpM+pyzhniZw==", + "requires": { + "@uifabric/styling": "5.31.2", + "tslib": "1.8.1" + } + }, + "@uifabric/styling": { + "version": "5.31.2", + "resolved": "https://registry.npmjs.org/@uifabric/styling/-/styling-5.31.2.tgz", + "integrity": "sha512-G7grRENxdB4NcUEtQmSisRDnIeQHQmAfcpIe5AWmVQxnB/e8U/jT+SzYqK6V12SnLf4ufN5nepZkdOjgbtuA1Q==", + "requires": { + "@microsoft/load-themed-styles": "1.7.53", + "@uifabric/merge-styles": "5.17.1", + "@uifabric/utilities": "5.34.1", + "tslib": "1.8.1" + } + }, + "@uifabric/utilities": { + "version": "5.34.1", + "resolved": "https://registry.npmjs.org/@uifabric/utilities/-/utilities-5.34.1.tgz", + "integrity": "sha512-xUZ+KlCxmA9PCEOtutfeyYnPmySkEVA/ak3fb8Uj54684GlbrnlqrfNEencVG5YgQDcNEaztTwxW3I7jSCrYJQ==", + "requires": { + "@uifabric/merge-styles": "5.17.1", + "prop-types": "15.6.2", + "tslib": "1.8.1" + } + } } }, "on-finished": { @@ -13716,6 +13809,12 @@ "integrity": "sha1-QsPhjslUZra/DcQvOilFw/DK2Pw=", "dev": true }, + "opener": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/opener/-/opener-1.4.3.tgz", + "integrity": "sha1-XG2ixdflgx6P+jlklQ+NZnSskLg=", + "dev": true + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -18123,6 +18222,12 @@ "integrity": "sha1-jbAWIuh35RuDFAyu58gIZK05DII=", "dev": true }, + "tryer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", + "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", + "dev": true + }, "tslib": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.8.1.tgz", @@ -19035,6 +19140,73 @@ } } }, + "webpack-bundle-analyzer": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.13.1.tgz", + "integrity": "sha512-rwxyfecTAxoarCC9VlHlIpfQCmmJ/qWD5bpbjkof+7HrNhTNZIwZITxN6CdlYL2axGmwNUQ+tFgcSOiNXMf/sQ==", + "dev": true, + "requires": { + "acorn": "5.7.1", + "bfj-node4": "5.3.1", + "chalk": "2.4.1", + "commander": "2.16.0", + "ejs": "2.6.1", + "express": "4.16.3", + "filesize": "3.6.1", + "gzip-size": "4.1.0", + "lodash": "4.17.10", + "mkdirp": "0.5.1", + "opener": "1.4.3", + "ws": "4.1.0" + }, + "dependencies": { + "acorn": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", + "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "1.9.2" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "3.0.0" + } + }, + "ws": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz", + "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==", + "dev": true, + "requires": { + "async-limiter": "1.0.0", + "safe-buffer": "5.1.2" + } + } + } + }, "webpack-dev-middleware": { "version": "1.12.2", "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-1.12.2.tgz", diff --git a/samples/react-search-refiners/package.json b/samples/react-search-refiners/package.json index 2b930d579..cf01fe389 100644 --- a/samples/react-search-refiners/package.json +++ b/samples/react-search-refiners/package.json @@ -11,49 +11,50 @@ "test": "gulp test" }, "dependencies": { - "react": "15.6.2", - "react-dom": "15.6.2", - "@types/react": "15.6.6", - "@types/react-dom": "15.5.6", - "@microsoft/sp-loader": "1.5.1-plusbeta", + "@microsoft/decorators": "1.5.1-plusbeta", + "@microsoft/sp-application-base": "1.5.1-plusbeta", "@microsoft/sp-core-library": "1.5.1-plusbeta", - "@microsoft/sp-webpart-base": "1.5.1-plusbeta", + "@microsoft/sp-dialog": "1.5.1-plusbeta", + "@microsoft/sp-loader": "1.5.1-plusbeta", "@microsoft/sp-lodash-subset": "1.5.1-plusbeta", "@microsoft/sp-office-ui-fabric-core": "1.5.1-plusbeta", - "@types/webpack-env": "1.13.1", - "@types/es6-promise": "0.0.33", + "@microsoft/sp-webpart-base": "1.5.1-plusbeta", "@pnp/common": "1.0.3", "@pnp/logging": "1.0.3", "@pnp/odata": "1.0.3", "@pnp/sp": "1.0.3", "@pnp/spfx-controls-react": "1.5.0", "@pnp/spfx-property-controls": "1.7.0", - "@types/fabric": "^1.5.34", - "@types/handlebars": "^4.0.38", + "@types/es6-promise": "0.0.33", + "@types/fabric": "^1.5.40", + "@types/handlebars": "^4.0.39", + "@types/react": "15.6.6", + "@types/react-dom": "15.5.6", "@types/sharepoint": "2013.1.9", + "@types/webpack-env": "1.13.1", "common-tags": "^1.8.0", "downshift": "^1.31.14", "handlebars": "4.0.11", - "handlebars-helpers": "0.8.2", + "handlebars-helpers": "0.8.4", "immutability-helper": "2.4.0", "lodash-es": "4.17.4", "moment": "2.21.0", - "office-ui-fabric-react": "5.21.0", + "office-ui-fabric-react": "^5.118.0", + "react": "15.6.2", "react-ace": "^6.1.1", "react-custom-scrollbars": "4.1.2", - "react-js-pagination": "3.0.0", - "@microsoft/decorators": "1.5.1-plusbeta", - "@microsoft/sp-dialog": "1.5.1-plusbeta", - "@microsoft/sp-application-base": "1.5.1-plusbeta" + "react-dom": "15.6.2", + "react-js-pagination": "3.0.0" }, "devDependencies": { "@microsoft/sp-build-web": "1.5.1-plusbeta", "@microsoft/sp-module-interfaces": "1.5.1-plusbeta", "@microsoft/sp-webpart-workbench": "1.5.1-plusbeta", - "gulp": "~3.9.1", "@types/chai": "3.4.34", "@types/mocha": "2.2.38", "ajv": "~5.2.2", - "unlazy-loader": "0.1.2" + "gulp": "~3.9.1", + "unlazy-loader": "0.1.2", + "webpack-bundle-analyzer": "^2.13.1" } } diff --git a/samples/react-search-refiners/src/services/TemplateService/BaseTemplateService.ts b/samples/react-search-refiners/src/services/TemplateService/BaseTemplateService.ts index 25032449b..85dcf5dbf 100644 --- a/samples/react-search-refiners/src/services/TemplateService/BaseTemplateService.ts +++ b/samples/react-search-refiners/src/services/TemplateService/BaseTemplateService.ts @@ -1,13 +1,13 @@ -import * as Handlebars from 'handlebars'; -import { ISearchResult } from '../../models/ISearchResult'; -import { html } from 'common-tags'; -import { isEmpty } from '@microsoft/sp-lodash-subset'; -import * as strings from 'SearchWebPartStrings'; -import { Text } from '@microsoft/sp-core-library'; -import * as moment from 'moment'; +import * as Handlebars from 'handlebars'; +import { ISearchResult } from '../../models/ISearchResult'; +import { html } from 'common-tags'; +import { isEmpty } from '@microsoft/sp-lodash-subset'; +import * as strings from 'SearchWebPartStrings'; +import { Text } from '@microsoft/sp-core-library'; +import * as moment from 'moment'; abstract class BaseTemplateService { - + constructor() { // Registers all helpers this.registerTemplateServices(); @@ -111,11 +111,11 @@ abstract class BaseTemplateService { * Registers useful helpers for search results templates */ private registerTemplateServices() { - + // Return the URL of the search result item // Usage: Handlebars.registerHelper("getUrl", (item: ISearchResult) => { - if (!isEmpty(item)) + if (!isEmpty(item)) return item.ServerRedirectedURL ? item.ServerRedirectedURL : item.Path; }); @@ -156,7 +156,17 @@ abstract class BaseTemplateService { Handlebars.registerHelper("getDate", (date: string, format: string) => { if (moment(date).isValid()) { return moment(date).format(format); - } + } + }); + + // Return the URL or Title part of a URL automatic managed property + //

{{getDate MyLinkOWSURLH "Title"}}

+ Handlebars.registerHelper("getUrlField", (urlField: string, value: "URL" | "Title" ) => { + let separatorPos = urlField.lastIndexOf(","); + if(value === "URL") { + return urlField.substr(0, separatorPos); + } + return urlField.substr(separatorPos+1).trim(); }); } diff --git a/samples/react-search-refiners/src/webparts/controls/PropertyPaneTextDialog/components/TextDialog/TextDialog.tsx b/samples/react-search-refiners/src/webparts/controls/PropertyPaneTextDialog/components/TextDialog/TextDialog.tsx index 20d02ad49..d72dc6cc1 100644 --- a/samples/react-search-refiners/src/webparts/controls/PropertyPaneTextDialog/components/TextDialog/TextDialog.tsx +++ b/samples/react-search-refiners/src/webparts/controls/PropertyPaneTextDialog/components/TextDialog/TextDialog.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; -import { Dialog, DialogType, DialogFooter } from 'office-ui-fabric-react'; -import { Button, ButtonType, Label } from 'office-ui-fabric-react'; -import { TextField } from 'office-ui-fabric-react'; +import { Dialog, DialogType, DialogFooter } from 'office-ui-fabric-react/lib/Dialog'; +import { Button, ButtonType } from 'office-ui-fabric-react/lib/Button'; +import { Label } from 'office-ui-fabric-react/lib/Label'; import { ITextDialogProps } from './ITextDialogProps'; import { ITextDialogState } from './ITextDialogState'; import AceEditor from 'react-ace'; diff --git a/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.manifest.json b/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.manifest.json index dd1a3a89e..d3d092bc9 100644 --- a/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.manifest.json +++ b/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.manifest.json @@ -3,16 +3,12 @@ "id": "42ad2740-3c60-49cf-971a-c44e33511b93", "alias": "SearchWebPart", "componentType": "WebPart", - // The "*" signifies that the version should be taken from the package.json "version": "*", "manifestVersion": 2, - // If true, the component can only be installed on sites where Custom Script is allowed. - // Components that allow authors to embed arbitrary script code should set this to true. - // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f "requiresCustomScript": false, "preconfiguredEntries": [ { - "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other + "groupId": "5c03119e-3074-46fd-976b-c60198311f70", "group": { "default": "PnP" }, diff --git a/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.ts b/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.ts index bd0b8e6e1..f38fc9c5a 100644 --- a/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.ts +++ b/samples/react-search-refiners/src/webparts/searchResults/SearchResultsWebPart.ts @@ -547,7 +547,8 @@ export default class SearchResultsWebPart extends BaseClientSideWebPart { diff --git a/samples/react-search-refiners/src/webparts/searchResults/components/Layouts/ISearchResultsTemplateContext.ts b/samples/react-search-refiners/src/webparts/searchResults/components/Layouts/ISearchResultsTemplateContext.ts index 1d05a5385..47ff6882d 100644 --- a/samples/react-search-refiners/src/webparts/searchResults/components/Layouts/ISearchResultsTemplateContext.ts +++ b/samples/react-search-refiners/src/webparts/searchResults/components/Layouts/ISearchResultsTemplateContext.ts @@ -8,6 +8,8 @@ interface ISearchResultsTemplateContext { totalRows: number; keywords: string; showResultsCount: boolean; + siteUrl: string; + webUrl: string; } export default ISearchResultsTemplateContext; \ No newline at end of file diff --git a/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/ISearchResultsContainerProps.ts b/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/ISearchResultsContainerProps.ts index 4f794df0d..9861e8104 100644 --- a/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/ISearchResultsContainerProps.ts +++ b/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/ISearchResultsContainerProps.ts @@ -2,6 +2,7 @@ import ISearchService from '../../../../services/SearchService/ISearchServi import ITaxonomyService from '../../../../services/TaxonomyService/ITaxonomyService'; import { DisplayMode } from '@microsoft/sp-core-library'; import TemplateService from '../../../../services/TemplateService/TemplateService'; +import { WebPartContext } from '@microsoft/sp-webpart-base'; interface ISearchResultsContainerProps { @@ -74,6 +75,11 @@ interface ISearchResultsContainerProps { * The template raw content to display */ templateContent: string; + + /** + * The web part context + */ + context: WebPartContext; } export default ISearchResultsContainerProps; \ No newline at end of file diff --git a/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/SearchResultsContainer.tsx b/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/SearchResultsContainer.tsx index da1202b11..64ba1cd7c 100644 --- a/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/SearchResultsContainer.tsx +++ b/samples/react-search-refiners/src/webparts/searchResults/components/SearchResultsContainer/SearchResultsContainer.tsx @@ -94,7 +94,9 @@ export default class SearchResultsContainer extends React.Component