Merge pull request #3476 from HarminderSethi/main

First checkin for M365 Services Health SPFx webpart
This commit is contained in:
Hugo Bernier 2023-02-20 12:40:28 -05:00 committed by GitHub
commit 7bc16397eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 66582 additions and 0 deletions

View File

@ -0,0 +1,39 @@
// 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.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.
"extensions": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
4321,
35729
],
"portsAttributes": {
"4321": {
"protocol": "https",
"label": "Manifest",
"onAutoForward": "silent",
"requireLocalPort": true
},
// Not needed for SPFx>= 1.12.1
// "5432": {
// "protocol": "https",
// "label": "Workbench",
// "onAutoForward": "silent"
// },
"35729": {
"protocol": "https",
"label": "LiveReload",
"onAutoForward": "silent",
"requireLocalPort": true
}
},
"postCreateCommand": "bash .devcontainer/spfx-startup.sh",
"remoteUser": "node"
}

View File

@ -0,0 +1,33 @@
echo
echo -e "\e[1;94mInstalling Node dependencies\e[0m"
npm install
## commands to create dev certificate and copy it to the root folder of the project
echo
echo -e "\e[1;94mGenerating dev certificate\e[0m"
gulp trust-dev-cert
# Convert the generated PEM certificate to a CER certificate
openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer
# Copy the PEM ecrtificate for non-Windows hosts
cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem
## add *.cer to .gitignore to prevent certificates from being saved in repo
if ! grep -Fxq '*.cer' ./.gitignore
then
echo "# .CER Certificates" >> .gitignore
echo "*.cer" >> .gitignore
fi
## add *.pem to .gitignore to prevent certificates from being saved in repo
if ! grep -Fxq '*.pem' ./.gitignore
then
echo "# .PEM Certificates" >> .gitignore
echo "*.pem" >> .gitignore
fi
echo
echo -e "\e[1;92mReady!\e[0m"
echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********"

View File

@ -0,0 +1,352 @@
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
parserOptions: { tsconfigRootDir: __dirname },
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
'parserOptions': {
'project': './tsconfig.json',
'ecmaVersion': 2018,
'sourceType': 'module'
},
rules: {
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/no-new-null': 1,
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/hoist-jest-mock': 1,
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
'@rushstack/security/no-unsafe-regexp': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/adjacent-overload-signatures': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
//
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
'@typescript-eslint/ban-types': [
1,
{
'extendDefaults': false,
'types': {
'String': {
'message': 'Use \'string\' instead',
'fixWith': 'string'
},
'Boolean': {
'message': 'Use \'boolean\' instead',
'fixWith': 'boolean'
},
'Number': {
'message': 'Use \'number\' instead',
'fixWith': 'number'
},
'Object': {
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
},
'Symbol': {
'message': 'Use \'symbol\' instead',
'fixWith': 'symbol'
},
'Function': {
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
}
}
}
],
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
// Even if the compiler may be able to infer a type, this inference will be unavailable
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
// but writing code is a much less important activity than reading it.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/explicit-function-return-type': [
1,
{
'allowExpressions': true,
'allowTypedFunctionExpressions': true,
'allowHigherOrderFunctions': false
}
],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
// Set to 1 (warning) or 2 (error) to enable.
'@typescript-eslint/explicit-member-accessibility': 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-array-constructor': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
//
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
// This rule should be suppressed only in very special cases such as JSON.stringify()
// where the type really can be anything. Even if the type is flexible, another type
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
'@typescript-eslint/no-explicit-any': 1,
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
// or else return the object to a caller (who assumes this responsibility). Unterminated
// promise chains are a serious issue. Besides causing errors to be silently ignored,
// they can also cause a NodeJS process to terminate unexpectedly.
'@typescript-eslint/no-floating-promises': 2,
// RATIONALE: Catches a common coding mistake.
'@typescript-eslint/no-for-in-array': 2,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-misused-new': 2,
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
// optimizations. If you are declaring loose functions/variables, it's better to make them
// static members of a class, since classes support property getters and their private
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
// class name tends to produce more discoverable APIs: for example, search+replacing
// the function "reverse()" is likely to return many false matches, whereas if we always
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
// to decompose your code into separate NPM packages, which ensures that component
// dependencies are tracked more conscientiously.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-namespace': [
1,
{
'allowDeclarations': false,
'allowDefinitionFiles': false
}
],
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
// code easier to write, but arguably sacrifices readability: In the notes for
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
// a class's design, so we wouldn't want to bury them in a constructor signature
// just to save some typing.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/no-parameter-properties': 0,
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
// may impact performance.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-unused-vars': [
1,
{
'vars': 'all',
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
// that are overriding a base class method or implementing an interface.
'args': 'none'
}
],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-use-before-define': [
2,
{
'functions': false,
'classes': true,
'variables': true,
'enums': true,
'typedefs': true
}
],
// 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',
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/prefer-namespace-keyword': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
// Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/no-inferrable-types': 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
'@typescript-eslint/no-empty-interface': 0,
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
'accessor-pairs': 1,
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
'dot-notation': [
1,
{
'allowPattern': '^_'
}
],
// RATIONALE: Catches code that is likely to be incorrect
'eqeqeq': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'for-direction': 1,
// RATIONALE: Catches a common coding mistake.
'guard-for-in': 2,
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
// to split up your code.
'max-lines': ['warn', { max: 2000 }],
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-async-promise-executor': 2,
// RATIONALE: Deprecated language feature.
'no-caller': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-compare-neg-zero': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-cond-assign': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-constant-condition': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-control-regex': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-debugger': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-delete-var': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-duplicate-case': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-character-class': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-pattern': 1,
// RATIONALE: Eval is a security concern and a performance concern.
'no-eval': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-ex-assign': 2,
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
// If two different libraries (or two versions of the same library) both try to modify
// a type, only one of them can win. Polyfills are acceptable because they implement
// a standardized interoperable contract, but polyfills are generally coded in plain
// JavaScript.
'no-extend-native': 1,
// Disallow unnecessary labels
'no-extra-label': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-fallthrough': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-func-assign': 1,
// RATIONALE: Catches a common coding mistake.
'no-implied-eval': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-invalid-regexp': 2,
// RATIONALE: Catches a common coding mistake.
'no-label-var': 2,
// RATIONALE: Eliminates redundant code.
'no-lone-blocks': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-misleading-character-class': 2,
// RATIONALE: Catches a common coding mistake.
'no-multi-str': 2,
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
// or else implies that the constructor is doing nontrivial computations, which is often
// a poor class design.
'no-new': 1,
// RATIONALE: Obsolete language feature that is deprecated.
'no-new-func': 2,
// RATIONALE: Obsolete language feature that is deprecated.
'no-new-object': 2,
// RATIONALE: Obsolete notation.
'no-new-wrappers': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-octal': 2,
// RATIONALE: Catches code that is likely to be incorrect
'no-octal-escape': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-regex-spaces': 2,
// RATIONALE: Catches a common coding mistake.
'no-return-assign': 2,
// RATIONALE: Security risk.
'no-script-url': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-self-assign': 2,
// RATIONALE: Catches a common coding mistake.
'no-self-compare': 2,
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
// commas to create compound expressions. In general code is more readable if each
// step is split onto a separate line. This also makes it easier to set breakpoints
// in the debugger.
'no-sequences': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-shadow-restricted-names': 2,
// RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-sparse-arrays': 2,
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
// such flexibility adds pointless complexity, by requiring every catch block to test
// the type of the object that it receives. Whereas if catch blocks can always assume
// that their object implements the "Error" contract, then the code is simpler, and
// we generally get useful additional information like a call stack.
'no-throw-literal': 2,
// RATIONALE: Catches a common coding mistake.
'no-unmodified-loop-condition': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unsafe-finally': 2,
// RATIONALE: Catches a common coding mistake.
'no-unused-expressions': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unused-labels': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-useless-catch': 1,
// RATIONALE: Avoids a potential performance problem.
'no-useless-concat': 1,
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
// Always use "let" or "const" instead.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'no-var': 2,
// RATIONALE: Generally not needed in modern code.
'no-void': 1,
// RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-with': 2,
// RATIONALE: Makes logic easier to understand, since constants always have a known value
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
'prefer-const': 1,
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
'promise/param-names': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-atomic-updates': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-yield': 1,
// "Use strict" is redundant when using the TypeScript compiler.
'strict': [
2,
'never'
],
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'use-isnan': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
// Set to 1 (warning) or 2 (error) to enable.
// Rationale to disable: !!{}
'no-extra-boolean-cast': 0,
// ====================================================================
// @microsoft/eslint-plugin-spfx
// ====================================================================
'@microsoft/spfx/import-requires-chunk-name': 1,
'@microsoft/spfx/no-require-ensure': 2,
'@microsoft/spfx/pair-react-dom-render-unmount': 1
}
},
{
// For unit tests, we can be a little bit less strict. The settings below revise the
// defaults specified in the extended configurations, as well as above.
files: [
// Test files
'*.test.ts',
'*.test.tsx',
'*.spec.ts',
'*.spec.tsx',
// Facebook convention
'**/__mocks__/*.ts',
'**/__mocks__/*.tsx',
'**/__tests__/*.ts',
'**/__tests__/*.tsx',
// Microsoft convention
'**/test/*.ts',
'**/test/*.tsx'
],
rules: {}
}
]
};

View File

@ -0,0 +1,35 @@
# Logs
logs
*.log
npm-debug.log*
# Dependency directories
node_modules
# Build generated files
dist
lib
release
solution
temp
*.sppkg
.heft
# Coverage directory used by tools like istanbul
coverage
# OSX
.DS_Store
# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj
# Resx Generated Code
*.resx.ts
# Styles Generated Code
*.scss.ts
*.scss.d.ts

View File

@ -0,0 +1,16 @@
!dist
config
gulpfile.js
release
src
temp
tsconfig.json
tslint.json
*.log
.yo-rc.json
.vscode

View File

@ -0,0 +1,21 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": false,
"isCreatingSolution": true,
"nodeVersion": "16.16.0",
"sdksVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.4.1"
},
"version": "1.16.1",
"libraryName": "react-m-365-services-health",
"libraryId": "f4d4b329-f1c6-49c9-a2fa-12a9816ac717",
"environment": "spo",
"packageManager": "npm",
"solutionName": "react-m365-services-health",
"solutionShortDescription": "react-m365-services-health description",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "webpart"
}
}

View File

@ -0,0 +1,109 @@
# Service Health for Microsoft 365
## Summary
Contains SPFx web part with below functionalities
1. Show the health status for all the M365 services
2. Complete details including all the updates for all the impacted services
![M365 Services Health List](./assets/M365ServiceHealthList.png)
![Service Health Detail](./assets/M365ServiceHealthDetail.png)
## Compatibility
| :warning: Important |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node. |
| Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
This sample is optimally compatible with the following environment configuration:
![SPFx 1.16.1](https://img.shields.io/badge/SPFx-1.16.1-green.svg)
![Node.js v16 | v14 | v12](https://img.shields.io/badge/Node.js-v16%20%7C%20v14%20%7C%20v12-green.svg)
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
![Does not work with SharePoint 2016 (Feature Pack 2)](<https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg> "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above")
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
For more information about SPFx compatibility, please refer to <https://aka.ms/spfx-matrix>
## Applies to
- [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
- [Microsoft 365 tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/m365devprogram)
## Prerequisites
- SharePoint Online tenant
- You have to provide permission in SharePoint admin for accessing Graph API on behalf of your solution. You can do it before deployment as proactive steps, or after deployment. You can refer to [steps about how to do this post-deployment](https://learn.microsoft.com/sharepoint/dev/spfx/use-aad-tutorial#deploy-the-solution-and-grant-permissions). You have to use API Access Page of SharePoint admin and add below permission for our use case.
```
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "ServiceHealth.Read.All"
}
]
```
## Contributors
[Harminder Singh](https://github.com/HarminderSethi) <https://www.linkedin.com/in/harmindersinghsethi/> |
## Version history
| Version | Date | Comments |
| ------- | ----------------- | --------------- |
| 1.0 | February 15, 2023 | Initial release |
## Minimal Path to Awesome
- Clone this repository (or [download this solution as a .ZIP file](https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-m365-services-health) then unzip it)
- From your command line, change your current directory to the directory containing this sample (`react-m365-services-health`, located under `samples`)
- in the command line run:
- `npm install`
- `gulp serve`
> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit <https://aka.ms/spfx-devcontainer> for further instructions.
## Features
1. Show the health status for all the M365 services
2. Complete details including all the updates for all the impacted services
## References
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [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)
- [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
## Help
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.
You can try looking at [issues related to this sample](https://github.com/pnp/sp-dev-fx-webparts/issues?q=label%3A%22sample%3A%20react-m365-services-health%22) to see if anybody else is having the same issues.
You can also try looking at [discussions related to this sample](https://github.com/pnp/sp-dev-fx-webparts/discussions?discussions_q=react-m365-services-health) and see what the community is saying.
If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-m365-services-health&template=bug-report.yml&sample=react-m365-services-health&authors=@HarminderSethi&title=react-m365-services-health%20-%20).
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-m365-services-health&template=question.yml&sample=react-m365-services-health&authors=@HarminderSethi&title=react-m365-services-health%20-%20).
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-m365-services-health&template=suggestion.yml&sample=react-m365-services-health&authors=@HarminderSethi&title=react-m365-services-health%20-%20).
## Disclaimer
**THIS CODE IS PROVIDED _AS IS_ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
<img src="https://pnptelemetry.azurewebsites.net/sp-dev-fx-webparts/samples/react-m365-services-health" />
---

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,50 @@
[
{
"name": "pnp-sp-dev-spfx-web-parts-react-m365-services-health",
"source": "pnp",
"title": "Service Health for Microsoft 365",
"shortDescription": "Service Health for Microsoft 365 solution show the health status for all the Microsoft 365 services",
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-m365-services-health",
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-m365-services-health",
"longDescription": [
"Service Health for Microsoft 365 solution show the health status for all the M365 services"
],
"creationDateTime": "2023-02-03",
"updateDateTime": "2023-02-03",
"products": [
"SharePoint"
],
"metadata": [
{
"key": "CLIENT-SIDE-DEV",
"value": "React"
},
{
"key": "SPFX-VERSION",
"value": "1.16.1"
}
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-m365-services-health/assets/M365ServiceHealthDetail.png",
"alt": "Web Part Preview"
}
],
"authors": [
{
"gitHubAccount": "HarminderSethi",
"pictureUrl": "https://github.com/HarminderSethi.png",
"name": "Harminder Singh"
}
],
"references": [
{
"name": "Build your first SharePoint client-side web part",
"description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.",
"url": "https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part"
}
]
}
]

View File

@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"m-365-services-health-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/m365ServicesHealth/M365ServicesHealthWebPart.js",
"manifest": "./src/webparts/m365ServicesHealth/M365ServicesHealthWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"M365ServicesHealthWebPartStrings": "lib/webparts/m365ServicesHealth/loc/{locale}.js"
}
}

View File

@ -0,0 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "react-m-365-services-health",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -0,0 +1,49 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "Service Health for Microsoft 365",
"id": "f4d4b329-f1c6-49c9-a2fa-12a9816ac717",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"developer": {
"name": "Harminder Singh",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.16.1"
},
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "ServiceHealth.Read.All"
}
],
"metadata": {
"shortDescription": {
"default": "Service Health for Microsoft 365"
},
"longDescription": {
"default": "Service Health for Microsoft 365"
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "Service Health for Microsoft 365 Feature",
"description": "The feature that activates elements of the react-m-365-services-health solution.",
"id": "9d9e7584-45be-4df4-8023-5c271402cf87",
"version": "1.0.0.0"
}
]
},
"paths": {
"zippedPackage": "solution/M365-Services-Health.sppkg"
}
}

