Unverified Commit b382de50 authored by Tamika Tannis's avatar Tamika Tannis Committed by GitHub

Pass product name to query list item UI (#510)

parent d8d4cb82
...@@ -7,6 +7,7 @@ import QueryListItem from '../QueryListItem'; ...@@ -7,6 +7,7 @@ import QueryListItem from '../QueryListItem';
const setup = (propOverrides?: Partial<QueryListProps>) => { const setup = (propOverrides?: Partial<QueryListProps>) => {
const props = { const props = {
product: 'Mode',
queries: [], queries: [],
...propOverrides, ...propOverrides,
}; };
......
...@@ -5,12 +5,13 @@ import QueryListItem from '../QueryListItem'; ...@@ -5,12 +5,13 @@ import QueryListItem from '../QueryListItem';
import './styles.scss'; import './styles.scss';
export interface QueryListProps { export interface QueryListProps {
product: string;
queries: QueryResource[]; queries: QueryResource[];
} }
class QueryList extends React.Component<QueryListProps> { class QueryList extends React.Component<QueryListProps> {
render() { render() {
const { queries } = this.props; const { product, queries } = this.props;
if (queries.length === 0) { if (queries.length === 0) {
return null; return null;
...@@ -19,6 +20,7 @@ class QueryList extends React.Component<QueryListProps> { ...@@ -19,6 +20,7 @@ class QueryList extends React.Component<QueryListProps> {
const queryList = queries.map(({ name, query_text, url }) => ( const queryList = queries.map(({ name, query_text, url }) => (
<QueryListItem <QueryListItem
key={`key:${name}`} key={`key:${name}`}
product={product}
text={query_text} text={query_text}
url={url} url={url}
name={name} name={name}
......
...@@ -6,6 +6,7 @@ import QueryListItem, { QueryListItemProps } from '.'; ...@@ -6,6 +6,7 @@ import QueryListItem, { QueryListItemProps } from '.';
const setup = (propOverrides?: Partial<QueryListItemProps>) => { const setup = (propOverrides?: Partial<QueryListItemProps>) => {
const props: QueryListItemProps = { const props: QueryListItemProps = {
product: 'Mode',
text: 'testQuery', text: 'testQuery',
url: 'http://test.url', url: 'http://test.url',
name: 'testName', name: 'testName',
......
import * as React from 'react'; import * as React from 'react';
import { OverlayTrigger, Popover } from 'react-bootstrap'; import { OverlayTrigger, Popover } from 'react-bootstrap';
import { ResourceType } from 'interfaces';
import { getSourceDisplayName, getSourceIconClass } from 'config/config-utils';
import './styles.scss'; import './styles.scss';
export interface QueryListItemProps { export interface QueryListItemProps {
name: string;
product: string;
text: string; text: string;
url: string; url: string;
name: string;
} }
type GoToDashboardLinkProps = { type GoToDashboardLinkProps = {
product: string;
url: string; url: string;
}; };
const QUERY_LABEL = 'Query'; const QUERY_LABEL = 'Query';
const MODE_LINK_TOOLTIP_TEXT = 'View in Mode'; const LINK_TOOLTIP_TEXT = 'View in';
const LOADING_QUERY_MESSAGE = 'Loading Query Component, please wait...'; const LOADING_QUERY_MESSAGE = 'Loading Query Component, please wait...';
const LazyComponent = React.lazy(() => import('./CodeBlock')); const LazyComponent = React.lazy(() => import('./CodeBlock'));
const GoToDashboardLink = ({ url }: GoToDashboardLinkProps) => { const GoToDashboardLink = ({ product, url }: GoToDashboardLinkProps) => {
const productName = getSourceDisplayName(product, ResourceType.dashboard);
const popoverHoverFocus = ( const popoverHoverFocus = (
<Popover id="popover-trigger-hover-focus">{MODE_LINK_TOOLTIP_TEXT}</Popover> <Popover id="popover-trigger-hover-focus">{`${LINK_TOOLTIP_TEXT} ${productName}`}</Popover>
); );
return ( return (
...@@ -61,7 +68,7 @@ const QueryBlockShimmer = () => { ...@@ -61,7 +68,7 @@ const QueryBlockShimmer = () => {
); );
}; };
const QueryListItem = ({ name, text, url }: QueryListItemProps) => { const QueryListItem = ({ product, name, text, url }: QueryListItemProps) => {
const [isExpanded, setExpanded] = React.useState(false); const [isExpanded, setExpanded] = React.useState(false);
const toggleExpand = () => { const toggleExpand = () => {
setExpanded(!isExpanded); setExpanded(!isExpanded);
...@@ -84,7 +91,7 @@ const QueryListItem = ({ name, text, url }: QueryListItemProps) => { ...@@ -84,7 +91,7 @@ const QueryListItem = ({ name, text, url }: QueryListItemProps) => {
<label className="query-list-query-label section-title"> <label className="query-list-query-label section-title">
{QUERY_LABEL}: {QUERY_LABEL}:
<div className="query-list-query-content"> <div className="query-list-query-content">
<GoToDashboardLink url={url} /> <GoToDashboardLink product={product} url={url} />
<React.Suspense fallback={<QueryBlockShimmer />}> <React.Suspense fallback={<QueryBlockShimmer />}>
<LazyComponent text={text} /> <LazyComponent text={text} />
</React.Suspense> </React.Suspense>
......
...@@ -132,7 +132,12 @@ export class DashboardPage extends React.Component< ...@@ -132,7 +132,12 @@ export class DashboardPage extends React.Component<
} }
tabInfo.push({ tabInfo.push({
content: <QueryList queries={this.props.dashboard.queries} />, content: (
<QueryList
product={this.props.dashboard.product}
queries={this.props.dashboard.queries}
/>
),
key: 'queries', key: 'queries',
title: `Queries (${this.props.dashboard.queries.length})`, title: `Queries (${this.props.dashboard.queries.length})`,
}); });
......
...@@ -86,8 +86,6 @@ $avatar-container-size: 40px; ...@@ -86,8 +86,6 @@ $avatar-container-size: 40px;
} }
} }
.logo-icon { .logo-icon {
margin-right: $spacer-2; margin-right: $spacer-2;
max-height: 32px; max-height: 32px;
......
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