mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
updates file names and adds breadcrumb
This commit is contained in:
parent
b933155f07
commit
90081e4e6e
@ -20,7 +20,7 @@ import Login from './screens/Login';
|
||||
import { isAuthenticated } from './util/auth';
|
||||
import { getLanguageWithoutRegionCode } from './util/language';
|
||||
import { dynamicActivate, locales } from './i18nLoader';
|
||||
import ObservabilityMetrics from './screens/ObservabilityMetrics';
|
||||
import Metrics from './screens/Metrics';
|
||||
|
||||
import getRouteConfig from './routeConfig';
|
||||
import SubscriptionEdit from './screens/Setting/Subscription/SubscriptionEdit';
|
||||
@ -59,6 +59,9 @@ const AuthorizedRoutes = ({ routeConfig }) => {
|
||||
</ProtectedRoute>
|
||||
))
|
||||
.concat(
|
||||
<ProtectedRoute key="metrics" path="/metrics">
|
||||
<Metrics />
|
||||
</ProtectedRoute>,
|
||||
<ProtectedRoute key="not-found" path="*">
|
||||
<NotFound />
|
||||
</ProtectedRoute>
|
||||
@ -88,7 +91,6 @@ function App() {
|
||||
const { hash, search, pathname } = useLocation();
|
||||
|
||||
return (
|
||||
<<<<<<< HEAD
|
||||
<I18nProvider i18n={i18n}>
|
||||
<Background>
|
||||
<Switch>
|
||||
@ -110,47 +112,6 @@ function App() {
|
||||
</ProtectedRoute>
|
||||
</Switch>
|
||||
</Background>
|
||||
=======
|
||||
<I18nProvider language={language} catalogs={catalogs}>
|
||||
<I18n>
|
||||
{({ i18n }) => (
|
||||
<Background>
|
||||
<Switch>
|
||||
<Route exact strict path="/*/">
|
||||
<Redirect to={`${pathname.slice(0, -1)}${search}${hash}`} />
|
||||
</Route>
|
||||
<Route path="/login">
|
||||
<Login isAuthenticated={isAuthenticated} />
|
||||
</Route>
|
||||
<Route exact path="/">
|
||||
<Redirect to="/home" />
|
||||
</Route>
|
||||
<ProtectedRoute>
|
||||
<AppContainer navRouteConfig={getRouteConfig(i18n)}>
|
||||
<Switch>
|
||||
{getRouteConfig(i18n)
|
||||
.flatMap(({ routes }) => routes)
|
||||
.map(({ path, screen: Screen }) => (
|
||||
<ProtectedRoute key={path} path={path}>
|
||||
<Screen match={match} />
|
||||
</ProtectedRoute>
|
||||
))
|
||||
.concat(
|
||||
<Route exact path="/metrics">
|
||||
<ObservabilityMetrics />
|
||||
</Route>,
|
||||
<ProtectedRoute key="not-found" path="*">
|
||||
<NotFound />
|
||||
</ProtectedRoute>
|
||||
)}
|
||||
</Switch>
|
||||
</AppContainer>
|
||||
</ProtectedRoute>
|
||||
</Switch>
|
||||
</Background>
|
||||
)}
|
||||
</I18n>
|
||||
>>>>>>> Adds observability metrics chart
|
||||
</I18nProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -164,6 +164,7 @@ describe('<InstanceGroupList />', () => {
|
||||
});
|
||||
|
||||
test('should render deletion error modal', async () => {
|
||||
jest.setTimeout(5000 * 4);
|
||||
InstanceGroupsAPI.destroy.mockRejectedValue(
|
||||
new Error({
|
||||
response: {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import React, { useEffect, useCallback } from 'react';
|
||||
import * as d3 from 'd3';
|
||||
import { PageContextConsumer } from '@patternfly/react-core';
|
||||
|
||||
function LineChart({ data, helpText }) {
|
||||
const count = data[0]?.values.length;
|
||||
@ -256,14 +255,4 @@ function LineChart({ data, helpText }) {
|
||||
return <div id="chart" />;
|
||||
}
|
||||
|
||||
const withPageContext = Component => {
|
||||
return function contextComponent(props) {
|
||||
return (
|
||||
<PageContextConsumer>
|
||||
{pageContext => <Component {...props} pageContext={pageContext} />}
|
||||
</PageContextConsumer>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export default withPageContext(LineChart);
|
||||
export default LineChart;
|
||||
@ -18,6 +18,7 @@ import LineChart from './LineChart';
|
||||
import { MetricsAPI, InstancesAPI } from '../../api';
|
||||
import useRequest from '../../util/useRequest';
|
||||
import ContentEmpty from '../../components/ContentEmpty';
|
||||
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||
import ContentError from '../../components/ContentError';
|
||||
|
||||
let count = [0];
|
||||
@ -43,7 +44,7 @@ function useInterval(callback, delay, instance, metric) {
|
||||
}, [callback, delay, instance, metric]);
|
||||
return { count };
|
||||
}
|
||||
function ObservabilityMetrics({ i18n }) {
|
||||
function Metrics({ i18n }) {
|
||||
const [instanceIsOpen, setInstanceIsOpen] = useState(false);
|
||||
const [instance, setInstance] = useState(null);
|
||||
const [metric, setMetric] = useState(null);
|
||||
@ -154,7 +155,6 @@ function ObservabilityMetrics({ i18n }) {
|
||||
fetchInstances();
|
||||
}, [fetchInstances]);
|
||||
if (fetchInitialError || updateError) {
|
||||
console.log('here');
|
||||
return (
|
||||
<PageSection>
|
||||
<Card>
|
||||
@ -166,74 +166,78 @@ function ObservabilityMetrics({ i18n }) {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<PageSection>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Toolbar>
|
||||
<ToolbarContent>
|
||||
<ToolbarGroup>
|
||||
<ToolbarItem>{i18n._(t`Instance`)}</ToolbarItem>
|
||||
<ToolbarItem>
|
||||
<Select
|
||||
ouiaId="Instance-select"
|
||||
onToggle={setInstanceIsOpen}
|
||||
isOpen={instanceIsOpen}
|
||||
onSelect={(e, value) => {
|
||||
count = [0];
|
||||
setInstance(value);
|
||||
setInstanceIsOpen(false);
|
||||
setRenderedData([]);
|
||||
}}
|
||||
selections={instance}
|
||||
placeholderText={i18n._(t`Select a instance`)}
|
||||
>
|
||||
{instances.map(inst => (
|
||||
<SelectOption value={inst} key={inst} />
|
||||
))}
|
||||
</Select>
|
||||
</ToolbarItem>
|
||||
<ToolbarItem>{i18n._(t`Metric`)}</ToolbarItem>
|
||||
<ToolbarItem>
|
||||
<Select
|
||||
ouiaId="Metric-select"
|
||||
placeholderText={i18n._(t`Select a metric`)}
|
||||
isOpen={metricIsOpen}
|
||||
onSelect={(e, value) => {
|
||||
count = [0];
|
||||
setMetric(value);
|
||||
setRenderedData([]);
|
||||
setMetricIsOpen(false);
|
||||
}}
|
||||
onToggle={setMetricIsOpen}
|
||||
selections={metric}
|
||||
>
|
||||
{metrics.map(met => (
|
||||
<SelectOption value={met} key={met} />
|
||||
))}
|
||||
</Select>
|
||||
</ToolbarItem>
|
||||
</ToolbarGroup>
|
||||
</ToolbarContent>
|
||||
</Toolbar>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
{instance && metric ? (
|
||||
Object.keys(renderedData).length > 0 && (
|
||||
<LineChart
|
||||
data={renderedData}
|
||||
count={count}
|
||||
helpText={helpText}
|
||||
<>
|
||||
<ScreenHeader breadcrumbConfig={{ '/metrics': i18n._(t`Metrics`) }} />
|
||||
|
||||
<PageSection>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Toolbar>
|
||||
<ToolbarContent>
|
||||
<ToolbarGroup>
|
||||
<ToolbarItem>{i18n._(t`Instance`)}</ToolbarItem>
|
||||
<ToolbarItem>
|
||||
<Select
|
||||
ouiaId="Instance-select"
|
||||
onToggle={setInstanceIsOpen}
|
||||
isOpen={instanceIsOpen}
|
||||
onSelect={(e, value) => {
|
||||
count = [0];
|
||||
setInstance(value);
|
||||
setInstanceIsOpen(false);
|
||||
setRenderedData([]);
|
||||
}}
|
||||
selections={instance}
|
||||
placeholderText={i18n._(t`Select a instance`)}
|
||||
>
|
||||
{instances.map(inst => (
|
||||
<SelectOption value={inst} key={inst} />
|
||||
))}
|
||||
</Select>
|
||||
</ToolbarItem>
|
||||
<ToolbarItem>{i18n._(t`Metric`)}</ToolbarItem>
|
||||
<ToolbarItem>
|
||||
<Select
|
||||
ouiaId="Metric-select"
|
||||
placeholderText={i18n._(t`Select a metric`)}
|
||||
isOpen={metricIsOpen}
|
||||
onSelect={(e, value) => {
|
||||
count = [0];
|
||||
setMetric(value);
|
||||
setRenderedData([]);
|
||||
setMetricIsOpen(false);
|
||||
}}
|
||||
onToggle={setMetricIsOpen}
|
||||
selections={metric}
|
||||
>
|
||||
{metrics.map(met => (
|
||||
<SelectOption value={met} key={met} />
|
||||
))}
|
||||
</Select>
|
||||
</ToolbarItem>
|
||||
</ToolbarGroup>
|
||||
</ToolbarContent>
|
||||
</Toolbar>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
{instance && metric ? (
|
||||
Object.keys(renderedData).length > 0 && (
|
||||
<LineChart
|
||||
data={renderedData}
|
||||
count={count}
|
||||
helpText={helpText}
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<ContentEmpty
|
||||
title={i18n._(t`Select an instance and a metric to show chart`)}
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<ContentEmpty
|
||||
title={i18n._(t`Select an instance and a metric to show chart`)}
|
||||
/>
|
||||
)}
|
||||
</CardBody>
|
||||
</Card>
|
||||
</PageSection>
|
||||
)}
|
||||
</CardBody>
|
||||
</Card>
|
||||
</PageSection>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default withI18n()(ObservabilityMetrics);
|
||||
export default withI18n()(Metrics);
|
||||
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
|
||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||
import ObservabilityMetrics from './ObservabilityMetrics';
|
||||
import Metrics from './Metrics';
|
||||
import { MetricsAPI, InstancesAPI } from '../../api';
|
||||
|
||||
jest.mock('../../api/models/Instances');
|
||||
@ -23,11 +23,11 @@ MetricsAPI.read.mockResolvedValue({
|
||||
},
|
||||
});
|
||||
|
||||
describe('<ObservabilityMetrics/>', () => {
|
||||
describe('<Metrics/>', () => {
|
||||
let wrapper;
|
||||
beforeEach(async () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(<ObservabilityMetrics />);
|
||||
wrapper = mountWithContexts(<Metrics />);
|
||||
});
|
||||
});
|
||||
afterEach(() => {
|
||||
@ -35,7 +35,7 @@ describe('<ObservabilityMetrics/>', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
test('should mound properly', () => {
|
||||
expect(wrapper.find('ObservabilityMetrics').length).toBe(1);
|
||||
expect(wrapper.find('Metrics').length).toBe(1);
|
||||
expect(wrapper.find('EmptyStateBody').length).toBe(1);
|
||||
expect(wrapper.find('ChartLine').length).toBe(0);
|
||||
});
|
||||
1
awx/ui_next/src/screens/Metrics/index.js
Normal file
1
awx/ui_next/src/screens/Metrics/index.js
Normal file
@ -0,0 +1 @@
|
||||
export { default } from './Metrics';
|
||||
@ -1 +0,0 @@
|
||||
export { default } from './ObservabilityMetrics';
|
||||
Loading…
x
Reference in New Issue
Block a user