mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 18:52:33 +08:00
ux: search progress
This commit is contained in:
@ -80,7 +80,9 @@
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="search-item__actions">
|
<span class="search-item__actions">
|
||||||
|
<span class="search-item__actions__item" ng-click="ctrl.toggleStar()">
|
||||||
<i class="fa" ng-class="{'fa-star': item.isStarred, 'fa-star-o': !item.isStarred}"></i>
|
<i class="fa" ng-class="{'fa-star': item.isStarred, 'fa-star-o': !item.isStarred}"></i>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
///<reference path="../../headers/common.d.ts" />
|
|
||||||
|
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import coreModule from 'app/core/core_module';
|
import coreModule from 'app/core/core_module';
|
||||||
|
@ -2,6 +2,7 @@ import _ from 'lodash';
|
|||||||
import coreModule from 'app/core/core_module';
|
import coreModule from 'app/core/core_module';
|
||||||
import impressionSrv from 'app/core/services/impression_srv';
|
import impressionSrv from 'app/core/services/impression_srv';
|
||||||
import store from 'app/core/store';
|
import store from 'app/core/store';
|
||||||
|
import { contextSrv } from 'app/core/services/context_srv';
|
||||||
|
|
||||||
export class SearchSrv {
|
export class SearchSrv {
|
||||||
recentIsOpen: boolean;
|
recentIsOpen: boolean;
|
||||||
@ -20,6 +21,7 @@ export class SearchSrv {
|
|||||||
title: 'Recent Boards',
|
title: 'Recent Boards',
|
||||||
icon: 'fa fa-clock-o',
|
icon: 'fa fa-clock-o',
|
||||||
score: -1,
|
score: -1,
|
||||||
|
removable: true,
|
||||||
expanded: this.recentIsOpen,
|
expanded: this.recentIsOpen,
|
||||||
toggle: this.toggleRecent.bind(this),
|
toggle: this.toggleRecent.bind(this),
|
||||||
items: result,
|
items: result,
|
||||||
@ -60,6 +62,10 @@ export class SearchSrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getStarred(sections) {
|
private getStarred(sections) {
|
||||||
|
if (!contextSrv.isSignedIn) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
return this.backendSrv.search({starred: true, limit: 5}).then(result => {
|
return this.backendSrv.search({starred: true, limit: 5}).then(result => {
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
sections['starred'] = {
|
sections['starred'] = {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { SearchSrv } from 'app/core/services/search_srv';
|
import { SearchSrv } from 'app/core/services/search_srv';
|
||||||
import { BackendSrvMock } from 'test/mocks/backend_srv';
|
import { BackendSrvMock } from 'test/mocks/backend_srv';
|
||||||
import impressionSrv from 'app/core/services/impression_srv';
|
import impressionSrv from 'app/core/services/impression_srv';
|
||||||
|
import { contextSrv } from 'app/core/services/context_srv';
|
||||||
|
|
||||||
jest.mock('app/core/store', () => {
|
jest.mock('app/core/store', () => {
|
||||||
return {
|
return {
|
||||||
@ -22,6 +23,7 @@ describe('SearchSrv', () => {
|
|||||||
backendSrvMock = new BackendSrvMock();
|
backendSrvMock = new BackendSrvMock();
|
||||||
searchSrv = new SearchSrv(backendSrvMock, Promise);
|
searchSrv = new SearchSrv(backendSrvMock, Promise);
|
||||||
|
|
||||||
|
contextSrv.isSignedIn = true;
|
||||||
impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([]);
|
impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -141,14 +141,6 @@
|
|||||||
&.selected {
|
&.selected {
|
||||||
background: $list-item-hover-bg;
|
background: $list-item-hover-bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// .fa-star, .fa-star-o {
|
|
||||||
// padding-left: 13px;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// .fa-star {
|
|
||||||
// color: $orange;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-item__body {
|
.search-item__body {
|
||||||
@ -182,7 +174,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.search-item__actions {
|
.search-item__actions {
|
||||||
visibility: hidden;
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-item__actions__item {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-item:hover {
|
||||||
|
.search-item__actions__item {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-button-row {
|
.search-button-row {
|
||||||
|
Reference in New Issue
Block a user