mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix editor history in wrong order (#88666)
This commit is contained in:
parent
3f7017a471
commit
2fb63cd2e6
@ -13,21 +13,28 @@ const history: Array<HistoryItem<LokiQuery>> = [
|
|||||||
ts: 12345678,
|
ts: 12345678,
|
||||||
query: {
|
query: {
|
||||||
refId: 'test-1',
|
refId: 'test-1',
|
||||||
expr: '{test: unit}',
|
expr: '{test="unit"}',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ts: 87654321,
|
ts: 87654321,
|
||||||
query: {
|
query: {
|
||||||
refId: 'test-1',
|
refId: 'test-1',
|
||||||
expr: '{unit: test}',
|
expr: '{unit="test"}',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ts: 87654321,
|
ts: 87654321,
|
||||||
query: {
|
query: {
|
||||||
refId: 'test-1',
|
refId: 'test-1',
|
||||||
expr: '{unit: test}',
|
expr: '{unit="test"}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ts: 87654325,
|
||||||
|
query: {
|
||||||
|
refId: 'test-2',
|
||||||
|
expr: '{unit="test"} ', // will be trimmed and removed
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -82,11 +89,11 @@ describe('CompletionDataProvider', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Returns the expected history entries', () => {
|
test('Returns the expected history entries', () => {
|
||||||
expect(completionProvider.getHistory()).toEqual(['{test: unit}', '{unit: test}']);
|
expect(completionProvider.getHistory()).toEqual(['{unit="test"}', '{test="unit"}']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Processes updates to the current historyRef value', () => {
|
test('Processes updates to the current historyRef value', () => {
|
||||||
expect(completionProvider.getHistory()).toEqual(['{test: unit}', '{unit: test}']);
|
expect(completionProvider.getHistory()).toEqual(['{unit="test"}', '{test="unit"}']);
|
||||||
|
|
||||||
historyRef.current = [
|
historyRef.current = [
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,8 @@ export class CompletionDataProvider {
|
|||||||
|
|
||||||
getHistory() {
|
getHistory() {
|
||||||
return chain(this.historyRef.current)
|
return chain(this.historyRef.current)
|
||||||
.map((history: HistoryItem<LokiQuery>) => history.query.expr)
|
.orderBy('ts', 'desc')
|
||||||
|
.map((history: HistoryItem<LokiQuery>) => history.query.expr.trim())
|
||||||
.filter()
|
.filter()
|
||||||
.uniq()
|
.uniq()
|
||||||
.value();
|
.value();
|
||||||
|
Loading…
Reference in New Issue
Block a user