diff --git a/ui/src/ifql/components/DatabaseList.tsx b/ui/src/ifql/components/DatabaseList.tsx index 515b0109ef..71b15db130 100644 --- a/ui/src/ifql/components/DatabaseList.tsx +++ b/ui/src/ifql/components/DatabaseList.tsx @@ -1,6 +1,5 @@ import React, {PureComponent} from 'react' import PropTypes from 'prop-types' -import _ from 'lodash' import DatabaseListItem from 'src/ifql/components/DatabaseListItem' @@ -47,31 +46,15 @@ class DatabaseList extends PureComponent<{}, DatabaseListState> { const sorted = databases.sort() this.setState({databases: sorted}) - const db = _.get(sorted, '0', '') - this.handleChooseDatabase(db) } catch (err) { console.error(err) } } public render() { - return ( -
- {this.state.databases.map(db => { - return ( - - ) - })} -
- ) - } - - private handleChooseDatabase = (db: string): void => { - this.setState({db}) + return this.state.databases.map(db => { + return + }) } } diff --git a/ui/src/ifql/components/DatabaseListItem.tsx b/ui/src/ifql/components/DatabaseListItem.tsx index 697d28618a..17ac4c948f 100644 --- a/ui/src/ifql/components/DatabaseListItem.tsx +++ b/ui/src/ifql/components/DatabaseListItem.tsx @@ -6,7 +6,6 @@ import TagList from 'src/ifql/components/TagList' interface Props { db: string - onChooseDatabase: (db: string) => void } interface State { @@ -27,7 +26,7 @@ class DatabaseListItem extends PureComponent { return (
-
+ {db}
{this.state.isOpen && } diff --git a/ui/src/ifql/components/SchemaExplorer.tsx b/ui/src/ifql/components/SchemaExplorer.tsx index 702634bff2..62db36dffe 100644 --- a/ui/src/ifql/components/SchemaExplorer.tsx +++ b/ui/src/ifql/components/SchemaExplorer.tsx @@ -5,6 +5,27 @@ class SchemaExplorer extends PureComponent { public render() { return (
+
+
+ +
+ +
) diff --git a/ui/src/ifql/components/TagList.tsx b/ui/src/ifql/components/TagList.tsx index 3e4e3e2f3d..abf6c3079c 100644 --- a/ui/src/ifql/components/TagList.tsx +++ b/ui/src/ifql/components/TagList.tsx @@ -48,21 +48,17 @@ class TagList extends PureComponent { const keys = await getTags() const values = await getTagValues() - const tags = keys.map(k => { - return (this.state.tags[k] = values) - }) + const tags = keys.reduce((acc, k) => { + return {...acc, [k]: values} + }, {}) this.setState({tags}) } public render() { - return ( -
- {_.map(this.state.tags, (tagValues: string[], tagKey: string) => ( - - ))} -
- ) + return _.map(this.state.tags, (tagValues: string[], tagKey: string) => ( + + )) } } diff --git a/ui/src/ifql/components/TagListItem.tsx b/ui/src/ifql/components/TagListItem.tsx index 7a235c7567..76599367b7 100644 --- a/ui/src/ifql/components/TagListItem.tsx +++ b/ui/src/ifql/components/TagListItem.tsx @@ -9,7 +9,6 @@ interface Props { interface State { isOpen: boolean - filterText: string } @ErrorHandling @@ -17,102 +16,52 @@ class TagListItem extends PureComponent { constructor(props) { super(props) this.state = { - filterText: '', isOpen: false, } - - this.handleEscape = this.handleEscape.bind(this) - this.handleClickKey = this.handleClickKey.bind(this) - this.handleFilterText = this.handleFilterText.bind(this) } - public handleClickKey(e: MouseEvent) { + public render() { + const {isOpen} = this.state + + return ( +
+
+ + {this.tagItemLabel} +
+ {isOpen && this.renderTagValues} +
+ ) + } + + private handleClick = (e: MouseEvent): void => { e.stopPropagation() this.setState({isOpen: !this.state.isOpen}) } - public handleFilterText(e) { - e.stopPropagation() - this.setState({ - filterText: e.target.value, - }) + private get tagItemLabel(): string { + const {tagKey, tagValues} = this.props + return `${tagKey} — ${tagValues.length}` } - public handleEscape(e) { - if (e.key !== 'Escape') { - return - } - - e.stopPropagation() - this.setState({ - filterText: '', - }) - } - - public handleInputClick(e: MouseEvent) { - e.stopPropagation() - } - - public renderTagValues() { + private get renderTagValues(): JSX.Element[] | JSX.Element { const {tagValues} = this.props if (!tagValues || !tagValues.length) { - return
no tag values
+ return
No tag values
} - const filterText = this.state.filterText.toLowerCase() - const filtered = tagValues.filter(v => v.toLowerCase().includes(filterText)) - - return ( -
-
- - + return tagValues.map(v => { + return ( +
+ {v}
- {filtered.map(v => { - return ( -
- {v} -
- ) - })} -
- ) + ) + }) } - public render() { - const {tagKey, tagValues} = this.props + private get className(): string { const {isOpen} = this.state - const tagItemLabel = `${tagKey} — ${tagValues.length}` - - return ( -
-
- -
- {tagItemLabel} - -
- {isOpen ? this.renderTagValues() : null} -
- ) + return classnames('ifql-schema-tree', {expanded: isOpen}) } } diff --git a/ui/src/style/components/time-machine/ifql-explorer.scss b/ui/src/style/components/time-machine/ifql-explorer.scss index 05ae155ef8..0f5067032b 100644 --- a/ui/src/style/components/time-machine/ifql-explorer.scss +++ b/ui/src/style/components/time-machine/ifql-explorer.scss @@ -3,47 +3,92 @@ ---------------------------------------------------------------------------- */ -$ifql-tree-indent: 30px; +$ifql-tree-indent: 28px; .ifql-schema-explorer { width: 100%; height: 100%; + background-color: $g2-kevlar; } .ifql-schema-tree { display: flex; flex-direction: column; align-items: stretch; + padding-left: 0; - & > .ifql-schema-tree { + > .ifql-schema-tree { padding-left: $ifql-tree-indent; } - - .ifql-schema-item + & { - display: none; - } - - .expanded .ifql-schema-item + & { - display: flex; - } } -.ifql-schema-item { - position: relative; - height: 30px; +.ifql-schema-tree__empty { + height: $ifql-tree-indent; display: flex; align-items: center; padding: 0 11px; - padding-left: 32px; + font-size: 12px; + font-weight: 600; + color: $g8-storm; + font-style: italic; +} - > span { +.ifql-schema-item { + @include no-user-select(); + position: relative; + height: $ifql-tree-indent; + display: flex; + align-items: center; + padding: 0 11px; + padding-left: $ifql-tree-indent; + font-size: 12px; + font-weight: 600; + color: $g11-sidewalk; + transition: color 0.25s ease, background-color 0.25s ease; + + > span.icon { position: absolute; top: 50%; - left: 14px; + left: $ifql-tree-indent / 2; transform: translate(-50%, -50%); transition: transform 0.25s ease; } - + + &:hover { + color: $g15-platinum; + cursor: pointer; + background-color: $g4-onyx; + } + + .expanded > & { + color: $c-pool; + background-color: $g3-castle; + + > span.icon { + transform: translate(-50%, -50%) rotate(90deg); + } + } + + &.readonly, + &.readonly:hover { + background-color: transparent; + color: $g11-sidewalk; + cursor: default; + } } +/* + Controls + ---------------------------------------------------------------------------- +*/ +.ifql-schema--controls { + padding: 11px; + display: flex; + align-items: center; + justify-content: space-between; +} +.ifql-schema--filter { + flex: 1 0 0; + margin-right: 4px; +} diff --git a/ui/src/style/pages/time-machine.scss b/ui/src/style/pages/time-machine.scss index 308c8128ed..2b6c49f5b7 100644 --- a/ui/src/style/pages/time-machine.scss +++ b/ui/src/style/pages/time-machine.scss @@ -5,6 +5,6 @@ @import '../components/time-machine/ifql-editor'; @import '../components/time-machine/ifql-builder'; -// @import '../components/time-machine/ifql-explorer'; +@import '../components/time-machine/ifql-explorer'; @import '../components/time-machine/visualization'; @import '../components/time-machine/add-func-button'; \ No newline at end of file