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UrJ,EAAasJ,gBAAkBtJ,EAAauJ,UAAYC,EAAAA,GAAAA,MAClEC,EAAkBxJ,IAAeyG,EAAAA,GAAAA,MAGvC,OAFgC2C,GAAWI,IAER1J","sources":["webpack://grafana/./public/app/core/components/connectWithCleanUp.tsx","webpack://grafana/./public/app/core/components/RolePicker/TeamRolePicker.tsx","webpack://grafana/./public/app/features/teams/TeamList.tsx","webpack://grafana/./public/app/features/teams/state/actions.ts","webpack://grafana/./public/app/features/teams/state/navModel.ts","webpack://grafana/./public/app/features/teams/state/selectors.ts"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport React, { ComponentType, FunctionComponent, useEffect } from 'react';\nimport { connect, MapDispatchToPropsParam, MapStateToPropsParam, useDispatch } from 'react-redux';\n\nimport { cleanUpAction, StateSelector } from '../actions/cleanUp';\n\nexport const connectWithCleanUp =\n <\n TStateProps extends {} = {},\n TDispatchProps = {},\n TOwnProps = {},\n State = {},\n TSelector extends object = {},\n Statics = {}\n >(\n mapStateToProps: MapStateToPropsParam,\n mapDispatchToProps: MapDispatchToPropsParam,\n stateSelector: StateSelector\n ) =>\n (Component: ComponentType) => {\n const ConnectedComponent = connect(\n mapStateToProps,\n mapDispatchToProps\n // @ts-ignore\n )(Component);\n\n const ConnectedComponentWithCleanUp: FunctionComponent = (props) => {\n const dispatch = useDispatch();\n useEffect(() => {\n return function cleanUp() {\n dispatch(cleanUpAction({ stateSelector }));\n };\n }, [dispatch]);\n // @ts-ignore\n return ;\n };\n\n ConnectedComponentWithCleanUp.displayName = `ConnectWithCleanUp(${ConnectedComponent.displayName})`;\n hoistNonReactStatics(ConnectedComponentWithCleanUp, Component);\n type Hoisted = typeof ConnectedComponentWithCleanUp & Statics;\n\n return ConnectedComponentWithCleanUp as Hoisted;\n };\n","import React, { FC, useEffect } from 'react';\nimport { useAsyncFn } from 'react-use';\n\nimport { Role } from 'app/types';\n\nimport { RolePicker } from './RolePicker';\n// @ts-ignore\nimport { fetchTeamRoles, updateTeamRoles } from './api';\n\nexport interface Props {\n teamId: number;\n orgId?: number;\n roleOptions: Role[];\n disabled?: boolean;\n builtinRolesDisabled?: boolean;\n}\n\nexport const TeamRolePicker: FC = ({ teamId, orgId, roleOptions, disabled, builtinRolesDisabled }) => {\n const [{ loading, value: appliedRoles = [] }, getTeamRoles] = useAsyncFn(async () => {\n try {\n return await fetchTeamRoles(teamId, orgId);\n } catch (e) {\n // TODO handle error\n console.error('Error loading options');\n }\n return [];\n }, [orgId, teamId]);\n\n useEffect(() => {\n getTeamRoles();\n }, [orgId, teamId, getTeamRoles]);\n\n const onRolesChange = async (roles: Role[]) => {\n await updateTeamRoles(roles, teamId, orgId);\n await getTeamRoles();\n };\n\n return (\n \n );\n};\n","import React, { PureComponent } from 'react';\n\nimport { NavModel } from '@grafana/data';\nimport { DeleteButton, LinkButton, FilterInput, VerticalGroup, HorizontalGroup, Pagination } from '@grafana/ui';\nimport EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';\nimport Page from 'app/core/components/Page/Page';\nimport { TeamRolePicker } from 'app/core/components/RolePicker/TeamRolePicker';\nimport { fetchRoleOptions } from 'app/core/components/RolePicker/api';\nimport { config } from 'app/core/config';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { contextSrv, User } from 'app/core/services/context_srv';\nimport { AccessControlAction, Role, StoreState, Team } from 'app/types';\n\nimport { connectWithCleanUp } from '../../core/components/connectWithCleanUp';\n\nimport { deleteTeam, loadTeams } from './state/actions';\nimport { setSearchQuery, setTeamsSearchPage } from './state/reducers';\nimport { getSearchQuery, getTeams, getTeamsCount, getTeamsSearchPage, isPermissionTeamAdmin } from './state/selectors';\n\nconst pageLimit = 30;\n\nexport interface Props {\n navModel: NavModel;\n teams: Team[];\n searchQuery: string;\n searchPage: number;\n teamsCount: number;\n hasFetched: boolean;\n loadTeams: typeof loadTeams;\n deleteTeam: typeof deleteTeam;\n setSearchQuery: typeof setSearchQuery;\n setTeamsSearchPage: typeof setTeamsSearchPage;\n editorsCanAdmin: boolean;\n signedInUser: User;\n}\n\nexport interface State {\n roleOptions: Role[];\n}\n\nexport class TeamList extends PureComponent {\n constructor(props: Props) {\n super(props);\n this.state = { roleOptions: [] };\n }\n\n componentDidMount() {\n this.fetchTeams();\n if (contextSrv.licensedAccessControlEnabled() && contextSrv.hasPermission(AccessControlAction.ActionRolesList)) {\n this.fetchRoleOptions();\n }\n }\n\n async fetchTeams() {\n await this.props.loadTeams();\n }\n\n async fetchRoleOptions() {\n const roleOptions = await fetchRoleOptions();\n this.setState({ roleOptions });\n }\n\n deleteTeam = (team: Team) => {\n this.props.deleteTeam(team.id);\n };\n\n onSearchQueryChange = (value: string) => {\n this.props.setSearchQuery(value);\n };\n\n renderTeam(team: Team) {\n const { editorsCanAdmin, signedInUser } = this.props;\n const permission = team.permission;\n const teamUrl = `org/teams/edit/${team.id}`;\n const isTeamAdmin = isPermissionTeamAdmin({ permission, editorsCanAdmin, signedInUser });\n const canDelete = contextSrv.hasAccessInMetadata(AccessControlAction.ActionTeamsDelete, team, isTeamAdmin);\n const canReadTeam = contextSrv.hasAccessInMetadata(AccessControlAction.ActionTeamsRead, team, isTeamAdmin);\n const canSeeTeamRoles = contextSrv.hasAccessInMetadata(AccessControlAction.ActionTeamsRolesList, team, false);\n const canUpdateTeamRoles =\n contextSrv.hasAccess(AccessControlAction.ActionTeamsRolesAdd, false) ||\n contextSrv.hasAccess(AccessControlAction.ActionTeamsRolesRemove, false);\n const displayRolePicker =\n contextSrv.licensedAccessControlEnabled() &&\n contextSrv.hasPermission(AccessControlAction.ActionTeamsRolesList) &&\n contextSrv.hasPermission(AccessControlAction.ActionRolesList);\n\n return (\n \n \n {canReadTeam ? (\n \n \"Team\n \n ) : (\n \"Team\n )}\n \n \n {canReadTeam ? {team.name} :
{team.name}
}\n \n \n {canReadTeam ? (\n 0 ? undefined : 'Empty email cell'}>\n {team.email}\n \n ) : (\n
0 ? undefined : 'Empty email cell'}>\n {team.email}\n
\n )}\n \n \n {canReadTeam ? (\n {team.memberCount}\n ) : (\n
{team.memberCount}
\n )}\n \n {displayRolePicker && (\n \n {canSeeTeamRoles && (\n \n )}\n \n )}\n \n this.deleteTeam(team)}\n />\n \n \n );\n }\n\n renderEmptyList() {\n return (\n \n );\n }\n\n getPaginatedTeams = (teams: Team[]) => {\n const offset = (this.props.searchPage - 1) * pageLimit;\n return teams.slice(offset, offset + pageLimit);\n };\n\n renderTeamList() {\n const { teams, searchQuery, editorsCanAdmin, searchPage, setTeamsSearchPage } = this.props;\n const teamAdmin = contextSrv.hasRole('Admin') || (editorsCanAdmin && contextSrv.hasRole('Editor'));\n const canCreate = contextSrv.hasAccess(AccessControlAction.ActionTeamsCreate, teamAdmin);\n const displayRolePicker =\n contextSrv.licensedAccessControlEnabled() &&\n contextSrv.hasPermission(AccessControlAction.ActionTeamsRolesList) &&\n contextSrv.hasPermission(AccessControlAction.ActionRolesList);\n const newTeamHref = canCreate ? 'org/teams/new' : '#';\n const paginatedTeams = this.getPaginatedTeams(teams);\n const totalPages = Math.ceil(teams.length / pageLimit);\n\n return (\n <>\n
\n
\n \n
\n\n \n New Team\n \n
\n\n
\n \n \n \n \n \n \n \n {displayRolePicker && }\n \n \n {paginatedTeams.map((team) => this.renderTeam(team))}\n
\n NameEmailMembersRoles\n
\n \n \n \n
\n
\n \n );\n }\n\n renderList() {\n const { teamsCount, hasFetched } = this.props;\n\n if (!hasFetched) {\n return null;\n }\n\n if (teamsCount > 0) {\n return this.renderTeamList();\n } else {\n return this.renderEmptyList();\n }\n }\n\n render() {\n const { hasFetched, navModel } = this.props;\n\n return (\n \n {this.renderList()}\n \n );\n }\n}\n\nfunction mapStateToProps(state: StoreState) {\n return {\n navModel: getNavModel(state.navIndex, 'teams'),\n teams: getTeams(state.teams),\n searchQuery: getSearchQuery(state.teams),\n searchPage: getTeamsSearchPage(state.teams),\n teamsCount: getTeamsCount(state.teams),\n hasFetched: state.teams.hasFetched,\n editorsCanAdmin: config.editorsCanAdmin, // this makes the feature toggle mockable/controllable from tests,\n signedInUser: contextSrv.user, // this makes the feature toggle mockable/controllable from tests,\n };\n}\n\nconst mapDispatchToProps = {\n loadTeams,\n deleteTeam,\n setSearchQuery,\n setTeamsSearchPage,\n};\n\nexport default connectWithCleanUp(mapStateToProps, mapDispatchToProps, (state) => state.teams)(TeamList);\n","import { getBackendSrv } from '@grafana/runtime';\nimport { updateNavIndex } from 'app/core/actions';\nimport { contextSrv } from 'app/core/core';\nimport { accessControlQueryParam } from 'app/core/utils/accessControl';\nimport { AccessControlAction, TeamMember, ThunkResult } from 'app/types';\n\nimport { buildNavModel } from './navModel';\nimport { teamGroupsLoaded, teamLoaded, teamMembersLoaded, teamsLoaded } from './reducers';\n\nexport function loadTeams(): ThunkResult {\n return async (dispatch) => {\n // Early return if the user cannot list teams\n if (!contextSrv.hasPermission(AccessControlAction.ActionTeamsRead)) {\n dispatch(teamsLoaded([]));\n return;\n }\n\n const response = await getBackendSrv().get(\n '/api/teams/search',\n accessControlQueryParam({ perpage: 1000, page: 1 })\n );\n dispatch(teamsLoaded(response.teams));\n };\n}\n\nexport function loadTeam(id: number): ThunkResult {\n return async (dispatch) => {\n const response = await getBackendSrv().get(`/api/teams/${id}`, accessControlQueryParam());\n dispatch(teamLoaded(response));\n dispatch(updateNavIndex(buildNavModel(response)));\n };\n}\n\nexport function loadTeamMembers(): ThunkResult {\n return async (dispatch, getStore) => {\n const team = getStore().team.team;\n const response = await getBackendSrv().get(`/api/teams/${team.id}/members`);\n dispatch(teamMembersLoaded(response));\n };\n}\n\nexport function addTeamMember(id: number): ThunkResult {\n return async (dispatch, getStore) => {\n const team = getStore().team.team;\n await getBackendSrv().post(`/api/teams/${team.id}/members`, { userId: id });\n dispatch(loadTeamMembers());\n };\n}\n\nexport function removeTeamMember(id: number): ThunkResult {\n return async (dispatch, getStore) => {\n const team = getStore().team.team;\n await getBackendSrv().delete(`/api/teams/${team.id}/members/${id}`);\n dispatch(loadTeamMembers());\n };\n}\n\nexport function updateTeam(name: string, email: string): ThunkResult {\n return async (dispatch, getStore) => {\n const team = getStore().team.team;\n await getBackendSrv().put(`/api/teams/${team.id}`, { name, email });\n dispatch(loadTeam(team.id));\n };\n}\n\nexport function loadTeamGroups(): ThunkResult {\n return async (dispatch, getStore) => {\n const team = getStore().team.team;\n const response = await getBackendSrv().get(`/api/teams/${team.id}/groups`);\n dispatch(teamGroupsLoaded(response));\n };\n}\n\nexport function addTeamGroup(groupId: string): ThunkResult {\n return async (dispatch, getStore) => {\n const team = getStore().team.team;\n await getBackendSrv().post(`/api/teams/${team.id}/groups`, { groupId: groupId });\n dispatch(loadTeamGroups());\n };\n}\n\nexport function removeTeamGroup(groupId: string): ThunkResult {\n return async (dispatch, getStore) => {\n const team = getStore().team.team;\n await getBackendSrv().delete(`/api/teams/${team.id}/groups/${encodeURIComponent(groupId)}`);\n dispatch(loadTeamGroups());\n };\n}\n\nexport function deleteTeam(id: number): ThunkResult {\n return async (dispatch) => {\n await getBackendSrv().delete(`/api/teams/${id}`);\n // Update users permissions in case they lost teams.read with the deletion\n await contextSrv.fetchUserPermissions();\n dispatch(loadTeams());\n };\n}\n\nexport function updateTeamMember(member: TeamMember): ThunkResult {\n return async (dispatch) => {\n await getBackendSrv().put(`/api/teams/${member.teamId}/members/${member.userId}`, {\n permission: member.permission,\n });\n dispatch(loadTeamMembers());\n };\n}\n","import { NavModelItem, NavModel } from '@grafana/data';\nimport { featureEnabled } from '@grafana/runtime';\nimport { ProBadge } from 'app/core/components/Upgrade/ProBadge';\nimport config from 'app/core/config';\nimport { contextSrv } from 'app/core/services/context_srv';\nimport { highlightTrial } from 'app/features/admin/utils';\nimport { AccessControlAction, Team, TeamPermissionLevel } from 'app/types';\n\nconst loadingTeam = {\n avatarUrl: 'public/img/user_profile.png',\n id: 1,\n name: 'Loading',\n email: 'loading',\n memberCount: 0,\n permission: TeamPermissionLevel.Member,\n};\n\nexport function buildNavModel(team: Team): NavModelItem {\n const navModel: NavModelItem = {\n img: team.avatarUrl,\n id: 'team-' + team.id,\n subTitle: 'Manage members and settings',\n url: '',\n text: team.name,\n breadcrumbs: [{ title: 'Teams', url: 'org/teams' }],\n children: [\n // With RBAC this tab will always be available (but not always editable)\n // With Legacy it will be hidden by hideTabsFromNonTeamAdmin should the user not be allowed to see it\n {\n active: false,\n icon: 'sliders-v-alt',\n id: `team-settings-${team.id}`,\n text: 'Settings',\n url: `org/teams/edit/${team.id}/settings`,\n },\n ],\n };\n\n // While team is loading we leave the members tab\n // With RBAC the Members tab is available when user has ActionTeamsPermissionsRead for this team\n // With Legacy it will always be present\n if (\n team === loadingTeam ||\n contextSrv.hasPermissionInMetadata(AccessControlAction.ActionTeamsPermissionsRead, team)\n ) {\n navModel.children!.unshift({\n active: false,\n icon: 'users-alt',\n id: `team-members-${team.id}`,\n text: 'Members',\n url: `org/teams/edit/${team.id}/members`,\n });\n }\n\n const teamGroupSync: NavModelItem = {\n active: false,\n icon: 'sync',\n id: `team-groupsync-${team.id}`,\n text: 'External group sync',\n url: `org/teams/edit/${team.id}/groupsync`,\n };\n\n const isLoadingTeam = team === loadingTeam;\n\n if (highlightTrial()) {\n teamGroupSync.tabSuffix = () =>\n ProBadge({ experimentId: isLoadingTeam ? '' : 'feature-highlights-team-sync-badge', eventVariant: 'trial' });\n }\n\n // With both Legacy and RBAC the tab is protected being featureEnabled\n // While team is loading we leave the teamsync tab\n // With RBAC the External Group Sync tab is available when user has ActionTeamsPermissionsRead for this team\n if (featureEnabled('teamsync')) {\n if (isLoadingTeam || contextSrv.hasPermissionInMetadata(AccessControlAction.ActionTeamsPermissionsRead, team)) {\n navModel.children!.push(teamGroupSync);\n }\n } else if (config.featureToggles.featureHighlights) {\n navModel.children!.push({\n ...teamGroupSync,\n tabSuffix: () => ProBadge({ experimentId: isLoadingTeam ? '' : 'feature-highlights-team-sync-badge' }),\n });\n }\n\n return navModel;\n}\n\nexport function getTeamLoadingNav(pageName: string): NavModel {\n const main = buildNavModel(loadingTeam);\n\n let node: NavModelItem;\n\n // find active page\n for (const child of main.children!) {\n if (child.id!.indexOf(pageName) > 0) {\n child.active = true;\n node = child;\n break;\n }\n }\n\n return {\n main: main,\n node: node!,\n };\n}\n","import { User } from 'app/core/services/context_srv';\nimport { Team, TeamsState, TeamState, TeamMember, OrgRole, TeamPermissionLevel } from 'app/types';\n\nexport const getSearchQuery = (state: TeamsState) => state.searchQuery;\nexport const getSearchMemberQuery = (state: TeamState) => state.searchMemberQuery;\nexport const getTeamGroups = (state: TeamState) => state.groups;\nexport const getTeamsCount = (state: TeamsState) => state.teams.length;\nexport const getTeamsSearchPage = (state: TeamsState) => state.searchPage;\n\nexport const getTeam = (state: TeamState, currentTeamId: any): Team | null => {\n if (state.team.id === parseInt(currentTeamId, 10)) {\n return state.team;\n }\n\n return null;\n};\n\nexport const getTeams = (state: TeamsState) => {\n const regex = RegExp(state.searchQuery, 'i');\n\n return state.teams.filter((team) => {\n return regex.test(team.name);\n });\n};\n\nexport const getTeamMembers = (state: TeamState) => {\n const regex = RegExp(state.searchMemberQuery, 'i');\n\n return state.members.filter((member) => {\n return regex.test(member.login) || regex.test(member.email) || regex.test(member.name);\n });\n};\n\nexport interface Config {\n members: TeamMember[];\n editorsCanAdmin: boolean;\n signedInUser: User;\n}\n\nexport const isSignedInUserTeamAdmin = (config: Config): boolean => {\n const { members, signedInUser, editorsCanAdmin } = config;\n const userInMembers = members.find((m) => m.userId === signedInUser.id);\n const permission = userInMembers ? userInMembers.permission : TeamPermissionLevel.Member;\n\n return isPermissionTeamAdmin({ permission, signedInUser, editorsCanAdmin });\n};\n\nexport interface PermissionConfig {\n permission: TeamPermissionLevel;\n editorsCanAdmin: boolean;\n signedInUser: User;\n}\n\nexport const isPermissionTeamAdmin = (config: PermissionConfig): boolean => {\n const { permission, signedInUser, editorsCanAdmin } = config;\n const isAdmin = signedInUser.isGrafanaAdmin || signedInUser.orgRole === OrgRole.Admin;\n const userIsTeamAdmin = permission === TeamPermissionLevel.Admin;\n const isSignedInUserTeamAdmin = isAdmin || userIsTeamAdmin;\n\n return isSignedInUserTeamAdmin || !editorsCanAdmin;\n};\n"],"names":["connectWithCleanUp","mapStateToProps","mapDispatchToProps","stateSelector","Component","ConnectedComponent","connect","ConnectedComponentWithCleanUp","props","dispatch","useDispatch","useEffect","cleanUpAction","displayName","hoistNonReactStatics","TeamRolePicker","teamId","orgId","roleOptions","disabled","builtinRolesDisabled","loading","value","appliedRoles","getTeamRoles","useAsyncFn","async","fetchTeamRoles","e","console","error","RolePicker","onRolesChange","updateTeamRoles","roles","isLoading","TeamList","PureComponent","constructor","super","team","this","deleteTeam","id","setSearchQuery","teams","offset","searchPage","slice","state","componentDidMount","fetchTeams","contextSrv","AccessControlAction","fetchRoleOptions","loadTeams","setState","renderTeam","editorsCanAdmin","signedInUser","permission","teamUrl","isTeamAdmin","isPermissionTeamAdmin","canDelete","canReadTeam","canSeeTeamRoles","canUpdateTeamRoles","displayRolePicker","className","href","src","avatarUrl","alt","name","style","padding","email","length","undefined","memberCount","DeleteButton","size","onConfirm","renderEmptyList","EmptyListCTA","title","buttonIcon","buttonLink","buttonTitle","buttonDisabled","proTip","proTipLink","proTipLinkTitle","proTipTarget","renderTeamList","searchQuery","setTeamsSearchPage","teamAdmin","canCreate","newTeamHref","paginatedTeams","getPaginatedTeams","totalPages","Math","ceil","FilterInput","placeholder","onChange","onSearchQueryChange","LinkButton","VerticalGroup","spacing","width","map","HorizontalGroup","justify","Pagination","onNavigate","currentPage","numberOfPages","hideWhenSinglePage","renderList","teamsCount","hasFetched","render","navModel","Page","getNavModel","navIndex","getTeams","getSearchQuery","getTeamsSearchPage","getTeamsCount","config","teamsLoaded","response","getBackendSrv","get","accessControlQueryParam","perpage","page","loadTeam","teamLoaded","updateNavIndex","buildNavModel","loadTeamMembers","getStore","teamMembersLoaded","addTeamMember","post","userId","removeTeamMember","delete","updateTeam","put","loadTeamGroups","teamGroupsLoaded","addTeamGroup","groupId","removeTeamGroup","encodeURIComponent","updateTeamMember","member","loadingTeam","TeamPermissionLevel","img","subTitle","url","text","breadcrumbs","children","active","icon","unshift","teamGroupSync","isLoadingTeam","highlightTrial","tabSuffix","ProBadge","experimentId","eventVariant","featureEnabled","push","getTeamLoadingNav","pageName","main","node","child","indexOf","getSearchMemberQuery","searchMemberQuery","getTeamGroups","groups","getTeam","currentTeamId","parseInt","regex","RegExp","filter","test","getTeamMembers","members","login","isSignedInUserTeamAdmin","userInMembers","find","m","isAdmin","isGrafanaAdmin","orgRole","OrgRole","userIsTeamAdmin"],"sourceRoot":""}