a better fix. just set the extensionUxElements to a blank array instead of creating a new state
This commit is contained in:
parent
7a62a8688c
commit
90c49f8e5c
|
@ -22,12 +22,9 @@ import NavigationBar from './components/NavigationBar';
|
||||||
|
|
||||||
export default function ContainerForExtensions() {
|
export default function ContainerForExtensions() {
|
||||||
const [backendIsUp, setBackendIsUp] = useState<boolean | null>(null);
|
const [backendIsUp, setBackendIsUp] = useState<boolean | null>(null);
|
||||||
const [extensionUxElements, setExtensionNavigationItems] = useState<
|
const [extensionUxElements, setExtensionUxElements] = useState<
|
||||||
UiSchemaUxElement[] | null
|
UiSchemaUxElement[] | null
|
||||||
>(null);
|
>(null);
|
||||||
const [canLoadExtensions, setCanLoadExtensions] = useState<boolean | null>(
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
let contentClassName = 'main-site-body-centered';
|
let contentClassName = 'main-site-body-centered';
|
||||||
if (window.location.pathname.startsWith('/editor/')) {
|
if (window.location.pathname.startsWith('/editor/')) {
|
||||||
|
@ -70,7 +67,7 @@ export default function ContainerForExtensions() {
|
||||||
})
|
})
|
||||||
.flat();
|
.flat();
|
||||||
if (eni) {
|
if (eni) {
|
||||||
setExtensionNavigationItems(eni);
|
setExtensionUxElements(eni);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,13 +77,13 @@ export default function ContainerForExtensions() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ability.can('GET', targetUris.extensionListPath)) {
|
if (ability.can('GET', targetUris.extensionListPath)) {
|
||||||
setCanLoadExtensions(true);
|
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: targetUris.extensionListPath,
|
path: targetUris.extensionListPath,
|
||||||
successCallback: processExtensionResult,
|
successCallback: processExtensionResult,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setCanLoadExtensions(false);
|
// set to an empty array so we know that it loaded
|
||||||
|
setExtensionUxElements([]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,12 +104,7 @@ export default function ContainerForExtensions() {
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route
|
<Route
|
||||||
path="/*"
|
path="/*"
|
||||||
element={
|
element={<BaseRoutes extensionUxElements={extensionUxElements} />}
|
||||||
<BaseRoutes
|
|
||||||
extensionUxElements={extensionUxElements}
|
|
||||||
canLoadExtensions={canLoadExtensions}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Route path="/editor/*" element={<EditorRoutes />} />
|
<Route path="/editor/*" element={<EditorRoutes />} />
|
||||||
<Route path="/extensions/:page_identifier" element={<Extension />} />
|
<Route path="/extensions/:page_identifier" element={<Extension />} />
|
||||||
|
|
|
@ -19,14 +19,10 @@ import { ExtensionUxElementMap } from '../components/ExtensionUxElementForDispla
|
||||||
import Extension from './Extension';
|
import Extension from './Extension';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
canLoadExtensions: boolean | null;
|
|
||||||
extensionUxElements?: UiSchemaUxElement[] | null;
|
extensionUxElements?: UiSchemaUxElement[] | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function BaseRoutes({
|
export default function BaseRoutes({ extensionUxElements }: OwnProps) {
|
||||||
canLoadExtensions,
|
|
||||||
extensionUxElements,
|
|
||||||
}: OwnProps) {
|
|
||||||
const elementCallback = (uxElement: UiSchemaUxElement) => {
|
const elementCallback = (uxElement: UiSchemaUxElement) => {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Route
|
||||||
|
@ -36,7 +32,7 @@ export default function BaseRoutes({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (extensionUxElements || canLoadExtensions === false) {
|
if (extensionUxElements) {
|
||||||
const extensionRoutes = ExtensionUxElementMap({
|
const extensionRoutes = ExtensionUxElementMap({
|
||||||
displayLocation: 'routes',
|
displayLocation: 'routes',
|
||||||
elementCallback,
|
elementCallback,
|
||||||
|
|
Loading…
Reference in New Issue