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

New Control MyTeams #874

Merged
merged 17 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion config/serve.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321,
"initialPage": "https://localhost:5432/workbench",
"initialPage": "https://localhost:5432/workbench",
"https": true,
"api": {
"port": 5432,
Expand Down
Binary file added docs/documentation/docs/assets/myteams01.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/docs/assets/myteams01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/docs/assets/myteams02.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions docs/documentation/docs/controls/MyTeams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# MyTeams control

This control show all Teams the user has access (joined),and for each Team the user can see the channels has permissions and quick open the channel or if callback is specified can return the Team Id and Channel Id for use in App.

The user can quick see the members and owner of group.
This control use [mgt-toolkit](https://docs.microsoft.com/en-us/graph/toolkit/overview) component [People](https://docs.microsoft.com/en-us/graph/toolkit/components/people) that can be configured to show Person Card on hover.

Here is an example of the control:

![myTeams](../assets/myteams01.gif)

![myTeams](../assets/myteams02.gif)

![myTeams](../assets/myteams01.png)

## How to use this control in your solutions

- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../../#getting-started) page for more information about installing the dependency.
- Import the control into your component:

```TypeScript
import { MyTeams } from "@pnp/spfx-controls-react/lib/MyTeams";
```

- Use the `MyTeams` control in your code as follows:

```TypeScript
<MyTeams
title="My Teams"
webPartContext={context}
themeVariant={themeVariant}/>
```

```TypeScript
<MyTeams
title="My Teams"
webPartContext={context}
themeVariant={themeVariant}
enablePersonCardInteraction={true}
onSelectedChannel={onSelectedChannel}
/>
```


- The `onSelectedChannel` callback returns the teamId and ChannelId and can be implemented as follows:

```TypeScript
const onSelectedChannel = (teamsId: string, channelId: string) => {
console.log("TeamsId", teamsId);
console.log("ChannelId", channelId);
};
```

## Implementation


The `MyTeams` control can be configured with the following properties:

| Property | Type | Required | Description |
| ---- | ---- | ---- | ---- |
| webPartContext | WebPartContext | yes | The context object of the SPFx loaded webpart |
| title | string | no | Title of WebPart |
| themeVariant |IReadonlyTheme | no | themeVariant |
| enablePersonCardInteraction | boolean | no | Show Person Card on hover |
| onSelectedChannel | (teamId:string,channelId:string) => void; | no | callBack with TeamId and ChannelId Selected |


## MSGraph Permissions required

This control required the flowing scopes :

at least : Team.ReadBasic.All, Channel.ReadBasic.All,
and all Scopes used by [mgt-people](https://docs.microsoft.com/en-us/graph/toolkit/components/people),
and [Person-Card](https://docs.microsoft.com/en-us/graph/toolkit/components/person-card) components
221 changes: 221 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"dependencies": {
"@fluentui/react-northstar": "0.51.3",
"@microsoft/decorators": "1.12.0",
"@microsoft/mgt": "^2.1.0",
"@microsoft/mgt-react": "^2.1.0",
"@microsoft/sp-core-library": "1.12.0",
"@microsoft/sp-listview-extensibility": "1.12.0",
"@microsoft/sp-lodash-subset": "1.12.0",
Expand Down
1 change: 1 addition & 0 deletions src/MyTeams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./controls/MyTeams";
4 changes: 4 additions & 0 deletions src/common/model/EMembershipType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum EMembershipType {
"Standard" = "standard",
"Private" = "private"
}
8 changes: 8 additions & 0 deletions src/common/model/ITeamMember.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface ITeamMenber {
'@odata.type': string;
id: string;
roles: any[];
displayName: string;
userId: string;
email: string;
}
6 changes: 6 additions & 0 deletions src/controls/MyTeams/EMyTeamsTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum EMyTeamsTypes {
"SET_MYTEAMS" = "SET_MYTEAMS",
"SET_MESSAGE" = "SET_MESSAGE",
"SET_HAS_ERROR" = "SET_HAS_ERROR",
"SET_IS_LOADING" = "SET_IS_LOADING",
}
26 changes: 26 additions & 0 deletions src/controls/MyTeams/IMyTeamsProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { IReadonlyTheme , BaseComponentContext} from "@microsoft/sp-component-base";

export interface IMyTeamsProps {
/**
/**
* Title of MyTeams
*/
title?: string;
/**
* themeVariant
*/
themeVariant?: IReadonlyTheme;
/**
* webPart COntext
*/
webPartContext: BaseComponentContext;
/**
/**
* onSelectedChannel callBack return teamId and ChannelId if this is not defined default handler open channel
*/
onSelectedChannel?: (teamsId: string, channelId: string) => void;
/**
* Enable Hover Card on Person
*/
enablePersonCardInteraction?: boolean;
}
Loading