diff --git a/samples/react-follow-document/Assets/FollowDocumentSample1.gif b/samples/react-follow-document/Assets/FollowDocumentSample1.gif index 778f3933f..6f476ed81 100644 Binary files a/samples/react-follow-document/Assets/FollowDocumentSample1.gif and b/samples/react-follow-document/Assets/FollowDocumentSample1.gif differ diff --git a/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/IfollowDocumentSendMessageState.ts b/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/IfollowDocumentSendMessageState.ts index 5e5b27247..bc1b765cf 100644 --- a/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/IfollowDocumentSendMessageState.ts +++ b/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/IfollowDocumentSendMessageState.ts @@ -1,5 +1,7 @@ -import { ITag } from 'office-ui-fabric-react'; +import { IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; export interface IfollowDocumentSendMessageState { - selectedTeam: ITag[]; - selectedTeamChannels: ITag[]; + selectedTeamOption: IDropdownOption[]; + selectedTeamChannelsOption: IDropdownOption[]; + selectedTeamId: string; + selectedTeamChannelId: string; } diff --git a/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/followDocumentSendMessage.tsx b/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/followDocumentSendMessage.tsx index c9d34efab..2b4756183 100644 --- a/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/followDocumentSendMessage.tsx +++ b/samples/react-follow-document/src/webparts/followDocumentWebPart/components/followDocumentSendMessage/followDocumentSendMessage.tsx @@ -3,13 +3,12 @@ import * as React from 'react'; import { TextField } from 'office-ui-fabric-react/lib/TextField'; import { DialogContent, DialogFooter } from 'office-ui-fabric-react/lib/Dialog'; import { PrimaryButton, DefaultButton } from 'office-ui-fabric-react/lib/Button'; -import { TeamChannelPicker } from "@pnp/spfx-controls-react/lib/TeamChannelPicker"; -import { TeamPicker } from "@pnp/spfx-controls-react/lib/TeamPicker"; import { IfollowDocumentSendMessageProps } from "./IfollowDocumentSendMessageProps"; import { IfollowDocumentSendMessageState } from "./IfollowDocumentSendMessageState"; import { ITag, } from "office-ui-fabric-react/lib/Pickers"; import * as AdaptiveCards from "adaptivecards"; import Graph from "../../Service/GraphService"; +import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; export class FollowDocumentSendMessage extends React.Component { private card: any; @@ -17,14 +16,29 @@ export class FollowDocumentSendMessage extends React.Component { + const Teams = await this.getjoinedTeams(); + let Teamsoptions: Array = new Array(); + Teams.value.forEach(element => { + Teamsoptions.push({ + key: element.id, + text: element.displayName, + }); + }); + this.setState({ + selectedTeamOption: Teamsoptions, + }); + } private sendMessageChannell = async () => { const graphService: Graph = new Graph(); @@ -36,11 +50,23 @@ export class FollowDocumentSendMessage extends React.Component${this.props.fileInfo.fields.Title}` } }; - const getresult = await graphService.postGraphContent(`https://graph.microsoft.com/v1.0/teams/${this.state.selectedTeam[0].key}/channels/${this.state.selectedTeamChannels[0].key}/messages`, HeadersendMessage); - console.log(getresult); + const getresult = await graphService.postGraphContent(`https://graph.microsoft.com/v1.0/teams/${this.state.selectedTeamId}/channels/${this.state.selectedTeamChannelId}/messages`, HeadersendMessage); } } + + private getjoinedTeams = async () => { + const graphService: Graph = new Graph(); + const getresult = await graphService.getGraphContent(`https://graph.microsoft.com/v1.0/me/joinedTeams?$select=id,displayName`, this.props.context); + return getresult; + } + + private getTeamsChannels = async (TeamID) => { + const graphService: Graph = new Graph(); + const getresult = await graphService.getGraphContent(`https://graph.microsoft.com/v1.0/teams/${TeamID}/channels?$select=id,displayName`, this.props.context); + return getresult; + } + public showAdaptiveCard(fileInfo: any) { this.card = { @@ -83,7 +109,7 @@ export class FollowDocumentSendMessage extends React.Component { - const _onSelectedTeamChannels = (tagList: ITag[]) => { - this.setState({ selectedTeamChannels: tagList }); - }; const sendMessageTeam = () => { this.sendMessageChannell(); this.props.close(); @@ -123,6 +146,29 @@ export class FollowDocumentSendMessage extends React.Component, selectedOption: IDropdownOption) => { + this.setState({ + selectedTeamId: "", + selectedTeamChannelsOption: null, + }); + const TeamsChannels = await this.getTeamsChannels(selectedOption.key.toString()); + let Teamsoptions: Array = new Array(); + TeamsChannels.value.forEach(element => { + Teamsoptions.push({ + key: element.id, + text: element.displayName, + }); + }); + this.setState({ + selectedTeamId: selectedOption.key.toString(), + selectedTeamChannelsOption: Teamsoptions, + }); + }; + const handleSelectChannel = async (event: React.FormEvent, selectedOption: IDropdownOption) => { + this.setState({ + selectedTeamChannelId: selectedOption.key.toString(), + }); + }; return (
- { - this.setState({ selectedTeamChannels: [] }); - this.setState({ selectedTeam: tagList }); - }} + - {this.state?.selectedTeam && this.state?.selectedTeam.length > 0 && ( + {this.state?.selectedTeamId !== "" && ( <> - + )}