From 9fed3266e6c1be413cc353e2007e769bd0810741 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Mon, 9 Oct 2017 16:21:23 +0300 Subject: [PATCH] Show links based on permissions the user have. --- .../app/components/app-header/app-header.html | 20 +++++------ client/app/components/app-header/index.js | 1 + client/app/components/settings-screen.html | 4 +-- client/app/components/settings-screen.js | 34 +++++++++---------- client/app/pages/home/home.html | 27 +++++++-------- client/app/pages/home/index.js | 1 + 6 files changed, 44 insertions(+), 43 deletions(-) diff --git a/client/app/components/app-header/app-header.html b/client/app/components/app-header/app-header.html index ee7b2e7596..4db2a4ff83 100644 --- a/client/app/components/app-header/app-header.html +++ b/client/app/components/app-header/app-header.html @@ -32,7 +32,7 @@
  • Queries
  • -
  • +
  • Alerts
  • @@ -59,7 +59,7 @@
    - +
    - + \ No newline at end of file diff --git a/client/app/components/app-header/index.js b/client/app/components/app-header/index.js index 9020dcde10..e35c7e9e0a 100644 --- a/client/app/components/app-header/index.js +++ b/client/app/components/app-header/index.js @@ -11,6 +11,7 @@ function controller($rootScope, $location, $uibModal, Auth, currentUser, clientC this.basePath = clientConfig.basePath; this.currentUser = currentUser; this.showQueriesMenu = currentUser.hasPermission('view_query'); + this.showAlertsLink = currentUser.hasPermission('list_alerts'); this.showNewQueryMenu = currentUser.hasPermission('create_query'); this.showSettingsMenu = currentUser.hasPermission('list_users'); this.showDashboardsMenu = currentUser.hasPermission('list_dashboards'); diff --git a/client/app/components/settings-screen.html b/client/app/components/settings-screen.html index e8f1c9ca30..8446b4093a 100644 --- a/client/app/components/settings-screen.html +++ b/client/app/components/settings-screen.html @@ -8,11 +8,11 @@
  • Users
  • Groups
  • Alert Destinations
  • -
  • Query Snippets
  • +
  • Query Snippets
  • - + \ No newline at end of file diff --git a/client/app/components/settings-screen.js b/client/app/components/settings-screen.js index f6317e5f9a..c52c29aaab 100644 --- a/client/app/components/settings-screen.js +++ b/client/app/components/settings-screen.js @@ -2,22 +2,22 @@ import startsWith from 'underscore.string/startsWith'; import template from './settings-screen.html'; export default function init(ngModule) { - ngModule.directive('settingsScreen', $location => - ({ - restrict: 'E', - transclude: true, - template, - controller($scope, currentUser) { - $scope.usersPage = startsWith($location.path(), '/users'); - $scope.groupsPage = startsWith($location.path(), '/groups'); - $scope.dsPage = startsWith($location.path(), '/data_sources'); - $scope.destinationsPage = startsWith($location.path(), '/destinations'); - $scope.snippetsPage = startsWith($location.path(), '/query_snippets'); + ngModule.directive('settingsScreen', $location => ({ + restrict: 'E', + transclude: true, + template, + controller($scope, currentUser) { + $scope.usersPage = startsWith($location.path(), '/users'); + $scope.groupsPage = startsWith($location.path(), '/groups'); + $scope.dsPage = startsWith($location.path(), '/data_sources'); + $scope.destinationsPage = startsWith($location.path(), '/destinations'); + $scope.snippetsPage = startsWith($location.path(), '/query_snippets'); - $scope.showGroupsLink = currentUser.hasPermission('list_users'); - $scope.showUsersLink = currentUser.hasPermission('list_users'); - $scope.showDsLink = currentUser.hasPermission('admin'); - $scope.showDestinationsLink = currentUser.hasPermission('admin'); - }, - })); + $scope.showGroupsLink = currentUser.hasPermission('list_users'); + $scope.showUsersLink = currentUser.hasPermission('list_users'); + $scope.showDsLink = currentUser.hasPermission('admin'); + $scope.showDestinationsLink = currentUser.hasPermission('admin'); + $scope.showQuerySnippetsLink = currentUser.hasPermission('create_query'); + }, + })); } diff --git a/client/app/pages/home/home.html b/client/app/pages/home/home.html index 67d9c5e40c..6d88cea270 100644 --- a/client/app/pages/home/home.html +++ b/client/app/pages/home/home.html @@ -1,34 +1,33 @@
    -
    +
    New Query - New Alert + New Alert
    -
    -

    Recent Dashboards

    - -
    -

    Recent Queries

    - +
    +

    Recent Queries

    + +
    -
    +
    \ No newline at end of file diff --git a/client/app/pages/home/index.js b/client/app/pages/home/index.js index 0969f66ff7..8d2ef12817 100644 --- a/client/app/pages/home/index.js +++ b/client/app/pages/home/index.js @@ -6,6 +6,7 @@ function HomeCtrl($scope, $uibModal, currentUser, Events, Dashboard, Query) { // todo: maybe this should come from some serivce as we have this logic elsewhere. this.canCreateQuery = currentUser.hasPermission('create_query'); this.canCreateDashboard = currentUser.hasPermission('create_dashboard'); + this.canCreateAlert = currentUser.hasPermission('list_alerts'); this.recentQueries = Query.recent(); this.recentDashboards = Dashboard.recent();