Added devcontainer, sample.json, and updated readme

This commit is contained in:
Hugo Bernier 2023-02-03 22:19:03 -05:00
parent dcbb7e8fca
commit 8ac2cdb02d
10 changed files with 152 additions and 14 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

@ -1,11 +1,11 @@
# react-my-one-drive-info
# My OneDrive Info
## Summary
MyOneDriveInfo solution contains Adaptive card extension for Viva connection with below functionalities
1. Show the one drive quota/space utilized in card view
2. Show other details like Web url, last modified time, state, remaining size in quick view
2. Show other details like Web URL, last modified time, state, remaining size in quick view
3. Allows to set the ACE title, quick view button label
![ACE in action](./assets/ACEScreenshot1.png)
@ -37,11 +37,9 @@ For more information about SPFx compatibility, please refer to <https://aka.ms/s
> Any special pre-requisites?
## Solution
## Authors
| Solution | Author(s) |
| ---------------------- | ------------------------------------------------------------------------------------------------------- |
| react-my-onedrive-info | [Harminder Singh](https://github.com/HarminderSethi) <https://www.linkedin.com/in/harmindersinghsethi/> |
[Harminder Singh](https://github.com/HarminderSethi) <https://www.linkedin.com/in/harmindersinghsethi/> |
## Version history
@ -62,7 +60,7 @@ For more information about SPFx compatibility, please refer to <https://aka.ms/s
## Features
1. Show the one drive quota/space utilized in card view
2. Show other details like Web url, last modified time, state, remaining size in quick view
2. Show other details like Web URL, last modified time, state, remaining size in quick view
3. Allows to set the ACE title, quick view button label
## References
@ -73,6 +71,24 @@ For more information about SPFx compatibility, please refer to <https://aka.ms/s
- [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-my-onedrive-info%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-my-onedrive-info) 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-my-onedrive-info&template=bug-report.yml&sample=react-my-onedrive-info&authors=@HarminderSethi&title=react-my-onedrive-info%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-my-onedrive-info&template=question.yml&sample=react-my-onedrive-info&authors=@HarminderSethi&title=react-my-onedrive-info%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-my-onedrive-info&template=suggestion.yml&sample=react-my-onedrive-info&authors=@HarminderSethi&title=react-my-onedrive-info%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.**
**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-my-onedrive-info" />

View File

@ -0,0 +1,50 @@
[
{
"name": "pnp-sp-dev-spfx-web-parts-react-my-onedrive-info",
"source": "pnp",
"title": "My OneDrive Info",
"shortDescription": "MyOneDriveInfo solution contains Adaptive card extension for Viva connection with below functionalities",
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-my-onedrive-info",
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-my-onedrive-info",
"longDescription": [
"MyOneDriveInfo solution contains Adaptive card extension for Viva connection with below functionalities"
],
"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-my-onedrive-info/assets/YOUR-IMAGE-NAME-HERE",
"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

@ -14,6 +14,7 @@ export interface IMyOneDriveInfoAdaptiveCardExtensionProps {
export interface IMyOneDriveInfoAdaptiveCardExtensionState {
myDriveDetails: Drive;
hasError: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any;
}

View File

@ -12,7 +12,7 @@ export class GraphService {
return await this.context.msGraphClientFactory.getClient("3");
};
public getMyDriveInfo = async (): Promise<any> => {
public getMyDriveInfo = async (): Promise<Drive> => {
try {
const client = await this.getClient();
const request: GraphRequest = client.api("/me/drive");

View File

@ -1,7 +1,8 @@
import { round } from "@microsoft/sp-lodash-subset";
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace HelperService {
export const calculateSpace = (value: number) => {
export const calculateSpace = (value: number): { space: number; spaceString: string; } => {
let space = 0;
let spaceString = "";
if (value) {

View File

@ -113,7 +113,7 @@ Don't worry if you're unsure about the compatibility matrix above. We'll verify
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/m365devprogram)
## Solution
## Authors
<!--
We use this section to recognize and promote your contributions. Please provide one author per line -- even if you worked together on it.
@ -124,9 +124,7 @@ Provide a link to your GitHub profile to help others find more cool things you h
If you provide a link to your Twitter profile, we'll promote your contribution on social media.
-->
Solution|Author(s)
--------|---------
folder name | [Author Name](LinkToYourGitHubProfile) ([@yourtwitterhandle](https://twitter.com/yourtwitterhandle)), Company
[Author Name](LinkToYourGitHubProfile) ([@yourtwitterhandle](https://twitter.com/yourtwitterhandle)), Company
## Version history