Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7a1eff19
Unverified
Commit
7a1eff19
authored
Oct 22, 2019
by
Ivana Huckova
Committed by
GitHub
Oct 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explore: Add functionality to show/hide query row results (#19794)
parent
2a78d2a6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
172 additions
and
28 deletions
+172
-28
public/app/features/explore/QueryRow.tsx
+21
-28
public/app/features/explore/QueryRowActions.test.tsx
+39
-0
public/app/features/explore/QueryRowActions.tsx
+54
-0
public/app/features/explore/__snapshots__/QueryRowActions.test.tsx.snap
+58
-0
No files found.
public/app/features/explore/QueryRow.tsx
View file @
7a1eff19
...
...
@@ -7,11 +7,12 @@ import { hot } from 'react-hot-loader';
import
{
connect
}
from
'react-redux'
;
// Components
import
QueryEditor
from
'./QueryEditor'
;
import
{
QueryRowActions
}
from
'./QueryRowActions'
;
// Actions
import
{
changeQuery
,
modifyQueries
,
runQueries
,
addQueryRow
}
from
'./state/actions'
;
// Types
import
{
StoreState
}
from
'app/types'
;
import
{
TimeRange
,
AbsoluteTimeRange
}
from
'@grafana/data'
;
import
{
TimeRange
,
AbsoluteTimeRange
,
LoadingState
}
from
'@grafana/data'
;
import
{
DataQuery
,
DataSourceApi
,
QueryFixAction
,
DataSourceStatus
,
PanelData
}
from
'@grafana/ui'
;
import
{
HistoryItem
,
ExploreItemState
,
ExploreId
,
ExploreMode
}
from
'app/types/explore'
;
import
{
Emitter
}
from
'app/core/utils/emitter'
;
...
...
@@ -76,8 +77,13 @@ export class QueryRow extends PureComponent<QueryRowProps, QueryRowState> {
this
.
props
.
addQueryRow
(
exploreId
,
index
);
};
onClickClearButton
=
()
=>
{
this
.
onChange
(
null
,
true
);
onClickToggleHiddenQuery
=
()
=>
{
const
{
exploreId
,
index
,
query
}
=
this
.
props
;
const
newQuery
=
{
...
query
,
hide
:
!
query
.
hide
,
};
this
.
props
.
changeQuery
(
exploreId
,
newQuery
,
index
,
true
);
};
onClickHintFix
=
(
action
:
QueryFixAction
)
=>
{
...
...
@@ -120,8 +126,10 @@ export class QueryRow extends PureComponent<QueryRowProps, QueryRowState> {
latency
,
mode
,
}
=
this
.
props
;
const
canToggleEditorModes
=
mode
===
ExploreMode
.
Metrics
&&
has
(
datasourceInstance
,
'components.QueryCtrl.prototype.toggleEditorMode'
);
const
canHide
=
queryResponse
.
state
!==
LoadingState
.
NotStarted
;
const
queryErrors
=
queryResponse
.
error
&&
queryResponse
.
error
.
refId
===
query
.
refId
?
[
queryResponse
.
error
]
:
[];
let
QueryField
;
...
...
@@ -163,32 +171,17 @@ export class QueryRow extends PureComponent<QueryRowProps, QueryRowState> {
)
}
</
div
>
<
div
className=
"query-row-status"
>
<
QueryStatus
queryResponse=
{
queryResponse
}
latency=
{
latency
}
/>
</
div
>
<
div
className=
"gf-form-inline flex-shrink-0"
>
{
canToggleEditorModes
&&
(
<
div
className=
"gf-form"
>
<
button
className=
"gf-form-label gf-form-label--btn"
onClick=
{
this
.
onClickToggleEditorMode
}
>
<
i
className=
"fa fa-pencil"
/>
</
button
>
</
div
>
)
}
<
div
className=
"gf-form"
>
<
button
className=
"gf-form-label gf-form-label--btn"
onClick=
{
this
.
onClickClearButton
}
>
<
i
className=
"fa fa-times"
/>
</
button
>
</
div
>
<
div
className=
"gf-form"
>
<
button
className=
"gf-form-label gf-form-label--btn"
onClick=
{
this
.
onClickAddButton
}
>
<
i
className=
"fa fa-plus"
/>
</
button
>
</
div
>
<
div
className=
"gf-form"
>
<
button
className=
"gf-form-label gf-form-label--btn"
onClick=
{
this
.
onClickRemoveButton
}
>
<
i
className=
"fa fa-minus"
/>
</
button
>
</
div
>
<
QueryStatus
queryResponse=
{
queryResponse
}
latency=
{
query
.
hide
?
0
:
latency
}
/>
</
div
>
<
QueryRowActions
canToggleEditorModes=
{
canToggleEditorModes
}
hideQuery=
{
query
.
hide
}
canHide=
{
canHide
}
onClickToggleEditorMode=
{
this
.
onClickToggleEditorMode
}
onClickToggleHiddenQuery=
{
this
.
onClickToggleHiddenQuery
}
onClickAddButton=
{
this
.
onClickAddButton
}
onClickRemoveButton=
{
this
.
onClickRemoveButton
}
/>
</
div
>
);
}
...
...
public/app/features/explore/QueryRowActions.test.tsx
0 → 100644
View file @
7a1eff19
import
React
from
'react'
;
import
{
QueryRowActions
,
Props
}
from
'./QueryRowActions'
;
import
{
shallow
}
from
'enzyme'
;
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
hideQuery
:
false
,
canHide
:
true
,
canToggleEditorModes
:
true
,
onClickToggleEditorMode
:
()
=>
{},
onClickToggleHiddenQuery
:
()
=>
{},
onClickAddButton
:
()
=>
{},
onClickRemoveButton
:
()
=>
{},
};
Object
.
assign
(
props
,
propOverrides
);
const
wrapper
=
shallow
(<
QueryRowActions
{
...
props
}
/>);
return
wrapper
;
};
describe
(
'QueryRowActions'
,
()
=>
{
it
(
'should render component'
,
()
=>
{
const
wrapper
=
setup
();
expect
(
wrapper
).
toMatchSnapshot
();
});
it
(
'should render component without editor mode'
,
()
=>
{
const
wrapper
=
setup
({
canToggleEditorModes
:
false
});
expect
(
wrapper
.
find
({
'aria-label'
:
'Edit mode button'
})).
toHaveLength
(
0
);
});
it
(
'should change icon to fa-eye-slash when query row result is hidden'
,
()
=>
{
const
wrapper
=
setup
({
hideQuery
:
true
});
expect
(
wrapper
.
find
(
'i.fa-eye-slash'
)).
toHaveLength
(
1
);
});
it
(
'should change icon to fa-eye when query row result is not hidden'
,
()
=>
{
const
wrapper
=
setup
({
hideQuery
:
false
});
expect
(
wrapper
.
find
(
'i.fa-eye'
)).
toHaveLength
(
1
);
});
});
public/app/features/explore/QueryRowActions.tsx
0 → 100644
View file @
7a1eff19
import
React
from
'react'
;
export
type
Props
=
{
canToggleEditorModes
:
boolean
;
hideQuery
:
boolean
;
canHide
:
boolean
;
onClickToggleEditorMode
:
()
=>
void
;
onClickToggleHiddenQuery
:
()
=>
void
;
onClickAddButton
:
()
=>
void
;
onClickRemoveButton
:
()
=>
void
;
};
export
function
QueryRowActions
(
props
:
Props
)
{
const
{
canToggleEditorModes
,
onClickToggleEditorMode
,
onClickToggleHiddenQuery
,
onClickAddButton
,
onClickRemoveButton
,
hideQuery
,
canHide
,
}
=
props
;
return
(
<
div
className=
"gf-form-inline flex-shrink-0"
>
{
canToggleEditorModes
&&
(
<
div
className=
"gf-form"
>
<
button
aria
-
label=
"Edit mode button"
className=
"gf-form-label gf-form-label--btn"
onClick=
{
onClickToggleEditorMode
}
>
<
i
className=
"fa fa-pencil"
/>
</
button
>
</
div
>
)
}
<
div
className=
"gf-form"
>
<
button
disabled=
{
!
canHide
}
className=
"gf-form-label gf-form-label--btn"
onClick=
{
onClickToggleHiddenQuery
}
>
<
i
className=
{
hideQuery
?
'fa fa-eye-slash'
:
'fa fa-eye'
}
/>
</
button
>
</
div
>
<
div
className=
"gf-form"
>
<
button
className=
"gf-form-label gf-form-label--btn"
onClick=
{
onClickAddButton
}
>
<
i
className=
"fa fa-plus"
/>
</
button
>
</
div
>
<
div
className=
"gf-form"
>
<
button
className=
"gf-form-label gf-form-label--btn"
onClick=
{
onClickRemoveButton
}
>
<
i
className=
"fa fa-minus"
/>
</
button
>
</
div
>
</
div
>
);
}
public/app/features/explore/__snapshots__/QueryRowActions.test.tsx.snap
0 → 100644
View file @
7a1eff19
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`QueryRowActions should render component 1`] = `
<div
className="gf-form-inline flex-shrink-0"
>
<div
className="gf-form"
>
<button
aria-label="Edit mode button"
className="gf-form-label gf-form-label--btn"
onClick={[Function]}
>
<i
className="fa fa-pencil"
/>
</button>
</div>
<div
className="gf-form"
>
<button
className="gf-form-label gf-form-label--btn"
disabled={false}
onClick={[Function]}
>
<i
className="fa fa-eye"
/>
</button>
</div>
<div
className="gf-form"
>
<button
className="gf-form-label gf-form-label--btn"
onClick={[Function]}
>
<i
className="fa fa-plus"
/>
</button>
</div>
<div
className="gf-form"
>
<button
className="gf-form-label gf-form-label--btn"
onClick={[Function]}
>
<i
className="fa fa-minus"
/>
</button>
</div>
</div>
`;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment