Add 'samples/react-my-groups/' from commit 'd8c8c2275fb625db60744608aa9e83a82e437252'
git-subtree-dir: samples/react-my-groups git-subtree-mainline:7450d5547c
git-subtree-split:d8c8c2275f
This commit is contained in:
commit
7777804075
|
@ -0,0 +1,25 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# we recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[{package,bower}.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1,32 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
|
||||
# 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
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"msjsdiag.debugger-for-chrome"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
/**
|
||||
* Install Chrome Debugger Extension for Visual Studio Code to debug your components with the
|
||||
* Chrome browser: https://aka.ms/spfx-debugger-extensions
|
||||
*/
|
||||
"version": "0.2.0",
|
||||
"configurations": [{
|
||||
"name": "Local workbench",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "https://localhost:4321/temp/workbench.html",
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Hosted workbench",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "https://enter-your-SharePoint-site/_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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// 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,
|
||||
"**/lib-amd": true,
|
||||
"src/**/*.scss.ts": true
|
||||
},
|
||||
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"isCreatingSolution": true,
|
||||
"environment": "spo",
|
||||
"version": "1.9.1",
|
||||
"libraryName": "react-my-groups",
|
||||
"libraryId": "da7eafe2-f2ec-486f-99d8-d36fba06a2bf",
|
||||
"packageManager": "npm",
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
# react-my-groups
|
||||
|
||||
## Summary
|
||||
|
||||
Using Microsoft Graph this webpart grabs the current user's Office 365 groups with links to the groups SharePoint site.
|
||||
|
||||
![Demo](./assets/example.png)
|
||||
|
||||
## Used SharePoint Framework Version
|
||||
|
||||
![drop](https://img.shields.io/badge/drop-1.9.1-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
* [SharePoint Framework](https:/dev.office.com/sharepoint)
|
||||
|
||||
|
||||
## Solution
|
||||
|
||||
Solution|Author(s)
|
||||
--------|---------
|
||||
react-my-groups | Zach Roberts
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
1.0|September 13, 2019|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
|
||||
* in the command line run:
|
||||
* `npm install`
|
||||
* `gulp bundle --ship`
|
||||
* `gulp package-solution --ship`
|
||||
* Add the package to your app catalog
|
||||
* Approve the Graph API permissions in the SharePoint admin center
|
||||
* Add the webpart to your page
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
This web part lists the current user's Office 365 groups with links to the groups SharePoint site.
|
||||
|
||||
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-my-groups" />
|
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"react-my-groups-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/reactMyGroups/ReactMyGroupsWebPart.js",
|
||||
"manifest": "./src/webparts/reactMyGroups/ReactMyGroupsWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"ReactMyGroupsWebPartStrings": "lib/webparts/reactMyGroups/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-my-groups",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-my-groups-client-side-solution",
|
||||
"id": "da7eafe2-f2ec-486f-99d8-d36fba06a2bf",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"isDomainIsolated": false
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-my-groups.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
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.`);
|
||||
|
||||
build.initialize(gulp);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "react-my-groups",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "16.8.5",
|
||||
"react-dom": "16.8.5",
|
||||
"@types/react": "16.8.8",
|
||||
"@types/react-dom": "16.8.3",
|
||||
"office-ui-fabric-react": "6.189.2",
|
||||
"@microsoft/sp-core-library": "1.9.1",
|
||||
"@microsoft/sp-webpart-base": "1.9.1",
|
||||
"@microsoft/sp-lodash-subset": "1.9.1",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.9.1",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"@types/es6-promise": "0.0.33"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/react": "16.8.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/microsoft-graph-types": "^1.10.0",
|
||||
"@microsoft/rush-stack-compiler-2.9": "0.7.16",
|
||||
"@microsoft/sp-build-web": "1.9.1",
|
||||
"@microsoft/sp-module-interfaces": "1.9.1",
|
||||
"@microsoft/sp-tslint-rules": "1.9.1",
|
||||
"@microsoft/sp-webpart-workbench": "1.9.1",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/mocha": "2.2.38",
|
||||
"ajv": "~5.2.2",
|
||||
"gulp": "~3.9.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,9 @@
|
|||
export interface IGroup {
|
||||
id: string;
|
||||
displayName: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface IGroupCollection {
|
||||
value: IGroup[];
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from './IGroup';
|
|
@ -0,0 +1,74 @@
|
|||
import { MSGraphClient } from "@microsoft/sp-http";
|
||||
import * as MicrosoftGraph from "@microsoft/microsoft-graph-types";
|
||||
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||
import { IGroup, IGroupCollection } from "../models";
|
||||
import { GraphRequest } from "@microsoft/microsoft-graph-client";
|
||||
|
||||
|
||||
export class GroupServiceManager {
|
||||
public context: WebPartContext;
|
||||
|
||||
public setup(context: WebPartContext): void {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public getGroups(): Promise<MicrosoftGraph.Group[]> {
|
||||
return new Promise<MicrosoftGraph.Group[]>((resolve, reject) => {
|
||||
try {
|
||||
this.context.msGraphClientFactory
|
||||
.getClient()
|
||||
.then((client: MSGraphClient) => {
|
||||
client
|
||||
.api("/me/memberOf/$/microsoft.graph.group?$filter=groupTypes/any(a:a eq 'unified')")
|
||||
.get((error: any, groups: IGroupCollection, rawResponse: any) => {
|
||||
resolve(groups.value);
|
||||
});
|
||||
});
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getGroupLinks(groups: IGroup): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
try {
|
||||
this.context.msGraphClientFactory
|
||||
.getClient()
|
||||
.then((client: MSGraphClient) => {
|
||||
client
|
||||
.api(`/groups/${groups.id}/sites/root/weburl`)
|
||||
.get((error: any, group: any, rawResponse: any) => {
|
||||
resolve(group);
|
||||
});
|
||||
});
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getGroupThumbnails(groups: IGroup): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
try {
|
||||
this.context.msGraphClientFactory
|
||||
.getClient()
|
||||
.then((client: MSGraphClient) => {
|
||||
client
|
||||
.api(`/groups/${groups.id}/photos/48x48/$value`)
|
||||
.responseType('blob')
|
||||
.get((error: any, group: any, rawResponse: any) => {
|
||||
resolve(window.URL.createObjectURL(group));
|
||||
});
|
||||
});
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const GroupService = new GroupServiceManager();
|
||||
export default GroupService;
|
||||
|
|
@ -0,0 +1 @@
|
|||
export * from './GroupService';
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "1b857fd9-5268-4112-8241-da46dd8d9d53",
|
||||
"alias": "ReactMyGroupsWebPart",
|
||||
"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"],
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||
"group": { "default": "Other" },
|
||||
"title": { "default": "react-my-groups" },
|
||||
"description": { "default": "react-my-groups description" },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"description": "react-my-groups"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
BaseClientSideWebPart,
|
||||
IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-webpart-base';
|
||||
import GroupService from '../../services/GroupService';
|
||||
import * as strings from 'ReactMyGroupsWebPartStrings';
|
||||
import { ReactMyGroups, IReactMyGroupsProps } from './components';
|
||||
|
||||
export interface IReactMyGroupsWebPartProps {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export default class ReactMyGroupsWebPart extends BaseClientSideWebPart<IReactMyGroupsWebPartProps> {
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IReactMyGroupsProps > = React.createElement(
|
||||
ReactMyGroups,
|
||||
{
|
||||
description: this.properties.description
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
protected onInit(): Promise<void> {
|
||||
return super.onInit().then(() => {
|
||||
GroupService.setup(this.context);
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
@import "~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss";
|
||||
|
||||
:export {
|
||||
padding: 20;
|
||||
minWidth: 210;
|
||||
maxWidth: 320;
|
||||
rowsPerPage: 3;
|
||||
}
|
||||
|
||||
.compactLayout {
|
||||
overflow: hidden;
|
||||
font-size: 0;
|
||||
position: relative;
|
||||
background-color: transparent;
|
||||
|
||||
:global(.ms-DocumentCard) {
|
||||
position: relative;
|
||||
background-color: $ms-color-white;
|
||||
height: 100%;
|
||||
|
||||
&:global(.ms-DocumentCard--compact), &:global(.ms-DocumentCard--actionable) {
|
||||
border: none;
|
||||
|
||||
:global(.ms-DocumentCardPreview) {
|
||||
-ms-flex-negative: 0;
|
||||
flex-shrink: 0;
|
||||
width: 48px;
|
||||
}
|
||||
|
||||
:global(.ms-DocumentCardTitle) {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border:none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(.ms-List-cell) {
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
import * as React from 'react';
|
||||
import { IGroupListProps } from './IGroupListProps';
|
||||
import { List, FocusZone, FocusZoneDirection } from 'office-ui-fabric-react';
|
||||
import { IRectangle } from 'office-ui-fabric-react/lib/Utilities';
|
||||
import styles from './GroupList.module.scss';
|
||||
|
||||
const ROWS_PER_PAGE: number = +styles.rowsPerPage;
|
||||
const MAX_ROW_HEIGHT: number = +styles.maxWidth;
|
||||
const PADDING: number = +styles.padding;
|
||||
const MIN_WIDTH: number = +styles.minWidth;
|
||||
|
||||
export class GroupList extends React.Component<IGroupListProps, {}> {
|
||||
|
||||
private _columnCount: number;
|
||||
private _columnWidth: number;
|
||||
private _rowHeight: number;
|
||||
|
||||
public render(): React.ReactElement<IGroupListProps> {
|
||||
|
||||
|
||||
return (
|
||||
<div role="group">
|
||||
<FocusZone
|
||||
direction={FocusZoneDirection.horizontal}
|
||||
isCircularNavigation={false}
|
||||
>
|
||||
<List
|
||||
className={styles.compactLayout}
|
||||
items={this.props.groups}
|
||||
getItemCountForPage={this._getItemCountForPage}
|
||||
getPageHeight={this._getPageHeight}
|
||||
onRenderCell={this._onRenderCell}
|
||||
/>
|
||||
</FocusZone>
|
||||
</div>
|
||||
// <div>
|
||||
// <ul>
|
||||
// {this.props.groups.map(group => (
|
||||
// <li><a href={group.url}>{group.displayName}</a></li>
|
||||
// ))}
|
||||
// </ul>
|
||||
// </div>
|
||||
);
|
||||
}
|
||||
|
||||
private _getItemCountForPage = (itemIndex: number, surfaceRect: IRectangle): number => {
|
||||
if (itemIndex === 0) {
|
||||
this._columnCount = Math.ceil(surfaceRect.width / (MAX_ROW_HEIGHT));
|
||||
this._columnWidth = Math.max(MIN_WIDTH, Math.floor(surfaceRect.width / this._columnCount) + Math.floor(PADDING / this._columnCount));
|
||||
this._rowHeight = this._columnWidth;
|
||||
}
|
||||
|
||||
return this._columnCount * ROWS_PER_PAGE;
|
||||
}
|
||||
|
||||
private _getPageHeight = (): number => {
|
||||
return this._rowHeight * ROWS_PER_PAGE;
|
||||
}
|
||||
|
||||
private _onRenderCell = (item: any, index: number | undefined): JSX.Element => {
|
||||
const cellPadding: number = index % this._columnCount !== this._columnCount - 1 && PADDING;
|
||||
const cellWidth: number = this._columnWidth - PADDING;
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
width: `${cellWidth}px`,
|
||||
marginRight: `${cellPadding}px`
|
||||
}}
|
||||
>
|
||||
{this.props.onRenderItem(item, index)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export interface IGroupListProps {
|
||||
groups?: any[];
|
||||
onRenderItem: (item: any, index: number) => JSX.Element;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from './GroupList';
|
|
@ -0,0 +1,2 @@
|
|||
export * from './reactMyGroups';
|
||||
export * from './GroupList';
|
|
@ -0,0 +1,3 @@
|
|||
export interface IReactMyGroupsProps {
|
||||
description: string;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import * as MicrosoftGroup from '@microsoft/microsoft-graph-types';
|
||||
|
||||
export interface IReactMyGroupsState {
|
||||
groups: MicrosoftGroup.Group[];
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
@import '~office-ui-fabric-react/dist/sass/References.scss';
|
||||
|
||||
.reactMyGroups {
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 700px;
|
||||
margin: 0px auto;
|
||||
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.row {
|
||||
@include ms-Grid-row;
|
||||
@include ms-fontColor-white;
|
||||
background-color: $ms-color-themeDark;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.column {
|
||||
@include ms-Grid-col;
|
||||
@include ms-lg10;
|
||||
@include ms-xl8;
|
||||
@include ms-xlPush2;
|
||||
@include ms-lgPush1;
|
||||
}
|
||||
|
||||
.title {
|
||||
@include ms-font-xl;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.subTitle {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.description {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.button {
|
||||
// Our button
|
||||
text-decoration: none;
|
||||
height: 32px;
|
||||
|
||||
// Primary Button
|
||||
min-width: 80px;
|
||||
background-color: $ms-color-themePrimary;
|
||||
border-color: $ms-color-themePrimary;
|
||||
color: $ms-color-white;
|
||||
|
||||
// Basic Button
|
||||
outline: transparent;
|
||||
position: relative;
|
||||
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: $ms-font-size-m;
|
||||
font-weight: $ms-font-weight-regular;
|
||||
border-width: 0;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
padding: 0 16px;
|
||||
|
||||
.label {
|
||||
font-weight: $ms-font-weight-semibold;
|
||||
font-size: $ms-font-size-m;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0 4px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
import * as React from 'react';
|
||||
import styles from './ReactMyGroups.module.scss';
|
||||
import { IReactMyGroupsProps } from './IReactMyGroupsProps';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
import GroupService from '../../../../services/GroupService';
|
||||
import { IReactMyGroupsState } from './IReactMyGroupsState';
|
||||
import { GroupList } from '../GroupList';
|
||||
import { IGroup } from '../../../../models';
|
||||
import { DocumentCard, DocumentCardType, DocumentCardDetails, DocumentCardTitle, IDocumentCardPreviewProps, ImageFit, DocumentCardPreview } from 'office-ui-fabric-react';
|
||||
|
||||
export class ReactMyGroups extends React.Component<IReactMyGroupsProps, IReactMyGroupsState> {
|
||||
|
||||
constructor(props: IReactMyGroupsProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
groups: []
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public render(): React.ReactElement<IReactMyGroupsProps> {
|
||||
return (
|
||||
<div className={ styles.reactMyGroups }>
|
||||
<h1>My Office 365 Groups</h1>
|
||||
<GroupList groups={this.state.groups} onRenderItem={(item: any, index: number) => this._onRenderItem(item, index)}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
public componentDidMount (): void {
|
||||
this._getGroups();
|
||||
}
|
||||
|
||||
public _getGroups = (): void => {
|
||||
GroupService.getGroups().then(groups => {
|
||||
// console.log(groups);
|
||||
this.setState({
|
||||
groups: groups
|
||||
});
|
||||
this._getGroupLinks(groups);
|
||||
});
|
||||
}
|
||||
|
||||
public _getGroupLinks = (groups: any): void => {
|
||||
groups.map(groupItem => (
|
||||
GroupService.getGroupLinks(groupItem).then(groupurl => {
|
||||
// console.log(groupurl.value);
|
||||
this.setState(prevState => ({
|
||||
groups: prevState.groups.map(group => group.id === groupItem.id ? {...group, url: groupurl.value} : group)
|
||||
}));
|
||||
})
|
||||
));
|
||||
this._getGroupThumbnails(groups);
|
||||
}
|
||||
|
||||
public _getGroupThumbnails = (groups: any): void => {
|
||||
groups.map(groupItem => (
|
||||
GroupService.getGroupThumbnails(groupItem).then(grouptb => {
|
||||
console.log(grouptb);
|
||||
this.setState(prevState => ({
|
||||
groups: prevState.groups.map(group => group.id === groupItem.id ? {...group, thumbnail: grouptb} : group)
|
||||
}));
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
private _onRenderItem = (item: any, index: number): JSX.Element => {
|
||||
const previewProps: IDocumentCardPreviewProps = {
|
||||
previewImages: [
|
||||
{
|
||||
previewImageSrc: item.thumbnail,
|
||||
imageFit: ImageFit.center,
|
||||
height: 48,
|
||||
width: 48
|
||||
}
|
||||
]
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
<DocumentCard
|
||||
type={DocumentCardType.compact}
|
||||
>
|
||||
<DocumentCardPreview {...previewProps} />
|
||||
<DocumentCardDetails>
|
||||
<a href={item.url}>
|
||||
<DocumentCardTitle
|
||||
title={item.displayName}
|
||||
/>
|
||||
</a>
|
||||
</DocumentCardDetails>
|
||||
</DocumentCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
export * from './IReactMyGroupsProps';
|
||||
export * from './ReactMyGroups';
|
||||
export * from './IReactMyGroupsState';
|
|
@ -0,0 +1,7 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Description",
|
||||
"BasicGroupName": "Group Name",
|
||||
"DescriptionFieldLabel": "Description Field"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
declare interface IReactMyGroupsWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
}
|
||||
|
||||
declare module 'ReactMyGroupsWebPartStrings' {
|
||||
const strings: IReactMyGroupsWebPartStrings;
|
||||
export = strings;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-2.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": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"extends": "@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-use-before-declare": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue