Commit 143c0022 by Johannes Schill

Merge branch 'master' into 10190_fix_select_icon_and_firefox

parents bc7462cd b1621e1e
import coreModule from '../../core_module';
import {NavModel} from '../../nav_model_srv';
import appEvents from 'app/core/app_events';
export class NavbarCtrl {
model: NavModel;
/** @ngInject */
constructor(private $rootScope) {
}
constructor() {}
showSearch() {
this.$rootScope.appEvent('show-dash-search');
appEvents.emit('show-dash-search');
}
navItemClicked(navItem, evt) {
......
......@@ -57,11 +57,11 @@
<div class="search-filter-box">
<a href="dashboard/new" class="search-filter-box-link">
<i class="gicon gicon-dashboard-new"></i>
Dashboard
New dashboard
</a>
<a href="dashboards/folder/new" class="search-filter-box-link">
<i class="gicon gicon-folder-new"></i>
Folder
New folder
</a>
<a class="search-filter-box-link" target="_blank" href="https://grafana.com/dashboards?utm_source=grafana_search">
<img src="public/img/icn-dashboard-tiny.svg" width="20" /> Find dashboards on Grafana.com
......
import _ from 'lodash';
import coreModule from '../../core_module';
import { SearchSrv } from 'app/core/services/search_srv';
import appEvents from 'app/core/app_events';
export class SearchCtrl {
isOpen: boolean;
......@@ -16,9 +17,9 @@ export class SearchCtrl {
initialFolderFilterTitle: string;
/** @ngInject */
constructor($scope, private $location, private $timeout, private searchSrv: SearchSrv, $rootScope) {
$rootScope.onAppEvent('show-dash-search', this.openSearch.bind(this), $scope);
$rootScope.onAppEvent('hide-dash-search', this.closeSearch.bind(this), $scope);
constructor($scope, private $location, private $timeout, private searchSrv: SearchSrv) {
appEvents.on('show-dash-search', this.openSearch.bind(this), $scope);
appEvents.on('hide-dash-search', this.closeSearch.bind(this), $scope);
this.initialFolderFilterTitle = "All";
}
......@@ -74,6 +75,7 @@ export class SearchCtrl {
if (selectedDash) {
this.$location.search({});
this.$location.path(selectedDash.url);
this.closeSearch();
}
} else {
const selectedFolder = this.results[currentItem.folderIndex];
......
......@@ -32,7 +32,7 @@
<span class="search-item__icon">
<i class="gicon mini gicon-dashboard-list"></i>
</span>
<span class="search-item__body">
<span class="search-item__body" ng-click="ctrl.onItemClick(item)">
<div class="search-item__body-title">{{::item.title}}</div>
</span>
<span class="search-item__tags">
......
import _ from 'lodash';
import coreModule from '../../core_module';
import appEvents from 'app/core/app_events';
export class SearchResultsCtrl {
results: any;
......@@ -61,6 +62,12 @@ export class SearchResultsCtrl {
}
}
onItemClick(item) {
if (this.$location.path().indexOf(item.url) > -1) {
appEvents.emit('hide-dash-search');
}
}
selectTag(tag, evt) {
if (this.onTagSelected) {
this.onTagSelected({$tag: tag});
......
......@@ -36,15 +36,15 @@ export class KeybindingSrv {
}
openSearchStarred() {
this.$rootScope.appEvent('show-dash-search', {starred: true});
appEvents.emit('show-dash-search', {starred: true});
}
openSearchTags() {
this.$rootScope.appEvent('show-dash-search', {tagsMode: true});
appEvents.emit('show-dash-search', {tagsMode: true});
}
openSearch() {
this.$rootScope.appEvent('show-dash-search');
appEvents.emit('show-dash-search');
}
openAlerting() {
......
......@@ -6,7 +6,7 @@ describe('SearchCtrl', () => {
search: (options: any) => {},
getDashboardTags: () => {}
};
let ctrl = new SearchCtrl({}, {}, {}, <SearchSrv>searchSrvStub, { onAppEvent: () => { } });
let ctrl = new SearchCtrl({$on: () => {}}, {}, {}, <SearchSrv>searchSrvStub);
describe('Given an empty result', () => {
beforeEach(() => {
......
import { SearchResultsCtrl } from '../components/search/search_results';
import { beforeEach, afterEach } from 'test/lib/common';
import appEvents from 'app/core/app_events';
jest.mock('app/core/app_events', () => {
return {
emit: jest.fn<any>()
};
});
describe('SearchResultsCtrl', () => {
let ctrl;
......@@ -94,4 +102,39 @@ describe('SearchResultsCtrl', () => {
expect(folderExpanded).toBeFalsy();
});
});
describe('when clicking on a link in search result', () => {
const dashPath = 'dashboard/path';
const $location = { path: () => dashPath};
const appEventsMock = appEvents as any;
describe('with the same url as current path', () => {
beforeEach(() => {
ctrl = new SearchResultsCtrl($location);
const item = { url: dashPath};
ctrl.onItemClick(item);
});
it('should close the search', () => {
expect(appEventsMock.emit.mock.calls.length).toBe(1);
expect(appEventsMock.emit.mock.calls[0][0]).toBe('hide-dash-search');
});
});
describe('with a different url than current path', () => {
beforeEach(() => {
ctrl = new SearchResultsCtrl($location);
const item = { url: 'another/path'};
ctrl.onItemClick(item);
});
it('should do nothing', () => {
expect(appEventsMock.emit.mock.calls.length).toBe(0);
});
});
afterEach(() => {
appEventsMock.emit.mockClear();
});
});
});
......@@ -33,9 +33,9 @@
<i class="fa fa-save"></i>
</button>
<button class="btn navbar-button navbar-button--snapshot-origin" ng-if="::ctrl.dashboard.snapshot.originalUrl" ng-href="{{ctrl.dashboard.snapshot.originalUrl}}" bs-tooltip="'Open original dashboard'" data-placement="bottom">
<a class="btn navbar-button navbar-button--snapshot-origin" ng-if="::ctrl.dashboard.snapshot.originalUrl" href="{{ctrl.dashboard.snapshot.originalUrl}}" bs-tooltip="'Open original dashboard'" data-placement="bottom">
<i class="fa fa-link"></i>
</button>
</a>
<button class="btn navbar-button navbar-button--settings" ng-click="ctrl.toggleSettings()" bs-tooltip="'Settings'" data-placement="bottom" ng-show="ctrl.dashboard.meta.showSettings">
<i class="fa fa-cog"></i>
......
......@@ -11,7 +11,6 @@ export class DashNavCtrl {
/** @ngInject */
constructor(
private $scope,
private $rootScope,
private dashboardSrv,
private $location,
public playlistSrv) {
......@@ -75,7 +74,7 @@ export class DashNavCtrl {
}
showSearch() {
this.$rootScope.appEvent('show-dash-search');
appEvents.emit('show-dash-search');
}
addPanel() {
......
///<reference path="../../headers/common.d.ts" />
import coreModule from "app/core/core_module";
import { appEvents } from "app/core/core";
import coreModule from 'app/core/core_module';
import appEvents from 'app/core/app_events';
export class TeamsCtrl {
teams: any;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment