update readme and remove permissions not required (#836)
* update deadme and remove permissions not required * Re-adding required permissions for tenant info * Removed all tenant references as not required
This commit is contained in:
parent
c929404080
commit
dcec947cd6
|
@ -40,19 +40,29 @@ The web part can be configured to open the team on the web browser or client app
|
|||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
- Clone this repository
|
||||
- in the command line run:
|
||||
- `npm install`
|
||||
- `gulp serve --nobrowser`
|
||||
- navigate to the hosted version of SharePoint workbench, eg. https://contoso.sharepoint.com/_layouts/15/workbench.aspx
|
||||
Clone this repository.
|
||||
|
||||
In the command line run:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
gulp serve --nobrowser
|
||||
```
|
||||
|
||||
Navigate to the hosted version of SharePoint workbench, eg. https://contoso.sharepoint.com/_layouts/15/workbench.aspx
|
||||
|
||||
### Grant the service principal permission to the MicroSoft Graph API
|
||||
|
||||
Once installed, the solution will request the required permissions via the Office 365 admin portal.
|
||||
If you prefer to approve the permissions in advance, for example when testing the solution in the Workbench page without installing it, you can do so using Office 365 CLI:
|
||||
|
||||
```bash
|
||||
o365 spo login https://contoso-admin.sharepoint.com
|
||||
o365 spo serviceprincipal grant add --resource 'Microsoft Graph' --scope 'User.Read.All'
|
||||
o365 spo serviceprincipal grant add --resource 'Microsoft Graph' --scope 'User.ReadWrite.All'
|
||||
o365 spo serviceprincipal grant add --resource 'Microsoft Graph' --scope 'Group.Read.All'
|
||||
o365 spo serviceprincipal grant add --resource 'Microsoft Graph' --scope 'Group.ReadWrite.All'
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
|
|
|
@ -2,4 +2,5 @@ export interface IChannel {
|
|||
id: string;
|
||||
displayName: string;
|
||||
description: string;
|
||||
webUrl: string;
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
export interface ITenant {
|
||||
id: string;
|
||||
}
|
|
@ -1,3 +1,2 @@
|
|||
export * from './ITenant';
|
||||
export * from './ITeam';
|
||||
export * from './IChannel';
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { ITenant, ITeam, IChannel } from "../interfaces";
|
||||
import { ITeam, IChannel } from "../interfaces";
|
||||
|
||||
export interface ITeamsService {
|
||||
GetTenantInfo(): Promise<ITenant>;
|
||||
GetTeams(): Promise<ITeam[]>;
|
||||
GetTeamChannels(teamId): Promise<IChannel[]>;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { MSGraphClient } from "@microsoft/sp-http";
|
||||
import { ITeam, IChannel, ITenant } from "../interfaces";
|
||||
import { ITeam, IChannel } from "../interfaces";
|
||||
import { ITeamsService } from "./ITeamsService";
|
||||
|
||||
export class TeamsService implements ITeamsService {
|
||||
|
@ -16,21 +16,6 @@ export class TeamsService implements ITeamsService {
|
|||
this._graphClient = graphClient;
|
||||
}
|
||||
|
||||
public GetTenantInfo = async (): Promise<ITenant> => {
|
||||
return await this._getTenantInfo();
|
||||
}
|
||||
|
||||
private _getTenantInfo = async (): Promise<ITenant> => {
|
||||
let tenant: ITenant = null;
|
||||
try {
|
||||
const tenantResponse = await this._graphClient.api('organization').select('id').version('v1.0').get();
|
||||
tenant = tenantResponse.value as ITenant;
|
||||
} catch (error) {
|
||||
console.log('Error getting tenant information', error);
|
||||
}
|
||||
return tenant;
|
||||
}
|
||||
|
||||
public GetTeams = async (): Promise<ITeam[]> => {
|
||||
return await this._getTeams();
|
||||
}
|
||||
|
|
|
@ -9,12 +9,10 @@ import {
|
|||
|
||||
import * as strings from 'MyTeamsWebPartStrings';
|
||||
import { MyTeams, IMyTeamsProps } from './components/myTeams';
|
||||
import { ITenant } from '../../shared/interfaces';
|
||||
import { MSGraphClient } from '@microsoft/sp-http';
|
||||
import { TeamsService, ITeamsService } from '../../shared/services';
|
||||
|
||||
export interface IMyTeamsWebPartProps {
|
||||
tenantInfo: ITenant;
|
||||
openInClientApp: boolean;
|
||||
}
|
||||
|
||||
|
@ -25,8 +23,6 @@ export default class MyTeamsWebPart extends BaseClientSideWebPart<IMyTeamsWebPar
|
|||
|
||||
public async onInit(): Promise<void> {
|
||||
|
||||
|
||||
|
||||
if (DEBUG && Environment.type === EnvironmentType.Local) {
|
||||
console.log("Mock data service not implemented yet");
|
||||
} else {
|
||||
|
@ -43,10 +39,6 @@ export default class MyTeamsWebPart extends BaseClientSideWebPart<IMyTeamsWebPar
|
|||
MyTeams,
|
||||
{
|
||||
teamsService: this._teamsService,
|
||||
tenantInfo: this.properties.tenantInfo,
|
||||
updateTenantInfo: (value: ITenant) => {
|
||||
this.properties.tenantInfo = value;
|
||||
},
|
||||
openInClientApp: this.properties.openInClientApp
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import { ITeamsService } from "../../../../shared/services";
|
||||
import { ITenant } from "../../../../shared/interfaces";
|
||||
import { IWebPartContext } from "@microsoft/sp-webpart-base";
|
||||
|
||||
export interface IMyTeamsProps {
|
||||
teamsService: ITeamsService;
|
||||
tenantInfo: ITenant;
|
||||
updateTenantInfo: (value: ITenant) => void;
|
||||
openInClientApp: boolean;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { ITeam, ITenant } from "../../../../shared/interfaces";
|
||||
import { ITeam } from "../../../../shared/interfaces";
|
||||
|
||||
export interface IMyTeamsState {
|
||||
items: ITeam[];
|
||||
tenantInfo: ITenant;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { List } from 'office-ui-fabric-react/lib/List';
|
|||
import styles from '../myTeams/MyTeams.module.scss';
|
||||
import { IMyTeamsProps, IMyTeamsState } from '.';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
import { ITeam, IChannel, ITenant } from '../../../../shared/interfaces';
|
||||
import { ITeam, IChannel } from '../../../../shared/interfaces';
|
||||
|
||||
export class MyTeams extends React.Component<IMyTeamsProps, IMyTeamsState> {
|
||||
|
||||
|
@ -14,8 +14,7 @@ export class MyTeams extends React.Component<IMyTeamsProps, IMyTeamsState> {
|
|||
super(props);
|
||||
|
||||
this.state = {
|
||||
items: [],
|
||||
tenantInfo: null
|
||||
items: []
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -31,21 +30,12 @@ export class MyTeams extends React.Component<IMyTeamsProps, IMyTeamsState> {
|
|||
|
||||
private _load = async (): Promise<void> => {
|
||||
|
||||
// get tenant info if required and not available yet
|
||||
// then update the web part properties to persist the value
|
||||
let tenantInfo: ITenant = this.props.tenantInfo;
|
||||
if ((!this.props.tenantInfo || this.props.tenantInfo === undefined) && this.props.openInClientApp) {
|
||||
tenantInfo = await this._getTenantInfo();
|
||||
this.props.updateTenantInfo(tenantInfo);
|
||||
}
|
||||
|
||||
// get teams
|
||||
this._myTeams = await this._getTeams();
|
||||
|
||||
|
||||
this.setState({
|
||||
items: this._myTeams,
|
||||
tenantInfo: tenantInfo
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -79,8 +69,8 @@ export class MyTeams extends React.Component<IMyTeamsProps, IMyTeamsState> {
|
|||
const teamChannels: IChannel[] = await this._getTeamChannels(teamId);
|
||||
const channel = teamChannels[0];
|
||||
|
||||
if (this.props.openInClientApp && this.state.tenantInfo) {
|
||||
link = `https://teams.microsoft.com/l/channel/${channel.id}/${channel.displayName}?groupId=${teamId}&tenantId=${this.state.tenantInfo.id}`;
|
||||
if (this.props.openInClientApp) {
|
||||
link = channel.webUrl;
|
||||
} else {
|
||||
link = `https://teams.microsoft.com/_#/conversations/${channel.displayName}?threadId=${channel.id}&ctx=channel`;
|
||||
}
|
||||
|
@ -88,17 +78,6 @@ export class MyTeams extends React.Component<IMyTeamsProps, IMyTeamsState> {
|
|||
window.open(link, '_blank');
|
||||
}
|
||||
|
||||
private _getTenantInfo = async (): Promise<ITenant> => {
|
||||
let tenant: ITenant = null;
|
||||
try {
|
||||
tenant = await this.props.teamsService.GetTenantInfo();
|
||||
console.log(tenant);
|
||||
} catch (error) {
|
||||
console.log('Error getting tenant information', error);
|
||||
}
|
||||
return tenant;
|
||||
}
|
||||
|
||||
private _getTeams = async (): Promise<ITeam[]> => {
|
||||
let myTeams: ITeam[] = [];
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue