Updated containers, sample.json and tslint issues

This commit is contained in:
Hugo Bernier 2023-03-11 21:31:45 -05:00
parent 3cb06e5ad6
commit 65083eb8d3
4 changed files with 29 additions and 29 deletions

View File

@ -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 // 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", "name": "SPFx 1.16.1",
"image": "docker.io/m365pnp/spfx:1.15.0", "image": "docker.io/m365pnp/spfx:1.16.1",
// Set *default* container specific settings.json values on container create. // Set *default* container specific settings.json values on container create.
"settings": {}, "settings": {},
// Add the IDs of extensions you want installed when the container is created. // Add the IDs of extensions you want installed when the container is created.

View File

@ -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." "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", "creationDateTime": "2021-09-17",
"updateDateTime": "2022-07-07", "updateDateTime": "2023-03-06",
"products": [ "products": [
"SharePoint" "SharePoint"
], ],
@ -20,7 +20,7 @@
}, },
{ {
"key": "SPFX-VERSION", "key": "SPFX-VERSION",
"value": "1.15.0" "value": "1.16.1"
}, },
{ {
"key": "PNPCONTROLS", "key": "PNPCONTROLS",

View File

@ -29,6 +29,7 @@ export default class GraphAppSecretExpirationWebPart extends BaseClientSideWebPa
{ key: "type", text: "Type" }]; { key: "type", text: "Type" }];
public onInit(): Promise<void> { public onInit(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new Promise<void>((resolve: () => void, reject: (error: any) => void): void => { return new Promise<void>((resolve: () => void, reject: (error: any) => void): void => {
this.context.msGraphClientFactory this.context.msGraphClientFactory
.getClient("3") .getClient("3")

View File

@ -7,7 +7,6 @@ import { IGraphAppSecretExpirationState } from './GraphAppSecretExpirationState'
import * as moment from 'moment'; import * as moment from 'moment';
import { Spinner, mergeStyles, SearchBox } from '@fluentui/react'; import { Spinner, mergeStyles, SearchBox } from '@fluentui/react';
import { Pagination } from "@pnp/spfx-controls-react/lib/pagination"; import { Pagination } from "@pnp/spfx-controls-react/lib/pagination";
import * as strings from 'GraphAppSecretExpirationWebPartStrings';
import sampleApplications from '../../../models/SampleApplications.json'; import sampleApplications from '../../../models/SampleApplications.json';
const stackItemHidden = mergeStyles({ const stackItemHidden = mergeStyles({
@ -31,14 +30,14 @@ const _viewFields: IViewField[] = [
displayName: "Days left", displayName: "Days left",
minWidth: 80, minWidth: 80,
sorting: true, sorting: true,
render: (app: any) => { render: (app) => {
let fontColor; let fontColor;
if (app.daysLeft == 0) { if (app.daysLeft === 0) {
fontColor = "Red"; fontColor = "Red";
} else if (app.daysLeft < 30) { } else if (app.daysLeft < 30) {
fontColor = "Orange"; 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; return element;
} }
}, },
@ -91,15 +90,15 @@ export default class GraphAppSecretExpiration extends React.Component<IGraphAppS
.api("applications") .api("applications")
.version("v1.0") .version("v1.0")
.select("appId,displayName,passwordCredentials,keyCredentials") .select("appId,displayName,passwordCredentials,keyCredentials")
.get((err: any, res: IApplications): void => { .get((err: { message: string; }, res: IApplications): void => {
if (err) { if (err) {
this.setState({ this.setState({
error: err.message ? err.message : "An error occured", error: err.message ? err.message : "An error occurred",
loading: false loading: false
}); });
return; return;
} }
// applications retrived successfully // applications retrieved successfully
if (res && res.value && res.value.length > 0) { if (res && res.value && res.value.length > 0) {
this.setState({ this.setState({
loading: false loading: false
@ -116,19 +115,19 @@ export default class GraphAppSecretExpiration extends React.Component<IGraphAppS
} }
private _getSelection(items: any[]) { private _getSelection(items: []):void {
console.log('Selected items:', items); console.log('Selected items:', items);
} }
private _propertiesMapping = (applications: IApplication[]) => { private _propertiesMapping = (applications: IApplication[]):void => {
let displayedApplication: IFormattedApplication[] = []; const displayedApplication: IFormattedApplication[] = [];
var today = (moment(Date.now())).format('DD-MMM-YYYY'); const today = (moment(Date.now())).format('DD-MMM-YYYY');
try { try {
applications.forEach(app => { applications.forEach(app => {
app.passwordCredentials.forEach(pswd => { app.passwordCredentials.forEach(pswd => {
let daysBeforeExpiration = moment.duration((moment(pswd.endDateTime)).diff(today, 'days'), 'days').asDays(); const daysBeforeExpiration = moment.duration((moment(pswd.endDateTime)).diff(today, 'days'), 'days').asDays();
let formatedApp: IFormattedApplication = { const formattedApp: IFormattedApplication = {
applicationId: app.appId, applicationId: app.appId,
displayName: app.displayName, displayName: app.displayName,
type: "Secret", type: "Secret",
@ -138,15 +137,15 @@ export default class GraphAppSecretExpiration extends React.Component<IGraphAppS
}; };
if (this.props.expiringSoon) { if (this.props.expiringSoon) {
if (daysBeforeExpiration < 30) { if (daysBeforeExpiration < 30) {
displayedApplication.push(formatedApp); displayedApplication.push(formattedApp);
} }
} else { } else {
displayedApplication.push(formatedApp); displayedApplication.push(formattedApp);
} }
}); });
app.keyCredentials.forEach(keyCred => { app.keyCredentials.forEach(keyCred => {
let daysBeforeExpiration = moment.duration((moment(keyCred.endDateTime)).diff(today, 'days'), 'days').asDays(); const daysBeforeExpiration = moment.duration((moment(keyCred.endDateTime)).diff(today, 'days'), 'days').asDays();
let formatedApp: IFormattedApplication = { const formattedApp: IFormattedApplication = {
applicationId: app.appId, applicationId: app.appId,
displayName: app.displayName, displayName: app.displayName,
type: "Certificate", type: "Certificate",
@ -156,10 +155,10 @@ export default class GraphAppSecretExpiration extends React.Component<IGraphAppS
}; };
if (this.props.expiringSoon) { if (this.props.expiringSoon) {
if (daysBeforeExpiration < 30) { if (daysBeforeExpiration < 30) {
displayedApplication.push(formatedApp); displayedApplication.push(formattedApp);
} }
} else { } else {
displayedApplication.push(formatedApp); displayedApplication.push(formattedApp);
} }
}); });
}); });
@ -174,14 +173,14 @@ export default class GraphAppSecretExpiration extends React.Component<IGraphAppS
this._groupView(); this._groupView();
} }
private _getPage(selectedPage: number) { private _getPage(selectedPage: number):void {
this.setState({ this.setState({
page: selectedPage page: selectedPage
}); });
} }
private _filterApplication = (value: string, clear: boolean) => { private _filterApplication = (value: string, clear: boolean):void => {
let searchResult: IFormattedApplication[] = []; const searchResult: IFormattedApplication[] = [];
if (clear) { if (clear) {
this.state.applications.forEach(app => { this.state.applications.forEach(app => {
if (this._filterByProperties(app, value)) { if (this._filterByProperties(app, value)) {
@ -202,7 +201,7 @@ export default class GraphAppSecretExpiration extends React.Component<IGraphAppS
} }
private _filterByProperties(application: IFormattedApplication, filterValue: string) { private _filterByProperties(application: IFormattedApplication, filterValue: string): boolean {
if (application.applicationId.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) { if (application.applicationId.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) {
return true; return true;
} else if (application.displayName.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) { } else if (application.displayName.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0) {
@ -216,9 +215,9 @@ export default class GraphAppSecretExpiration extends React.Component<IGraphAppS
} }
} }
private _groupView = () => { private _groupView = ():void => {
if (this.props.groupByColumn !== "none") { if (this.props.groupByColumn !== "none") {
let groupByFields: IGrouping[] = [ const groupByFields: IGrouping[] = [
{ {
name: this.props.groupByColumn, name: this.props.groupByColumn,
order: GroupOrder.ascending order: GroupOrder.ascending