Merge branch 'pnp:main' into main

This commit is contained in:
Takashi Shinohara 2021-10-14 21:53:49 +09:00 committed by GitHub
commit 19d2775130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 17 deletions

View File

@ -10001,9 +10001,9 @@
} }
}, },
"i": { "i": {
"version": "0.3.6", "version": "0.3.7",
"resolved": "https://registry.npmjs.org/i/-/i-0.3.6.tgz", "resolved": "https://registry.npmjs.org/i/-/i-0.3.7.tgz",
"integrity": "sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0=", "integrity": "sha512-FYz4wlXgkQwIPqhzC5TdNMLSE5+GS1IIDJZY/1ZiEPCT2S3COUVZeT5OW4BmW4r5LHLQuOosSwsvnroG9GR59Q==",
"dev": true "dev": true
}, },
"iconv-lite": { "iconv-lite": {

View File

@ -43,7 +43,7 @@
"@types/mocha": "2.2.38", "@types/mocha": "2.2.38",
"ajv": "~5.2.2", "ajv": "~5.2.2",
"gulp": "~3.9.1", "gulp": "~3.9.1",
"i": "0.3.6", "i": "0.3.7",
"npm": "6.14.6", "npm": "6.14.6",
"tslint-microsoft-contrib": "5.0.0" "tslint-microsoft-contrib": "5.0.0"
}, },

View File

@ -2,7 +2,7 @@
## Summary ## Summary
This sample shows how to initegrate SharePoint Framework, PnP React Controls, and Microsoft Graph Toolkit in a solution available for SharePoint web parts or Microsoft Teams personal application. This sample shows how to integrate SharePoint Framework, PnP React Controls, and Microsoft Graph Toolkit in a solution available for SharePoint web parts or Microsoft Teams personal application.
![Lead Assist Dashboard](./assets/LeadAssistDashboard_overview.png) ![Lead Assist Dashboard](./assets/LeadAssistDashboard_overview.png)
@ -73,7 +73,9 @@ This web part illustrates the following concepts:
- [Building for Microsoft Teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview) - [Building for Microsoft Teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis) - [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview) - [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development - [The easiest way to store user settings of your Microsoft 365 app
](https://blog.mastykarz.nl/easiest-store-user-settings-microsoft-365-app/ )
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
## Disclaimer ## Disclaimer

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 150 KiB

View File

@ -3,7 +3,7 @@
"solution": { "solution": {
"name": "lead-assist-client-side-solution", "name": "lead-assist-client-side-solution",
"id": "c311a0fc-3dcb-4316-a798-fd7d8a6d5344", "id": "c311a0fc-3dcb-4316-a798-fd7d8a6d5344",
"version": "1.0.11.0", "version": "1.0.13.0",
"includeClientSideAssets": true, "includeClientSideAssets": true,
"skipFeatureDeployment": true, "skipFeatureDeployment": true,
"isDomainIsolated": false, "isDomainIsolated": false,

View File

@ -1,6 +1,6 @@
{ {
"name": "lead-assist", "name": "lead-assist",
"version": "1.0.11", "version": "1.0.13",
"private": true, "private": true,
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {

View File

@ -2,15 +2,16 @@ import { HttpClient, MSGraphClient } from "@microsoft/sp-http";
export default class SettingsService { export default class SettingsService {
/** /**
* Get the application settings from drive * Get the application settings from OneDrive
* @param graphClient Graph client to be used for the request * @param graphClient Graph client to be used for the request
* @param httpClient Http client to be used for the request * @param httpClient Http client to be used for the request
* @param settingsFilename Name of the file to read the settings from
* @returns Object representing the JSON settings file * @returns Object representing the JSON settings file
*/ */
public static async getSettings(graphClient: MSGraphClient, httpClient: HttpClient): Promise<any> { public static async getSettings(graphClient: MSGraphClient, httpClient: HttpClient, settingsFilename: string): Promise<any> {
// Get approot files // Get approot files
const approotFiles = await graphClient const approotFiles = await graphClient
.api('/me/drive/special/approot/children') .api(`/me/drive/special/approot/children?$filter=name%20eq%20'${settingsFilename}'`)
.version("v1.0") .version("v1.0")
.get(); .get();
@ -30,14 +31,15 @@ export default class SettingsService {
} }
/** /**
* Save the specified settings to drive * Save the specified settings to OneDrive
* @param graphClient Graph client to be used for the request * @param graphClient Graph client to be used for the request
* @param settings Object representing the settings to be saved on the JSON settings file * @param settings Object representing the settings to be saved on the JSON settings file
* @param settingsFilename Name of the file to store the settings on
*/ */
public static async saveSiteUrl(graphClient: MSGraphClient, settings: any) { public static async saveSettings(graphClient: MSGraphClient, settings: any, settingsFilename: string) {
// Save the settings in the application dedicated folder // Save the settings in the application dedicated folder
await graphClient await graphClient
.api('/me/drive/special/approot:/settings.json:/content') .api(`/me/drive/special/approot:/${settingsFilename}:/content`)
.version("v1.0") .version("v1.0")
.header('content-type', 'text/plain') .header('content-type', 'text/plain')
.put(JSON.stringify(settings)); .put(JSON.stringify(settings));

View File

@ -39,7 +39,7 @@ export default class LeadAssistDashboardWebPart extends BaseClientSideWebPart<IL
this.graphClient = await this.context.msGraphClientFactory.getClient(); this.graphClient = await this.context.msGraphClientFactory.getClient();
// Get the settings // Get the settings
const settings = await SettingsService.getSettings(this.graphClient, this.context.httpClient); const settings = await SettingsService.getSettings(this.graphClient, this.context.httpClient, 'lead_dashboard_settings.json');
// If there are settings specified // If there are settings specified
if (settings) { if (settings) {

View File

@ -136,7 +136,7 @@ export default class LeadAssistDashboard extends React.Component<ILeadAssistDash
<TextField value={this.props.siteUrl} onChange={this.changeSiteUrlHandler} /> <TextField value={this.props.siteUrl} onChange={this.changeSiteUrlHandler} />
</div> </div>
<div className={styles.padding5}> <div className={styles.padding5}>
<PrimaryButton text={strings.SaveConfiguration} onClick={() => { SettingsService.saveSiteUrl(this.props.graphClient, { siteUrl: this.state.siteUrl }); }} /> <PrimaryButton text={strings.SaveConfiguration} onClick={() => { SettingsService.saveSettings(this.props.graphClient, { siteUrl: this.state.siteUrl }, 'lead_dashboard_settings.json'); }} />
</div> </div>
</div>; </div>;
} }

View File

@ -28,7 +28,7 @@ export default class LeadAssistDashboardSettingsWebPart extends BaseClientSideWe
const graphClient = await this.context.msGraphClientFactory.getClient(); const graphClient = await this.context.msGraphClientFactory.getClient();
// Get the settings // Get the settings
const settings = await SettingsService.getSettings(graphClient, this.context.httpClient); const settings = await SettingsService.getSettings(graphClient, this.context.httpClient, 'lead_dashboard_settings.json');
// If there are settings specified // If there are settings specified
if (settings) { if (settings) {