Skip to content

Commit

Permalink
split dropdowns / panels when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Jun 17, 2024
1 parent 58868cc commit c320bcf
Show file tree
Hide file tree
Showing 29 changed files with 1,796 additions and 1,704 deletions.
6 changes: 3 additions & 3 deletions web/locales/en/plugin__netobserv-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@
"Dropped packets": "Dropped packets",
"DNS latencies": "DNS latencies",
"RTT": "RTT",
"Display options": "Display options",
"The level of details represented.": "The level of details represented.",
"Scope": "Scope",
"Long labels can reduce visibility.": "Long labels can reduce visibility.",
"Truncate labels": "Truncate labels",
"Single graph focus": "Single graph focus",
"Display options": "Display options",
"Query options": "Query options",
"Conversation": "Conversation",
"Flow": "Flow",
"Loki": "Loki",
Expand Down Expand Up @@ -87,7 +88,6 @@
"Depending on the matching and filter settings, several queries can be performed under the cover, each with this parameter set, resulting in more results after aggregation.": "Depending on the matching and filter settings, several queries can be performed under the cover, each with this parameter set, resulting in more results after aggregation.",
"Top / Bottom": "Top / Bottom",
"Limit": "Limit",
"Query options": "Query options",
"Refresh off": "Refresh off",
"15 seconds": "15 seconds",
"30 seconds": "30 seconds",
Expand Down Expand Up @@ -298,6 +298,7 @@
"Name": "Name",
"IP": "IP",
"No information available for this content. Change scope to get more details.": "No information available for this content. Change scope to get more details.",
"Cluster name": "Cluster name",
"Stats": "Stats",
"Top 5 DNS latency": "Top 5 DNS latency",
"Top 5 flow RTT": "Top 5 flow RTT",
Expand All @@ -311,7 +312,6 @@
"Average rate": "Average rate",
"Latest time": "Latest time",
"Latest rate": "Latest rate",
"Cluster name": "Cluster name",
"Edge": "Edge",
"Drops": "Drops",
"Query is slow": "Query is slow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from 'react';
import { FlowScope } from '../../../model/flow-query';
import { MetricScopeOptions } from '../../../model/metrics';
import { TopologyGroupTypes } from '../../../model/topology';
import GroupDropdown from '../group-dropdown';
import { GroupDropdown } from '../group-dropdown';

describe('<GroupDropdown />', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mount, shallow } from 'enzyme';
import * as React from 'react';

import { LayoutName } from '../../../model/topology';
import LayoutDropdown from '../layout-dropdown';
import { LayoutDropdown } from '../layout-dropdown';

describe('<LayoutDropdown />', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount, shallow } from 'enzyme';
import * as React from 'react';

import MetricFunctionDropdown from '../metric-function-dropdown';
import { MetricFunctionDropdown } from '../metric-function-dropdown';

describe('<MetricDropdown />', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount, shallow } from 'enzyme';
import * as React from 'react';

import MetricTypeDropdown from '../metric-type-dropdown';
import { MetricTypeDropdown } from '../metric-type-dropdown';

