refactoring: enterprise build/hooks refactorings (#12478)

This commit is contained in:
Torkel Ödegaard
2018-07-02 04:33:39 -07:00
committed by GitHub
parent 2941dff428
commit b8724ae0c4
13 changed files with 73 additions and 55 deletions

View File

@@ -1,11 +1,18 @@
import _ from 'lodash';
class Settings {
export interface BuildInfo {
version: string;
commit: string;
isEnterprise: boolean;
env: string;
}
export class Settings {
datasources: any;
panels: any;
appSubUrl: string;
window_title_prefix: string;
buildInfo: any;
buildInfo: BuildInfo;
new_panel_title: string;
bootData: any;
externalUserMngLinkUrl: string;
@@ -22,7 +29,6 @@ class Settings {
disableUserSignUp: boolean;
loginHint: any;
loginError: any;
enterprise: boolean;
constructor(options) {
var defaults = {
@@ -33,7 +39,14 @@ class Settings {
playlist_timespan: '1m',
unsaved_changes_warning: true,
appSubUrl: '',
buildInfo: {
version: 'v1.0',
commit: '1',
env: 'production',
isEnterprise: false,
},
};
_.extend(this, defaults, options);
}
}

View File

@@ -34,14 +34,10 @@ export class ContextSrv {
constructor() {
this.sidemenu = store.getBool('grafana.sidemenu', true);
if (!config.buildInfo) {
config.buildInfo = {};
}
if (!config.bootData) {
config.bootData = { user: {}, settings: {} };
}
this.version = config.buildInfo.version;
this.user = new User();
this.isSignedIn = this.user.isSignedIn;
this.isGrafanaAdmin = this.user.isGrafanaAdmin;

View File

@@ -86,9 +86,7 @@ describe('given dashboard with repeated panels', () => {
],
};
config.buildInfo = {
version: '3.0.2',
};
config.buildInfo.version = '3.0.2';
//Stubs test function calls
var datasourceSrvStub = { get: jest.fn(arg => getStub(arg)) };

View File

@@ -67,39 +67,39 @@
</div>
<div class="gf-form-group" ng-if="ctrl.enterprise">
<div class="gf-form-group" ng-if="ctrl.isMappingsEnabled">
<h3 class="page-heading">Team Group Mapping</h3>
<form name="ctrl.addGroupForm" class="gf-form-group">
<div class="gf-form">
<span class="gf-form-label width-10">Add group</span>
<input class="gf-form-input max-width-22" type="text" ng-model="ctrl.newGroupId">
</div>
<div class="gf-form-button-row">
<button type="submit" class="btn btn-success" ng-click="ctrl.addGroup()">Add</button>
</div>
</form>
<h3 class="page-heading">Mappings to external groups</h3>
<form name="ctrl.addGroupForm" class="gf-form-group">
<div class="gf-form">
<span class="gf-form-label width-10">Add group</span>
<input class="gf-form-input max-width-22" type="text" ng-model="ctrl.newGroupId">
</div>
<div class="gf-form-button-row">
<button type="submit" class="btn btn-success" ng-click="ctrl.addGroup()">Add</button>
</div>
</form>
<table class="filter-table" ng-show="ctrl.teamGroups.length > 0">
<thead>
<tr>
<th>Group</th>
<th></th>
</tr>
</thead>
<tr ng-repeat="group in ctrl.teamGroups">
<td>{{group.groupId}}</td>
<td style="width: 1%">
<a ng-click="ctrl.removeGroup(group)" class="btn btn-danger btn-mini">
<i class="fa fa-remove"></i>
</a>
</td>
</tr>
</table>
<div>
<em class="muted" ng-hide="ctrl.teamGroups.length > 0">
This team has no associated groups yet.
</em>
</div>
<table class="filter-table" ng-show="ctrl.teamGroups.length > 0">
<thead>
<tr>
<th>Group</th>
<th></th>
</tr>
</thead>
<tr ng-repeat="group in ctrl.teamGroups">
<td>{{group.groupId}}</td>
<td style="width: 1%">
<a ng-click="ctrl.removeGroup(group)" class="btn btn-danger btn-mini">
<i class="fa fa-remove"></i>
</a>
</td>
</tr>
</table>
<div>
<em class="muted" ng-hide="ctrl.teamGroups.length > 0">
This team has no associated groups yet.
</em>
</div>
</div>
</div>

View File

@@ -7,7 +7,7 @@ export default class TeamDetailsCtrl {
navModel: any;
teamGroups: TeamGroup[] = [];
newGroupId: string;
enterprise: boolean;
isMappingsEnabled: boolean;
/** @ngInject **/
constructor(private $scope, private backendSrv, private $routeParams, navModelSrv) {
@@ -15,7 +15,7 @@ export default class TeamDetailsCtrl {
this.userPicked = this.userPicked.bind(this);
this.get = this.get.bind(this);
this.newGroupId = '';
this.enterprise = config.enterprise;
this.isMappingsEnabled = config.buildInfo.isEnterprise;
this.get();
}
@@ -29,7 +29,7 @@ export default class TeamDetailsCtrl {
this.teamMembers = result;
});
if (config.enterprise) {
if (this.isMappingsEnabled) {
this.backendSrv.get(`/api/teams/${this.$routeParams.id}/groups`).then(result => {
this.teamGroups = result;
});

View File

@@ -65,7 +65,7 @@
</a>
</li>
<li>
<a href="https://grafana.com" target="_blank">Grafana</a>
<a href="https://grafana.com" target="_blank">[[.AppName]]</a>
<span>v[[.BuildVersion]] (commit: [[.BuildCommit]])</span>
</li>
[[if .NewGrafanaVersionExists]]