Adds deprecation banner

This commit is contained in:
Alex Corey 2021-09-01 13:22:36 -04:00
parent 1d3a36d821
commit 35a51b393a
4 changed files with 72 additions and 35 deletions

View File

@ -2,8 +2,9 @@ import React, { useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
import { t } from '@lingui/macro';
import { Button } from '@patternfly/react-core';
import { Button, Alert as PFAlert } from '@patternfly/react-core';
import { CaretLeftIcon } from '@patternfly/react-icons';
import styled from 'styled-components';
import { CardBody, CardActionsRow } from 'components/Card';
import ContentLoading from 'components/ContentLoading';
import ContentError from 'components/ContentError';
@ -15,6 +16,10 @@ import { useConfig } from 'contexts/Config';
import { useSettings } from 'contexts/Settings';
import { SettingDetail } from '../../shared';
const Alert = styled(PFAlert)`
margin-bottom: 20px;
`;
function RADIUSDetail() {
const { me } = useConfig();
const { GET: options } = useSettings();
@ -61,22 +66,30 @@ function RADIUSDetail() {
{isLoading && <ContentLoading />}
{!isLoading && error && <ContentError error={error} />}
{!isLoading && radius && (
<DetailList>
{Object.keys(radius).map((key) => {
const record = options?.[key];
return (
<SettingDetail
key={key}
id={key}
helpText={record?.help_text}
label={record?.label}
type={record?.type}
unit={record?.unit}
value={radius?.[key]}
/>
);
})}
</DetailList>
<>
<Alert
variant="info"
isInline
data-cy="RADIUS-deprecation-warning"
title={t`This feature is deprecated and will be removed in a future release.`}
/>
<DetailList>
{Object.keys(radius).map((key) => {
const record = options?.[key];
return (
<SettingDetail
key={key}
id={key}
helpText={record?.help_text}
label={record?.label}
type={record?.type}
unit={record?.unit}
value={radius?.[key]}
/>
);
})}
</DetailList>
</>
)}
{me?.is_superuser && (
<CardActionsRow>

View File

@ -52,6 +52,9 @@ describe('<RADIUSDetail />', () => {
});
test('should render expected details', () => {
expect(wrapper.find('Alert').prop('title')).toBe(
'This feature is deprecated and will be removed in a future release.'
);
assertDetail(wrapper, 'RADIUS Server', 'example.org');
assertDetail(wrapper, 'RADIUS Port', '1812');
assertDetail(wrapper, 'RADIUS Secret', 'Encrypted');

View File

@ -2,8 +2,9 @@ import React, { useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
import { t } from '@lingui/macro';
import { Button } from '@patternfly/react-core';
import { Button, Alert as PFAlert } from '@patternfly/react-core';
import { CaretLeftIcon } from '@patternfly/react-icons';
import styled from 'styled-components';
import { CardBody, CardActionsRow } from 'components/Card';
import ContentLoading from 'components/ContentLoading';
import ContentError from 'components/ContentError';
@ -15,6 +16,10 @@ import { useConfig } from 'contexts/Config';
import { useSettings } from 'contexts/Settings';
import { SettingDetail } from '../../shared';
const Alert = styled(PFAlert)`
margin-bottom: 20px;
`;
function TACACSDetail() {
const { me } = useConfig();
const { GET: options } = useSettings();
@ -53,7 +58,12 @@ function TACACSDetail() {
id: 0,
},
];
if (isLoading) {
return <ContentLoading />;
}
if (!isLoading && error) {
return <ContentError error={error} />;
}
return (
<>
<RoutedTabs tabsArray={tabsArray} />
@ -61,22 +71,30 @@ function TACACSDetail() {
{isLoading && <ContentLoading />}
{!isLoading && error && <ContentError error={error} />}
{!isLoading && tacacs && (
<DetailList>
{Object.keys(tacacs).map((key) => {
const record = options?.[key];
return (
<SettingDetail
key={key}
id={key}
helpText={record?.help_text}
label={record?.label}
type={record?.type}
unit={record?.unit}
value={tacacs?.[key]}
/>
);
})}
</DetailList>
<>
<Alert
variant="info"
isInline
data-cy="TACACS-deprecation-warning"
title={t`This feature is deprecated and will be removed in a future release.`}
/>
<DetailList>
{Object.keys(tacacs).map((key) => {
const record = options?.[key];
return (
<SettingDetail
key={key}
id={key}
helpText={record?.help_text}
label={record?.label}
type={record?.type}
unit={record?.unit}
value={tacacs?.[key]}
/>
);
})}
</DetailList>
</>
)}
{me?.is_superuser && (
<CardActionsRow>

View File

@ -54,6 +54,9 @@ describe('<TACACSDetail />', () => {
});
test('should render expected details', () => {
expect(wrapper.find('Alert').prop('title')).toBe(
'This feature is deprecated and will be removed in a future release.'
);
assertDetail(wrapper, 'TACACS+ Server', 'mockhost');
assertDetail(wrapper, 'TACACS+ Port', '49');
assertDetail(wrapper, 'TACACS+ Secret', 'Encrypted');