Skip to content

Commit

Permalink
Fix: show connect data source link only to admins
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr committed Mar 8, 2018
1 parent 051f12c commit 797b558
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 6 additions & 2 deletions client/app/components/empty-state/empty-state.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ <h2 ng-if="$ctrl.icon">
<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}">
<a href="alerts/new">Create</a> your first Alert</li>
<li ng-if="$ctrl.showDashboardStep" ng-class="{done: $ctrl.dashboardStepCompleted}">
<a ng-click="$ctrl.newDashboard()">Create</a> your first Dashboard</li>
<li ng-if="$ctrl.showInviteStep" ng-class="{done: $ctrl.inviteStepCompleted}">
<li ng-if="$ctrl.showInviteStep" ng-class="{done: $ctrl.inviteStepCompleted}">
<a href="users/new">Invite</a> your team members</li>
</ol>
<p>Need more support?
Expand Down
3 changes: 2 additions & 1 deletion client/app/components/empty-state/empty-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 7 additions & 6 deletions redash/handlers/organization.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
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


@routes.route(org_scoped_rule('/api/organization/status'), methods=['GET'])
@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))

0 comments on commit 797b558

Please sign in to comment.