Made welcome page configurable (#6232)

Co-authored-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Jim EhrismannandSebastian Malton authored and GitHub committed 2022-09-14 09:07:44 -04:00
1 parent 2555643749
commit a2d52fa6b8
11 files changed
+211 -23

No files matched your search

@@ -25,6 +25,10 @@
grid-area: menu;
}
.error {
z-index: 1;
}
#lens-views {
position: absolute;
left: 0;
@@ -21,12 +21,14 @@ import { buildURL } from "../../../common/utils/buildUrl";
import type { StorageLayer } from "../../utils";
import type { WatchForGeneralEntityNavigation } from "../../api/helpers/watch-for-general-entity-navigation.injectable";
import watchForGeneralEntityNavigationInjectable from "../../api/helpers/watch-for-general-entity-navigation.injectable";
import currentPathInjectable from "../../routes/current-path.injectable";
interface Dependencies {
catalogPreviousActiveTabStorage: StorageLayer<string | null>;
currentRouteComponent: IComputedValue<React.ElementType | undefined>;
welcomeUrl: string;
watchForGeneralEntityNavigation: WatchForGeneralEntityNavigation;
currentPath: IComputedValue<string>;
}
@observer
@@ -37,19 +39,40 @@ class NonInjectedClusterManager extends React.Component<Dependencies> {
]);
}
render() {
renderMainComponent() {
const Component = this.props.currentRouteComponent.get();
if (!Component) {
if (Component) {
return <Component />;
}
const currentPath = this.props.currentPath.get();
if (currentPath !== this.props.welcomeUrl) {
return <Redirect exact to={this.props.welcomeUrl} />;
}
return (
<div className="error">
<h2>ERROR!!</h2>
<p>
No matching route for the current path:
{" "}
<code>{currentPath}</code>
{" "}
which is the welcomeUrl. This is a bug.
</p>
</div>
);
}
render() {
return (
<div className="ClusterManager">
<TopBar />
<main>
<div id="lens-views" />
<Component />
{this.renderMainComponent()}
</main>
<HotbarMenu />
<StatusBar />
@@ -65,5 +88,6 @@ export const ClusterManager = withInjectables<Dependencies>(NonInjectedClusterMa
currentRouteComponent: di.inject(currentRouteComponentInjectable),
welcomeUrl: buildURL(di.inject(welcomeRouteInjectable).path),
watchForGeneralEntityNavigation: di.inject(watchForGeneralEntityNavigationInjectable),
currentPath: di.inject(currentPathInjectable),
}),
});