Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGT login sample in React #20

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
352 changes: 352 additions & 0 deletions samples/app/react-login-spfx/.eslintrc.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions samples/app/react-login-spfx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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
16 changes: 16 additions & 0 deletions samples/app/react-login-spfx/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!dist
config

gulpfile.js

release
src
temp

tsconfig.json
tslint.json

*.log

.yo-rc.json
.vscode
1 change: 1 addition & 0 deletions samples/app/react-login-spfx/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.1
23 changes: 23 additions & 0 deletions samples/app/react-login-spfx/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Hosted workbench",
"type": "msedge",
"request": "launch",
"url": "https://{tenantDomain}/_layouts/workbench.aspx",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///.././src/*": "${webRoot}/src/*",
"webpack:///../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../../src/*": "${webRoot}/src/*"
},
"runtimeArgs": [
"--remote-debugging-port=9222",
"-incognito"
]
}
]
}
14 changes: 14 additions & 0 deletions samples/app/react-login-spfx/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Place your settings in this file to overwrite default and user settings.
{
// Configure glob patterns for excluding files and folders in the file explorer.
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/bower_components": true,
"**/coverage": true,
"**/jest-output": true,
"**/lib-amd": true,
"src/**/*.scss.ts": true
},
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
}
21 changes: 21 additions & 0 deletions samples/app/react-login-spfx/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": false,
"isCreatingSolution": true,
"nodeVersion": "18.17.1",
"sdksVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.12.0"
},
"version": "1.18.2",
"libraryName": "mgt-login-spfx",
"libraryId": "86763da1-f3b1-4297-85d7-610e358316b4",
"environment": "spo",
"packageManager": "npm",
"solutionName": "mgt-login-spfx",
"solutionShortDescription": "mgt-login-spfx description",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "webpart"
}
}
51 changes: 51 additions & 0 deletions samples/app/react-login-spfx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# mgt-login-spfx

## Summary

This sample illustrates how to use the `Login` component from the Microsoft Graph Toolkit React package in a SharePoint Framework web part.

![mgt-login-spfx](./assets/react-login-spfx.gif)

## Used SharePoint Framework Version

![version](https://img.shields.io/badge/version-1.18.2-green.svg)

## Contributors

Guido Zambarda ([@iamguidozam](https://x.com/iamguidozam)), PiaSys.com

## Version history

| Version | Date | Comments |
| ------- | ---------------- | --------------- |
| 1.0 | June 22, 2024 | Initial release |

## 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.**

---

## Minimal Path to Awesome

- Clone this repository
- Ensure that you are at the solution folder
- in the command-line run:
- **npm install**
- **gulp serve**

## Features

This sample illustrates the following concepts on top of the SharePoint Framework:

- Using the `Login` component from the Microsoft Graph Toolkit.
- Using the Microsoft Graph Toolkit in a SharePoint Framework web part.

## References

- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
- [Microsoft Graph Toolkit with React](https://learn.microsoft.com/en-us/graph/toolkit/get-started/mgt-react)
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development

<img src="https://pnptelemetry.azurewebsites.net/mgt-samples/samples/app/react-login-spfx" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions samples/app/react-login-spfx/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[
{
"name": "pnp-mgt-samples-react-login-spfx",
"source": "pnp",
"title": "Using login control in SPFx with React",
"shortDescription": "Using the mgt-login component in a SharePoint Framework web part with React",
"url": "https://github.com/pnp/mgt-samples/tree/main/samples/app/react-login-spfx",
"longDescription": [
"This sample demonstrates how to use the Microsoft Graph Toolkit login component in a SharePoint Framework web part with React."
],
"creationDateTime": "2024-06-22",
"updateDateTime": "2024-06-22",
"products": ["Microsoft Graph", "Microsoft Graph Toolkit"],
"metadata": [
{
"key": "MGT-COMPONENT",
"value": "mgt-login"
},
{
"key": "SPFX-VERSION",
"value": "1.18.2"
},
{
"key": "CLIENT-SIDE-DEV",
"value": "React"
}
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://github.com/pnp/mgt-samples/blob/main/samples/app/react-login-spfx/assets/react-login-spfx.gif",
"alt": "Preview"
}
],
"authors": [
{
"gitHubAccount": "guidozam",
"pictureUrl": "https://github.com/guidozam.png",
"name": "Guido Zambarda"
}
],
"references": [
{
"name": "Getting started with the Microsoft Graph Toolkit in React",
"description": "The Microsoft Graph Toolkit components can easily be added to your web application, SharePoint web part, or Microsoft Teams tabs.",
"url": "https://learn.microsoft.com/en-us/graph/toolkit/get-started/mgt-react"
}
]
}
]
18 changes: 18 additions & 0 deletions samples/app/react-login-spfx/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"mgt-login-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/mgtLogin/MgtLoginWebPart.js",
"manifest": "./src/webparts/mgtLogin/MgtLoginWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"MgtLoginWebPartStrings": "lib/webparts/mgtLogin/loc/{locale}.js"
}
}
7 changes: 7 additions & 0 deletions samples/app/react-login-spfx/config/deploy-azure-storage.json
Original file line number Diff line number Diff line change
@@ -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": "mgt-login-spfx",
"accessKey": "<!-- ACCESS KEY -->"
}
40 changes: 40 additions & 0 deletions samples/app/react-login-spfx/config/package-solution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "mgt-login-spfx-client-side-solution",
"id": "86763da1-f3b1-4297-85d7-610e358316b4",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.18.2"
},
"metadata": {
"shortDescription": {
"default": "mgt-login-spfx description"
},
"longDescription": {
"default": "mgt-login-spfx description"
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "mgt-login-spfx Feature",
"description": "The feature that activates elements of the mgt-login-spfx solution.",
"id": "d8678a1a-380a-4771-9ffa-96f99508dedc",
"version": "1.0.0.0"
}
]
},
"paths": {
"zippedPackage": "solution/mgt-login-spfx.sppkg"
}
}
3 changes: 3 additions & 0 deletions samples/app/react-login-spfx/config/sass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
}
6 changes: 6 additions & 0 deletions samples/app/react-login-spfx/config/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://{tenantDomain}/_layouts/workbench.aspx"
}
4 changes: 4 additions & 0 deletions samples/app/react-login-spfx/config/write-manifests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}
16 changes: 16 additions & 0 deletions samples/app/react-login-spfx/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'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;
};

build.initialize(require('gulp'));
Loading
Loading