describe('<MetricDropdown />', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { Checkbox, Radio, Select } from '@patternfly/react-core';
import { shallow } from 'enzyme';
import * as React from 'react';
import { act } from 'react-dom/test-utils';
import QueryOptionsDropdown, { QueryOptionsDropdownProps, QueryOptionsPanel } from '../query-options-dropdown';
import { QueryOptionsDropdown, QueryOptionsProps } from '../query-options-dropdown';
import { QueryOptionsPanel } from '../query-options-panel';

describe('<QueryOptionsDropdown />', () => {
const props: QueryOptionsDropdownProps = {
const props: QueryOptionsProps = {
recordType: 'allConnections',
dataSource: 'auto',
showDuplicates: true,
Expand Down Expand Up @@ -35,7 +36,7 @@ describe('<QueryOptionsDropdown />', () => {
});

describe('<QueryOptionsPanel />', () => {
const props: QueryOptionsDropdownProps = {
const props: QueryOptionsProps = {
recordType: 'allConnections',
dataSource: 'auto',
showDuplicates: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount, shallow } from 'enzyme';
import * as React from 'react';

import RefreshDropdown, { RefreshDropdownProps } from '../refresh-dropdown';
import { RefreshDropdown, RefreshDropdownProps } from '../refresh-dropdown';

describe('<RefreshDropdown />', () => {
const props: RefreshDropdownProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { mount, shallow } from 'enzyme';
import * as React from 'react';

import { act } from 'react-dom/test-utils';
import { Size, TableDisplayDropdown, TableDisplayOptions } from '../table-display-dropdown';
import { Size, TableDisplayDropdown } from '../table-display-dropdown';
import { TableDisplayOptions } from '../table-display-options';

describe('<DisplayDropdown />', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount, shallow } from 'enzyme';
import * as React from 'react';

import TimeRangeDropdown, { TimeRangeDropdownProps } from '../time-range-dropdown';
import { TimeRangeDropdown, TimeRangeDropdownProps } from '../time-range-dropdown';

describe('<TimeRangeDropdown />', () => {
const props: TimeRangeDropdownProps = {
Expand Down
68 changes: 5 additions & 63 deletions web/src/components/dropdowns/overview-display-dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Select, Switch, Text, TextVariants, Tooltip } from '@patternfly/react-core';
import { InfoAltIcon } from '@patternfly/react-icons';
import { Select, Text, TextVariants } from '@patternfly/react-core';
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { FlowScope } from '../../model/flow-query';

import './overview-display-dropdown.css';
import ScopeDropdown from './scope-dropdown';
import TruncateDropdown, { TruncateLength } from './truncate-dropdown';
import { OverviewDisplayOptions } from './overview-display-options';
import { TruncateLength } from './truncate-dropdown';

export type Size = 's' | 'm' | 'l';

export interface OverviewDisplayOptionsProps {
export interface OverviewDisplayDropdownProps {
metricScope: FlowScope;
setMetricScope: (s: FlowScope) => void;
truncateLength: TruncateLength;
Expand All @@ -20,7 +18,7 @@ export interface OverviewDisplayOptionsProps {
allowedScopes: FlowScope[];
}

export const OverviewDisplayOptions: React.FC<OverviewDisplayOptionsProps> = ({
export const OverviewDisplayDropdown: React.FC<OverviewDisplayDropdownProps> = ({
metricScope,
setMetricScope,
truncateLength,
Expand All @@ -30,62 +28,6 @@ export const OverviewDisplayOptions: React.FC<OverviewDisplayOptionsProps> = ({
allowedScopes
}) => {
const { t } = useTranslation('plugin__netobserv-plugin');

return (
<>
<div className="pf-c-select__menu-group">
<Tooltip content={t('The level of details represented.')}>
<div className="pf-c-select__menu-group-title">
<Text component={TextVariants.p}>
{t('Scope')} <InfoAltIcon />
</Text>
</div>
</Tooltip>
<div className="display-dropdown-padding">
<ScopeDropdown
data-test="scope"
id="scope"
selected={metricScope}
setScopeType={setMetricScope}
allowedScopes={allowedScopes}
/>
</div>
</div>
<div className="pf-c-select__menu-group">
<Tooltip content={t('Long labels can reduce visibility.')}>
<div className="pf-c-select__menu-group-title">
<Text component={TextVariants.p}>
{t('Truncate labels')} <InfoAltIcon />
</Text>
</div>
</Tooltip>
<div className="display-dropdown-padding">
<TruncateDropdown id="truncate" selected={truncateLength} setTruncateLength={setTruncateLength} />
</div>
</div>
<div className="pf-c-select__menu-group">
<Switch
id="focus-switch"
className="display-dropdown-padding"
label={t('Single graph focus')}
isChecked={focus}
onChange={setFocus}
/>
</div>
</>
);
};

export const OverviewDisplayDropdown: React.FC<{
metricScope: FlowScope;
setMetricScope: (s: FlowScope) => void;
truncateLength: TruncateLength;
setTruncateLength: (v: TruncateLength) => void;
focus: boolean;
setFocus: (v: boolean) => void;
allowedScopes: FlowScope[];
}> = ({ metricScope, setMetricScope, truncateLength, setTruncateLength, focus, setFocus, allowedScopes }) => {
const { t } = useTranslation('plugin__netobserv-plugin');
const [isOpen, setOpen] = React.useState<boolean>(false);

return (
Expand Down
78 changes: 78 additions & 0 deletions web/src/components/dropdowns/overview-display-options.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { Switch, Text, TextVariants, Tooltip } from '@patternfly/react-core';
import { InfoAltIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { FlowScope } from '../../model/flow-query';

import ScopeDropdown from './scope-dropdown';
import TruncateDropdown, { TruncateLength } from './truncate-dropdown';

export type Size = 's' | 'm' | 'l';

export interface OverviewDisplayOptionsProps {
metricScope: FlowScope;
setMetricScope: (s: FlowScope) => void;
truncateLength: TruncateLength;
setTruncateLength: (v: TruncateLength) => void;
focus: boolean;
setFocus: (v: boolean) => void;
allowedScopes: FlowScope[];
}

export const OverviewDisplayOptions: React.FC<OverviewDisplayOptionsProps> = ({
metricScope,
setMetricScope,
truncateLength,
setTruncateLength,
focus,
setFocus,
allowedScopes
}) => {
const { t } = useTranslation('plugin__netobserv-plugin');

return (
<>
<div className="pf-c-select__menu-group">
<Tooltip content={t('The level of details represented.')}>
<div className="pf-c-select__menu-group-title">
<Text component={TextVariants.p}>
{t('Scope')} <InfoAltIcon />
</Text>
</div>
</Tooltip>
<div className="display-dropdown-padding">
<ScopeDropdown
data-test="scope"
id="scope"
selected={metricScope}
setScopeType={setMetricScope}
allowedScopes={allowedScopes}
/>
</div>
</div>
<div className="pf-c-select__menu-group">
<Tooltip content={t('Long labels can reduce visibility.')}>
<div className="pf-c-select__menu-group-title">
<Text component={TextVariants.p}>
{t('Truncate labels')} <InfoAltIcon />
</Text>
</div>
</Tooltip>
<div className="display-dropdown-padding">
<TruncateDropdown id="truncate" selected={truncateLength} setTruncateLength={setTruncateLength} />
</div>
</div>
<div className="pf-c-select__menu-group">
<Switch
id="focus-switch"
className="display-dropdown-padding"
label={t('Single graph focus')}
isChecked={focus}
onChange={setFocus}
/>
</div>
</>
);
};

export default OverviewDisplayOptions;
Loading

0 comments on commit c320bcf

Please sign in to comment.