Remove warnings

This commit is contained in:
mmsharepoint 2024-07-13 10:03:58 +02:00
parent 37a6d8bc21
commit 718195b2c9
No known key found for this signature in database
GPG Key ID: DC103BFDD388283F
4 changed files with 10 additions and 16 deletions

View File

@ -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

View File

@ -33,7 +33,6 @@ 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"];
@ -54,7 +53,7 @@ namespace SampleConsumeFunc
//string siteDescreption = body.Descreption;
bool siteDescreptionUpdated = await _graphClientService.UpdateSiteDescreption(bearerToken, siteUrl, siteDescreption);
return new OkObjectResult("Welcome to Azure Functions!");
return siteDescreptionUpdated ? new OkObjectResult("") : new BadRequestResult();
}
}
}

View File

@ -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<any[]> {
public async setNewSiteDescreption(siteUrl: string, siteDescreption: string): Promise<boolean> {
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

View File

@ -18,8 +18,7 @@ export const SampleSiteFunction: React.FC<ISampleSiteFunctionProps> = (props) =>
setDescription(value);
};
const assignPermissions = async () => {
console.log('Action');
const assignPermissions = async (): Promise<void> => {
const graphService = new FunctionService(props.serviceScope);
const resp = await graphService.setNewSiteDescreption(url, description);
@ -31,11 +30,6 @@ export const SampleSiteFunction: React.FC<ISampleSiteFunctionProps> = (props) =>
<div className={styles.field}>
<h2>{strings.HeaderLabel}</h2>
</div>
{/* <div>
{
props.isAdminMode?<div className={styles.field}><SelectSite serviceScope={props.serviceScope} siteSelectedCallback={retrieveSiteID} /></div>:<div className={styles.field}><h3>Current site is used</h3></div>
}
</div> */}
<div className={styles.field}>
<TextField
label={strings.URLLabel}