mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 11:55:04 -02:30
Add legend toggle to header.
This commit is contained in:
53
awx/ui/src/screens/TopologyView/Header.js
Normal file
53
awx/ui/src/screens/TopologyView/Header.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
|
import {
|
||||||
|
PageSection,
|
||||||
|
PageSectionVariants,
|
||||||
|
Switch,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
} from '@patternfly/react-core';
|
||||||
|
|
||||||
|
const Header = ({ title, handleSwitchToggle, toggleState }) => {
|
||||||
|
const { light } = PageSectionVariants;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageSection variant={light}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
minHeight: '31px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Title size="2xl" headingLevel="h2" data-cy="screen-title">
|
||||||
|
{title}
|
||||||
|
</Title>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Tooltip content={t`Toggle legend`} position="top">
|
||||||
|
<Switch
|
||||||
|
id="legend-toggle-switch"
|
||||||
|
label={t`Legend`}
|
||||||
|
isChecked={toggleState}
|
||||||
|
onChange={() => handleSwitchToggle(!toggleState)}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PageSection>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Header.propTypes = {
|
||||||
|
title: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Header;
|
||||||
@@ -8,7 +8,7 @@ import Legend from './Legend';
|
|||||||
import Tooltip from './Tooltip';
|
import Tooltip from './Tooltip';
|
||||||
|
|
||||||
// function MeshGraph({ data }) {
|
// function MeshGraph({ data }) {
|
||||||
function MeshGraph() {
|
function MeshGraph({ showLegend }) {
|
||||||
const [isNodeSelected, setIsNodeSelected] = useState(false);
|
const [isNodeSelected, setIsNodeSelected] = useState(false);
|
||||||
const [selectedNode, setSelectedNode] = useState(null);
|
const [selectedNode, setSelectedNode] = useState(null);
|
||||||
const [nodeDetail, setNodeDetail] = useState(null);
|
const [nodeDetail, setNodeDetail] = useState(null);
|
||||||
@@ -517,7 +517,7 @@ function MeshGraph() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="chart" style={{ position: 'relative' }}>
|
<div id="chart" style={{ position: 'relative' }}>
|
||||||
<Legend />
|
{showLegend && <Legend />}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
isNodeSelected={isNodeSelected}
|
isNodeSelected={isNodeSelected}
|
||||||
renderNodeIcon={renderNodeIcon}
|
renderNodeIcon={renderNodeIcon}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import React, { useEffect, useCallback } from 'react';
|
import React, { useEffect, useCallback, useState } from 'react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import ScreenHeader from 'components/ScreenHeader/ScreenHeader';
|
|
||||||
import { PageSection, Card, CardBody } from '@patternfly/react-core';
|
import { PageSection, Card, CardBody } from '@patternfly/react-core';
|
||||||
import useRequest from 'hooks/useRequest';
|
import useRequest from 'hooks/useRequest';
|
||||||
import { MeshAPI } from 'api';
|
import { MeshAPI } from 'api';
|
||||||
|
import Header from './Header';
|
||||||
import MeshGraph from './MeshGraph';
|
import MeshGraph from './MeshGraph';
|
||||||
|
|
||||||
function TopologyView() {
|
function TopologyView() {
|
||||||
|
const [showLegend, setShowLegend] = useState(true);
|
||||||
const {
|
const {
|
||||||
isLoading,
|
isLoading,
|
||||||
result: { meshData },
|
result: { meshData },
|
||||||
@@ -26,11 +27,18 @@ function TopologyView() {
|
|||||||
}, [fetchMeshVisualizer]);
|
}, [fetchMeshVisualizer]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ScreenHeader breadcrumbConfig={{ '/topology_view': t`Topology View` }} />
|
<Header
|
||||||
|
title={t`Topology View`}
|
||||||
|
handleSwitchToggle={setShowLegend}
|
||||||
|
toggleState={showLegend}
|
||||||
|
/>
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card>
|
||||||
<CardBody>{!isLoading && <MeshGraph data={meshData} />}</CardBody>
|
<CardBody>
|
||||||
|
{!isLoading && (
|
||||||
|
<MeshGraph data={meshData} showLegend={showLegend} />
|
||||||
|
)}
|
||||||
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
</PageSection>
|
</PageSection>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user