From 718195b2c90a6565f4f58e2d72f736a4b8c4b0f5 Mon Sep 17 00:00:00 2001 From: mmsharepoint Date: Sat, 13 Jul 2024 10:03:58 +0200 Subject: [PATCH] Remove warnings --- samples/react-site-secure-function-call/.eslintrc.js | 2 +- .../Functions/SampleConumeFunc/SiteFunction.cs | 7 +++---- .../src/services/FunctionService.ts | 7 ++++--- .../components/SampleSiteFunction.tsx | 10 ++-------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/samples/react-site-secure-function-call/.eslintrc.js b/samples/react-site-secure-function-call/.eslintrc.js index 473df80cd..fa02c8f13 100644 --- a/samples/react-site-secure-function-call/.eslintrc.js +++ b/samples/react-site-secure-function-call/.eslintrc.js @@ -146,7 +146,7 @@ module.exports = { ], // Disallows require statements except in import statements. // In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports. - '@typescript-eslint/no-var-requires': 'error', + '@typescript-eslint/no-var-requires': 'off', // RATIONALE: The "module" keyword is deprecated except when describing legacy libraries. // // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json diff --git a/samples/react-site-secure-function-call/Functions/SampleConumeFunc/SiteFunction.cs b/samples/react-site-secure-function-call/Functions/SampleConumeFunc/SiteFunction.cs index 00d86965b..320e64ce3 100644 --- a/samples/react-site-secure-function-call/Functions/SampleConumeFunc/SiteFunction.cs +++ b/samples/react-site-secure-function-call/Functions/SampleConumeFunc/SiteFunction.cs @@ -33,8 +33,7 @@ namespace SampleConsumeFunc var bearerToken = await _tokenValidationService .ValidateAuthorizationHeaderAsync(req); - _logger.LogInformation("Bootstrap token: " + bearerToken); // not nessesary - + string siteUrl = req.Query["URL"]; string siteDescreption = req.Query["Descreption"]; @@ -53,8 +52,8 @@ namespace SampleConsumeFunc //string siteUrl = body.URL; //string siteDescreption = body.Descreption; - bool siteDescreptionUpdated = await _graphClientService.UpdateSiteDescreption(bearerToken, siteUrl, siteDescreption); - return new OkObjectResult("Welcome to Azure Functions!"); + bool siteDescreptionUpdated = await _graphClientService.UpdateSiteDescreption(bearerToken, siteUrl, siteDescreption); + return siteDescreptionUpdated ? new OkObjectResult("") : new BadRequestResult(); } } } diff --git a/samples/react-site-secure-function-call/src/services/FunctionService.ts b/samples/react-site-secure-function-call/src/services/FunctionService.ts index ae3fafcf2..84ddd45a3 100644 --- a/samples/react-site-secure-function-call/src/services/FunctionService.ts +++ b/samples/react-site-secure-function-call/src/services/FunctionService.ts @@ -1,6 +1,7 @@ import { ServiceKey, ServiceScope } from "@microsoft/sp-core-library"; import { AadHttpClientFactory, AadHttpClient, HttpClientResponse } from "@microsoft/sp-http"; -const config: any = require('./azFunct.json') + +const config = require('./azFunct.json'); export default class FunctionService { private aadHttpClientFactory: AadHttpClientFactory; @@ -15,13 +16,13 @@ export default class FunctionService { }); } - public async setNewSiteDescreption(siteUrl: string, siteDescreption: string): Promise { + public async setNewSiteDescreption(siteUrl: string, siteDescreption: string): Promise { this.client = await this.aadHttpClientFactory.getClient(`${config.appIdUri}`); const requestUrl = `${config.hostUrl}/api/SiteFunction?URL=${siteUrl}&Descreption=${siteDescreption}`; return this.client .get(requestUrl, AadHttpClient.configurations.v1) .then((response: HttpClientResponse) => { - return response.json(); + return response.ok; }); // POST alternative diff --git a/samples/react-site-secure-function-call/src/webparts/sampleSiteFunction/components/SampleSiteFunction.tsx b/samples/react-site-secure-function-call/src/webparts/sampleSiteFunction/components/SampleSiteFunction.tsx index b7ca4c6c7..27d24474b 100644 --- a/samples/react-site-secure-function-call/src/webparts/sampleSiteFunction/components/SampleSiteFunction.tsx +++ b/samples/react-site-secure-function-call/src/webparts/sampleSiteFunction/components/SampleSiteFunction.tsx @@ -18,8 +18,7 @@ export const SampleSiteFunction: React.FC = (props) => setDescription(value); }; - const assignPermissions = async () => { - console.log('Action'); + const assignPermissions = async (): Promise => { const graphService = new FunctionService(props.serviceScope); const resp = await graphService.setNewSiteDescreption(url, description); @@ -30,12 +29,7 @@ export const SampleSiteFunction: React.FC = (props) =>

{strings.HeaderLabel}

-
- {/*
- { - props.isAdminMode?
:

Current site is used

- } -
*/} +