|
|
@@ -4,11 +4,13 @@ import { hot } from 'react-hot-loader';
|
|
|
import Page from 'app/core/components/Page/Page';
|
|
|
import { DeleteButton } from '@grafana/ui';
|
|
|
import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
|
|
|
-import { NavModel, Team } from 'app/types';
|
|
|
+import { NavModel, Team, OrgRole } from 'app/types';
|
|
|
import { loadTeams, deleteTeam, setSearchQuery } from './state/actions';
|
|
|
import { getSearchQuery, getTeams, getTeamsCount } from './state/selectors';
|
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
|
|
import { FilterInput } from 'app/core/components/FilterInput/FilterInput';
|
|
|
+import { config } from 'app/core/config';
|
|
|
+import { contextSrv, User } from 'app/core/services/context_srv';
|
|
|
|
|
|
export interface Props {
|
|
|
navModel: NavModel;
|
|
|
@@ -19,6 +21,8 @@ export interface Props {
|
|
|
loadTeams: typeof loadTeams;
|
|
|
deleteTeam: typeof deleteTeam;
|
|
|
setSearchQuery: typeof setSearchQuery;
|
|
|
+ editorsCanAdmin?: boolean;
|
|
|
+ signedInUser?: User;
|
|
|
}
|
|
|
|
|
|
export class TeamList extends PureComponent<Props, any> {
|
|
|
@@ -84,7 +88,8 @@ export class TeamList extends PureComponent<Props, any> {
|
|
|
}
|
|
|
|
|
|
renderTeamList() {
|
|
|
- const { teams, searchQuery } = this.props;
|
|
|
+ const { teams, searchQuery, editorsCanAdmin, signedInUser } = this.props;
|
|
|
+ const disabledClass = editorsCanAdmin && signedInUser.orgRole === OrgRole.Viewer ? ' disabled' : '';
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
@@ -101,7 +106,7 @@ export class TeamList extends PureComponent<Props, any> {
|
|
|
|
|
|
<div className="page-action-bar__spacer" />
|
|
|
|
|
|
- <a className="btn btn-primary" href="org/teams/new">
|
|
|
+ <a className={`btn btn-primary${disabledClass}`} href="org/teams/new">
|
|
|
New team
|
|
|
</a>
|
|
|
</div>
|
|
|
@@ -152,6 +157,8 @@ function mapStateToProps(state) {
|
|
|
searchQuery: getSearchQuery(state.teams),
|
|
|
teamsCount: getTeamsCount(state.teams),
|
|
|
hasFetched: state.teams.hasFetched,
|
|
|
+ editorsCanAdmin: config.editorsCanAdmin, // this makes the feature toggle mockable/controllable from tests,
|
|
|
+ signedInUser: contextSrv.user, // this makes the feature toggle mockable/controllable from tests,
|
|
|
};
|
|
|
}
|
|
|
|