View File

@ -0,0 +1,3 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
}

View File

@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}

View File

@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}

View File

@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/s-KaiNet/spfx-fast-serve/master/schema/config.latest.schema.json",
"cli": {
"isLibraryComponent": false
}
}

View File

@ -0,0 +1,24 @@
/*
* User webpack settings file. You can add your own settings here.
* Changes from this file will be merged into the base webpack configuration file.
* This file will not be overwritten by the subsequent spfx-fast-serve calls.
*/
// you can add your project related webpack configuration here, it will be merged using webpack-merge module
// i.e. plugins: [new webpack.Plugin()]
const webpackConfig = {
}
// for even more fine-grained control, you can apply custom webpack settings using below function
const transformConfig = function (initialWebpackConfig) {
// transform the initial webpack config here, i.e.
// initialWebpackConfig.plugins.push(new webpack.Plugin()); etc.
return initialWebpackConfig;
}
module.exports = {
webpackConfig,
transformConfig
}

View File

@ -0,0 +1,22 @@
'use strict';
const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);
result.set('serve', result.get('serve-deprecated'));
return result;
};
/* fast-serve */
const { addFastServe } = require("spfx-fast-serve-helpers");
addFastServe(build);
/* end of fast-serve */
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
{
"name": "react-m-365-services-health",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=16.13.0 <17.0.0"
},
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test",
"serve": "gulp bundle --custom-serve --max_old_space_size=4096 && fast-serve"
},
"dependencies": {
"@fluentui/react": "^8.104.8",
"@microsoft/microsoft-graph-types": "^2.25.0",
"@microsoft/sp-core-library": "1.16.1",
"@microsoft/sp-lodash-subset": "1.16.1",
"@microsoft/sp-office-ui-fabric-core": "1.16.1",
"@microsoft/sp-property-pane": "1.16.1",
"@microsoft/sp-webpart-base": "1.16.1",
"moment": "^2.29.4",
"office-ui-fabric-react": "^7.199.1",
"react": "17.0.1",
"react-dom": "17.0.1",
"tslib": "2.3.1"
},
"devDependencies": {
"@microsoft/eslint-config-spfx": "1.16.1",
"@microsoft/eslint-plugin-spfx": "1.16.1",
"@microsoft/rush-stack-compiler-4.5": "0.2.2",
"@microsoft/sp-build-web": "1.16.1",
"@microsoft/sp-module-interfaces": "1.16.1",
"@rushstack/eslint-config": "2.5.1",
"@types/react": "17.0.45",
"@types/react-dom": "17.0.17",
"@types/webpack-env": "~1.15.2",
"ajv": "^6.12.5",
"eslint-plugin-react-hooks": "4.3.0",
"gulp": "4.0.2",
"spfx-fast-serve-helpers": "~1.16.0",
"typescript": "4.5.5"
}
}

