do not remove errors from configuration route useEffect and do not display errors on extensions page if under configuration w/ burnettk
This commit is contained in:
parent
5907339918
commit
f8555c55bb
|
@ -3,7 +3,6 @@ import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
|||
// @ts-ignore
|
||||
import { Tabs, TabList, Tab } from '@carbon/react';
|
||||
import { Can } from '@casl/react';
|
||||
import useAPIError from '../hooks/UseApiError';
|
||||
import SecretList from './SecretList';
|
||||
import SecretNew from './SecretNew';
|
||||
import SecretShow from './SecretShow';
|
||||
|
@ -22,7 +21,6 @@ type OwnProps = {
|
|||
|
||||
export default function Configuration({ extensionUxElements }: OwnProps) {
|
||||
const location = useLocation();
|
||||
const { removeError } = useAPIError();
|
||||
const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
@ -36,14 +34,13 @@ export default function Configuration({ extensionUxElements }: OwnProps) {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
removeError();
|
||||
setPageTitle(['Configuration']);
|
||||
let newSelectedTabIndex = 0;
|
||||
if (location.pathname.match(/^\/configuration\/authentications\b/)) {
|
||||
newSelectedTabIndex = 1;
|
||||
}
|
||||
setSelectedTabIndex(newSelectedTabIndex);
|
||||
}, [location, removeError]);
|
||||
}, [location]);
|
||||
|
||||
const configurationExtensionTab = (
|
||||
uxElement: UiSchemaUxElement,
|
||||
|
@ -103,7 +100,11 @@ export default function Configuration({ extensionUxElements }: OwnProps) {
|
|||
<Route path="secrets/new" element={<SecretNew />} />
|
||||
<Route path="secrets/:key" element={<SecretShow />} />
|
||||
<Route path="authentications" element={<AuthenticationList />} />
|
||||
<Route path="extension/:page_identifier" element={<Extension />} />;
|
||||
<Route
|
||||
path="extension/:page_identifier"
|
||||
element={<Extension displayErrors={false} />}
|
||||
/>
|
||||
;
|
||||
</Routes>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -18,8 +18,12 @@ import {
|
|||
import ErrorDisplay from '../components/ErrorDisplay';
|
||||
import FormattingService from '../services/FormattingService';
|
||||
|
||||
type OwnProps = {
|
||||
displayErrors?: boolean;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
export default function Extension() {
|
||||
export default function Extension({ displayErrors = true }: OwnProps) {
|
||||
const { targetUris } = useUriListForPermissions();
|
||||
const params = useParams();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
@ -176,7 +180,9 @@ export default function Extension() {
|
|||
};
|
||||
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
const handleFormSubmit = (formObject: any, _event: any) => {
|
||||
const handleFormSubmit = (formObject: any, event: any) => {
|
||||
event.preventDefault();
|
||||
|
||||
if (formButtonsDisabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -219,7 +225,6 @@ export default function Extension() {
|
|||
// NOTE: rjsf sets blanks values to undefined and JSON.stringify removes keys with undefined values
|
||||
// so we convert undefined values to null recursively so that we can unset values in form fields
|
||||
recursivelyChangeNullAndUndefined(dataToSubmit, null);
|
||||
|
||||
HttpService.makeCallToBackend({
|
||||
path: apiPath,
|
||||
successCallback: processSubmitResult,
|
||||
|
@ -329,7 +334,7 @@ export default function Extension() {
|
|||
}
|
||||
return (
|
||||
<div className="fixed-width-container">
|
||||
<ErrorDisplay />
|
||||
{displayErrors ? <ErrorDisplay /> : null}
|
||||
{componentsToDisplay}
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue