WIP - listing awards as plain list

This commit is contained in:
Luis Mañez 2022-05-21 17:39:39 +02:00
parent a93be1a70b
commit ab21d02d69
30 changed files with 22387 additions and 0 deletions

View File

@ -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

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,16 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": true,
"isCreatingSolution": true,
"version": "1.15.0-beta.1",
"libraryName": "react-graph-profile-awards",
"libraryId": "a87cd7b4-ccbe-47ce-9ff4-4f2f1a686f8c",
"environment": "spo",
"packageManager": "npm",
"solutionName": "react-graph-profile-awards",
"solutionShortDescription": "react-graph-profile-awards description",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "webpart"
}
}

View File

@ -0,0 +1,73 @@
# react-graph-profile-awards
## Summary
Short summary on functionality and used technologies.
[picture of the solution in action, if possible]
## Used SharePoint Framework Version
![version](https://img.shields.io/badge/version-1.13-green.svg)
## Applies to
- [SharePoint Framework](https://aka.ms/spfx)
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
## Prerequisites
> Any special pre-requisites?
## Solution
| Solution | Author(s) |
| ----------- | ------------------------------------------------------- |
| folder name | Author details (name, company, twitter alias with link) |
## Version history
| Version | Date | Comments |
| ------- | ---------------- | --------------- |
| 1.1 | March 10, 2021 | Update comment |
| 1.0 | January 29, 2021 | 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**
> Include any additional steps as needed.
## Features
Description of the extension that expands upon high-level summary above.
This extension illustrates the following concepts:
- topic 1
- topic 2
- topic 3
> Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance.
> Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
## 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

View File

@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"my-awards-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/myAwards/MyAwardsWebPart.js",
"manifest": "./src/webparts/myAwards/MyAwardsWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"MyAwardsWebPartStrings": "lib/webparts/myAwards/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-graph-profile-awards",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -0,0 +1,40 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "react-graph-profile-awards-client-side-solution",
"id": "a87cd7b4-ccbe-47ce-9ff4-4f2f1a686f8c",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.15.0-beta.1"
},
"metadata": {
"shortDescription": {
"default": "react-graph-profile-awards description"
},
"longDescription": {
"default": "react-graph-profile-awards description"
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "react-graph-profile-awards Feature",
"description": "The feature that activates elements of the react-graph-profile-awards solution.",
"id": "bd1abcc5-5e4c-4e5b-972b-f0758adf4413",
"version": "1.0.0.0"
}
]
},
"paths": {
"zippedPackage": "solution/react-graph-profile-awards.sppkg"
}
}

View File

@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/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,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'));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
{
"name": "react-graph-profile-awards",
"version": "0.0.1",
"private": true,
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
},
"dependencies": {
"tslib": "1.13.0",
"react": "16.13.1",
"react-dom": "16.13.1",
"office-ui-fabric-react": "7.181.1",
"@microsoft/sp-core-library": "1.15.0-beta.1",
"@microsoft/sp-property-pane": "1.15.0-beta.1",
"@microsoft/sp-webpart-base": "1.15.0-beta.1",
"@microsoft/sp-lodash-subset": "1.15.0-beta.1",
"@microsoft/sp-office-ui-fabric-core": "1.15.0-beta.1"
},
"devDependencies": {
"@microsoft/rush-stack-compiler-3.9": "0.4.47",
"@microsoft/sp-tslint-rules": "1.15.0-beta.1",
"@microsoft/sp-build-web": "1.15.0-beta.1",
"@types/webpack-env": "~1.15.2",
"ajv": "^6.12.5",
"gulp": "4.0.2",
"@types/react": "16.9.51",
"@types/react-dom": "16.9.8",
"@microsoft/sp-module-interfaces": "1.15.0-beta.1"
}
}

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,12 @@
type allowedAudiences = "me" | "organization" | "groupMembers" | "everyone";
export interface IAward {
id: string;
displayName: string;
allowedAudiences: allowedAudiences;
description: string;
issuedDate: Date;
issuingAuthority: string;
thumbnailUrl: string;
webUrl: string;
}

View File

@ -0,0 +1,5 @@
import { IAward } from "./IAward";
export interface IListAwardsResponse {
value: IAward[];
}

View File

@ -0,0 +1,29 @@
import { ServiceKey, ServiceScope } from "@microsoft/sp-core-library";
import { IAward } from "../models/IAward";
import { MSGraphClientFactory, HttpClientResponse } from "@microsoft/sp-http";
import { IListAwardsResponse } from "../models/IListAwardsResponse";
export interface IAwardsService {
getMyAwards(): Promise<IAward[]>;
}
export default class AwardsService implements IAwardsService {
private readonly GraphMyAwardsEndpoint: string = 'https://graph.microsoft.com/beta/me/profile/awards';
private _msGraphClientFactory: MSGraphClientFactory;
constructor(serviceScope:ServiceScope) {
serviceScope.whenFinished(async () => {
this._msGraphClientFactory = serviceScope.consume(MSGraphClientFactory.serviceKey);
});
}
public async getMyAwards(): Promise<IAward[]> {
const msGraphClient = await this._msGraphClientFactory.getClient("3");
const listAwardsResponse: IListAwardsResponse = await msGraphClient.api(this.GraphMyAwardsEndpoint).get();
return listAwardsResponse.value || [];
}
}
export const AwardsServiceKey = ServiceKey.create<IAwardsService>("atlas:featuresService", AwardsService);

View File