View File

@ -0,0 +1,22 @@
import { ServiceHealth } from "@microsoft/microsoft-graph-types";
import { MSGraphClientV3, GraphRequest } from "@microsoft/sp-http-msgraph";
import { WebPartContext } from "@microsoft/sp-webpart-base";
export class GraphService {
private context: WebPartContext;
constructor(context: WebPartContext) {
this.context = context;
}
private getClient = async (): Promise<MSGraphClientV3> => {
return await this.context.msGraphClientFactory.getClient("3");
};
public getHealthOverviews = async (): Promise<ServiceHealth[]> => {
const client = await this.getClient();
const request: GraphRequest = client.api("/admin/serviceAnnouncement/healthOverviews");
const response = await request.expand("issues").get();
return Promise.resolve(response.value);
};
}

View File

@ -0,0 +1,91 @@
export const getFormattedDateTime = (value: string): string => {
const date = new Date(value);
const dateString = date.toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",
});
const timeString = date.toLocaleTimeString("en-US", {
hour: "numeric",
minute: "numeric",
hour12: true,
});
return `${dateString} ${timeString}`;
};
export const getProductIcon = (value: string): string => {
let icon: string = "Product";
switch (value?.toLowerCase()) {
case "microsoft intune":
case "mobile device management for office 365":
case "identity service":
case "microsoft 365 apps":
case "microsoft 365 defender":
case "microsoft 365 for the web":
case "microsoft defender for cloud apps":
case "privileged access":
icon = "Product";
break;
case "exchange online":
icon = "ExchangeLogo";
break;
case "microsoft 365 suite":
icon = "AdminALogoInverse32";
break;
case "microsoft teams":
icon = "TeamsLogo";
break;
case "sharepoint online":
case "microsoft viva":
icon = "SharepointLogo";
break;
case "azure information protection":
icon = "AzureLogo";
break;
case "dynamics 365 apps":
icon = "Dynamics365Logo";
break;
case "microsoft bookings":
icon = "BookingsLogo";
break;
case "microsoft forms":
icon = "OfficeFormsLogo";
break;
case "microsoft power automate":
case "microsoft power automate in microsoft 365":
icon = "MicrosoftFlowLogo";
break;
case "microsoft staffHub":
icon = "MicrosoftStaffhubLogo";
break;
case "microsoft stream":
icon = "StreamLogo";
break;
case "onedrive for business":
icon = "OneDriveLogo";
break;
case "planner":
icon = "PlannerLogo";
break;
case "power apps":
case "power apps in microsoft 365":
icon = "PowerAppsLogo";
break;
case "power bi":
icon = "PowerBILogo";
break;
case "project for the web":
icon = "ProjectLogoInverse";
break;
case "skype for Business":
icon = "SkypeForBusinessLogo";
break;
case "sway":
icon = "SwayLogoInverse";
break;
case "Yammer Enterprise":
icon = "YammerLogo";
break;
}
return icon;
};

View File

@ -0,0 +1 @@
// A file is required to be in the root of the /src directory by the TypeScript compiler

View File

@ -0,0 +1,28 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "b43bbaf4-e46b-4106-9495-700bc965996f",
"alias": "M365ServicesHealthWebPart",
"componentType": "WebPart",
// The "*" signifies that the version should be taken from the package.json
"version": "*",
"manifestVersion": 2,
// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript": false,
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
"supportsThemeVariants": true,
"preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
"group": { "default": "Advanced" },
"title": { "default": "Service Health for Microsoft 365" },
"description": { "default": "m365-services-health description" },
"officeFabricIconFontName": "HealthSolid",
"properties": {
"description": "m365-services-health"
}
}]
}

View File

@ -0,0 +1,64 @@
import * as React from "react";
import * as ReactDom from "react-dom";
import { Version } from "@microsoft/sp-core-library";
import { IPropertyPaneConfiguration, PropertyPaneTextField } from "@microsoft/sp-property-pane";
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
import * as strings from "M365ServicesHealthWebPartStrings";
import M365ServicesHealth from "./components/M365ServicesHealth";
import { IM365ServicesHealthProps } from "./components/IM365ServicesHealthProps";
import { GraphService } from "../../common/services/GraphService";
export interface IM365ServicesHealthWebPartProps {
title: string;
height: number;
}
export default class M365ServicesHealthWebPart extends BaseClientSideWebPart<IM365ServicesHealthWebPartProps> {
private graphService: GraphService;
public render(): void {
const element: React.ReactElement<IM365ServicesHealthProps> = React.createElement(M365ServicesHealth, {
title: this.properties.title,
context: this.context,
graphService: this.graphService,
});
ReactDom.render(element, this.domElement);
}
protected onInit(): Promise<void> {
this.graphService = new GraphService(this.context);
return Promise.resolve();
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse("1.0");
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription,
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField("title", {
label: strings.TitleFieldLabel,
}),
],
},
],
},
],
};
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,7 @@
import { WebPartContext } from "@microsoft/sp-webpart-base";
import { GraphService } from "../../../common/services/GraphService";
export interface IM365ServicesHealthProps {
title: string;
context: WebPartContext;
graphService: GraphService;
}

View File

@ -0,0 +1,15 @@
import * as React from "react";
import { IM365ServicesHealthProps } from "./IM365ServicesHealthProps";
import { ServiceHealthHeader } from "./ServiceHealthHeader/ServiceHealthHeader";
import { ServiceHealthOverview } from "./ServiceHealthOverview/ServiceHealthOverview";
const M365ServicesHealth = (props: IM365ServicesHealthProps): JSX.Element => {
return (
<>
<ServiceHealthHeader title={props.title} />
<ServiceHealthOverview graphService={props.graphService} />
</>
);
};
export default M365ServicesHealth;

View File

