mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 05:47:38 -02:30
update Breadcrumb component to ScreenHeader:
- show last breadcrum item as Title on new line - add activity stream type (to display activity stream icon link in header)
This commit is contained in:
@@ -1,73 +0,0 @@
|
|||||||
import React, { Fragment } from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import {
|
|
||||||
PageSection as PFPageSection,
|
|
||||||
PageSectionVariants,
|
|
||||||
Breadcrumb,
|
|
||||||
BreadcrumbItem,
|
|
||||||
BreadcrumbHeading,
|
|
||||||
} from '@patternfly/react-core';
|
|
||||||
import { Link, Route, useRouteMatch } from 'react-router-dom';
|
|
||||||
|
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
const PageSection = styled(PFPageSection)`
|
|
||||||
padding-top: 10px;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Breadcrumbs = ({ breadcrumbConfig }) => {
|
|
||||||
const { light } = PageSectionVariants;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageSection variant={light}>
|
|
||||||
<Breadcrumb>
|
|
||||||
<Route path="/:path">
|
|
||||||
<Crumb breadcrumbConfig={breadcrumbConfig} />
|
|
||||||
</Route>
|
|
||||||
</Breadcrumb>
|
|
||||||
</PageSection>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Crumb = ({ breadcrumbConfig, showDivider }) => {
|
|
||||||
const match = useRouteMatch();
|
|
||||||
const crumb = breadcrumbConfig[match.url];
|
|
||||||
|
|
||||||
let crumbElement = (
|
|
||||||
<BreadcrumbItem key={match.url} showDivider={showDivider}>
|
|
||||||
<Link to={match.url}>{crumb}</Link>
|
|
||||||
</BreadcrumbItem>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (match.isExact) {
|
|
||||||
crumbElement = (
|
|
||||||
<BreadcrumbHeading key="breadcrumb-heading" showDivider={showDivider}>
|
|
||||||
{crumb}
|
|
||||||
</BreadcrumbHeading>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!crumb) {
|
|
||||||
crumbElement = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
{crumbElement}
|
|
||||||
<Route path={`${match.url}/:path`}>
|
|
||||||
<Crumb breadcrumbConfig={breadcrumbConfig} showDivider />
|
|
||||||
</Route>
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
Breadcrumbs.propTypes = {
|
|
||||||
breadcrumbConfig: PropTypes.objectOf(PropTypes.string).isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
Crumb.propTypes = {
|
|
||||||
breadcrumbConfig: PropTypes.objectOf(PropTypes.string).isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Breadcrumbs;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './Breadcrumbs';
|
|
||||||
129
awx/ui_next/src/components/ScreenHeader/ScreenHeader.jsx
Normal file
129
awx/ui_next/src/components/ScreenHeader/ScreenHeader.jsx
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
import React, { Fragment } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { withI18n } from '@lingui/react';
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
PageSection,
|
||||||
|
PageSectionVariants,
|
||||||
|
Breadcrumb,
|
||||||
|
BreadcrumbItem,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
} from '@patternfly/react-core';
|
||||||
|
import { HistoryIcon } from '@patternfly/react-icons';
|
||||||
|
import { Link, Route, useRouteMatch } from 'react-router-dom';
|
||||||
|
|
||||||
|
const ScreenHeader = ({ breadcrumbConfig, i18n, streamType }) => {
|
||||||
|
const { light } = PageSectionVariants;
|
||||||
|
const oneCrumbMatch = useRouteMatch({
|
||||||
|
path: Object.keys(breadcrumbConfig)[0],
|
||||||
|
strict: true,
|
||||||
|
});
|
||||||
|
const isOnlyOneCrumb = oneCrumbMatch && oneCrumbMatch.isExact;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageSection variant={light}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
{!isOnlyOneCrumb && (
|
||||||
|
<Breadcrumb>
|
||||||
|
<Route path="/:path">
|
||||||
|
<Crumb breadcrumbConfig={breadcrumbConfig} />
|
||||||
|
</Route>
|
||||||
|
</Breadcrumb>
|
||||||
|
)}
|
||||||
|
<Route path="/:path">
|
||||||
|
<ActualTitle breadcrumbConfig={breadcrumbConfig} />
|
||||||
|
</Route>
|
||||||
|
</div>
|
||||||
|
{streamType !== 'none' && (
|
||||||
|
<div>
|
||||||
|
<Tooltip content={i18n._(t`View activity stream`)} position="top">
|
||||||
|
<Button
|
||||||
|
aria-label={i18n._(t`View activity stream`)}
|
||||||
|
variant="plain"
|
||||||
|
component={Link}
|
||||||
|
to={`/activity_stream${
|
||||||
|
streamType ? `?type=${streamType}` : ''
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<HistoryIcon />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</PageSection>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ActualTitle = ({ breadcrumbConfig }) => {
|
||||||
|
const match = useRouteMatch();
|
||||||
|
const title = breadcrumbConfig[match.url];
|
||||||
|
let titleElement;
|
||||||
|
|
||||||
|
if (match.isExact) {
|
||||||
|
titleElement = (
|
||||||
|
<Title size="2xl" headingLevel="h2">
|
||||||
|
{title}
|
||||||
|
</Title>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!title) {
|
||||||
|
titleElement = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
{titleElement}
|
||||||
|
<Route path={`${match.url}/:path`}>
|
||||||
|
<ActualTitle breadcrumbConfig={breadcrumbConfig} />
|
||||||
|
</Route>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Crumb = ({ breadcrumbConfig, showDivider }) => {
|
||||||
|
const match = useRouteMatch();
|
||||||
|
const crumb = breadcrumbConfig[match.url];
|
||||||
|
|
||||||
|
let crumbElement = (
|
||||||
|
<BreadcrumbItem key={match.url} showDivider={showDivider}>
|
||||||
|
<Link to={match.url}>{crumb}</Link>
|
||||||
|
</BreadcrumbItem>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (match.isExact) {
|
||||||
|
crumbElement = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!crumb) {
|
||||||
|
crumbElement = null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
{crumbElement}
|
||||||
|
<Route path={`${match.url}/:path`}>
|
||||||
|
<Crumb breadcrumbConfig={breadcrumbConfig} showDivider />
|
||||||
|
</Route>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ScreenHeader.propTypes = {
|
||||||
|
breadcrumbConfig: PropTypes.objectOf(PropTypes.string).isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
Crumb.propTypes = {
|
||||||
|
breadcrumbConfig: PropTypes.objectOf(PropTypes.string).isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withI18n()(ScreenHeader);
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import Breadcrumbs from './Breadcrumbs';
|
|
||||||
|
|
||||||
describe('<Breadcrumb />', () => {
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
|
|
||||||
|
import ScreenHeader from './ScreenHeader';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('<ScreenHeader />', () => {
|
||||||
let breadcrumbWrapper;
|
let breadcrumbWrapper;
|
||||||
let breadcrumb;
|
let breadcrumb;
|
||||||
let breadcrumbItem;
|
let breadcrumbItem;
|
||||||
@@ -17,15 +23,15 @@ describe('<Breadcrumb />', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const findChildren = () => {
|
const findChildren = () => {
|
||||||
breadcrumb = breadcrumbWrapper.find('Breadcrumb');
|
breadcrumb = breadcrumbWrapper.find('ScreenHeader');
|
||||||
breadcrumbItem = breadcrumbWrapper.find('BreadcrumbItem');
|
breadcrumbItem = breadcrumbWrapper.find('BreadcrumbItem');
|
||||||
breadcrumbHeading = breadcrumbWrapper.find('BreadcrumbHeading');
|
breadcrumbHeading = breadcrumbWrapper.find('Title');
|
||||||
};
|
};
|
||||||
|
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
breadcrumbWrapper = mount(
|
breadcrumbWrapper = mountWithContexts(
|
||||||
<MemoryRouter initialEntries={['/foo/1/bar']} initialIndex={0}>
|
<MemoryRouter initialEntries={['/foo/1/bar']} initialIndex={0}>
|
||||||
<Breadcrumbs breadcrumbConfig={config} />
|
<ScreenHeader streamType="all_activity" breadcrumbConfig={config} />
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -51,9 +57,9 @@ describe('<Breadcrumb />', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
routes.forEach(([location, crumbLength]) => {
|
routes.forEach(([location, crumbLength]) => {
|
||||||
breadcrumbWrapper = mount(
|
breadcrumbWrapper = mountWithContexts(
|
||||||
<MemoryRouter initialEntries={[location]}>
|
<MemoryRouter initialEntries={[location]}>
|
||||||
<Breadcrumbs breadcrumbConfig={config} />
|
<ScreenHeader streamType="all_activity" breadcrumbConfig={config} />
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
|
|
||||||
1
awx/ui_next/src/components/ScreenHeader/index.js
Normal file
1
awx/ui_next/src/components/ScreenHeader/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './ScreenHeader';
|
||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
import ApplicationsList from './ApplicationsList';
|
import ApplicationsList from './ApplicationsList';
|
||||||
import ApplicationAdd from './ApplicationAdd';
|
import ApplicationAdd from './ApplicationAdd';
|
||||||
import Application from './Application';
|
import Application from './Application';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
import { Detail, DetailList } from '../../components/DetailList';
|
import { Detail, DetailList } from '../../components/DetailList';
|
||||||
|
|
||||||
const ApplicationAlert = styled(Alert)`
|
const ApplicationAlert = styled(Alert)`
|
||||||
@@ -45,7 +45,10 @@ function Applications({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="o_auth2_application,o_auth2_access_token"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/applications/add">
|
<Route path="/applications/add">
|
||||||
<ApplicationAdd
|
<ApplicationAdd
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Applications from './Applications';
|
import Applications from './Applications';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Applications />', () => {
|
describe('<Applications />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Route, Switch } from 'react-router-dom';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Config } from '../../contexts/Config';
|
import { Config } from '../../contexts/Config';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
import Credential from './Credential';
|
import Credential from './Credential';
|
||||||
import CredentialAdd from './CredentialAdd';
|
import CredentialAdd from './CredentialAdd';
|
||||||
import { CredentialList } from './CredentialList';
|
import { CredentialList } from './CredentialList';
|
||||||
@@ -34,7 +34,10 @@ function Credentials({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="credential"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/credentials/add">
|
<Route path="/credentials/add">
|
||||||
<Config>{({ me }) => <CredentialAdd me={me || {}} />}</Config>
|
<Config>{({ me }) => <CredentialAdd me={me || {}} />}</Config>
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { createMemoryHistory } from 'history';
|
|||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
import Credentials from './Credentials';
|
import Credentials from './Credentials';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Credentials />', () => {
|
describe('<Credentials />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
@@ -30,8 +34,8 @@ describe('<Credentials />', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.find('Crumb').length).toBe(1);
|
expect(wrapper.find('Crumb').length).toBe(0);
|
||||||
expect(wrapper.find('BreadcrumbHeading').text()).toBe('Credentials');
|
expect(wrapper.find('Title').text()).toBe('Credentials');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should display create new credential breadcrumb heading', () => {
|
test('should display create new credential breadcrumb heading', () => {
|
||||||
@@ -51,8 +55,6 @@ describe('<Credentials />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.find('Crumb').length).toBe(2);
|
expect(wrapper.find('Crumb').length).toBe(2);
|
||||||
expect(wrapper.find('BreadcrumbHeading').text()).toBe(
|
expect(wrapper.find('Title').text()).toBe('Create New Credential');
|
||||||
'Create New Credential'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Route, Switch } from 'react-router-dom';
|
|||||||
import CredentialTypeAdd from './CredentialTypeAdd';
|
import CredentialTypeAdd from './CredentialTypeAdd';
|
||||||
import CredentialTypeList from './CredentialTypeList';
|
import CredentialTypeList from './CredentialTypeList';
|
||||||
import CredentialType from './CredentialType';
|
import CredentialType from './CredentialType';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
|
|
||||||
function CredentialTypes({ i18n }) {
|
function CredentialTypes({ i18n }) {
|
||||||
const [breadcrumbConfig, setBreadcrumbConfig] = useState({
|
const [breadcrumbConfig, setBreadcrumbConfig] = useState({
|
||||||
@@ -33,7 +33,10 @@ function CredentialTypes({ i18n }) {
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="credential_type"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/credential_types/add">
|
<Route path="/credential_types/add">
|
||||||
<CredentialTypeAdd />
|
<CredentialTypeAdd />
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import CredentialTypes from './CredentialTypes';
|
import CredentialTypes from './CredentialTypes';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<CredentialTypes/>', () => {
|
describe('<CredentialTypes/>', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
let pageSections;
|
let pageSections;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
|
|
||||||
import useRequest from '../../util/useRequest';
|
import useRequest from '../../util/useRequest';
|
||||||
import { DashboardAPI } from '../../api';
|
import { DashboardAPI } from '../../api';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
import JobList from '../../components/JobList';
|
import JobList from '../../components/JobList';
|
||||||
import ContentLoading from '../../components/ContentLoading';
|
import ContentLoading from '../../components/ContentLoading';
|
||||||
import LineChart from './shared/LineChart';
|
import LineChart from './shared/LineChart';
|
||||||
@@ -117,7 +117,10 @@ function Dashboard({ i18n }) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Breadcrumbs breadcrumbConfig={{ '/home': i18n._(t`Dashboard`) }} />
|
<ScreenHeader
|
||||||
|
streamType="all"
|
||||||
|
breadcrumbConfig={{ '/home': i18n._(t`Dashboard`) }}
|
||||||
|
/>
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Counts>
|
<Counts>
|
||||||
<Count
|
<Count
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import { DashboardAPI } from '../../api';
|
|||||||
import Dashboard from './Dashboard';
|
import Dashboard from './Dashboard';
|
||||||
|
|
||||||
jest.mock('../../api');
|
jest.mock('../../api');
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Dashboard />', () => {
|
describe('<Dashboard />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { withI18n } from '@lingui/react';
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { Config } from '../../contexts/Config';
|
import { Config } from '../../contexts/Config';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
|
|
||||||
import HostList from './HostList';
|
import HostList from './HostList';
|
||||||
import HostAdd from './HostAdd';
|
import HostAdd from './HostAdd';
|
||||||
@@ -37,7 +37,7 @@ function Hosts({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader streamType="host" breadcrumbConfig={breadcrumbConfig} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/hosts/add">
|
<Route path="/hosts/add">
|
||||||
<HostAdd />
|
<HostAdd />
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Hosts from './Hosts';
|
import Hosts from './Hosts';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Hosts />', () => {
|
describe('<Hosts />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mountWithContexts(<Hosts />);
|
mountWithContexts(<Hosts />);
|
||||||
@@ -27,7 +31,7 @@ describe('<Hosts />', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(wrapper.find('BreadcrumbHeading').length).toBe(1);
|
expect(wrapper.find('Title').length).toBe(1);
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import InstanceGroup from './InstanceGroup';
|
|||||||
|
|
||||||
import ContainerGroupAdd from './ContainerGroupAdd';
|
import ContainerGroupAdd from './ContainerGroupAdd';
|
||||||
import ContainerGroup from './ContainerGroup';
|
import ContainerGroup from './ContainerGroup';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
|
|
||||||
function InstanceGroups({ i18n }) {
|
function InstanceGroups({ i18n }) {
|
||||||
const [breadcrumbConfig, setBreadcrumbConfig] = useState({
|
const [breadcrumbConfig, setBreadcrumbConfig] = useState({
|
||||||
@@ -54,7 +54,10 @@ function InstanceGroups({ i18n }) {
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="instance_group"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/instance_groups/container_group/add">
|
<Route path="/instance_groups/container_group/add">
|
||||||
<ContainerGroupAdd />
|
<ContainerGroupAdd />
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import InstanceGroups from './InstanceGroups';
|
import InstanceGroups from './InstanceGroups';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<InstanceGroups/>', () => {
|
describe('<InstanceGroups/>', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
let pageSections;
|
let pageSections;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { Route, Switch } from 'react-router-dom';
|
import { Route, Switch } from 'react-router-dom';
|
||||||
|
|
||||||
import { Config } from '../../contexts/Config';
|
import { Config } from '../../contexts/Config';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
import { InventoryList } from './InventoryList';
|
import { InventoryList } from './InventoryList';
|
||||||
import Inventory from './Inventory';
|
import Inventory from './Inventory';
|
||||||
import SmartInventory from './SmartInventory';
|
import SmartInventory from './SmartInventory';
|
||||||
@@ -95,7 +95,10 @@ function Inventories({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="inventory"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/inventories/inventory/add">
|
<Route path="/inventories/inventory/add">
|
||||||
<InventoryAdd />
|
<InventoryAdd />
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Inventories from './Inventories';
|
import Inventories from './Inventories';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Inventories />', () => {
|
describe('<Inventories />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Job from './Jobs';
|
import Job from './Jobs';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Job />', () => {
|
describe('<Job />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mountWithContexts(<Job />);
|
mountWithContexts(<Job />);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Route, Switch, useParams, useRouteMatch } from 'react-router-dom';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { PageSection } from '@patternfly/react-core';
|
import { PageSection } from '@patternfly/react-core';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
import Job from './Job';
|
import Job from './Job';
|
||||||
import JobTypeRedirect from './JobTypeRedirect';
|
import JobTypeRedirect from './JobTypeRedirect';
|
||||||
import JobList from '../../components/JobList';
|
import JobList from '../../components/JobList';
|
||||||
@@ -40,7 +40,7 @@ function Jobs({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader streamType="job" breadcrumbConfig={breadcrumbConfig} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path={match.path}>
|
<Route exact path={match.path}>
|
||||||
<PageSection>
|
<PageSection>
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Jobs from './Jobs';
|
import Jobs from './Jobs';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Jobs />', () => {
|
describe('<Jobs />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mountWithContexts(<Jobs />);
|
mountWithContexts(<Jobs />);
|
||||||
@@ -27,7 +31,7 @@ describe('<Jobs />', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(wrapper.find('BreadcrumbHeading').length).toBe(1);
|
expect(wrapper.find('Title').length).toBe(1);
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import React, { Fragment } from 'react';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
|
|
||||||
function ManagementJobs({ i18n }) {
|
function ManagementJobs({ i18n }) {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Breadcrumbs
|
<ScreenHeader
|
||||||
|
streamType="none"
|
||||||
breadcrumbConfig={{ '/management_jobs': i18n._(t`Management Jobs`) }}
|
breadcrumbConfig={{ '/management_jobs': i18n._(t`Management Jobs`) }}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import ManagementJobs from './ManagementJobs';
|
import ManagementJobs from './ManagementJobs';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<ManagementJobs />', () => {
|
describe('<ManagementJobs />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
|
|
||||||
@@ -17,6 +21,6 @@ describe('<ManagementJobs />', () => {
|
|||||||
|
|
||||||
test('initially renders without crashing', () => {
|
test('initially renders without crashing', () => {
|
||||||
expect(pageWrapper.length).toBe(1);
|
expect(pageWrapper.length).toBe(1);
|
||||||
expect(pageWrapper.find('Breadcrumbs').length).toBe(1);
|
expect(pageWrapper.find('ScreenHeader').length).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { t } from '@lingui/macro';
|
|||||||
import NotificationTemplateList from './NotificationTemplateList';
|
import NotificationTemplateList from './NotificationTemplateList';
|
||||||
import NotificationTemplateAdd from './NotificationTemplateAdd';
|
import NotificationTemplateAdd from './NotificationTemplateAdd';
|
||||||
import NotificationTemplate from './NotificationTemplate';
|
import NotificationTemplate from './NotificationTemplate';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
|
|
||||||
function NotificationTemplates({ i18n }) {
|
function NotificationTemplates({ i18n }) {
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
@@ -32,7 +32,10 @@ function NotificationTemplates({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="notification_template"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={`${match.url}/add`}>
|
<Route path={`${match.url}/add`}>
|
||||||
<NotificationTemplateAdd />
|
<NotificationTemplateAdd />
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import React from 'react';
|
|||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
import NotificationTemplates from './NotificationTemplates';
|
import NotificationTemplates from './NotificationTemplates';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<NotificationTemplates />', () => {
|
describe('<NotificationTemplates />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
let pageSections;
|
let pageSections;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { withI18n } from '@lingui/react';
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { Config } from '../../contexts/Config';
|
import { Config } from '../../contexts/Config';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
|
|
||||||
import OrganizationsList from './OrganizationList/OrganizationList';
|
import OrganizationsList from './OrganizationList/OrganizationList';
|
||||||
import OrganizationAdd from './OrganizationAdd/OrganizationAdd';
|
import OrganizationAdd from './OrganizationAdd/OrganizationAdd';
|
||||||
@@ -42,7 +42,10 @@ function Organizations({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="organization"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={`${match.path}/add`}>
|
<Route path={`${match.path}/add`}>
|
||||||
<OrganizationAdd />
|
<OrganizationAdd />
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
import Organizations from './Organizations';
|
import Organizations from './Organizations';
|
||||||
|
|
||||||
jest.mock('../../api');
|
jest.mock('../../api');
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Organizations />', () => {
|
describe('<Organizations />', () => {
|
||||||
test('initially renders succesfully', async () => {
|
test('initially renders succesfully', async () => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Route, withRouter, Switch } from 'react-router-dom';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
|
|
||||||
import ProjectsList from './ProjectList/ProjectList';
|
import ProjectsList from './ProjectList/ProjectList';
|
||||||
import ProjectAdd from './ProjectAdd/ProjectAdd';
|
import ProjectAdd from './ProjectAdd/ProjectAdd';
|
||||||
@@ -45,7 +45,7 @@ function Projects({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader streamType="project" breadcrumbConfig={breadcrumbConfig} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/projects/add">
|
<Route path="/projects/add">
|
||||||
<ProjectAdd />
|
<ProjectAdd />
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Projects from './Projects';
|
import Projects from './Projects';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Projects />', () => {
|
describe('<Projects />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mountWithContexts(<Projects />);
|
mountWithContexts(<Projects />);
|
||||||
@@ -27,7 +31,7 @@ describe('<Projects />', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(wrapper.find('BreadcrumbHeading').length).toBe(1);
|
expect(wrapper.find('Title').length).toBe(1);
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { withI18n } from '@lingui/react';
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { PageSection, Card } from '@patternfly/react-core';
|
import { PageSection, Card } from '@patternfly/react-core';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
import { ScheduleList } from '../../components/Schedule';
|
import { ScheduleList } from '../../components/Schedule';
|
||||||
import { SchedulesAPI } from '../../api';
|
import { SchedulesAPI } from '../../api';
|
||||||
|
|
||||||
@@ -19,7 +19,8 @@ function AllSchedules({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs
|
<ScreenHeader
|
||||||
|
streamType="schedule"
|
||||||
breadcrumbConfig={{
|
breadcrumbConfig={{
|
||||||
'/schedules': i18n._(t`Schedules`),
|
'/schedules': i18n._(t`Schedules`),
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { createMemoryHistory } from 'history';
|
|||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
import AllSchedules from './AllSchedules';
|
import AllSchedules from './AllSchedules';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<AllSchedules />', () => {
|
describe('<AllSchedules />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
@@ -30,7 +34,6 @@ describe('<AllSchedules />', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.find('Crumb').length).toBe(1);
|
expect(wrapper.find('Title').text()).toBe('Schedules');
|
||||||
expect(wrapper.find('BreadcrumbHeading').text()).toBe('Schedules');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { PageSection, Card } from '@patternfly/react-core';
|
import { PageSection, Card } from '@patternfly/react-core';
|
||||||
import ContentError from '../../components/ContentError';
|
import ContentError from '../../components/ContentError';
|
||||||
import ContentLoading from '../../components/ContentLoading';
|
import ContentLoading from '../../components/ContentLoading';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
import ActivityStream from './ActivityStream';
|
import ActivityStream from './ActivityStream';
|
||||||
import AzureAD from './AzureAD';
|
import AzureAD from './AzureAD';
|
||||||
import GitHub from './GitHub';
|
import GitHub from './GitHub';
|
||||||
@@ -129,7 +129,7 @@ function Settings({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsProvider value={result}>
|
<SettingsProvider value={result}>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader streamType="setting" breadcrumbConfig={breadcrumbConfig} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/settings/activity_stream">
|
<Route path="/settings/activity_stream">
|
||||||
<ActivityStream />
|
<ActivityStream />
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ jest.mock('../../api/models/Settings');
|
|||||||
SettingsAPI.readAllOptions.mockResolvedValue({
|
SettingsAPI.readAllOptions.mockResolvedValue({
|
||||||
data: mockAllOptions,
|
data: mockAllOptions,
|
||||||
});
|
});
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Settings />', () => {
|
describe('<Settings />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { withI18n } from '@lingui/react';
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { Config } from '../../contexts/Config';
|
import { Config } from '../../contexts/Config';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader';
|
||||||
import TeamList from './TeamList';
|
import TeamList from './TeamList';
|
||||||
import TeamAdd from './TeamAdd';
|
import TeamAdd from './TeamAdd';
|
||||||
import Team from './Team';
|
import Team from './Team';
|
||||||
@@ -36,7 +36,7 @@ function Teams({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader streamType="team" breadcrumbConfig={breadcrumbConfig} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/teams/add">
|
<Route path="/teams/add">
|
||||||
<TeamAdd />
|
<TeamAdd />
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
import Teams from './Teams';
|
import Teams from './Teams';
|
||||||
|
|
||||||
jest.mock('../../api');
|
jest.mock('../../api');
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Teams />', () => {
|
describe('<Teams />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { Route, withRouter, Switch } from 'react-router-dom';
|
import { Route, withRouter, Switch } from 'react-router-dom';
|
||||||
import { PageSection } from '@patternfly/react-core';
|
import { PageSection } from '@patternfly/react-core';
|
||||||
|
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
import { TemplateList } from './TemplateList';
|
import { TemplateList } from './TemplateList';
|
||||||
import Template from './Template';
|
import Template from './Template';
|
||||||
import WorkflowJobTemplate from './WorkflowJobTemplate';
|
import WorkflowJobTemplate from './WorkflowJobTemplate';
|
||||||
@@ -12,22 +12,24 @@ import JobTemplateAdd from './JobTemplateAdd';
|
|||||||
import WorkflowJobTemplateAdd from './WorkflowJobTemplateAdd';
|
import WorkflowJobTemplateAdd from './WorkflowJobTemplateAdd';
|
||||||
|
|
||||||
function Templates({ i18n }) {
|
function Templates({ i18n }) {
|
||||||
const initBreadcrumbs = useRef({
|
const initScreenHeader = useRef({
|
||||||
'/templates': i18n._(t`Templates`),
|
'/templates': i18n._(t`Templates`),
|
||||||
'/templates/job_template/add': i18n._(t`Create New Job Template`),
|
'/templates/job_template/add': i18n._(t`Create New Job Template`),
|
||||||
'/templates/workflow_job_template/add': i18n._(
|
'/templates/workflow_job_template/add': i18n._(
|
||||||
t`Create New Workflow Template`
|
t`Create New Workflow Template`
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
const [breadcrumbConfig, setBreadcrumbs] = useState(initBreadcrumbs.current);
|
const [breadcrumbConfig, setScreenHeader] = useState(
|
||||||
|
initScreenHeader.current
|
||||||
|
);
|
||||||
const setBreadcrumbConfig = useCallback(
|
const setBreadcrumbConfig = useCallback(
|
||||||
(template, schedule) => {
|
(template, schedule) => {
|
||||||
if (!template) return;
|
if (!template) return;
|
||||||
const templatePath = `/templates/${template.type}/${template.id}`;
|
const templatePath = `/templates/${template.type}/${template.id}`;
|
||||||
const schedulesPath = `${templatePath}/schedules`;
|
const schedulesPath = `${templatePath}/schedules`;
|
||||||
const surveyPath = `${templatePath}/survey`;
|
const surveyPath = `${templatePath}/survey`;
|
||||||
setBreadcrumbs({
|
setScreenHeader({
|
||||||
...initBreadcrumbs.current,
|
...initScreenHeader.current,
|
||||||
[templatePath]: `${template.name}`,
|
[templatePath]: `${template.name}`,
|
||||||
[`${templatePath}/details`]: i18n._(t`Details`),
|
[`${templatePath}/details`]: i18n._(t`Details`),
|
||||||
[`${templatePath}/edit`]: i18n._(t`Edit Details`),
|
[`${templatePath}/edit`]: i18n._(t`Edit Details`),
|
||||||
@@ -49,7 +51,10 @@ function Templates({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="job_template,workflow_job_template"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/templates/job_template/add">
|
<Route path="/templates/job_template/add">
|
||||||
<JobTemplateAdd />
|
<JobTemplateAdd />
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Templates from './Templates';
|
import Templates from './Templates';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Templates />', () => {
|
describe('<Templates />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Route, useRouteMatch, Switch } from 'react-router-dom';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
import { Config } from '../../contexts/Config';
|
import { Config } from '../../contexts/Config';
|
||||||
|
|
||||||
import UsersList from './UserList/UserList';
|
import UsersList from './UserList/UserList';
|
||||||
@@ -46,7 +46,7 @@ function Users({ i18n }) {
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader streamType="user" breadcrumbConfig={breadcrumbConfig} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={`${match.path}/add`}>
|
<Route path={`${match.path}/add`}>
|
||||||
<UserAdd />
|
<UserAdd />
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import Users from './Users';
|
import Users from './Users';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<Users />', () => {
|
describe('<Users />', () => {
|
||||||
test('initially renders successfully', () => {
|
test('initially renders successfully', () => {
|
||||||
mountWithContexts(<Users />);
|
mountWithContexts(<Users />);
|
||||||
@@ -27,7 +31,7 @@ describe('<Users />', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(wrapper.find('BreadcrumbHeading').length).toBe(1);
|
expect(wrapper.find('Title').length).toBe(1);
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { withI18n } from '@lingui/react';
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import WorkflowApprovalList from './WorkflowApprovalList';
|
import WorkflowApprovalList from './WorkflowApprovalList';
|
||||||
import WorkflowApproval from './WorkflowApproval';
|
import WorkflowApproval from './WorkflowApproval';
|
||||||
import Breadcrumbs from '../../components/Breadcrumbs/Breadcrumbs';
|
import ScreenHeader from '../../components/ScreenHeader/ScreenHeader';
|
||||||
|
|
||||||
function WorkflowApprovals({ i18n }) {
|
function WorkflowApprovals({ i18n }) {
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
@@ -26,7 +26,10 @@ function WorkflowApprovals({ i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
|
<ScreenHeader
|
||||||
|
streamType="workflow_approval"
|
||||||
|
breadcrumbConfig={breadcrumbConfig}
|
||||||
|
/>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={`${match.url}/:id`}>
|
<Route path={`${match.url}/:id`}>
|
||||||
<WorkflowApproval setBreadcrumb={updateBreadcrumbConfig} />
|
<WorkflowApproval setBreadcrumb={updateBreadcrumbConfig} />
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { createMemoryHistory } from 'history';
|
|||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
import WorkflowApprovals from './WorkflowApprovals';
|
import WorkflowApprovals from './WorkflowApprovals';
|
||||||
|
|
||||||
|
jest.mock('react-router-dom', () => ({
|
||||||
|
...jest.requireActual('react-router-dom'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('<WorkflowApprovals />', () => {
|
describe('<WorkflowApprovals />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mountWithContexts(<WorkflowApprovals />);
|
mountWithContexts(<WorkflowApprovals />);
|
||||||
@@ -29,7 +33,8 @@ describe('<WorkflowApprovals />', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(wrapper.find('BreadcrumbHeading').length).toBe(1);
|
|
||||||
|
expect(wrapper.find('Title').length).toBe(1);
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user