@ -0,0 +1,28 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "a62fd5a8-90e0-4712-8569-57c0b11d9f89",
"alias": "MyAwardsWebPart",
"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", // Other
"group": { "default": "Other" },
"title": { "default": "MyAwards" },
"description": { "default": "MyAwards description" },
"officeFabricIconFontName": "Page",
"properties": {
"description": "MyAwards"
}
}]
}

View File

@ -0,0 +1,94 @@
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 { IReadonlyTheme } from '@microsoft/sp-component-base';
import * as strings from 'MyAwardsWebPartStrings';
import MyAwards from './components/MyAwards';
import { IMyAwardsProps } from './components/IMyAwardsProps';
import { AwardsServiceKey, IAwardsService } from '../../services/AwardsService';
export interface IMyAwardsWebPartProps {
description: string;
}
export default class MyAwardsWebPart extends BaseClientSideWebPart<IMyAwardsWebPartProps> {
private _isDarkTheme: boolean = false;
private _awardsService: IAwardsService;
public render(): void {
const element: React.ReactElement<IMyAwardsProps> = React.createElement(
MyAwards,
{
isDarkTheme: this._isDarkTheme,
hasTeamsContext: !!this.context.sdks.microsoftTeams,
awardsService: this._awardsService
}
);
ReactDom.render(element, this.domElement);
}
protected onInit(): Promise<void> {
return super.onInit()
.then(_ => {
let webpartScope = this.context.serviceScope.startNewChild();
webpartScope.finish();
return webpartScope;
})
.then(serviceScope => {
this._awardsService = serviceScope.consume(AwardsServiceKey);
});
}
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
if (!currentTheme) {
return;
}
this._isDarkTheme = !!currentTheme.isInverted;
const {
semanticColors
} = currentTheme;
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText);
this.domElement.style.setProperty('--link', semanticColors.link);
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered);
}
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('description', {
label: strings.DescriptionFieldLabel
})
]
}
]
}
]
};
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,7 @@
import { IAwardsService } from "../../../services/AwardsService";
export interface IMyAwardsProps {
isDarkTheme: boolean;
hasTeamsContext: boolean;
awardsService: IAwardsService;
}

View File

@ -0,0 +1,5 @@
import { IAward } from "../../../models/IAward";
export interface IMyAwardsState {
awards: IAward[];
}

View File

@ -0,0 +1,34 @@
@import '~office-ui-fabric-react/dist/sass/References.scss';
.myAwards {
overflow: hidden;
padding: 1em;
color: "[theme:bodyText, default: #323130]";
color: var(--bodyText);
&.teams {
font-family: $ms-font-family-fallbacks;
}
}
.welcome {
text-align: center;
}
.welcomeImage {
width: 100%;
max-width: 420px;
}
.links {
a {
text-decoration: none;
color: "[theme:link, default:#03787c]";
color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only
&:hover {
text-decoration: underline;
color: "[theme:linkHovered, default: #014446]";
color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only
}
}
}

View File

@ -0,0 +1,47 @@
import * as React from 'react';
import styles from './MyAwards.module.scss';
import { IMyAwardsProps } from './IMyAwardsProps';
import { IMyAwardsState } from './IMyAwardsState';
import { IAwardsService } from '../../../services/AwardsService';
export default class MyAwards extends React.Component<IMyAwardsProps, IMyAwardsState> {
private _service: IAwardsService;
constructor(props: IMyAwardsProps) {
super(props);
this.state = {
awards: []
};
this._service = this.props.awardsService;
}
public componentDidMount(): void {
this._service.getMyAwards().then(awards => {
this.setState({
awards: awards
});
});
}
public render(): React.ReactElement<IMyAwardsProps> {
const {
isDarkTheme,
hasTeamsContext,
} = this.props;
const awards = <ul>{this.state.awards.map(t => <li key={t.id}>{t.displayName} ({t.description}%) - {t.issuedDate}</li>)}</ul>;
return (
<section className={`${styles.myAwards} ${hasTeamsContext ? styles.teams : ''}`}>
<div className={styles.welcome}>
<img alt="" src={isDarkTheme ? require('../assets/welcome-dark.png') : require('../assets/welcome-light.png')} className={styles.welcomeImage} />
</div>
<div>
<h3>My Awards</h3>
{awards}
</div>
</section>
);
}
}

View File

@ -0,0 +1,11 @@
define([], function() {
return {
"PropertyPaneDescription": "Description",
"BasicGroupName": "Group Name",
"DescriptionFieldLabel": "Description Field",
"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",
"AppSharePointEnvironment": "The app is running on SharePoint page",
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams"
}
});

View File

@ -0,0 +1,14 @@
declare interface IMyAwardsWebPartStrings {
PropertyPaneDescription: string;
BasicGroupName: string;
DescriptionFieldLabel: string;
AppLocalEnvironmentSharePoint: string;
AppLocalEnvironmentTeams: string;
AppSharePointEnvironment: string;
AppTeamsTabEnvironment: string;
}
declare module 'MyAwardsWebPartStrings' {
const strings: IMyAwardsWebPartStrings;
export = strings;
}

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,35 @@
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/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,
"noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection",
"es2015.promise"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
]
}

View File

@ -0,0 +1,29 @@
{
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json",
"rules": {
"class-name": false,
"export-name": false,
"forin": false,
"label-position": false,
"member-access": true,
"no-arg": false,
"no-console": false,
"no-construct": false,
"no-duplicate-variable": true,
"no-eval": false,
"no-function-expression": true,
"no-internal-module": true,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-unnecessary-semicolons": true,
"no-unused-expression": true,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"variable-name": false,
"whitespace": false
}
}