From 65083eb8d3fd56c63970b042e4a13f2fd43abbc3 Mon Sep 17 00:00:00 2001 From: Hugo Bernier Date: Sat, 11 Mar 2023 21:31:45 -0500 Subject: [PATCH] Updated containers, sample.json and tslint issues --- .../.devcontainer/devcontainer.json | 4 +- .../assets/sample.json | 4 +- .../GraphAppSecretExpirationWebPart.ts | 1 + .../components/GraphAppSecretExpiration.tsx | 49 +++++++++---------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/samples/react-graph-app-secret-expiration/.devcontainer/devcontainer.json b/samples/react-graph-app-secret-expiration/.devcontainer/devcontainer.json index f6340c327..d0df53099 100644 --- a/samples/react-graph-app-secret-expiration/.devcontainer/devcontainer.json +++ b/samples/react-graph-app-secret-expiration/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ // For more information on how to run this SPFx project in a VS Code Remote Container, please visit https://aka.ms/spfx-devcontainer { - "name": "SPFx 1.15.0", - "image": "docker.io/m365pnp/spfx:1.15.0", + "name": "SPFx 1.16.1", + "image": "docker.io/m365pnp/spfx:1.16.1", // Set *default* container specific settings.json values on container create. "settings": {}, // Add the IDs of extensions you want installed when the container is created. diff --git a/samples/react-graph-app-secret-expiration/assets/sample.json b/samples/react-graph-app-secret-expiration/assets/sample.json index c027c705c..357182f38 100644 --- a/samples/react-graph-app-secret-expiration/assets/sample.json +++ b/samples/react-graph-app-secret-expiration/assets/sample.json @@ -9,7 +9,7 @@ "This sample web part shows the list of your applications registered in Azure AD along with their associated client secret/certificate expiration date." ], "creationDateTime": "2021-09-17", - "updateDateTime": "2022-07-07", + "updateDateTime": "2023-03-06", "products": [ "SharePoint" ], @@ -20,7 +20,7 @@ }, { "key": "SPFX-VERSION", - "value": "1.15.0" + "value": "1.16.1" }, { "key": "PNPCONTROLS", diff --git a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/GraphAppSecretExpirationWebPart.ts b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/GraphAppSecretExpirationWebPart.ts index ab967d428..7e3820df2 100644 --- a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/GraphAppSecretExpirationWebPart.ts +++ b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/GraphAppSecretExpirationWebPart.ts @@ -29,6 +29,7 @@ export default class GraphAppSecretExpirationWebPart extends BaseClientSideWebPa { key: "type", text: "Type" }]; public onInit(): Promise { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return new Promise((resolve: () => void, reject: (error: any) => void): void => { this.context.msGraphClientFactory .getClient("3") diff --git a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx index 655d4d12a..f4a7c64bf 100644 --- a/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx +++ b/samples/react-graph-app-secret-expiration/src/webparts/graphAppSecretExpiration/components/GraphAppSecretExpiration.tsx @@ -7,7 +7,6 @@ import { IGraphAppSecretExpirationState } from './GraphAppSecretExpirationState' import * as moment from 'moment'; import { Spinner, mergeStyles, SearchBox } from '@fluentui/react'; import { Pagination } from "@pnp/spfx-controls-react/lib/pagination"; -import * as strings from 'GraphAppSecretExpirationWebPartStrings'; import sampleApplications from '../../../models/SampleApplications.json'; const stackItemHidden = mergeStyles({ @@ -31,14 +30,14 @@ const _viewFields: IViewField[] = [ displayName: "Days left", minWidth: 80, sorting: true, - render: (app: any) => { + render: (app) => { let fontColor; - if (app.daysLeft == 0) { + if (app.daysLeft === 0) { fontColor = "Red"; } else if (app.daysLeft < 30) { fontColor = "Orange"; } - const element: any = React.createElement("span", { style: { color: fontColor } }, app.daysLeft); + const element = React.createElement("span", { style: { color: fontColor } }, app.daysLeft); return element; } }, @@ -91,15 +90,15 @@ export default class GraphAppSecretExpiration extends React.Component { + .get((err: { message: string; }, res: IApplications): void => { if (err) { this.setState({ - error: err.message ? err.message : "An error occured", + error: err.message ? err.message : "An error occurred", loading: false }); return; } - // applications retrived successfully + // applications retrieved successfully if (res && res.value && res.value.length > 0) { this.setState({ loading: false @@ -116,19 +115,19 @@ export default class GraphAppSecretExpiration extends React.Component { - let displayedApplication: IFormattedApplication[] = []; - var today = (moment(Date.now())).format('DD-MMM-YYYY'); + private _propertiesMapping = (applications: IApplication[]):void => { + const displayedApplication: IFormattedApplication[] = []; + const today = (moment(Date.now())).format('DD-MMM-YYYY'); try { applications.forEach(app => { app.passwordCredentials.forEach(pswd => { - let daysBeforeExpiration = moment.duration((moment(pswd.endDateTime)).diff(today, 'days'), 'days').asDays(); - let formatedApp: IFormattedApplication = { + const daysBeforeExpiration = moment.duration((moment(pswd.endDateTime)).diff(today, 'days'), 'days').asDays(); + const formattedApp: IFormattedApplication = { applicationId: app.appId, displayName: app.displayName, type: "Secret", @@ -138,15 +137,15 @@ export default class GraphAppSecretExpiration extends React.Component { - let daysBeforeExpiration = moment.duration((moment(keyCred.endDateTime)).diff(today, 'days'), 'days').asDays(); - let formatedApp: IFormattedApplication = { + const daysBeforeExpiration = moment.duration((moment(keyCred.endDateTime)).diff(today, 'days'), 'days').asDays(); + const formattedApp: IFormattedApplication = { applicationId: app.appId, displayName: app.displayName, type: "Certificate", @@ -156,10 +155,10 @@ export default class GraphAppSecretExpiration extends React.Component { - let searchResult: IFormattedApplication[] = []; + private _filterApplication = (value: string, clear: boolean):void => { + const searchResult: IFormattedApplication[] = []; if (clear) { this.state.applications.forEach(app => { if (this._filterByProperties(app, value)) { @@ -202,7 +201,7 @@ export default class GraphAppSecretExpiration extends React.Component= 0) { return true; } else if (application.displayName.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) { @@ -216,9 +215,9 @@ export default class GraphAppSecretExpiration extends React.Component { + private _groupView = ():void => { if (this.props.groupByColumn !== "none") { - let groupByFields: IGrouping[] = [ + const groupByFields: IGrouping[] = [ { name: this.props.groupByColumn, order: GroupOrder.ascending