Merge pull request #2378 from getredash/fix_empty_states

Empty state screen fix: show connect data source link only to admins
This commit is contained in:
Arik Fraimovich 2018-03-08 09:53:29 +02:00 committed by GitHub
commit a824bd5da3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -23,7 +23,7 @@ deployment:
commands:
- bin/pack
docker:
tag: [/v[0-9]+(\.[0-9\-a-z]+)*/]
tag: /v[0-9]+(\.[0-9\-a-z]+)*/
commands:
- bin/pack
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS

View File

@ -10,7 +10,11 @@
<h4>Let's get started</h4>
<ol>
<li ng-class="{done: $ctrl.dataSourceStepCompleted}">
<a href="data_sources">Connect</a> a Data Source</li>
<span ng-if="!$ctrl.isAdmin">Ask an account admin to connect a data source.</span>
<span ng-if="$ctrl.isAdmin">
<a href="data_sources">Connect</a> a Data Source
</span>
</li>
<li ng-class="{done: $ctrl.queryStepCompleted}">
<a href="queries/new">Create</a> your first Query</li>
<li ng-if="$ctrl.showAlertStep" ng-class="{done: $ctrl.alertStepCompleted}">

View File

@ -14,8 +14,9 @@ const EmptyStateComponent = {
showInviteStep: '<',
onboardingMode: '<',
},
controller($http, $uibModal) {
controller($http, $uibModal, currentUser) {
this.loading = true;
this.isAdmin = currentUser.isAdmin;
$http.get('api/organization/status').then((response) => {
this.loading = false;

View File

@ -1,10 +1,11 @@
import json
from flask import request
from flask_login import login_required
from flask_login import current_user, login_required
from redash import models
from redash.handlers import routes
from redash.handlers.base import json_response, org_scoped_rule
from redash.authentication import current_org
from redash.permissions import require_admin
@ -12,10 +13,10 @@ from redash.permissions import require_admin
@login_required
def organization_status(org_slug=None):
counters = {
'users': models.User.query.count(),
'alerts': models.Alert.query.count(),
'data_sources': models.DataSource.query.count(),
'queries': models.Query.query.filter(models.Query.is_archived==False).count(),
'dashboards': models.Dashboard.query.filter(models.Dashboard.is_archived==False).count(),
'users': models.User.all(current_org).count(),
'alerts': models.Alert.all(group_ids=current_user.group_ids).count(),
'data_sources': models.DataSource.all(current_org, group_ids=current_user.group_ids).count(),
'queries': models.Query.all_queries(current_user.group_ids, current_user.id, drafts=True).count(),
'dashboards': models.Dashboard.all(current_org, current_user.group_ids, current_user.id).count(),
}
return json_response(dict(object_counters=counters))