import React, { PureComponent } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { SelectableValue } from '@grafana/data'; import { LegacyForms, DeleteButton } from '@grafana/ui'; import { TagBadge } from 'app/core/components/TagFilter/TagBadge'; import { WithFeatureToggle } from 'app/core/components/WithFeatureToggle'; import { TeamMember, teamsPermissionLevels, TeamPermissionLevel } from 'app/types'; import { updateTeamMember, removeTeamMember } from './state/actions'; const { Select } = LegacyForms; const mapDispatchToProps = { removeTeamMember, updateTeamMember, }; const connector = connect(null, mapDispatchToProps); interface OwnProps { member: TeamMember; syncEnabled: boolean; editorsCanAdmin: boolean; signedInUserIsTeamAdmin: boolean; } export type Props = ConnectedProps & OwnProps; export class TeamMemberRow extends PureComponent { constructor(props: Props) { super(props); this.renderLabels = this.renderLabels.bind(this); this.renderPermissions = this.renderPermissions.bind(this); } onRemoveMember(member: TeamMember) { this.props.removeTeamMember(member.userId); } onPermissionChange = (item: SelectableValue, member: TeamMember) => { const permission = item.value; const updatedTeamMember: TeamMember = { ...member, permission: permission as number, }; this.props.updateTeamMember(updatedTeamMember); }; renderPermissions(member: TeamMember) { const { editorsCanAdmin, signedInUserIsTeamAdmin } = this.props; const value = teamsPermissionLevels.find((dp) => dp.value === member.permission)!; return (
{signedInUserIsTeamAdmin && (