@ -0,0 +1,28 @@
.header {
border-bottom: 1px solid rgb(232, 232, 232);
padding-bottom: 20px;
position: sticky;
left: 0px;
}
.headerContainer {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.headerText {
font-family: inherit;
-webkit-font-smoothing: antialiased;
font-size: 24px;
font-weight: 700;
color: rgb(0, 0, 0);
margin-top: 24px;
margin-bottom: 14px;
}
.headerTimestamp {
font-family: inherit;
-webkit-font-smoothing: antialiased;
font-size: 12px;
font-weight: 600;
color: rgb(72, 70, 68);
}

View File

@ -0,0 +1,13 @@
import * as React from "react";
import { IServiceHealthHeaderProps } from "../../interfaces/ServiceHealthModels";
import style from "./ServiceHealthHeader.module.scss";
export const ServiceHealthHeader = (props: IServiceHealthHeaderProps): JSX.Element => {
return (
<div className={style.header}>
<div className={style.headerContainer}>
<span className={style.headerText}>{props.title}</span>
</div>
</div>
);
};

View File

@ -0,0 +1,79 @@
import { IButtonStyles, ILinkStyles, IPanelStyleProps, IPanelStyles, IStyleFunctionOrObject } from "@fluentui/react";
export const issueListPanelStyles: IStyleFunctionOrObject<IPanelStyleProps, IPanelStyles> = {
commands: { marginTop: "inherit" },
contentInner: { display: "flex", flexDirection: "column", flexGrow: 1, overflowY: "hidden" },
scrollableContent: { overflowY: "auto", flexGrow: 1, paddingLeft: 32, paddingRight: 32, paddingBottom: 16 },
};
export const issueDetailPanelStyles: IStyleFunctionOrObject<IPanelStyleProps, IPanelStyles> = {
commands: { marginTop: "inherit" },
contentInner: { display: "flex", flexDirection: "column", flexGrow: 1, overflowY: "hidden" },
scrollableContent: { overflowY: "auto", flexGrow: 1, paddingLeft: 32, paddingRight: 32, paddingBottom: 16 },
};
export const backButtonStyles: Partial<IButtonStyles> = {
root: {
outline: "transparent",
fontSize: 14,
fontWeight: 400,
border: "none",
display: "flex",
textAlign: "center",
margin: 8,
minHeight: 32,
minWidth: 32,
height: 32,
width: 32,
justifyContent: "center",
},
icon: { fontSize: 16, margin: "0px 4px", height: 16, lineHeight: 16, textAlign: "center", flexShrink: 0 },
};
export const cancelButtonStyle: Partial<IButtonStyles> = {
root: {
outline: "transparent",
fontSize: 14,
fontWeight: 400,
border: "none",
display: "flex",
textAlign: "center",
margin: 8,
minHeight: 32,
minWidth: 32,
height: 32,
width: 32,
justifyContent: "center",
},
icon: { fontSize: 16, margin: "0px 4px", height: 16, lineHeight: 16, textAlign: "center", flexShrink: 0 },
};
export const linkStyleAdvisory: Partial<ILinkStyles> = {
root: {
color: "rgb(0, 108, 190)",
"&:focus": {
color: "rgb(0, 108, 190)",
},
"&:active": {
color: "rgb(0, 108, 190)",
},
"&:hover": {
color: "rgb(0, 108, 190)",
},
},
};
export const linkStyleWarning: Partial<ILinkStyles> = {
root: {
color: "rgb(197, 54, 1)",
"&:focus": {
color: "rgb(197, 54, 1)",
},
"&:active": {
color: "rgb(197, 54, 1)",
},
"&:hover": {
color: "rgb(197, 54, 1)",
},
},
};

View File

@ -0,0 +1,87 @@
.issueDetailRoot {
margin-top: 16px;
margin-bottom: 16px;
display: flex;
justify-content: center;
}
.serviceStatusIcon {
line-height: 16px;
display: flex;
}
.rowItem {
font-family: inherit;
-webkit-font-smoothing: antialiased;
font-size: 12px;
font-weight: 400;
height: 1.25rem;
}
.issueDetailWrapper {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.issueDetailTitle {
font-family: inherit;
-webkit-font-smoothing: antialiased;
font-size: 20px;
font-weight: 700;
color: rgb(0, 0, 0);
max-height: none;
overflow: hidden;
margin: 0px;
}
.subHeaderContainer {
padding-bottom: 40px;
}
.subHeaderText {
color: rgb(50, 49, 48);
}
.textLabel {
padding-bottom: 4px;
font-weight: 600;
color: rgb(50, 49, 48);
}
.flyoutTextStyle {
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
font-weight: 400;
line-height: 20px;
padding-bottom: 24px;
}
.serviceIconStyles {
font-size: 16px;
margin-right: 4px;
vertical-align: sub;
}
.itemsContainer {
display: flex;
flex-wrap: wrap;
margin: -10.5px 16px -10.5px -16px;
}
.itemContainer {
flex: 1 1 calc(50% - 32px);
margin: 10.5px 16px;
max-width: 100%;
}
.flyoutContentDivider {
border-bottom: 1px solid rgb(225, 223, 221);
margin-bottom: 12px;
}
.textLabelForHistory {
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
font-weight: 600;
line-height: 20px;
padding-bottom: 8px;
color: rgb(50, 49, 48);
display: flex;
flex-direction: row;
}

View File

@ -0,0 +1,100 @@
import { ServiceHealthIssuePost } from "@microsoft/microsoft-graph-types";
import Style from "./IssueDetail.module.scss";
import * as React from "react";
import * as HelperService from "../../../../../common/services/HelperService";
import { Icon, Label } from "@fluentui/react";
import { IIssueDetailProps } from "../../../interfaces/ServiceHealthModels";
export const IssueDetail = (props: IIssueDetailProps): JSX.Element => {
return (
<>
<div className={Style.issueDetailRoot}>
<div className={Style.issueDetailWrapper}>
<h1 className={Style.issueDetailTitle}>{props.details?.title}</h1>
</div>
</div>
<div className={Style.subHeaderContainer}>
<div className={Style.subHeaderText}>
{props.details?.id}, Last updated: {HelperService.getFormattedDateTime(props.details?.lastModifiedDateTime)}
</div>
<div className={Style.subHeaderText}>Estimated Start time: {HelperService.getFormattedDateTime(props.details?.startDateTime)}</div>
</div>
<Label>Affected Services</Label>
<div className={Style.flyoutTextStyle}>
<Icon iconName={HelperService.getProductIcon(props.details?.service)} />
<span> {props.details?.service}</span>
</div>
<div className={Style.flyoutTextStyle} style={{ paddingBottom: 10 }}>
<div className={Style.itemsContainer}>
<div className={Style.itemContainer}>
<Label>Issue Type</Label>
<div className={Style.flyoutTextStyle}>
<span className={Style.rowItem}>
<div className={Style.serviceStatusIcon}>
<Icon
iconName={props.details?.classification === "advisory" ? "InfoSolid" : "WarningSolid"}
styles={{ root: { color: props.details?.classification === "advisory" ? "rgb(0, 120, 212)" : "rgb(197, 54, 1)" } }}
/>
<div style={{ fontSize: 14, fontWeight: 400, marginLeft: 6, verticalAlign: "middle" }}>
<span style={{ color: props.details?.classification === "advisory" ? "rgb(0, 120, 212)" : "rgb(197, 54, 1)" }}>
{props.details?.classification.charAt(0).toUpperCase() + props.details?.classification.slice(1)}
</span>
</div>
</div>
</span>
</div>
</div>
<div className={Style.itemContainer}>
<Label>Issue origin</Label>
<div className={Style.flyoutTextStyle}>
<span className={Style.rowItem}>
<div className={Style.serviceStatusIcon}>
<div style={{ fontSize: 14, fontWeight: 400, verticalAlign: "middle" }}>
<span>{props.details?.origin.charAt(0).toUpperCase() + props.details?.origin.slice(1)}</span>
</div>
</div>
</span>
</div>
</div>
</div>
</div>
<div className={Style.flyoutTextStyle} style={{ paddingBottom: 10 }}>
<div className={Style.itemsContainer}>
<div className={Style.itemContainer}>
<Label>Status</Label>
<div className={Style.flyoutTextStyle}>
<span className={Style.rowItem}>
<div className={Style.serviceStatusIcon}>
<div style={{ fontSize: 14, fontWeight: 400, verticalAlign: "middle" }}>
<span>{props.details?.status.charAt(0).toUpperCase() + props.details?.status.slice(1)}</span>
</div>
</div>
</span>
</div>
</div>
</div>
</div>
<div>
<Label> User Impact</Label>
<div className={Style.flyoutTextStyle}>{props.details?.impactDescription}</div>
</div>
<h2>All Updates</h2>
{props.details?.posts
?.sort((a, b) => {
return new Date(b.createdDateTime).valueOf() - new Date(a.createdDateTime).valueOf(); // descending
})
.map((post: ServiceHealthIssuePost, index: number) => {
return (
<div key={index}>
<div className={Style.flyoutContentDivider} />
<div className={Style.textLabelForHistory}>{HelperService.getFormattedDateTime(post.createdDateTime)}</div>
<div
dangerouslySetInnerHTML={{ __html: post.description?.content }}
style={{ whiteSpace: "pre-line", margin: 0, boxSizing: "inherit", color: "rgb(50,49,48)", paddingBottom: 10 }}
/>
</div>
);
})}
</>
);
};

View File

@ -0,0 +1,91 @@
.rowItem {
font-family: inherit;
-webkit-font-smoothing: antialiased;
font-size: 12px;
font-weight: 400;
height: 1.25rem;
}
.serviceStatusIcon {
line-height: 16px;
display: flex;
}
.healthStatusLink {
margin-top: 2px;
margin-left: 4px;
}
.headerText {
font-family: inherit;
-webkit-font-smoothing: antialiased;
font-size: 20px;
font-weight: 700;
color: rgb(50, 49, 48);
line-height: 27px;
overflow-wrap: break-word;
word-break: break-word;
hyphens: none;
}
.tableHeaderRow {
width: 100%;
display: grid;
grid-template-columns: repeat(2, 1fr);
&:hover {
cursor: pointer;
}
}
.content {
grid-column-start: 1;
grid-row-start: 1;
color: rgb(72, 70, 68);
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
outline: none;
border-top: none;
border-right: none;
border-left: none;
border-image-source: initial;
border-image-slice: initial;
border-image-outset: initial;
border-image-repeat: initial;
border-image-width: 0px;
text-decoration: none;
font-size: 12px;
background-color: rgb(255, 255, 255);
border-bottom: 1px solid rgb(225, 225, 225);
vertical-align: baseline;
padding: 15px 22px 14px 2px;
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
font-weight: 400;
}
.primaryColumnContainer {
grid-column-start: 2;
grid-row-start: 1;
color: rgb(72, 70, 68);
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
outline: none;
border-top: none;
border-right: none;
border-left: none;
border-image-source: initial;
border-image-slice: initial;
border-image-outset: initial;
border-image-repeat: initial;
border-image-width: 0px;
text-decoration: none;
font-size: 12px;
background-color: rgb(255, 255, 255);
border-bottom: 1px solid rgb(225, 225, 225);
vertical-align: baseline;
padding: 15px 22px 14px 2px;
font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
font-weight: 400;
}

View File

@ -0,0 +1,45 @@
import { Icon } from "@fluentui/react";
import { ServiceHealthIssue } from "@microsoft/microsoft-graph-types";
import * as React from "react";
import { IIssueListProps } from "../../../interfaces/ServiceHealthModels";
import Style from "./IssueList.module.scss";
export const IssueList = (props: IIssueListProps): JSX.Element => {
return (
<>
<h1 className={Style.headerText}>{`Health issues affecting ${props.selectedItem?.Service}`}</h1>
<table role={"grid"}>
<thead>
<tr role={"row"} className={Style.tableHeaderRow}>
<th className={Style.content}>Issue Title</th>
<th className={Style.primaryColumnContainer}>Issue Type</th>
</tr>
</thead>
<tbody>
{props.selectedItem?.InProgressItems?.map((item: ServiceHealthIssue, index: number) => {
return (
<tr role={"row"} className={Style.tableHeaderRow} onClick={() => props.onClick(item)} key={index}>
<td className={Style.content}>{item.title}</td>
<td className={Style.primaryColumnContainer}>
<span className={Style.rowItem}>
<div className={Style.serviceStatusIcon}>
<Icon
iconName={item.classification === "advisory" ? "InfoSolid" : "WarningSolid"}
styles={{ root: { color: item.classification === "advisory" ? "rgb(0, 120, 212)" : "rgb(197, 54, 1)", paddingTop: 3 } }}
/>
<div className={Style.healthStatusLink}>
<span style={{ color: item.classification === "advisory" ? "rgb(0, 120, 212)" : "rgb(197, 54, 1)" }}>
{item.classification.charAt(0).toUpperCase() + item.classification.slice(1)}
</span>
</div>
</div>
</span>
</td>
</tr>
);
})}
</tbody>
</table>
</>
);
};

View File

@ -0,0 +1,28 @@
.rowItem {
font-family: inherit;
-webkit-font-smoothing: antialiased;
font-size: 12px;
font-weight: 400;
height: 1.25rem;
}
.serviceStatusIcon {
line-height: 16px;
display: flex;
}
.healthStatusLink {
margin-top: 2px;
margin-left: 4px;
}
.serviceIconStyles {
font-size: 16px;
margin-right: 4px;
vertical-align: sub;
}
.message {
font-size: 12px;
font-weight: 400;
margin-left: 4px;
vertical-align: middle;
}

View File

@ -0,0 +1,52 @@
import { Icon, Label, Link } from "@fluentui/react";
import Style from "./ListItem.module.scss";
import * as React from "react";
import { IListItemProps, IServiceHealthOverviewItem } from "../../../interfaces/ServiceHealthModels";
import { linkStyleAdvisory, linkStyleWarning } from "../Constant";
export const ListItem = (props: IListItemProps): JSX.Element => {
const { column, item } = props;
const fieldContent = item[column.fieldName as keyof IServiceHealthOverviewItem] as string;
return (
<>
{column.fieldName === "Service" ? (
<Label>{fieldContent}</Label>
) : fieldContent.toLowerCase().indexOf("healthy") > -1 ? (
<span className={Style.rowItem}>
<div className={Style.serviceStatusIcon}>
<Icon iconName="CompletedSolid" styles={{ root: { color: "rgb(16, 124, 16)", paddingTop: 4 } }} />
<div className={Style.healthStatusLink}>
<span className={Style.message}>{fieldContent}</span>
</div>
</div>
</span>
) : (
fieldContent.split(",").map((value) => {
return value.indexOf("advisor") > -1 ? (
<span className={Style.rowItem}>
<div className={Style.serviceStatusIcon}>
<Icon iconName="InfoSolid" styles={{ root: { color: "rgb(0, 120, 212)", paddingTop: 3 } }} />
<div className={Style.healthStatusLink}>
<Link styles={linkStyleAdvisory} onClick={() => props.onLinkClick(item)}>
{value}
</Link>
</div>
</div>
</span>
) : (
<span className={Style.rowItem}>
<div className={Style.serviceStatusIcon}>
<Icon iconName="WarningSolid" styles={{ root: { color: "rgb(197, 54, 1)", paddingTop: 3 } }} />
<div className={Style.healthStatusLink}>
<Link styles={linkStyleWarning} onClick={() => props.onLinkClick(item)}>
{value}
</Link>
</div>
</div>
</span>
);
})
)}
</>
);
};

View File

@ -0,0 +1,116 @@
import { DefaultButton, DetailsList, IColumn, IPanelProps, IRenderFunction, Panel, PanelType, SelectionMode, Spinner } from "@fluentui/react";
import { ServiceHealth, ServiceHealthIssue } from "@microsoft/microsoft-graph-types";
import * as React from "react";
import { IServiceHealthOverviewItem, IServiceHealthOverviewProps, IServiceHealthOverviewState } from "../../interfaces/ServiceHealthModels";
import * as ListViewHelperService from "../../services/ListViewHelperService";
import { backButtonStyles, cancelButtonStyle, issueDetailPanelStyles, issueListPanelStyles } from "./Constant";
import { IssueDetail } from "./IssueDetail/IssueDetail";
import { IssueList } from "./IssueList/IssueList";
import { ListItem } from "./ListItem/ListItem";
export const ServiceHealthOverview = (props: IServiceHealthOverviewProps): JSX.Element => {
const [state, setState] = React.useState<IServiceHealthOverviewState>({
columns: ListViewHelperService.getOverviewListViewColumns(),
items: [],
showIssueListPanel: false,
showIssueDetailPanel: false,
selectedItem: null,
selectedIssue: null,
showBackButton: false,
spinner: true,
});
/* eslint-disable */
React.useEffect(() => {
let listViewItems: IServiceHealthOverviewItem[] = [];
(async () => {
try {
const response: ServiceHealth[] = await props.graphService.getHealthOverviews();
listViewItems = ListViewHelperService.getListViewItemsForOverview(response);
} catch (ex) {
console.log(ex);
}
setState((prevState: IServiceHealthOverviewState) => ({ ...prevState, items: listViewItems, spinner: false }));
})();
}, []);
const _renderItemColumn = (item: IServiceHealthOverviewItem, index: number, column: IColumn) => {
return <ListItem item={item} index={index} column={column} onLinkClick={handleLinkClick} />;
};
const handleLinkClick = (item: IServiceHealthOverviewItem) => {
if (item.InProgressItems.length > 1) {
setState((prevState: IServiceHealthOverviewState) => ({ ...prevState, showIssueListPanel: true, selectedItem: item }));
} else {
setState((prevState: IServiceHealthOverviewState) => ({
...prevState,
showIssueDetailPanel: true,
selectedItem: item,
selectedIssue: item.InProgressItems[0],
}));
}
};
const handleDismissPanel = () => {
setState((prevState: IServiceHealthOverviewState) => ({ ...prevState, showIssueDetailPanel: false, showIssueListPanel: false, showBackButton: false }));
};
const handleIssueDetailClick = (item: ServiceHealthIssue) => {
setState((prevState: IServiceHealthOverviewState) => ({
...prevState,
showIssueDetailPanel: true,
showIssueListPanel: false,
selectedIssue: item,
showBackButton: true,
}));
};
const handleBackClick = () => {
setState((prevState: IServiceHealthOverviewState) => ({
...prevState,
showIssueDetailPanel: false,
showIssueListPanel: true,
showBackButton: true,
}));
};
const handleCloseClick = () => {
setState((prevState: IServiceHealthOverviewState) => ({
...prevState,
showIssueDetailPanel: false,
showIssueListPanel: false,
showBackButton: true,
selectedItem: null,
selectedIssue: null,
}));
};
const _renderNavigation: IRenderFunction<IPanelProps> = (props: IPanelProps, defaultRender): JSX.Element => {
return state.showBackButton ? (
<div style={{ display: "flex", minHeight: 32, position: "relative", justifyContent: "space-between", marginLeft: -32 }}>
<DefaultButton iconProps={{ iconName: "Back" }} styles={backButtonStyles} onClick={handleBackClick}></DefaultButton>
<DefaultButton iconProps={{ iconName: "Cancel" }} styles={cancelButtonStyle} onClick={handleCloseClick}></DefaultButton>
</div>
) : (
defaultRender(props)
);
};
return (
<>
{state.spinner && <Spinner styles={{ root: { paddingTop: 20 } }} />}
{!state.spinner && <DetailsList columns={state.columns} items={state.items} selectionMode={SelectionMode.none} onRenderItemColumn={_renderItemColumn} />}
<Panel isOpen={state.showIssueListPanel} onDismiss={handleDismissPanel} type={PanelType.medium} styles={issueListPanelStyles}>
<IssueList selectedItem={state.selectedItem} onClick={handleIssueDetailClick} />
</Panel>
<Panel
isOpen={state.showIssueDetailPanel}
onDismiss={handleDismissPanel}
type={PanelType.medium}
styles={issueDetailPanelStyles}
onRenderNavigation={_renderNavigation}
>
<IssueDetail details={state.selectedIssue} />
</Panel>
</>
);
};

View File

@ -0,0 +1,42 @@
import { IColumn } from "@fluentui/react";
import { ServiceHealthIssue } from "@microsoft/microsoft-graph-types";
import { GraphService } from "../../../common/services/GraphService";
export interface IServiceHealthOverviewItem {
Service: string;
Status: string;
InProgressItems?: ServiceHealthIssue[];
}
export interface IServiceHealthOverviewProps {
graphService: GraphService;
}
export interface IServiceHealthHeaderProps {
title: string;
}
export interface IServiceHealthOverviewState {
columns: IColumn[];
items: IServiceHealthOverviewItem[];
showIssueListPanel: boolean;
showIssueDetailPanel: boolean;
selectedItem: IServiceHealthOverviewItem;
selectedIssue: ServiceHealthIssue;
showBackButton: boolean;
spinner: boolean;
}
export interface IIssueDetailProps {
details: ServiceHealthIssue;
}
export interface IIssueListProps {
selectedItem: IServiceHealthOverviewItem;
onClick: (item: ServiceHealthIssue) => void;
}
export interface IListItemProps {
column: IColumn;
item: IServiceHealthOverviewItem;
index: number;
onLinkClick: (item: IServiceHealthOverviewItem) => void;
}

View File

@ -0,0 +1,15 @@
define([], function() {
return {
"PropertyPaneDescription": "",
"BasicGroupName": "",
"TitleFieldLabel": "Title",
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
"AppLocalEnvironmentOffice": "The app is running on your local environment in office.com",
"AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook",
"AppSharePointEnvironment": "The app is running on SharePoint page",
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams",
"AppOfficeEnvironment": "The app is running in office.com",
"AppOutlookEnvironment": "The app is running in Outlook"
}
});

View File

@ -0,0 +1,18 @@
declare interface IM365ServicesHealthWebPartStrings {
PropertyPaneDescription: string;
BasicGroupName: string;
TitleFieldLabel: string;
AppLocalEnvironmentSharePoint: string;
AppLocalEnvironmentTeams: string;
AppLocalEnvironmentOffice: string;
AppLocalEnvironmentOutlook: string;
AppSharePointEnvironment: string;
AppTeamsTabEnvironment: string;
AppOfficeEnvironment: string;
AppOutlookEnvironment: string;
}
declare module "M365ServicesHealthWebPartStrings" {
const strings: IM365ServicesHealthWebPartStrings;
export = strings;
}

View File

@ -0,0 +1,63 @@
import { IServiceHealthOverviewItem } from "./../interfaces/ServiceHealthModels";
import { IColumn } from "@fluentui/react";
import { ServiceHealth, ServiceHealthIssue } from "@microsoft/microsoft-graph-types";
export const getOverviewListViewColumns = (): IColumn[] => {
const viewColumnsSchema: IColumn[] = [
{
key: "Service",
name: "Service",
fieldName: "Service",
minWidth: 80,
maxWidth: 300,
isResizable: true,
},
{
key: "Status",
name: "Status",
fieldName: "Status",
minWidth: 120,
},
];
return viewColumnsSchema;
};
export const getListViewItemsForOverview = (response: ServiceHealth[]): IServiceHealthOverviewItem[] => {
const overviewItems: IServiceHealthOverviewItem[] = [];
for (let i = 0; i < response.length; i++) {
const value = response[i];
const overviewItem = {} as IServiceHealthOverviewItem;
overviewItem.Service = value.service;
const inProgressIssues: ServiceHealthIssue[] = value.issues.filter((issue) => !issue.isResolved);
if (inProgressIssues.length > 0) {
const counts = inProgressIssues.reduce(
(acc, curr) => {
if (curr.classification === "advisory") {
acc.advisoryCount++;
} else if (curr.classification === "incident" || curr.classification === "unknownFutureValue") {
acc.incidentCount++;
}
return acc;
},
{ advisoryCount: 0, incidentCount: 0 }
);
const status: string[] = [];
if (counts.advisoryCount > 0) {
status.push(`${counts.advisoryCount} ${counts.advisoryCount === 1 ? "advisory" : "advisories"}`);
}
if (counts.incidentCount > 0) {
status.push(`${counts.incidentCount} ${counts.incidentCount === 1 ? "incident" : "incidents"}`);
}
overviewItem.Status = status.join(",");
overviewItem.InProgressItems = inProgressIssues;
} else {
overviewItem.Status = "Healthy";
overviewItem.InProgressItems = [];
}
overviewItems.push(overviewItem);
}
overviewItems.sort((a, b) => a.Status.localeCompare(b.Status));
return overviewItems;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

View File

@ -0,0 +1,23 @@
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.5/includes/tsconfig-web.json",
"compilerOptions": {
"target": "es5",
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "lib",
"inlineSources": false,
"strictNullChecks": false,
"noImplicitAny": true,
"typeRoots": ["./node_modules/@types", "./node_modules/@microsoft"],
"types": ["webpack-env"],
"lib": ["ES2017", "es5", "dom", "es2015.collection", "es2015.promise"]
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}