diff --git a/public/app/core/components/Select/TeamPicker.tsx b/public/app/core/components/Select/TeamPicker.tsx index b2a2acbb2c1..345c0e55012 100644 --- a/public/app/core/components/Select/TeamPicker.tsx +++ b/public/app/core/components/Select/TeamPicker.tsx @@ -9,10 +9,12 @@ import { Team } from 'app/types'; export interface Props { onSelected: (team: SelectableValue) => void; className?: string; + teamId?: number; } export interface State { isLoading: boolean; + value?: SelectableValue; } export class TeamPicker extends Component { @@ -29,6 +31,25 @@ export class TeamPicker extends Component { }); } + componentDidMount(): void { + const { teamId } = this.props; + if (!teamId) { + return; + } + + getBackendSrv() + .get(`/api/teams/${teamId}`) + .then((team: Team) => { + this.setState({ + value: { + value: team, + label: team.name, + imgUrl: team.avatarUrl, + }, + }); + }); + } + search(query?: string) { this.setState({ isLoading: true }); @@ -54,13 +75,14 @@ export class TeamPicker extends Component { render() { const { onSelected, className } = this.props; - const { isLoading } = this.state; + const { isLoading, value } = this.state; return (